Skip to content

Commit 55fcdd0

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents 915b020 + b377024 commit 55fcdd0

File tree

2 files changed

+17
-28
lines changed

2 files changed

+17
-28
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,8 @@ Instructions in the protobuf README https://github.com/google/protobuf/blob/mast
231231
Here are some outstanding issues and misc notes.
232232

233233

234-
## No image load! - See UPDATE below
235-
ofImage.load doesn't work for some reason. FreeImage_Load fails. Neither does cvLoadImage (or cv::imread). If I don't use tensorflow, it works. If I use tensorflow, it doesn't. Just fails silently. Needs serious investigation. (So for the inception demo, I had to test it by converting jpgs to raw data in gimp and load them via ofBuffers :/)
234+
## Jpegs don't load! - See UPDATE below
235+
ofImage.load doesn't work with jpegs for some reason. FreeImage_Load fails. Neither does cvLoadImage (or cv::imread). If I don't use tensorflow, it works. If I use tensorflow, it doesn't. Just fails silently. Needs serious investigation. PNGs work fine.
236236

237237
## No system dialogs - see UPDATE below
238238
Whatever it is that implements ofSystemDialog, was compiled with protobuf 2.6.1 whereas tensorflow needs protobuf>3.0.0 (not released yet, using dev version). So can't use ofSystemDialogs. Also needs investigation.

example-inception3/src/example-inception3.cpp

Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,6 @@
1414
#include "ofxMSATensorFlow.h"
1515

1616

17-
//--------------------------------------------------------------
18-
// ofImage::load() (ie. Freeimage load) doesn't work with TensorFlow! (See README.md)
19-
// so I have to resort to this awful trick of loading raw image data 299x299 RGB
20-
static void loadImageRaw(string path, ofImage &img, int w, int h) {
21-
ofFile file(path);
22-
img.setFromPixels((unsigned char*)file.readToBuffer().getData(), w, h, OF_IMAGE_COLOR);
23-
}
24-
25-
26-
2717
class ofApp : public ofBaseApp {
2818
public:
2919

@@ -45,19 +35,15 @@ class ofApp : public ofBaseApp {
4535
//--------------------------------------------------------------
4636
void loadNextImage() {
4737
static int file_index = 0;
48-
ofImage img;
49-
5038
// System load dialog doesn't work with tensorflow :(
5139
//auto o = ofSystemLoadDialog("Select image");
5240
//if(!o.bSuccess) return;
5341

54-
// FreeImage doesn't work with tensorflow! :(
55-
//img.load("images/fanboy.jpg");
56-
57-
// resorting to awful raw data file load hack!
58-
loadImageRaw(image_dir.getPath(file_index), img, 299, 299);
42+
// only PNGs work for some reason when Tensorflow is linked in
43+
ofImage img;
44+
img.load(image_dir.getPath(file_index));
45+
if(img.isAllocated()) classify(img.getPixels());
5946

60-
classify(img.getPixels());
6147
file_index = (file_index+1) % image_dir.getFiles().size();
6248
}
6349

@@ -126,8 +112,11 @@ class ofApp : public ofBaseApp {
126112
ofSetColor(255);
127113

128114
// if video grabber active, draw in bottom left corner
129-
if(video_grabber) video_grabber->draw(0, ofGetHeight() - 240, 320, 240);
130-
115+
if(video_grabber) {
116+
int vy = ofGetHeight() - 240;
117+
ofDrawBitmapString("Press SPACE to classify", 10, vy - 10);
118+
video_grabber->draw(0, vy, 320, 240);
119+
}
131120

132121
float x = 0;
133122

@@ -174,7 +163,7 @@ class ofApp : public ofBaseApp {
174163

175164
stringstream str_inst;
176165
str_inst << "'l' to load image\n";
177-
str_inst << "or drag an image (must be raw, 299x299) onto the window\n";
166+
str_inst << "or drag an image (must be PNG) onto the window\n";
178167
str_inst << "'v' to toggle video input";
179168
ofDrawBitmapString(str_inst.str(), 15, classifier.getHeight() + 30);
180169
}
@@ -202,12 +191,12 @@ class ofApp : public ofBaseApp {
202191
void dragEvent(ofDragInfo dragInfo){
203192
if(dragInfo.files.empty()) return;
204193

205-
ofImage img;
194+
string file_path = dragInfo.files[0];
206195

207-
string filePath = dragInfo.files[0];
208-
//img.load(filePath); // FreeImage doesn't work :(
209-
loadImageRaw(filePath, img, 299, 299);
210-
classify(img.getPixels());
196+
// only PNGs work for some reason when Tensorflow is linked in
197+
ofImage img;
198+
img.load(file_path);
199+
if(img.isAllocated()) classify(img.getPixels());
211200
}
212201

213202
};

0 commit comments

Comments
 (0)