Hi, all, thanks for your interest.
This is my indepedent project at HKUST under supervision of Prof. Huamin Qu during 2018 Fall.
In 2018, we've come to the 5th year landmark of deep learning really starting to hit the mainstream. However, for the majority of people outside the academia, deep learning is still remaining as a mystory, a black box algorithm.
Believing deep learning makes much more sense only when it is trusted for the whole human being community, we build tools to help people visualize and understand what a deep learning model is doing during an image classification task.
This repo is designed for human-eye to visualize what excatly a CNN network focus on during an image classification task.
VIS
is a tool which helps people visualize features inseide CNN model. This package include three advanced methods: ClassActivationMaps
, SaliencyMaps
, and GuidedBackPropagation
.
- Update(09/29/2018): Add Class Activation Maps module
- Update(10/01/2018): Add Class Activation Maps demo to Gallery
- Update(10/02/2018): Add Saliency Maps module
- Update(10/03/2018): Add Saliency Maps demo to Gallery
- Update(10/04/2018): Add Guided BackPropagation module
- Update(10/04/2018): Add Guided BackPropagation demo to Gallery
- Update(10/05/2018): Update Research Record
- Update(11/05/2018): Add a practical case for 5002A3 [Link]
- Update(1/12/2019): Add Usage module
Class Activation Mapping [Paper]
Saliency Maps [Paper]
Guided BackPropagation [Paper]
Some of my codes is implemented based on utkuozbulak's work. My contributions are listed as below:
- Fix bugs for up-to-date pytorch version
- Solve problems for up-to-date CNN model, eg. ResNet, DenseNet
- Re-organize as a package
URL='https://raw.githubusercontent.com/utkuozbulak/pytorch-cnn-visualizations/master/input_images/snake.jpg'
image = Image.open(io.BytesIO(requests.get(URL).content))
vis=VIS(image,'resnet152') # Class Parameters
vis.GuidedBackPropagation(type='norm') # Method Parameters
vis.plot()
Class Parameters:
--image input image, required PIL image object
--model CNN model, if string, use a pretrained model from torchvision
--verbose bool, whether print information during processing
--figsize output figure size, default (18,18)
--columns output display columns number, default 5
Metod Parameters:
ClassActivationMaps(topk=4,ratio=0.3,cm=cv2.COLORMAP_JET)
--topk number k of topk prediction, default 4
--ratio ratio of heatmap against original image, default 0.3
--cm type of heatmap, default cv2.COLORMAP_JET
SaliencyMaps(topk=4,cm='hot')
--topk number k of topk prediction, default 4
--cm type of colormap, default 'hot'
GuidedBackPropagation(topk=1,type='norm')
--topk number k of topk prediction, default 4
--type type of gradient to pass through, default 'norm'.
utkuozbulak/pytorch-cnn-visualizations
Sample code for the Class Activation Mapping
Learning Deep Features for Discriminative Localization
DeepTracker: Visualizing the Training Process of Convolutional Neural Networks