digitalbrain79 / pyyolo

Simple python wrapper for YOLO.
126 stars 65 forks source link

yolo_init should not change the working directory #21

Open sunsided opened 7 years ago

sunsided commented 7 years ago

In libyolo.c's yolo_init function here, the code is doing a chdir to the darknet directory. This massively impacts the calling code that assumes its working directory is actually the directory it is started in. Is there a way to not change the directory?

digitalbrain79 commented 7 years ago

Darknet find file by relative path. If you want not change directory, you should modify darknet code.

sunsided commented 7 years ago

Could we at least chdir back to where we came from?

digitalbrain79 commented 7 years ago

I added Darknet path parameter. You can run pyyolo outside of directory.

AndyTsangChun commented 7 years ago

@thomaspark-pkj Thanks for the path update However, I encounter two problems when I installed the new version. Originally, I have installed pyyolo in two separate directory for some purpose. I think they points to the same "pyyolo-0.1-py2.7.egg-info"(which I didn't aware before), not sure how it works, but they both function properly.

So today, I tried to update one of them to the latest version and build it. It installed/build properly, however problems happen when i run the "example.py"

  1. I have checked the new clone has "darknet_path" in init@libyolo.c , however

    Traceback (most recent call last):
    File "example.py", line 20, in <module>
    pyyolo.init(darknet_path, datacfg, cfgfile, weightfile)
    TypeError: function takes exactly 3 arguments (4 given) 
  2. When I try to run the older version with "example.py" in another directory, segmentation fault 11 appears. Which I tried to re-install/build the older version, same error returns.

    ----- test python API using a file
    Reading data/person.jpg
    Segmentation fault: 11

In older version, segmentation happens on image size > 698196 only, example image "person.jpg" is always fine. But now "person.jpg" trigger the same problem too, which I totally can't use pyyolo now.

FYI, I do think this error is correlated with this two post I replied before. segmentation error Import Error, AttributeError: 'module' object has no attribute 'init'

digitalbrain79 commented 7 years ago

I think example.py refer old library. Could you clean previous module then rebuild all?

AndyTsangChun commented 7 years ago

@thomaspark-pkj Sorry for another question. I had tried to clear the build inside pyyolo but it seems not working. I had remove pyyolo.so and pyyolo-0.1-py2.7.egg-info as well. Still not working at all. Is there any more hidden path i should know???????

=========================================================== I have just solved the problem!!!! I tried to grep search "pyyolo.so" but not sure y it just loading but not response. Therefore, I go for searching "sys.path" one by one. Turns out, I found out there is another pyyolo.so installed in another site-packages directory which was not shown when you run "python setup.py install". I remove that and re-build the whole stuff it works now!! I can call the library outside the directory now! Thanks a lot!!