Skip to content

Possible to do heatmaps using tflite models? #100

Answered by leondgarse
Medicmind asked this question in Q&A
Discussion options

You must be logged in to vote

OK, I think it's workng now. Two functions grads_to_heatmap and apply_heatmap are separated out from previous make_and_apply_gradcam_heatmap, and added a converting class ModelWithGradForTFLite with gradcam signature.

from keras_cv_attention_models import efficientnet, test_images
mm = efficientnet.EfficientNetV2B0()

from keras_cv_attention_models.visualizing.gradcam_heatmap import ModelWithGradForTFLite, grads_to_heatmap, apply_heatmap
saved_model = mm.name
bb = ModelWithGradForTFLite(mm)
signatures = {'serving_default': bb.serving_default.get_concrete_function(), 'gradcam': bb.gradcam.get_concrete_function()}
tf.saved_model.save(bb, saved_model, signatures=signatures)

# Convert the model

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@Medicmind
Comment options

Answer selected by Medicmind
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants