imatge-upc / detection-2016-nipsws

Hierarchical Object Detection with Deep Reinforcement Learning
http://imatge-upc.github.io/detection-2016-nipsws/
MIT License
423 stars 129 forks source link

IOError: Unable to open file (File signature not found) #7

Closed LiYingTW closed 7 years ago

LiYingTW commented 7 years ago

Dear miriambellver, thanks for your share. I met a problem when ran your code:

Traceback (most recent call last): File "image_zooms_testing.py", line 42, in model = get_q_network(weights_path + model_name) File "/auto/master05/liyi9487/project/detection-2016-nipsws/scripts/reinforcement.py", line 87, in get_q_network model.load_weights(weights_path) File "/home/master/05/liyi9487/.local/lib/python2.7/site-packages/keras/engine/topology.py", line 2486, in load_weights f = h5py.File(filepath, mode='r') File "/home/master/05/liyi9487/.local/lib/python2.7/site-packages/h5py/_hl/files.py", line 272, in init fid = make_fid(name, mode, userblock_size, fapl, swmr=swmr) File "/home/master/05/liyi9487/.local/lib/python2.7/site-packages/h5py/_hl/files.py", line 92, in make_fid fid = h5f.open(name, flags, fapl=fapl) File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper (/tmp/pip-build-v_zMzm/h5py/h5py/_objects.c:2847) File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper (/tmp/pip-build-v_zMzm/h5py/h5py/_objects.c:2805) File "h5py/h5f.pyx", line 76, in h5py.h5f.open (/tmp/pip-build-v_zMzm/h5py/h5py/h5f.c:2093) IOError: Unable to open file (File signature not found)

I use keras=1.0.8, Using Theano 0.8.2 backend. Thank you very much

LiYingTW commented 7 years ago

By the way, I've checked all package in "requirements.txt", all are the same except of these 8 packages, I have newer version:

And, here is my folder path: --font/ |----LiberationMono-Regular.ttf --img/ --models_image_zooms/ |----model_image_zooms --scripts/ --vgg16_weights.h5 --testing/

here, testing/ is empty and the file "model_image_zooms" under the folder models_image_zooms/ was created by "touch models_image_zooms/model_image_zooms" If not doing so (just have an empty folder models_image_zooms/) I'll get this error message:

Using Theano backend. Traceback (most recent call last): File "image_zooms_testing.py", line 42, in model = get_q_network(weights_path + model_name) File "/auto/master05/liyi9487/project/detection-2016-nipsws/scripts/reinforcement.py", line 87, in get_q_network model.load_weights(weights_path) File "/home/master/05/liyi9487/.local/lib/python2.7/site-packages/keras/engine/topology.py", line 2486, in load_weights f = h5py.File(filepath, mode='r') File "/home/master/05/liyi9487/.local/lib/python2.7/site-packages/h5py/_hl/files.py", line 272, in init fid = make_fid(name, mode, userblock_size, fapl, swmr=swmr) File "/home/master/05/liyi9487/.local/lib/python2.7/site-packages/h5py/_hl/files.py", line 92, in make_fid fid = h5f.open(name, flags, fapl=fapl) File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper (/tmp/pip-build-v_zMzm/h5py/h5py/_objects.c:2847) File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper (/tmp/pip-build-v_zMzm/h5py/h5py/_objects.c:2805) File "h5py/h5f.pyx", line 76, in h5py.h5f.open (/tmp/pip-build-v_zMzm/h5py/h5py/h5f.c:2093) IOError: Unable to open file (Unable to open file: name = '../models_image_zooms/model_image_zooms', errno = 2, error message = 'no such file or directory', flags = 0, o_flags = 0)

miriambellver commented 7 years ago

Hi! You have to download the model_image_zooms. Everything is explained in the README. Míriam

LiYingTW commented 7 years ago

"You should also create two folders in the root of the project, called models_image_zooms and models_pool45_crops, and store inside them the corresponding weights."

So I should store vgg16_weights.h5 into models_image_zoom/ ?

Thank you for answering

LiYingTW commented 7 years ago

I got that! "downloaded in the following links Image Zooms model and Pool45 Crops model"

yes, now I have these two weights under corresponding folders. However, I still cannot run the code successfully:

python scripts/image_zooms_testing.py Using Theano backend. Traceback (most recent call last): File "scripts/image_zooms_testing.py", line 41, in model_vgg = obtain_compiled_vgg_16(path_vgg) File "/auto/master05/liyi9487/project/detection-2016-nipsws/scripts/features.py", line 203, in obtain_compiled_vgg_16 model = vgg_16(vgg_weights_path) File "/auto/master05/liyi9487/project/detection-2016-nipsws/scripts/features.py", line 255, in vgg_16 model.load_weights(weights_path) File "/home/master/05/liyi9487/.local/lib/python2.7/site-packages/keras/engine/topology.py", line 2486, in load_weights f = h5py.File(filepath, mode='r') File "/home/master/05/liyi9487/.local/lib/python2.7/site-packages/h5py/_hl/files.py", line 272, in init fid = make_fid(name, mode, userblock_size, fapl, swmr=swmr) File "/home/master/05/liyi9487/.local/lib/python2.7/site-packages/h5py/_hl/files.py", line 92, in make_fid fid = h5f.open(name, flags, fapl=fapl) File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper (/tmp/pip-build-v_zMzm/h5py/h5py/_objects.c:2847) File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper (/tmp/pip-build-v_zMzm/h5py/h5py/_objects.c:2805) File "h5py/h5f.pyx", line 76, in h5py.h5f.open (/tmp/pip-build-v_zMzm/h5py/h5py/h5f.c:2093) IOError: Unable to open file (Unable to open file: name = '../vgg16_weights.h5', errno = 2, error message = 'no such file or directory', flags = 0, o_flags = 0)

Here are my files under the root of the project:

ls -l total 541448 -rw-r--r-- 1 liyi9487 cmlab 1101 Dec 20 09:46 LICENSE -rw-r--r-- 1 liyi9487 cmlab 12657 Dec 20 09:46 README.md drwxr-xr-x 2 liyi9487 cmlab 4096 Dec 20 09:46 authors -rw-r--r-- 1 liyi9487 cmlab 898570 Dec 20 09:46 bellver-2016-nipsws.pdf drwxr-xr-x 2 liyi9487 cmlab 4096 Dec 20 10:42 font drwxr-xr-x 2 liyi9487 cmlab 4096 Dec 20 09:46 img drwxr-xr-x 2 liyi9487 cmlab 4096 Dec 20 09:46 logos drwxr-xr-x 2 liyi9487 cmlab 4096 Dec 23 13:48 models_image_zooms drwxr-xr-x 2 liyi9487 cmlab 4096 Dec 23 13:50 models_pool45_crops -rw-r--r-- 1 liyi9487 cmlab 547 Dec 20 09:46 requirements.txt drwxr-xr-x 4 liyi9487 cmlab 4096 Dec 21 14:18 scripts drwxr-xr-x 2 liyi9487 cmlab 4096 Dec 20 10:24 testing -rwxrwxrwx 1 liyi9487 cmlab 553479920 Dec 20 14:56 vgg16_weights.h5

I do have the file " vgg16_weights.h5" and I even chmod to 0777.

Thank you for helping.

LiYingTW commented 7 years ago

I knew why!!

my classmate told me why, since I execute the file "image_zoom_testing.py" under the root of the project, but I need to execute that file under script/

thank u very much