Skip to content

Commit

Permalink
fixed SG2 demo so it isn't one frame behind
Browse files Browse the repository at this point in the history
  • Loading branch information
prismspecs committed Aug 27, 2021
1 parent 0613e4e commit 306b807
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
12 changes: 6 additions & 6 deletions example-StyleGAN2/src/ofApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,16 @@ void ofApp::setup()
//--------------------------------------------------------------
void ofApp::update()
{
// structuring it this way allows you use tryReceive
ofxRunwayData dataToReceive;

// infer/generate a new image if we have sent a request to Runway
if (bWaitingForResponse)
// using tryReceive we can make sure there is data available before grabbing it
while (runway.tryReceive(dataToReceive))
{
runway.get("image", currentImg); // stores generated image to currentImg
bWaitingForResponse = false;
dataToReceive.getImage("image", currentImg);
currentImg.update();
}

}
//--------------------------------------------------------------
void ofApp::draw()
Expand Down Expand Up @@ -100,8 +102,6 @@ void ofApp::generate_image(vector<float> z, float truncation)
// basically, the higher the truncation value the weirder the results

runway.send(data);

bWaitingForResponse = true;
}

// Runway sends information about the current model
Expand Down
12 changes: 5 additions & 7 deletions example-StyleGAN2/src/ofApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,24 @@

// make sure you make your ofApp or class to inherit from ofxRunwayListener
class ofApp : public ofBaseApp, public ofxRunwayListener{

public:
void setup();
void update();
void draw();
void keyReleased(int key);

ofxRunway runway;

ofImage currentImg;

vector<float> generate_random_z();
void generate_image(vector<float> z, float truncation);

// Callback functions that process what Runway sends back
void runwayInfoEvent(ofJson& info);
void runwayErrorEvent(string& message);

bool bWaitingForResponse = false;

// GAN options
float truncation = 1.5;
float min_max_vals = 2;
Expand Down

0 comments on commit 306b807

Please sign in to comment.