schwittlick / ofxDarknet

darknet neural network addon for openFrameworks
MIT License
496 stars 89 forks source link

OSX: cannot open .cfg files #4

Closed AndreasRef closed 7 years ago

AndreasRef commented 7 years ago

The examples builds successfully, but then spits out errors about not being able to open the .cfg files although they are placed in bin/cfg

For instance in example-yolo2: Couldn't open file: cfg/yolo.cfg

and in example-imagenet

Couldn't open file: cfg/darknet.cfg

Tested in of_v0.9.0 and of_v0.9.7 on OSX.

Any idea what might cause this?

genekogan commented 7 years ago

yeah we have to fix the paths -- the app and the static lib are in different locations, which is causing the path problems. for now you can fix this by changing the paths to the absolute paths of those files.

AndreasRef commented 7 years ago

Cool, thanks.

However, now in the I get the error in console (example-yolo2):

Couldn't open file: data/coco.names

Not sure whats up with this, since the setup function only calls coco.data and coco.list, but the addon does not contain any coco.list file as far as I can see? I specified its absolute path, and have tried swapping coco.list for coco.names without results.

For example-imagenet the issue is very similar: Couldn't open file: data/imagenet.shortnames.list

Tried to put place this file in the data folder: https://github.com/pjreddie/darknet/blob/master/data/imagenet.shortnames.list and link to its absolute path, but still get the same error.

genekogan commented 7 years ago

ah -- open the file coco.data and change the path to names to the absolute path for coco.names and that should temp fix it. we need to sort out these path issues.

AndreasRef commented 7 years ago

That did the trick for example-yolo2, thanks!

Any quick ideas for example-imagenet?

schwittlick commented 7 years ago

its really confusing that you guys are having problems with paths to files on osx. on windows it's working with these relative paths. one solution would be to construct absolute paths in a manner like (yolo2 example):

std::string datacfg = ofToDataPath( "../cfg/coco.data" );
std::string cfgfile = ofToDataPath( "../cfg/yolo.cfg" );
std::string weightfile = ofToDataPath( "yolo.weights" );
std::string nameslist = ofToDataPath( "coco.list" );
darknet.init( cfgfile, weightfile, datacfg, nameslist );

this works on windows as well and might fix the issues on osx as well. let me know if this goes anywhere

genekogan commented 7 years ago

the reason this happens is that the darknet static lib uses different file-handlers than OF, so they are being executed from a different root. using ofToDataPath as @mrzl suggested does fix this. i will fix this in the next commit. @mrzl is there any reason you include coco.names twice? in both data and cfg. probably makes sense just to have one.

schwittlick commented 7 years ago

while i was at it, i adjusted this in all examples, readme etc. and moved the configuration files consistently within the of data folder. let me known if this solved it all.

AndreasRef commented 7 years ago

My friend just cloned the repo and tried the yolo-2 example. We still needed to open the file coco.data and change the path to names to the absolute path for coco.names for the example to work.

genekogan commented 7 years ago

as of https://github.com/mrzl/ofxDarknet/pull/13 you no longer have to use the coco.data file and specify the names file manually. so these problems should be resolved now.