marcellacornia / sam

Predicting Human Eye Fixations via an LSTM-based Saliency Attentive Model. IEEE Transactions on Image Processing (2018)
https://ieeexplore.ieee.org/document/8400593
MIT License
208 stars 76 forks source link

Compiling SAM-ResNet failed #2

Closed Cogito2012 closed 7 years ago

Cogito2012 commented 7 years ago

When I run the command :

sudo python main.py test ./sample_images

the program terminated at line 63 with errors:

Traceback (most recent call last):
  File "main.py", line 63, in <module>
    m = Model(input=[x, x_maps], output=sam_resnet([x, x_maps]))
  File "/home/bwt/CZL/sam-master/models.py", line 142, in sam_resnet
    dcn = dcn_resnet(input_tensor=x[0])
  File "/home/bwt/CZL/sam-master/dcn_resnet.py", line 172, in dcn_resnet
    model.load_weights(weights_path)
  File "/usr/local/lib/python2.7/dist-packages/Keras-2.0.6-py2.7.egg/keras/engine/topology.py", line 2608, in load_weights
    load_weights_from_hdf5_group(f, self.layers)
  File "/usr/local/lib/python2.7/dist-packages/Keras-2.0.6-py2.7.egg/keras/engine/topology.py", line 3084, in load_weights_from_hdf5_group
    K.batch_set_value(weight_value_tuples)
  File "/usr/local/lib/python2.7/dist-packages/Keras-2.0.6-py2.7.egg/keras/backend/tensorflow_backend.py", line 2183, in batch_set_value
    assign_op = x.assign(assign_placeholder)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/variables.py", line 516, in assign
    return state_ops.assign(self._variable, value, use_locking=use_locking)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/state_ops.py", line 271, in assign
    validate_shape=validate_shape)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/gen_state_ops.py", line 45, in assign
    use_locking=use_locking, name=name)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/op_def_library.py", line 767, in apply_op
    op_def=op_def)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 2508, in create_op
    set_shapes_for_outputs(ret)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 1873, in set_shapes_for_outputs
    shapes = shape_func(op)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 1823, in call_with_requiring
    return call_cpp_shape_fn(op, require_shape_fn=True)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/common_shapes.py", line 610, in call_cpp_shape_fn
    debug_python_shape_fn, require_shape_fn)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/common_shapes.py", line 676, in _call_cpp_shape_fn_impl
    raise ValueError(err.message)
ValueError: Dimension 2 in both shapes must be equal, but are 320 and 64 for 'Assign' (op: 'Assign') with input shapes: [7,7,320,64], [7,7,64,3].

It seems that your code configurations have the wrong input shape, how to solve the problem?

marcellacornia commented 7 years ago

Hi @Cogito2012, thanks for downloading our code.

It seems that your settings are wrong. As clearly written in the readme, our code is compatible with Keras 1.1.0 configured with Theano as backend. Instead, you are using Keras 2 and Tensorflow.

Moreover, you are forgetting a slash at the end of the input path: python main.py test sample_images/.

Cogito2012 commented 7 years ago

@marcellacornia sorry for not carefully reading the readme file, now I have run the code successfully for your help, thanks very much!