iamaaditya / VQA_Demo

Visual Question Answering Demo on pretrained model
http://iamaaditya.github.io/2016/04/visual_question_answering_demo_notebook
MIT License
242 stars 133 forks source link

KeyError: "Can't open attribute (Can't locate attribute: 'layer_names')" #11

Closed burglarhobbit closed 7 years ago

burglarhobbit commented 7 years ago

I'm facing this issue when I run the python demo.py -image_file_name test.jpg -question "Is there a man in the picture?". I'm using Python 2.7, Keras 2.0.4, {Theano,th} backend in keras.json {backend,image_dim_ordering}, Theano 0.9.0. Here's the stacktrace:

Traceback (most recent call last):
  File "demo.py", line 116, in <module>
    main()
  File "demo.py", line 94, in main
    image_features = get_image_features(args.image_file_name, CNN_weights_file_name)
  File "demo.py", line 57, in get_image_features
    image_features[0,:] = get_image_model(CNN_weights_file_name).predict(im)[0]
  File "demo.py", line 22, in get_image_model
    image_model = VGG_16(CNN_weights_file_name)
  File "/media/bhavya/New_Volume/ICT/UGRP/Implementation/VQA_Demo/models/CNN/VGG.py", line 73, in VGG_16
    model.load_weights(weights_path)
  File "/usr/local/lib/python2.7/dist-packages/keras/models.py", line 717, in load_weights
    topology.load_weights_from_hdf5_group(f, layers)
  File "/usr/local/lib/python2.7/dist-packages/keras/engine/topology.py", line 2931, in load_weights_from_hdf5_group
    layer_names = [n.decode('utf8') for n in f.attrs['layer_names']]
  File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper (/tmp/pip-nCYoKW-build/h5py/_objects.c:2840)
  File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper (/tmp/pip-nCYoKW-build/h5py/_objects.c:2798)
  File "/usr/local/lib/python2.7/dist-packages/h5py/_hl/attrs.py", line 58, in __getitem__
    attr = h5a.open(self._id, self._e(name))
  File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper (/tmp/pip-nCYoKW-build/h5py/_objects.c:2840)
  File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper (/tmp/pip-nCYoKW-build/h5py/_objects.c:2798)
  File "h5py/h5a.pyx", line 77, in h5py.h5a.open (/tmp/pip-nCYoKW-build/h5py/h5a.c:2337)
KeyError: "Can't open attribute (Can't locate attribute: 'layer_names')"