Code Monkey home page Code Monkey logo

score-cam's People

Contributors

tabayashi0117 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

score-cam's Issues

Will the code have 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?

Question about max_N in Scorecam

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.

Faster ScoreCAM implementation

How can Faster ScoreCAM be used in a medical images classification app, so that the classified images appear with heatmaps?

Error, not uniform img size

act_map_resized_list = [cv2.resize(act_map_array[0,:,:,k], input_shape[:2], interpolation=cv2.INTER_LINEAR) for k in range(act_map_array.shape[3])]

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

masked_input[0,:,:,k] *= act_map_normalized

Guided Score-CAM part incompatible with TF2.2

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)

`

Error screenshot:
截屏2020-11-23 下午11 36 07

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!

while using transfer learning on vgg16, resnet152v2 and densenet121


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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.