keras-cam icon indicating copy to clipboard operation
keras-cam copied to clipboard

Model Error

Open Eliie58 opened this issue 6 years ago • 6 comments

I downloaded the checkpoint from the mentioned link: https://drive.google.com/open?id=0B1l5JSkBbENBdk95ZW1DOUhqQUE

When i run the command: python cam.py --model_path cam_checkpoint.hdf5 --image_path=image.jpg

I get the following error: File "/home/user/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 1570, in _create_c_op raise ValueError(str(e)) ValueError: Dimension 0 in both shapes must be equal, but are 3 and 64. Shapes are [3,3,5,64] and [64,3,3,3]. for 'Assign' (op: 'Assign') with input shapes: [3,3,5,64], [64,3,3,3].

The full Error is: Traceback (most recent call last): File "cam.py", line 61, in visualize_class_activation_map(args.model_path, args.image_path, args.output_path) File "cam.py", line 18, in visualize_class_activation_map model = load_model(model_path) File "/usr/local/lib/python2.7/dist-packages/keras/models.py", line 246, in load_model topology.load_weights_from_hdf5_group(f['model_weights'], model.layers) File "/usr/local/lib/python2.7/dist-packages/keras/engine/topology.py", line 3189, in load_weights_from_hdf5_group K.batch_set_value(weight_value_tuples) File "/usr/local/lib/python2.7/dist-packages/keras/backend/tensorflow_backend.py", line 2365, in batch_set_value assign_op = x.assign(assign_placeholder) File "/home/user/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/ops/variables.py", line 615, in assign return state_ops.assign(self._variable, value, use_locking=use_locking) File "/home/user/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/ops/state_ops.py", line 283, in assign validate_shape=validate_shape) File "/home/user/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/ops/gen_state_ops.py", line 60, in assign use_locking=use_locking, name=name) File "/home/user/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/framework/op_def_library.py", line 787, in _apply_op_helper op_def=op_def) File "/home/user/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 3392, in create_op op_def=op_def) File "/home/user/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 1734, in init control_input_ops) File "/home/user/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 1570, in _create_c_op raise ValueError(str(e)) ValueError: Dimension 0 in both shapes must be equal, but are 3 and 64. Shapes are [3,3,5,64] and [64,3,3,3]. for 'Assign' (op: 'Assign') with input shapes: [3,3,5,64], [64,3,3,3].

Any idea why is this happening?

Eliie58 avatar May 28 '18 11:05 Eliie58

i hava the same problem whith you, did you solve it?

95xueqian avatar Oct 26 '18 07:10 95xueqian

i aslo hava the same problem whith you, did you solve it?

Jeralyn123 avatar Jan 02 '19 11:01 Jeralyn123

god,i have the same error,anybody got the answer?

farm365 avatar Jan 02 '19 13:01 farm365

You need to run the command like below: python cam.py --model_path=cam_checkpoint.hdf5 --image_path=<Enter_the_imagePath_you_want_to_test_on> --output_path=test.jpg

meghana30 avatar Mar 19 '19 15:03 meghana30

I run the command like you said, problems still occur

jspir1t avatar Apr 02 '19 05:04 jspir1t

@meghana30 I tried the command your way but still getting the same error. Did anyone get any solution?

matak07 avatar Jan 06 '20 10:01 matak07