Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DoodleClassifier: Path to data/sqlite3 image-net-file seems to be off #22

Closed
HerrBertling opened this issue Nov 20, 2017 · 6 comments
Closed

Comments

@HerrBertling
Copy link
Contributor

HerrBertling commented Nov 20, 2017

Some train of thought and exploration about this issue with the relevant question at the end 😉 🚂

I get this error when trying to "Add samples": Thread 1: EXC_BAD_ACCESS (code=1, address=0x18)

Up until then, I can adjust the threshold, min/max and
It seems to happen here in the "hack" line, as far as I can tell from what XCode highlights:

vector<float> ofxCcv::encode(const ofPixels& pix, int layer) const {
    convnet->count = layer; // hack to extract a particular layer with encode

    ccv_dense_matrix_t image;

My app is in a different folder than the openFramework stuff, but from what I understood, this shouldn't be a problem.

Also, the XCode console says:

[ error ] Can't find network file ../../../data/../../../../data/image-net-2012.sqlite3
[notice ] Adding samples...

which I already wondered about since it is a relative path to a file.

Using the ml4a-ofx/apps/DoodleClassifier folder with adjustments to the .xml file produces the same error.

Running sh setup.sh did create the image-net-2012.sqlite3 file – not within data but directly within ml4a-ofx. Adjusting the path to that file in https://github.com/ml4a/ml4a-ofx/blob/master/apps/DoodleClassifier/src/ofApp.cpp#L22 (which would then say ccv.setup(ofToDataPath("../../../../image-net-2012.sqlite3")); apparently fixes this issue.

Is this path wrong in general or am I holding it wrong and my setup needs to be fixed? 😊

@genekogan
Copy link
Member

if you are compiling from source, the location depends on whether the #RELEASE flag is defined as you'll see in ofApp -- there's some weirdness with the new macs not interpreting relative paths the same way as before. we'll need to reevaluate this because the paths have been giving us trouble for a while now.

@stlou
Copy link

stlou commented Feb 2, 2018

I noticed this same problem, and it seems like you've already fixed the line on ofApp.cpp to reflect the change that HerrBertling mentioned. I ran the shell script as referenced, but when I go to Add Samples in the app, the app crashes and I'm still getting the error in the console:

[ error ] Can't find network file ../../../data/../../../../data/image-net-2012.sqlite3 [notice ] Adding samples...

Any ideas why this might still be happening?

(sorry if it's too much to be raising issues on multiple threads, but obviously just started playing around with these OF apps, and would love to get them working on my machine)

@stlou
Copy link

stlou commented Feb 2, 2018

Not sure if this could be the source, but the only other relevant place where I could find the ../../../data that's concatenated on to the beginning of the correct path (../../../../data/image-net-2012.sqlite3) is in the ofUtils.cpp file from Open Frameworks.

In that file, starting at L64:

string defaultDataPath(){
    #if defined TARGET_OSX
        try{
            return std::filesystem::canonical(ofFilePath::join(ofFilePath::getCurrentExeDir(),  "../../../data/")).string();
        }catch(...){
            return ofFilePath::join(ofFilePath::getCurrentExeDir(),  "../../../data/");
        }

Since I'm using OSX, I thought this could maybe be part of the issue. Based on my uneducated look at what this snippet of code is doing, it doesn't seem like it's the culprit, but is the only place I could find that might be connected with the faulty path.

Maybe this helps, maybe it's nothing.

@genekogan
Copy link
Member

try to remove the ofToDataPath in the link to the sql file or provide it an absolute path. i'm not exactly sure what's going wrong here.

@stlou
Copy link

stlou commented Feb 3, 2018

Hey! That seemed to work! Will play around with the app and see if I run into anything else, but thanks so much for your help!

If anyone else runs into this problem -- here's what I had to do:

  1. While in the ml4a master directory, run setup.sh. This should populate the directory with a bunch of files, including image-net-2012.sqlite3, our pesky culprit.
  2. In ofApp.cpp, remove ofToDataPath() from line 22 (I removed it from line 20, too, just to make sure). So, that line now reads: ccv.setup("../../../../data/image-net-2012.sqlite3");
  3. I was actually still getting an error, and realized that the image-net-2012.sqlite3 file was still in the ml4a master directory, and not in the data directory as expected. So, I just moved the file into the data directory.

This might be a bit of a hack, but it got the app up and running for me! Looking forward to playing with it.

@genekogan
Copy link
Member

this may also be caused by newer macs running translocation on all applications. if you run the setup script setup.sh first that will fix this, or moving the application to another folder, then moving it back will also give it access back to the files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants