Skip to content

Implementation of a Grad-CAM analysis in TensorFlow 1 for frozen graph models.

License

Notifications You must be signed in to change notification settings

lkreiskoether/grad-cam-analysis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

grad-cam-analysis

Gradient-weighted Class Activation Mapping [1] is a technique which produces visual explanations for decisions made by Convolutional Neural Networks without the need for architectural changes or retraining of the network under inspection.

This code offers a Grad-CAM based analysis for frozen graph models in TensorFlow 1. Images consisting of the heatmaps together with the original images are produced and stored in the defined image folder. More details about the implementation can be found in the comments of the code. The example images in the 'color' folder are taken from [2].

Setup

Clone the repository:

git clone https://github.com/lkreiskoether/grad-cam-analysis.git

General usage

python grad-cam-analysis.py <path to model> <path to image folder> '[<x-dim images>,<y-dim images>]' <number of classes>

Example usage

python grad-cam-analysis.py model/frozen_graph.pb color '[700,700]' 5

Example results

Example of one of the produced outputs running the example from above:

Acknowledgements

Thanks to https://github.com/jacobgil/keras-grad-cam and https://github.com/Ankush96/grad-cam.tensorflow for providing many building blocks for the code.

References

[1] R. R. Selvaraju et al., “Grad-CAM: Why did you say that? Visual Explanations from Deep Networks via Gradient-based Localization,” CoRR, vol. abs/1610.0, no. 2, pp. 336–359, 2016, doi: 10.1007/s11263-019-01228-7.

[2] P. Bergmann, M. Fauser, D. Sattlegger, and C. Steger, “MVTEC ad-A comprehensive real-world dataset for unsupervised anomaly detection,” in Proceedings of the IEEE Computer Society Conference on Computer Vision and Pattern Recognition, 2019, vol. 2019-June, pp. 9584–9592, doi: 10.1109/CVPR.2019.00982.

About

Implementation of a Grad-CAM analysis in TensorFlow 1 for frozen graph models.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages