awentzonline / image-analogies

Generate image analogies using neural matching and blending.
MIT License
3.52k stars 282 forks source link

Unable to open file: name = 'vgg16_weights.h5', errno = 17, error message = 'file exists' #34

Closed freeman-g closed 7 years ago

freeman-g commented 7 years ago

I am trying to run image-analogies on the Tensorflow docker image. This docker image already has tensor flow and python installed.

I ran pip install neural-image-analogies and then curl https://github.com/awentzonline/image-analogies/releases/download/v0.0.5/vgg16_weights.h5 > vgg16_weights.h5 so I have the vgg16 weights file in my working directory.

When I try to run the image-analogies script, I get an error that the weights file cannot be created because it already exists:

root@62081df76460:/share/training# make_image_analogy.py training.001.jpeg training.002.jpeg training.040.jpeg out/door
Using TensorFlow backend.
Tensorflow detected. Forcing --a-scale-mode=match (A images are scaled to same size as B images)
Using PatchMatch model
Scale factor 0.25 "A" shape (1, 3, 50, 50) "B" shape (1, 3, 50, 50)
Traceback (most recent call last):
  File "/usr/local/bin/make_image_analogy.py", line 27, in <module>
    image_analogy.main.main(args, model_class)
  File "/usr/local/lib/python2.7/dist-packages/image_analogy/main.py", line 69, in main
    net = vgg16.get_model(img_width, img_height, weights_path=args.vgg_weights, pool_mode=args.pool_mode)
  File "/usr/local/lib/python2.7/dist-packages/image_analogy/vgg16.py", line 79, in get_model
    f = h5py.File(weights_path)
  File "/usr/local/lib/python2.7/dist-packages/h5py/_hl/files.py", line 272, in __init__
    fid = make_fid(name, mode, userblock_size, fapl, swmr=swmr)
  File "/usr/local/lib/python2.7/dist-packages/h5py/_hl/files.py", line 117, in make_fid
    fid = h5f.create(name, h5f.ACC_EXCL, fapl=fapl, fcpl=fcpl)
  File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper (/tmp/pip-4rPeHA-build/h5py/_objects.c:2684)
  File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper (/tmp/pip-4rPeHA-build/h5py/_objects.c:2642)
  File "h5py/h5f.pyx", line 96, in h5py.h5f.create (/tmp/pip-4rPeHA-build/h5py/h5f.c:2097)
IOError: Unable to create file (Unable to open file: name = 'vgg16_weights.h5', errno = 17, error message = 'file exists', flags = 15, o_flags = c2)

I tried also tried putting the weights in another directory and using the VGG_WEIGHT_PATH var, but got the same error. Any help would be appreciated.

Thanks

freeman-g commented 7 years ago

Looks like curl didn't actually download the file:

cat vgg16_weights.h5
<html><body>You are being <a href="https://github-cloud.s3.amazonaws.com/releases/52701428/ea1d5778-e9f7-11e5-9f12-bc9a16c75380.h5?X-Amz-Algorithm=AWS4-HMAC-SHA256&amp;X-Amz-Credential=AKIAISTNZFOVBIJMK3TQ%2F20161216%2Fus-east-1%2Fs3%2Faws4_request&amp;X-Amz-Date=20161216T003949Z&amp;X-Amz-Expires=300&amp;X-Amz-Signature=e182f57009e3034f888ba611a78ffcdb86ef379756839cb6b59089fd25769a90&amp;X-Amz-SignedHeaders=host&amp;actor_id=0&amp;response-content-disposition=attachment%3B%20filename%3Dvgg16_weights.h5&amp;response-content-type=application%2Foctet-stream">redirected</a>.</body></html>