ndrplz / dreyeve

[TPAMI 2018] Predicting the Driver’s Focus of Attention: the DR(eye)VE Project. A deep neural network learnt to reproduce the human driver focus of attention (FoA) in a variety of real-world driving scenarios.
https://arxiv.org/pdf/1705.03854.pdf
MIT License
99 stars 33 forks source link

ValueError: total size of new array must be unchanged #3

Closed MathematicalModels closed 6 years ago

MathematicalModels commented 6 years ago

Hi, I'm trying to implement your code on my own server. But when I entered the /dreyeve-master/experiments/train$ directory and typed " python train.py", it showes "ValueError: total size of new array must be unchanged". The full information is as follows:

Traceback (most recent call last): File "train.py", line 114, in fine_tuning() File "train.py", line 20, in fine_tuning model = DreyeveNet(frames_per_seq=frames_per_seq, h=h, w=w) File "/data/aaa/dreyeve-master/experiments/train/models.py", line 123, in DreyeveNet im_net = SaliencyBranch(input_shape=(3, frames_per_seq, h, w), c3d_pretrained=True, branch='image') File "/data/aaa/dreyeve-master/experiments/train/models.py", line 72, in SaliencyBranch coarse_predictor = CoarseSaliencyModel(input_shape=(c, fr, h // 4, w // 4), pretrained=c3d_pretrained, branch=branch) File "/data/aaa/dreyeve-master/experiments/train/models.py", line 47, in CoarseSaliencyModel H = Reshape(target_shape=(512, h // 8, w // 8))(H) # squeeze out temporal dimension File "/data/aaa/.local/lib/python2.7/site-packages/keras/engine/topology.py", line 569, in call self.add_inbound_node(inbound_layers, node_indices, tensor_indices) File "/data/aaa/.local/lib/python2.7/site-packages/keras/engine/topology.py", line 632, in add_inbound_node Node.create_node(self, inbound_layers, node_indices, tensor_indices) File "/data/aaa/.local/lib/python2.7/site-packages/keras/engine/topology.py", line 168, in create_node output_shapes = to_list(outbound_layer.get_output_shape_for(input_shapes[0])) File "/data/aaa/.local/lib/python2.7/site-packages/keras/layers/core.py", line 336, in get_output_shape_for self.target_shape) File "/data/aaa/.local/lib/python2.7/site-packages/keras/layers/core.py", line 330, in _fix_unknown_dimension raise ValueError(msg) " It seems that the bug comes from this line: H = Reshape(target_shape=(512, h // 8, w // 8))(H) # squeeze out temporal dimension

line 47 in the models.py

I have searched about this error, but still have no clues. So could you be so kind to help me with this issue? Thank you!

DavideA commented 6 years ago

Hi! That is likely to be a channel first vs channel last conflict.

Can you make sure that in your keras.json file you have "image_dim_ordering":"th" or "image_data_format":"channels_first"

depending on your version of Keras.

I would recommend also to use Keras 1 with theano backend in order to run the code.

D

MathematicalModels commented 6 years ago

@DavideA Dear Abati,

  Thank you so much for your kindly reply.
  I have set the "image_data_format" to "channels_first", and the Keras version is 1.2.

But the error message remains the same.

DavideA commented 6 years ago

Try removing "image_data_format" and set "image_dim_ordering":"th".

D

MathematicalModels commented 6 years ago

Thank you very much! It just works! And began: Downloading data from http://imagelab.ing.unimore.it/files/c3d_weights/w_up2_conv4_new.h5

@DavideA Thank you very much! :)

DavideA commented 6 years ago

No problem! I recently had the same issues :)

Closing D