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

Unable to run the code #1

Closed dmardanbeigi closed 7 years ago

dmardanbeigi commented 7 years ago

I downloaded the code and I'm trying to run the code using python main.py test ./sample_image but I get the following error. I tried with both pretrained models and I get the same error. I'm using python3.6, theano 0.9.0, and keras 2.0.4.

Traceback (most recent call last): File "main.py", line 59, in m = Model(input=[x, x_maps], output=sam_vgg([x, x_maps])) File "/sam-master/models.py", line 119, in sam_vgg nb_cols=3, nb_rows=3)(att_convlstm) File "/usr/local/lib/python3.6/site-packages/keras/engine/topology.py", line 585, in call output = self.call(inputs, *kwargs) File "/sam-master/attentive_convlstm.py", line 156, in call input_length=input_shape[1]) File "/usr/local/lib/python3.6/site-packages/keras/backend/theano_backend.py", line 1335, in rnn go_backwards=go_backwards) File "/usr/local/lib/python3.6/site-packages/theano/scan_module/scan.py", line 773, in scan condition, outputs, updates = scan_utils.get_updates_and_outputs(fn(args)) File "/usr/local/lib/python3.6/site-packages/keras/backend/theano_backend.py", line 1323, in _step output, new_states = step_function(input, states) File "sam-master/attentive_convlstm.py", line 125, in step a = K.reshape(K.softmax(K.batch_flatten(e)), (x_shape[0], 1, x_shape[2], x_shape[3])) File "/usr/local/lib/python3.6/site-packages/keras/backend/theano_backend.py", line 933, in batch_flatten if None in x._keras_shape[1:]: TypeError: 'NoneType' object is not subscriptable

marcellacornia commented 7 years ago

Hi @dmardanbeigi, thanks for downloading our code!

You have to use Keras 1.1.0. Unfortunately, this code is not compatible with Keras 2.

dmardanbeigi commented 7 years ago

Thanks Marcella, I downgraded the Keras to version 1.1.0. No I get a different error whenI run the code (see the log below). I’m not sure if I need to download an older version of theano as well?

here is the error I get:

Compiling SAM-ResNet Loading SAM-ResNet weights Predicting saliency maps for /SaliencyMap/mlnet-master/sample_images Exception in thread Thread-1: Traceback (most recent call last): File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/threading.py", line 916, in _bootstrap_inner self.run() File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/threading.py", line 864, in run self._target(*self._args, **self._kwargs) File "/usr/local/lib/python3.6/site-packages/keras/engine/training.py", line 425, in data_generator_task generator_output = next(generator) File "main.py", line 47, in generator_test yield [preprocess_images(images[counter:counter + b_s], shape_r, shape_c), gaussian] File "/SaliencyMap/sam-master-2/utilities.py", line 79, in preprocess_images padded_image = padding(original_image, shape_r, shape_c, 3) File "/SaliencyMap/sam-master-2/utilities.py", line 13, in padding original_shape = img.shape AttributeError: 'NoneType' object has no attribute 'shape'

Traceback (most recent call last): File "main.py", line 113, in predictions = m.predict_generator(generator_test(b_s=b_s, imgs_test_path=imgs_test_path), nb_imgs_test)[0] File "/usr/local/lib/python3.6/site-packages/keras/engine/training.py", line 1634, in predict_generator outs = self.predict_on_batch(x) File "/usr/local/lib/python3.6/site-packages/keras/engine/training.py", line 1268, in predict_on_batch self.internal_input_shapes) File "/usr/local/lib/python3.6/site-packages/keras/engine/training.py", line 70, in standardize_input_data 'Found: ' + str(data)[:200] + '...') Exception: Error when checking : data should be a Numpy array, or list/dict of Numpy arrays. Found: None…

Diako

On May 5, 2017, at 9:11 AM, Marcella Cornia notifications@github.com wrote:

Hi @dmardanbeigi https://github.com/dmardanbeigi, thanks for downloading our code!

You have to use Keras 1.1.0. Unfortunately, this code is not compatible with Keras 2.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/marcellacornia/sam/issues/1#issuecomment-299407185, or mute the thread https://github.com/notifications/unsubscribe-auth/ADXb70Nq0LXWGzk-24LtRmgYlkW-ZOcEks5r2tmugaJpZM4NQ_AS.

marcellacornia commented 7 years ago

It seems that you are not loading the input images correctly. Try to add a slash at the end of your path. Your path should become "/SaliencyMap/mlnet-master/sample_images/".

dmardanbeigi commented 7 years ago

Thanks. Now it's working.