tabayashi0117 / Score-CAM

MIT License
56 stars 19 forks source link

while using transfer learning on vgg16, resnet152v2 and densenet121 #9

Open A-s-m-a opened 3 years ago

A-s-m-a commented 3 years ago

ValueError Traceback (most recent call last)

in () 7 img_array = read_and_preprocess_img('/content/drive/MyDrive/Phd_Data_set_Implementation/Aug-Training-four/BL/HL_0_1013.jpeg', size=(224,224)) 8 ----> 9 score_cam = ScoreCam(model,img_array,layer_name) 10 11 plt.imshow(score_cam) 2 frames in ScoreCam(model, img_array, layer_name, max_N) 5 def ScoreCam(model, img_array, layer_name, max_N=-1): 6 ----> 7 cls = np.argmax(model.predict(img_array)) 8 act_map_array = Model(inputs=model.input, outputs=model.get_layer(layer_name).output).predict(img_array) 9 /usr/local/lib/python3.7/dist-packages/tensorflow/python/keras/engine/training.py in predict(self, x, batch_size, verbose, steps, callbacks, max_queue_size, workers, use_multiprocessing) 1575 """ 1576 base_layer.keras_api_gauge.get_cell('predict').set(True) -> 1577 version_utils.disallow_legacy_graph('Model', 'predict') 1578 self._check_call_args('predict') 1579 _disallow_inside_tf_function('predict') /usr/local/lib/python3.7/dist-packages/tensorflow/python/keras/utils/version_utils.py in disallow_legacy_graph(cls_name, method_name) 120 " call `{cls_name}.{method_name}` with eager mode enabled.") 121 error_msg = error_msg.format(cls_name=cls_name, method_name=method_name) --> 122 raise ValueError(error_msg) 123 124 ValueError: Calling `Model.predict` in graph mode is not supported when the `Model` instance was constructed with eager mode enabled. Please construct your `Model` instance in graph mode or call `Model.predict` with eager mode enabled.