tabayashi0117 / score-cam Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
Hello. I like the clean implementation of yours. Currently there is no license for the repository. Would you kindly add one, for the community to modify and reuse the code?
can you share the requirements.txt file? I am having some errors.
Originally posted by @en-ashay in #1 (comment)
Hello.
First of all, I appreciate you for providing such a wonderful code.
I have a question in your code.
More specifically, about function ScoreCam() in gradcamutils.py.
Could you explain why you choose activation maps with large standard deviations?
I mean the procedure of extracting effective maps in case of max_N != =1.
How can Faster ScoreCAM be used in a medical images classification app, so that the classified images appear with heatmaps?
Line 85 in 313e190
cv.resize does not work as expected in this line. Please, rewrite this line as:
act_map_resized_list = [np.transpose(cv2.resize(act_map_array[0,:,:,k], input_shape[:2], interpolation=cv2.INTER_LINEAR)) for k in range(act_map_array.shape[3])]
otherwise error appears for rectangle image shape in line: below
Line 99 in 313e190
Hello
I am training VGG16 on my own dataset with TF2.2. The Score-CAM part seemed fine. But when i working on the Guided Score-CAM part, it raise the error 'Tensor is not an element of this graph.'
Here's the code:
`
layer_name = 'block5_conv3'
img_path = '1.jpg'
img_array = read_and_preprocess_img(img_path, size=(224,224))
model = load_model('my_model.h5')
guided_model = build_guided_model(model)
tf.compat.v1.disable_eager_execution()
saliency = GuidedBackPropagation(guided_model, img_array, layer_name)
`
This is my model:
`conv_base = VGG16(include_top=False, weights='imagenet',input_shape=(224, 224, 3))
top_layer = Flatten()(conv_base.output)
top_layer = Dense(256, activation='relu')(top_layer)
top_layer = Dense(3, activation='softmax')(top_layer)
model = Model(inputs=conv_base.input, outputs=top_layer)
model.compile(optimizer=SGD(lr=1e-4), loss='categorical_crossentropy', metrics=['accuracy'])`
Any help would be appreciated, thanks!
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.