GithubHelp home page GithubHelp logo

marcellacornia / sam Goto Github PK

View Code? Open in Web Editor NEW
205.0 10.0 77.0 838 KB

Predicting Human Eye Fixations via an LSTM-based Saliency Attentive Model. IEEE Transactions on Image Processing (2018)

Home Page: https://ieeexplore.ieee.org/document/8400593

License: MIT License

Python 100.00%
saliency-map saliency-prediction human-eye-fixations saliency saliency-model saliency-attentive-model

sam's Introduction

Predicting Human Eye Fixations via an LSTM-based Saliency Attentive Model

This repository contains the reference code for computing SAM (Saliency Attentive Model) saliency maps based on the following paper:

Marcella Cornia, Lorenzo Baraldi, Giuseppe Serra, Rita Cucchiara
Predicting Human Eye Fixations via an LSTM-based Saliency Attentive Model
IEEE Transactions on Image Processing, 2018

Please cite with the following Bibtex code:

@article{cornia2018predicting,
  author = {Cornia, Marcella and Baraldi, Lorenzo and Serra, Giuseppe and Cucchiara, Rita},
  title = {{Predicting Human Eye Fixations via an LSTM-based Saliency Attentive Model}},
  journal = {IEEE Transactions on Image Processing},
  volume={27},
  number={10},
  pages={5142--5154},
  year = {2018}
}

The PDF of the article is available at this link.

Additional experimental results are reported in the following short paper:

Marcella Cornia, Lorenzo Baraldi, Giuseppe Serra, Rita Cucchiara
SAM: Pushing the Limits of Saliency Prediction Models
Proceedings of the IEEE/CVF International Conference on Computer Vision and Pattern Recognition Workshops, 2018

Please cite with the following Bibtex code:

@inproceedings{cornia2018sam,
  author = {Cornia, Marcella and Baraldi, Lorenzo and Serra, Giuseppe and Cucchiara, Rita},
  title = {{SAM: Pushing the Limits of Saliency Prediction Models}},
  booktitle = {Proceedings of the IEEE/CVF International Conference on Computer Vision and Pattern Recognition Workshops},
  year = {2018}
}

Abstract

Data-driven saliency has recently gained a lot of attention thanks to the use of Convolutional Neural Networks for predicting gaze fixations. In this paper we go beyond standard approaches to saliency prediction, in which gaze maps are computed with a feed-forward network, and we present a novel model which can predict accurate saliency maps by incorporating neural attentive mechanisms. The core of our solution is a Convolutional LSTM that focuses on the most salient regions of the input image to iteratively refine the predicted saliency map. Additionally, to tackle the center bias present in human eye fixations, our model can learn a set of prior maps generated with Gaussian functions. We show, through an extensive evaluation, that the proposed architecture overcomes the current state of the art on two public saliency prediction datasets. We further study the contribution of each key components to demonstrate their robustness on different scenarios.

sam-fig

Requirements

  • Python 2.7
  • Theano 0.9.0
  • Keras 1.1.0, configured for using Theano as backend
  • OpenCV 3.0.0

Note: Be sure to have "image_dim_ordering": "th" and "backend": "theano" in your keras.json file.

Usage

We built two different versions of our model: one based on the VGG-16 (SAM-VGG) and the other based on the ResNet-50 (SAM-ResNet). It is possible use both versions of SAM by changing the version variable in the config.py file (set version = 0 for SAM-VGG or version = 1 for SAM-ResNet).

To compute saliency maps using our pre-trained model:

python main.py test path/to/images/folder/

where "path/to/images/folder/" is the path of a folder containing the images for which you want to calculate the saliency maps.

To train our model from scratch:

python main.py train

It is also necessary to set parameters and paths in the config.py file.

Note: To train our model, both binary fixation maps and groundtruth density maps are required. The current code for loading binary fixation maps supports the format used in SALICON (.mat files). If you want to train our model with other datasets, be sure to appropriately change the loading functions.

Pretrained Models

Download one of the following pretrained models and save it in the code folder:

Precomputed Saliency Maps

We provide saliency maps predicted by SAM-VGG and SAM-ResNet for three standard datasets (SALICON, MIT1003 and CAT2000):

In addition, we provide saliency maps predicted by SAM-ResNet on the new release of the SALICON dataset:

Contact

For more datails about our research please visit our page.

If you have any general doubt about our work, please use the public issues section on this github repo. Alternatively, drop us an e-mail at [email protected] or [email protected].

sam's People

Contributors

baraldilorenzo avatar marcellacornia avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sam's Issues

How to learn the prior maps in your method?

Hi,
Thanks for your excellent work, here I wanna know about the prior map.

However, rather than knowing how to use the prior maps, I'd like to know more about how you get the prior maps. What does the learn mean in learned priors? Is there another network to learn to generate the prior maps? Or is there any ground truth to train the network to produce the prior maps?

Looking forward to your reply!

Getting this IOError

(SAM) v818-0a87825a:SAM-VGG: SAM-ResNet $ python main.py test sample_images/
Using Theano backend.
/Users/opt/anaconda2/envs/SAM/lib/python2.7/site-packages/keras/engine/topology.py:376: UserWarning: The regularizers property of layers/models is deprecated. Regularization losses are now managed via the losses layer/model property.
warnings.warn('The regularizers property of layers/models '
Compiling SAM-ResNet
Loading SAM-ResNet weights
Traceback (most recent call last):
File "main.py", line 108, in
m.load_weights('weights/sam-resnet_salicon_weights.pkl')
File "/Users/opt/anaconda2/envs/SAM/lib/python2.7/site-packages/keras/engine/topology.py", line 2695, in load_weights
f = h5py.File(filepath, mode='r')
File "/Users/opt/anaconda2/envs/SAM/lib/python2.7/site-packages/h5py/_hl/files.py", line 394, in init
swmr=swmr)
File "/Users/opt/anaconda2/envs/SAM/lib/python2.7/site-packages/h5py/_hl/files.py", line 170, in make_fid
fid = h5f.open(name, flags, fapl=fapl)
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/h5f.pyx", line 85, in h5py.h5f.open
IOError: Unable to open file (unable to open file: name = 'weights/sam-resnet_salicon_weights.pkl', errno = 2, error message = 'No such file or directory', flags = 0, o_flags = 0)

theano

when theano=0.9.0 :ImportError: cannot import name inplace_increment
when theano=1.0.3:ValueError: CorrMM images and kernel must have the same stack size and HINT: Use the Theano flag 'exception_verbosity=high' for a debugprint and storage map footprint of this apply node.
could you help me?thanks

About error in concat

Hi, I am trying to run your code with the CAT2000 data. However, I receive this error.

Traceback (most recent call last):
File "main.py", line 63, in
m = Model(input=[x, x_maps], output=sam_resnet([x, x_maps]))
File "/home/jacky/sam/models.py", line 140, in sam_resnet
concateneted = merge([att_convlstm, priors1], mode='concat', concat_axis=1)
File "/usr/local/lib/python2.7/dist-packages/keras/engine/topology.py", line 1528, in merge
name=name)
File "/usr/local/lib/python2.7/dist-packages/keras/engine/topology.py", line 1186, in init
node_indices, tensor_indices)
File "/usr/local/lib/python2.7/dist-packages/keras/engine/topology.py", line 1253, in _arguments_validation
'Layer shapes: %s' % (input_shapes))
Exception: "concat" mode can only merge layers with matching output shapes except for the concat axis. Layer shapes: [(None, 512, 30, 512), (None, 16, 30, 40)]

I have set my library as the same as the requirement, which is Theano==0.9 and Keras==1.1.

Please advise. Thanks a lot.

what is your version of cuda cudnn ?

what is your version of cuda cudnn ?

ValueError: CorrMM images and kernel must have the same stack size

HINT: Use the Theano flag 'exception_verbosity=high' for a debugprint and storage map footprint of this apply node.

Compiling SAM-ResNet failed

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?

Loading Salicon dataset

Hi,

I'm trying to retrain the models on salicaon using your code. I don't see the fixations and fixation maps data as used in the code here. Like separate files for each image. Or is there a preprocessing part that I'm supposed to do before using the code?

Can you give me pointers to the dataset download url?

I'm currently downloading the dataset from
http://salicon.net/download/

Thank you so much!
Spandana

'NoneType' object is not subscriptable

Hi,
help me to rectify this error
Traceback (most recent call last):
File "main.py", line 73, in
m = Model(input=[x, x_maps], output=sam_resnet([x, x_maps]))
File "\sam-master\models.py", line 136, in sam_resnet
nb_cols=3, nb_rows=3)(att_convlstm)
File "\sam-master\keras\engine\base_layer.py", line 457, in call
output = self.call(inputs, **kwargs)
File "\sam-master\attentive_convlstm.py", line 154, in call
input_length=input_shape[1])
File "\sam-master\keras\backend\theano_backend.py", line 1591, in rnn
go_backwards=go_backwards)
File "\Anaconda3\lib\site-packages\theano\scan_module\scan.py", line 773, in scan
condition, outputs, updates = scan_utils.get_updates_and_outputs(fn(*args))
File "\sam-master\keras\backend\theano_backend.py", line 1575, in _step
outputs, new_states = step_function(inputs, states)
File "\sam-master\attentive_convlstm.py", line 123, in step
a = K.reshape(K.softmax(K.batch_flatten(e)), (x_shape[0], 1, x_shape[2], x_shape[3]))
File "\sam-master\keras\backend\theano_backend.py", line 1101, in batch_flatten
if None in x._keras_shape[1:]:
TypeError: 'NoneType' object is not subscriptable
thanks

Not getting good results using pretrained model

Thanks for open sourcing the code :)

I ran the pre-trained resnet-SAM model on the complete CAT2000 trainSet and caculated the mean CC. For me it is coming to be 0.65 which is much less than the test CC mentoined on MIT Saliency page (0.89).

I ran the model exactly as described in the README and am using this repo for CC metrics.

Is there something I am missing?

coefficient of correlation loss

`

def correlation_coefficient(y_true, y_pred):
    max_y_pred = K.repeat_elements(K.expand_dims(K.repeat_elements(K.expand_dims(K.max(K.max(y_pred, axis=2), axis=2)), 
                                                               shape_r_out, axis=-1)), shape_c_out, axis=-1)
    y_pred /= max_y_pred
    sum_y_true = K.repeat_elements(K.expand_dims(K.repeat_elements(K.expand_dims(K.sum(K.sum(y_true, axis=2), axis=2)), 
                                                               shape_r_out, axis=-1)), shape_c_out, axis=-1)
    sum_y_pred = K.repeat_elements(K.expand_dims(K.repeat_elements(K.expand_dims(K.sum(K.sum(y_pred, axis=2), axis=2)), 
                                                               shape_r_out, axis=-1)), shape_c_out, axis=-1)

    y_true /= (sum_y_true + K.epsilon())
    y_pred /= (sum_y_pred + K.epsilon())

    N = shape_r_out * shape_c_out
    sum_prod = K.sum(K.sum(y_true * y_pred, axis=2), axis=2)
    sum_x = K.sum(K.sum(y_true, axis=2), axis=2)
    sum_y = K.sum(K.sum(y_pred, axis=2), axis=2)
    sum_x_square = K.sum(K.sum(K.square(y_true), axis=2), axis=2)
    sum_y_square = K.sum(K.sum(K.square(y_pred), axis=2), axis=2)

    num = sum_prod - ((sum_x * sum_y) / N)
    den = K.sqrt((sum_x_square - K.square(sum_x) / N) * (sum_y_square - K.square(sum_y) / N))

    return -2 * num / den

`
Hi
thank you for this repo. I am trying to replicate your work but I am having some question understanding your implementation of coefficient of correlation.

Can you please explain why did you divided the prediction by max valuse in the array, and divided both prediction and ground truth by their sum respectively. Is this some kind of optimization trick?

AttributeError: 'NoneType' object has no attribute 'shape'

Hello, I've meet some errors when trying to use this code.
I have the same version as mentioned and I didn't change any code. But it gives me these two errors.
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
self.run()
File "/usr/lib/python2.7/threading.py", line 763, in run
self.__target(*self.__args, **self.__kwargs)
File "/usr/local/lib/python2.7/dist-packages/keras/engine/training.py", line 425, in data_generator_task
generator_output = next(generator)
File "main.py", line 48, in generator_test
yield [preprocess_images(images[counter:counter + b_s], shape_r, shape_c), gaussian]
File "/home/huying/workspace_linux/Saliency/sam-master/utilities.py", line 79, in preprocess_images
padded_image = padding(original_image, shape_r, shape_c, 3)
File "/home/huying/workspace_linux/Saliency/sam-master/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 112, 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/python2.7/dist-packages/keras/engine/training.py", line 1634, in predict_generator
outs = self.predict_on_batch(x)
File "/usr/local/lib/python2.7/dist-packages/keras/engine/training.py", line 1268, in predict_on_batch
self.internal_input_shapes)
File "/usr/local/lib/python2.7/dist-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...

Can you help with that?

Configuration for 84*84 input images

Hi @marcellacornia , Thanks once again for your code.
I was trying to use the SAM testing (with Res-Net) for an input image size of 84*84. I tried tweaking the config file to the below values and something similar also.

#version (0 for SAM-VGG and 1 for SAM-ResNet)
version = 1
#batch size
b_s = 1
# number of rows of input images
shape_r = 84 #240
# number of cols of input images
shape_c = 84 #320
# number of rows of downsampled maps
shape_r_gt = 40
# number of cols of downsampled maps
shape_c_gt = 40 #40
# number of rows of model outputs
shape_r_out = 168 #480
# number of cols of model outputs
shape_c_out = 168 #640
# final upsampling factor
upsampling_factor = 16
# number of epochs
nb_epoch = 10
# number of timestep
nb_timestep = 4
# number of learned priors
nb_gaussian = 16

But I think I am missing something. I am not giving the right dimensions for concat function when the model is created.
Exception: "concat" mode can only merge layers with matching output shapes except for the concat axis. Layer shapes: [(None, 512, 11, 11), (None, 16, 40, 40)]

Could you please suggest what should the values be for an 84*84 image such that this would work?
Really appreciate your inputs and time in replying.

Unable to run the code

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

train model

Hi, I successfully run it on the samples images using your pretrained model. Now i'm trying to retrain the models using your code but get this error:
Using Theano backend.
/home/kntu/anaconda3/lib/python3.6/site-packages/keras/backend/theano_backend.py:1282: UserWarning: DEPRECATION: the 'ds' parameter is not going to exist anymore as it is going to be replaced by the parameter 'ws'.
mode='max')
/home/kntu/anaconda3/lib/python3.6/site-packages/keras/backend/theano_backend.py:1282: UserWarning: DEPRECATION: the 'st' parameter is not going to exist anymore as it is going to be replaced by the parameter 'stride'.
mode='max')
/home/kntu/anaconda3/lib/python3.6/site-packages/keras/backend/theano_backend.py:1282: UserWarning: DEPRECATION: the 'padding' parameter is not going to exist anymore as it is going to be replaced by the parameter 'pad'.
mode='max')
/home/kntu/anaconda3/lib/python3.6/site-packages/h5py/init.py:36: FutureWarning: Conversion of the second argument of issubdtype from float to np.floating is deprecated. In future, it will be treated as np.float64 == np.dtype(float).type.
from ._conv import register_converters as _register_converters
Compiling SAM-ResNet
Training SAM-ResNet
Epoch 1/10
Exception in thread Thread-1:
Traceback (most recent call last):
File "/home/kntu/anaconda3/lib/python3.6/threading.py", line 916, in _bootstrap_inner
self.run()
File "/home/kntu/anaconda3/lib/python3.6/threading.py", line 864, in run
self._target(*self._args, **self._kwargs)
File "/home/kntu/anaconda3/lib/python3.6/site-packages/keras/engine/training.py", line 425, in data_generator_task
generator_output = next(generator)
File "main.py", line 46, in generator
Y_fix = preprocess_fixmaps(fixs[counter:counter + b_s], shape_r_out, shape_c_out)
File "/home/kntu/LS/new_sam/sam-master/sam-master/utilities.py", line 106, in preprocess_fixmaps
fix_map = scipy.io.loadmat(path)["I"]
KeyError: 'I'

Traceback (most recent call last):
File "main.py", line 97, in
ModelCheckpoint('weights.sam-resnet.{epoch:02d}-{val_loss:.4f}.pkl', save_best_only=True)])
File "/home/kntu/anaconda3/lib/python3.6/site-packages/keras/engine/training.py", line 1417, in fit_generator
'or (x, y). Found: ' + str(generator_output))
Exception: output of generator should be a tuple (x, y, sample_weight) or (x, y). Found: None
thanks.

Adapting different testing image shapes?

I got an error below:

Traceback (most recent call last):
File "main.py", line 63, in
m = Model(input=[x, x_maps], output=sam_resnet([x, x_maps]))
File "/Users/Terry/Documents/Memorix/sam-master/models.py", line 140, in sam_resnet
concateneted = merge([att_convlstm, priors1], mode='concat', concat_axis=1)
File "/Users/Terry/anaconda3/envs/python27/lib/python2.7/site-packages/keras/engine/topology.py", line 1528, in merge
name=name)
File "/Users/Terry/anaconda3/envs/python27/lib/python2.7/site-packages/keras/engine/topology.py", line 1186, in init
node_indices, tensor_indices)
File "/Users/Terry/anaconda3/envs/python27/lib/python2.7/site-packages/keras/engine/topology.py", line 1253, in _arguments_validation
'Layer shapes: %s' % (input_shapes))
Exception: "concat" mode can only merge layers with matching output shapes except for the concat axis. Layer shapes: [(None, 512, 113, 180), (None, 16, 30, 40)]

Is it because of my testing images are 1440x900? If so, How do I configure the input shape of the model?

--
Update I tested pics with

Is there a Pytorch version

Dear author, thank you very much for your open source code. May I ask, is there a Pytorch version of the open source code? thank you very much.

Retraining the models

Hi, Thanks for open sourcing the code :)
I successfully run your pretrained models on the Salicon dataset. Now I want to retrain these models in order to achieve the wights of pretrained models by myself. does current training setup lead to the same wights or I'm supposed to change the learning rate and optimizer?

On the CPU

theano.gof.opt.LocalMetaOptimizerSkipAssertionError: AbstractConv2d Theano optimization failed: there is no implementation available supporting the requested options. Did you ex
clude both "conv_dnn" and "conv_gemm" from the optimizer? If on GPU, is cuDNN available and does the GPU support it? If on CPU, do you have a BLAS library installed Theano can l
ink against? On the CPU we do not support float16.

ValueError: CorrMM images and kernel must have the same stack size

Traceback (most recent call last):
File "/home/cbl/PycharmProjects/Predicting Human Eye Fixations via an LSTM-based Saliency Attentive Model/main.py", line 155, in
predictions = m.predict_generator(generator_test(b_s=b_s, imgs_test_path=imgs_test_path), nb_imgs_test)[0]
File "/home/public/anaconda3/envs/py27/lib/python2.7/site-packages/keras/engine/training.py", line 1634, in predict_generator
outs = self.predict_on_batch(x)
File "/home/public/anaconda3/envs/py27/lib/python2.7/site-packages/keras/engine/training.py", line 1274, in predict_on_batch
outputs = self.predict_function(ins)
File "/home/public/anaconda3/envs/py27/lib/python2.7/site-packages/keras/backend/theano_backend.py", line 717, in call
return self.function(*inputs)
File "/home/public/anaconda3/envs/py27/lib/python2.7/site-packages/theano/compile/function_module.py", line 917, in call
storage_map=getattr(self.fn, 'storage_map', None))
File "/home/public/anaconda3/envs/py27/lib/python2.7/site-packages/theano/gof/link.py", line 325, in raise_with_op
reraise(exc_type, exc_value, exc_trace)
File "/home/public/anaconda3/envs/py27/lib/python2.7/site-packages/theano/compile/function_module.py", line 903, in call
self.fn() if output_subset is None else
ValueError: CorrMM images and kernel must have the same stack size

Apply node that caused the error: CorrMM{half, (1, 1), (1, 1), 1 False}(InplaceDimShuffle{0,3,1,2}.0, Subtensor{::, ::, ::int64, ::int64}.0)
Toposort index: 251
Inputs types: [TensorType(float32, (True, False, False, False)), TensorType(float32, 4D)]
Inputs shapes: [(1, 40, 512, 30), (1, 1, 512, 512)]
Inputs strides: [(160, 4, 4800, 160), (1048576, 1048576, -2048, -4)]
Inputs values: ['not shown', 'not shown']
Outputs clients: [[Subtensor{int64:int64:int8, int64:int64:int8, int64:int64:int8, :int64:}(CorrMM{half, (1, 1), (1, 1), 1 False}.0, Constant{0}, Constant{1}, Constant{1}, ScalarFromTensor.0, ScalarFromTensor.0, Constant{1}, ScalarFromTensor.0, ScalarFromTensor.0, Constant{1}, Constant{30})]]

Backtrace when the node is created(use Theano flag traceback.limit=N to make it longer):
File "/home/cbl/PycharmProjects/Predicting Human Eye Fixations via an LSTM-based Saliency Attentive Model/main.py", line 104, in
m = Model(input=[x, x_maps], output=sam_vgg([x, x_maps]))
File "/home/cbl/PycharmProjects/Predicting Human Eye Fixations via an LSTM-based Saliency Attentive Model/models.py", line 107, in sam_vgg
nb_cols=3, nb_rows=3)(att_convlstm)
File "/home/public/anaconda3/envs/py27/lib/python2.7/site-packages/keras/engine/topology.py", line 514, in call
self.add_inbound_node(inbound_layers, node_indices, tensor_indices)
File "/home/public/anaconda3/envs/py27/lib/python2.7/site-packages/keras/engine/topology.py", line 572, in add_inbound_node
Node.create_node(self, inbound_layers, node_indices, tensor_indices)
File "/home/public/anaconda3/envs/py27/lib/python2.7/site-packages/keras/engine/topology.py", line 149, in create_node
output_tensors = to_list(outbound_layer.call(input_tensors[0], mask=input_masks[0]))
File "/home/cbl/PycharmProjects/Predicting Human Eye Fixations via an LSTM-based Saliency Attentive Model/attentive_convlstm.py", line 149, in call
initial_states = self.get_initial_states(x)
File "/home/cbl/PycharmProjects/Predicting Human Eye Fixations via an LSTM-based Saliency Attentive Model/attentive_convlstm.py", line 43, in get_initial_states
initial_state = K.conv2d(initial_state, K.zeros((self.nb_filters_out, self.nb_filters_in, 1, 1)), border_mode='same')
File "/home/public/anaconda3/envs/py27/lib/python2.7/site-packages/keras/backend/theano_backend.py", line 1135, in conv2d
filter_shape=filter_shape)

HINT: Use the Theano flag 'exception_verbosity=high' for a debugprint and storage map footprint of this apply node.

raise NotImplementedError

zhaochang@mml-Precision-7920-Rack:~/workspace/sam$ python main.py /homeg/workspace/sam/sample_images/
Using Theano backend.
/home/zhaochang/.local/lib/python3.6/site-packages/keras/backend/theano_backend.py:1282: UserWarning: DEPRECATION: the 'ds' parameter is not going to exist anymore as it is going to be replaced by the parameter 'ws'.
mode='max')
/home/zhaochang/.local/lib/python3.6/site-packages/keras/backend/theano_backend.py:1282: UserWarning: DEPRECATION: the 'st' parameter is not going to exist anymore as it is going to be replaced by the parameter 'stride'.
mode='max')
/home/zhaochang/.local/lib/python3.6/site-packages/keras/backend/theano_backend.py:1282: UserWarning: DEPRECATION: the 'padding' parameter is not going to exist anymore as it is going to be replaced by the parameter 'pad'.
mode='max')
/usr/local/anaconda3/lib/python3.6/site-packages/h5py/init.py:36: FutureWarning: Conversion of the second argument of issubdtype from float to np.floating is deprecated. In future, it will be treated as np.float64 == np.dtype(float).type.
from ._conv import register_converters as _register_converters
Compiling SAM-ResNet
Traceback (most recent call last):
File "main.py", line 119, in
raise NotImplementedError
NotImplementedError

Theano==0.9.0
Keras==1.1.0
Opencv==4.0.0

I met this error

Hi, @baraldilorenzo @marcellacornia

I met this error:

ValueError: Dimension 2 in both shapes must be equal, but are 320 and 64. Shapes are [7,7,320,64] and [7,7,64,3]. for 'Assign' (op: 'Assign') with input shapes: [7,7,320,64], [7,7,64,3].

What's wrong to me?

where is the prediction

after i ran python main.py test img/ it says

Using Theano backend.
/Users/sichen/anaconda2/lib/python2.7/site-packages/keras/backend/theano_backend.py:1282: UserWarning: DEPRECATION: the 'ds' parameter is not going to exist anymore as it is going to be replaced by the parameter 'ws'.
mode='max')
/Users/sichen/anaconda2/lib/python2.7/site-packages/keras/backend/theano_backend.py:1282: UserWarning: DEPRECATION: the 'st' parameter is not going to exist anymore as it is going to be replaced by the parameter 'stride'.
mode='max')
/Users/sichen/anaconda2/lib/python2.7/site-packages/keras/backend/theano_backend.py:1282: UserWarning: DEPRECATION: the 'padding' parameter is not going to exist anymore as it is going to be replaced by the parameter 'pad'.
mode='max')
Compiling SAM-ResNet
Loading SAM-ResNet weights
Predicting saliency maps for img/

Then done. But I don't see any predictions popping up. Where are they supposed to be?

Concat Mode Error

Hi,

I still have this error even though I've edited my Keras.json file according to solved issue with the same problem.
I got this:
(venv) parallels@parallels-Parallels-Virtual-Platform:~/Saliency/sam$ python main.py test Saliency/sam/sample_images
Using Theano backend.
/home/parallels/venv/lib/python3.6/site-packages/keras/backend/theano_backend.py:1282: UserWarning: DEPRECATION: the 'ds' parameter is not going to exist anymore as it is going to be replaced by the parameter 'ws'.
mode='max')
/home/parallels/venv/lib/python3.6/site-packages/keras/backend/theano_backend.py:1282: UserWarning: DEPRECATION: the 'st' parameter is not going to exist anymore as it is going to be replaced by the parameter 'stride'.
mode='max')
/home/parallels/venv/lib/python3.6/site-packages/keras/backend/theano_backend.py:1282: UserWarning: DEPRECATION: the 'padding' parameter is not going to exist anymore as it is going to be replaced by the parameter 'pad'.
mode='max')
Traceback (most recent call last):
File "main.py", line 63, in
m = Model(input=[x, x_maps], output=sam_resnet([x, x_maps]))
File "/home/parallels/Saliency/sam/models.py", line 140, in sam_resnet
concateneted = merge([att_convlstm, priors1], mode='concat', concat_axis=1)
File "/home/parallels/venv/lib/python3.6/site-packages/keras/engine/topology.py", line 1528, in merge
name=name)
File "/home/parallels/venv/lib/python3.6/site-packages/keras/engine/topology.py", line 1186, in init
node_indices, tensor_indices)
File "/home/parallels/venv/lib/python3.6/site-packages/keras/engine/topology.py", line 1253, in _arguments_validation
'Layer shapes: %s' % (input_shapes))
Exception: "concat" mode can only merge layers with matching output shapes except for the concat axis. Layer shapes: [(None, 512, 60, 80), (None, 16, 30, 40)]

Have you got any ideas what the problem there is? Should I try a later version of Theano? Thank you very much.

Why stuck in 'Predicting saliency maps for sample_images/'?

Download your codes and I just want to test if it works well. But when I run main.py as so:
python main.py test sample_images/
Codes can work till it prints 'Predicting saliency maps for sample_images/' and move no more forward.
Could you pls take a look at this issue?

Keras: 1.1.0
Theano: 0.9.0
OpenCV: 3.0.0

conv2d() got an unexpected keyword argument 'border_mode'

Hi
help me to rectify this error

Traceback (most recent call last):
File "main.py", line 63, in
m = Model(input=[x, x_maps], output=sam_resnet([x, x_maps]))
File "E:\sam-master\models.py", line 136, in sam_resnet
nb_cols=3, nb_rows=3)(att_convlstm)
File "C:\ProgramData\Anaconda3\lib\site-packages\keras\engine\topology.py", line 617, in call
output = self.call(inputs, **kwargs)
File "E:\sam-master\attentive_convlstm.py", line 143, in call
initial_states = self.get_initial_states(x)
File "E:\sam-master\attentive_convlstm.py", line 42, in get_initial_states
initial_state = K.conv2d(initial_state, K.zeros((self.nb_filters_out, self.nb_filters_in, 1, 1)), border_mode='same')
TypeError: conv2d() got an unexpected keyword argument 'border_mode'

ImportError: cannot import name get_from_module

Dear I'm trying to use your network but when I execute the test with the weight that you have uploaded I have this error:
Using Theano backend.
Traceback (most recent call last):
File "main.py", line 10, in
from models import sam_vgg, sam_resnet, kl_divergence, correlation_coefficient, nss
File "/media/vrai/Data/eyeTracking/sam-master/models.py", line 9, in
from gaussian_prior import LearningPrior
File "/media/vrai/Data/eyeTracking/sam-master/gaussian_prior.py", line 5, in
from keras import initializations, regularizers, constraints
File "/home/vrai/.local/lib/python2.7/site-packages/keras/initializations.py", line 104, in
from .utils.generic_utils import get_from_module
ImportError: cannot import name get_from_module

Can you explain to me where I'm doing a mistake?

Support in TX2

Its a question not an issue.

I am exploring to extend gaze estimation solutions to my thesis in TX2 hardware.
Solutions with openCL were either not compatible with TX2 or had to modified to use cpu. It made it non-performant.

As this implementation tried in TX2? I would also had to extend this solution in ROS.
Any guidance and in sites in this direction would be very helpful.

Thanks

TypeError: 'module' object is not callable

Hi All,

I have been getting the following error:

Using Theano backend.
Traceback (most recent call last):
File "main.py", line 63, in
m = Model(input=[x, x_maps], output=sam_resnet([x, x_maps]))
File "/Users/MichaelYan/sam/models.py", line 130, in sam_resnet
dcn = dcn_resnet(input_tensor=x[0])
File "/Users/MichaelYan/sam/dcn_resnet.py", line 143, in dcn_resnet
x = conv_block(x, 3, [64, 64, 256], stage=2, block='a', strides=(1, 1))
File "/Users/MichaelYan/sam/dcn_resnet.py", line 66, in conv_block
x = merge([x, shortcut], mode='sum')
TypeError: 'module' object is not callable

Any ideas for the cause? Thanks!

I met this error about CorrMM images and kernel must have the same stack size

Thanks for you code,whenI run it,i met this error, I hope you can help me solve this problem.
Traceback (most recent call last):
File "main.py", line 114, in
predictions = m.predict_generator(generator_test(b_s=b_s, imgs_test_path=imgs_test_path), nb_imgs_test)[0]
File "/home/han/.local/lib/python2.7/site-packages/keras/engine/training.py", line 1634, in predict_generator
outs = self.predict_on_batch(x)
File "/home/han/.local/lib/python2.7/site-packages/keras/engine/training.py", line 1274, in predict_on_batch
outputs = self.predict_function(ins)
File "/home/han/.local/lib/python2.7/site-packages/keras/backend/theano_backend.py", line 717, in call
return self.function(*inputs)
File "/home/han/.local/lib/python2.7/site-packages/theano/compile/function_module.py", line 898, in call
storage_map=getattr(self.fn, 'storage_map', None))
File "/home/han/.local/lib/python2.7/site-packages/theano/gof/link.py", line 325, in raise_with_op
reraise(exc_type, exc_value, exc_trace)
File "/home/han/.local/lib/python2.7/site-packages/theano/compile/function_module.py", line 884, in call
self.fn() if output_subset is None else
ValueError: CorrMM images and kernel must have the same stack size

Apply node that caused the error: CorrMM{half, (1, 1), (1, 1)}(InplaceDimShuffle{0,3,1,2}.0, Subtensor{::, ::, ::int64, ::int64}.0)
Toposort index: 1222
Inputs types: [TensorType(float32, (True, False, False, False)), TensorType(float32, 4D)]
Inputs shapes: [(1, 40, 512, 30), (1, 1, 512, 512)]
Inputs strides: [(160, 4, 4800, 160), (1048576, 1048576, -2048, -4)]
Inputs values: ['not shown', 'not shown']
Outputs clients: [[Subtensor{int64:int64:int8, int64:int64:int8, int64:int64:int8, :int64:}(CorrMM{half, (1, 1), (1, 1)}.0, Constant{0}, Constant{1}, Constant{1}, ScalarFromTensor.0, ScalarFromTensor.0, Constant{1}, ScalarFromTensor.0, ScalarFromTensor.0, Constant{1}, Constant{30})]]

Backtrace when the node is created(use Theano flag traceback.limit=N to make it longer):
File "main.py", line 65, in
m = Model(input=[x, x_maps], output=sam_resnet([x, x_maps]))
File "/home/han/sam-master/models.py", line 136, in sam_resnet
nb_cols=3, nb_rows=3)(att_convlstm)
File "/home/han/.local/lib/python2.7/site-packages/keras/engine/topology.py", line 514, in call
self.add_inbound_node(inbound_layers, node_indices, tensor_indices)
File "/home/han/.local/lib/python2.7/site-packages/keras/engine/topology.py", line 572, in add_inbound_node
Node.create_node(self, inbound_layers, node_indices, tensor_indices)
File "/home/han/.local/lib/python2.7/site-packages/keras/engine/topology.py", line 149, in create_node
output_tensors = to_list(outbound_layer.call(input_tensors[0], mask=input_masks[0]))
File "/home/han/sam-master/attentive_convlstm.py", line 143, in call
initial_states = self.get_initial_states(x)
File "/home/han/sam-master/attentive_convlstm.py", line 42, in get_initial_states
initial_state = K.conv2d(initial_state, K.zeros((self.nb_filters_out, self.nb_filters_in, 1, 1)), border_mode='same')
File "/home/han/.local/lib/python2.7/site-packages/keras/backend/theano_backend.py", line 1135, in conv2d
filter_shape=filter_shape)

HINT: Use the Theano flag 'exception_verbosity=high' for a debugprint and storage map footprint of this apply node.

Exception: "concat" mode can only merge layers with matching output shapes

Hello,
I'm trying to test network on sample images from repo with:
python main.py test sample_images/

But got this error:

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 "/beegfs/120x/home/ilia/_res_arch/sam/models.py", line 140, in sam_resnet
    concateneted = merge([att_convlstm, priors1], mode='concat', concat_axis=1)
  File "/beegfs/120x/home/ilia/Theano/local/lib/python2.7/site-packages/keras/engine/topology.py", line 1528, in merge
    name=name)
  File "/beegfs/120x/home/ilia/Theano/local/lib/python2.7/site-packages/keras/engine/topology.py", line 1186, in __init__
    node_indices, tensor_indices)
  File "/beegfs/120x/home/ilia/Theano/local/lib/python2.7/site-packages/keras/engine/topology.py", line 1253, in _arguments_validation
    'Layer shapes: %s' % (input_shapes))
Exception: "concat" mode can only merge layers with matching output shapes except for the concat axis. Layer shapes: [(None, 512, 30, 512), (None, 16, 30, 40)]

running on GPU

Hi,
Thank you for sharing the code! I successfully run it on the sample images with CPU. But when I tried to configure theano to use device=gpu or device=cuda, they both failed with quite long error messages.
For cuda particularly, there was a warning message at the beginning
/home/mingbo/anaconda3/envs/sam/lib/python3.5/site-packages/theano/sandbox/cuda/__init__.py:631: UserWarning: Your cuDNN version is more recent than the one Theano officially supports. If you see any problems, try updating Theano or downgrading cuDNN to version 5.1.

My first question is, do you expect your code to run faster on GPU? If not then I will just stay with CPU.
In case the answer is yes, do you think the version of theano 0.9.0 can ever work with cuDNN 6?
I am using cuda-8.0 and cuDNN 6 now.
Thanks a lot!

Outputs must be theano variables or Out instances

When trying to run the cloned repository, I get a TypeError like ' TypeError: Outputs must be theano Variable or Out instances. Received InplaceDimShuffle{3,2,0,1}.0 of type <class 'theano.tensor.var.TensorVariable'>'

Can you suggest a solution to get rid of this?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.