jacobgil/keras-grad-cam

'Node' object has no attribute 'output_masks'

Matty0512 opened this issue · 2 comments

I've tried loading my own model (A fine tuned version of VGG16) using load_model but I get this error:
`AttributeError Traceback (most recent call last)
in ()
146
147 predicted_class = np.argmax(predictions)
--> 148 cam, heatmap = grad_cam(model, preprocessed_input, predicted_class, "block5_conv3")
149 cv2.imwrite("gradcam.jpg", cam)
150

in grad_cam(input_model, image, category_index, layer_name)
102
103 x = input_model.layers[-1].output
--> 104 x = Lambda(target_layer, output_shape=target_category_loss_output_shape)(x)
105 model = keras.models.Model(input_model.layers[0].input, x)
106

/usr/local/lib/python3.6/dist-packages/keras/engine/topology.py in call(self, inputs, **kwargs)
604
605 # Handle mask propagation.
--> 606 previous_mask = _collect_previous_mask(inputs)
607 user_kwargs = copy.copy(kwargs)
608 if not _is_all_none(previous_mask):

/usr/local/lib/python3.6/dist-packages/keras/engine/topology.py in _collect_previous_mask(input_tensors)
2832 inbound_layer, node_index, tensor_index = x._keras_history
2833 node = inbound_layer._inbound_nodes[node_index]
-> 2834 mask = node.output_masks[tensor_index]
2835 masks.append(mask)
2836 else:

AttributeError: 'Node' object has no attribute 'output_masks'`

I am also having a problem in this error . You found any solution ?

Me too ..