marcellacornia / mlnet

A Deep Multi-Level Network for Saliency Prediction. ICPR 2016
MIT License
94 stars 37 forks source link

ERROR #20

Closed diennv98 closed 4 years ago

diennv98 commented 5 years ago

Using Theano backend. Traceback (most recent call last): File "main.py", line 43, in model = ml_net_model(img_cols=shape_c, img_rows=shape_r, downsampling_factor_product=10) File "/content/mlnet/model.py", line 26, in ml_net_model weights = get_weights_vgg16(f, 1) File "/content/mlnet/model.py", line 14, in get_weightsvgg16 g = f['layer{}'.format(id)] File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper File "/usr/local/lib/python2.7/dist-packages/h5py/_hl/group.py", line 177, in getitem oid = h5o.open(self.id, self._e(name), lapl=self._lapl) File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper File "h5py/h5o.pyx", line 190, in h5py.h5o.open KeyError: "Unable to open object (object 'layer_1' doesn't exist)"

I am using keras 1.1.0 Theano 0.9.0 help me

marcellacornia commented 5 years ago

Hi @diendepzai1998, thanks for downloading our code.

Did you download the weight file correctly?

Azzurro96 commented 4 years ago

I am facing the same error now. And the weight file has been download correctly.

neoaashish commented 4 years ago

Exactly the same problem and I have Keras 1.1 with theano 0.9.

Traceback (most recent call last): File "main.py", line 43, in model = ml_net_model(img_cols=shape_c, img_rows=shape_r, downsampling_factor_product=10) File "/home/aashish/mlnet/model.py", line 44, in ml_net_model weights = get_weights_vgg16(f, 1) File "/home/aashish/mlnet/model.py", line 26, in get_weightsvgg16 g = f['layer{}'.format(id)] File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper File "/usr/local/lib/python2.7/dist-packages/h5py/_hl/group.py", line 264, in getitem oid = h5o.open(self.id, self._e(name), lapl=self._lapl) File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper File "h5py/h5o.pyx", line 190, in h5py.h5o.open KeyError: "Unable to open object (object 'layer_1' doesn't exist)"

Could it be possibly somehow related to this warning:

/home/aashish/mlnet/model.py:18: H5pyDeprecationWarning: The default file mode will change to 'r' (read-only) in h5py 3.0. To suppress this warning, pass the mode you need to h5py.File(), or set the global default h5.get_config().default_file_mode, or set the environment variable H5PY_DEFAULT_READONLY=1. Available modes are: 'r', 'r+', 'w', 'w-'/'x', 'a'. See the docs for details.

Please help. Regards, Aashish Neupane

marcellacornia commented 4 years ago

This is probably due to a too recent version of the h5py package. Please try to replace line 19 of the model.py file with: f = h5py.File("vgg16_weights.h5", mode="r")

Otherwise, you can try to downgrade the h5py package.

Note: be sure to have correctly downloaded the vgg16_weights.h5 under the code root folder.

XXEssie commented 1 year ago

@marcellacornia I also have the exact same problem. I think the problem is in the line 43 of the file main.py. Where the line "model = ml_net_model(img_cols=shape_c, img_rows=shape_r, downsampling_factor_product=10)" would generate following error: KeyError Traceback (most recent call last)

in () ----> 1 model = ml_net_model(img_cols=shape_c, img_rows=shape_r, downsampling_factor_product=10) C:\mlnet-master\model.pyc in ml_net_model(img_rows, img_cols, downsampling_factor_net, downsampling_factor_product) 24 # FEATURE EXTRACTION NETWORK # 25 ######################################################### ---> 26 weights = get_weights_vgg16(f, 1) 27 conv1_1 = Convolution2D(64, 3, 3, weights=weights, activation='relu', border_mode='same')(input_ml_net) 28 weights = get_weights_vgg16(f, 3) C:\mlnet-master\model.pyc in get_weights_vgg16(f, id) 12 13 def get_weights_vgg16(f, id): ---> 14 g = f['layer_{}'.format(id)] 15 return [g['param_{}'.format(p)] for p in range(g.attrs['nb_params'])] 16 h5py\_objects.pyx in h5py._objects.with_phil.wrapper() h5py\_objects.pyx in h5py._objects.with_phil.wrapper() c:\users\ran\.conda\envs\sam\lib\site-packages\h5py\_hl\group.pyc in __getitem__(self, name) 262 raise ValueError("Invalid HDF5 object reference") 263 else: --> 264 oid = h5o.open(self.id, self._e(name), lapl=self._lapl) 265 266 otype = h5i.get_type(oid) h5py\_objects.pyx in h5py._objects.with_phil.wrapper() h5py\_objects.pyx in h5py._objects.with_phil.wrapper() h5py\h5o.pyx in h5py.h5o.open() KeyError: "Unable to open object (object 'layer_1' doesn't exist)" ------------------------------------------------------- Please help~ Thank you very much :D