• Stars
    star
    292
  • Rank 142,152 (Top 3 %)
  • Language
    C
  • License
    MIT License
  • Created over 7 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Visualizer for Deep Neural Networks

CNN Visualizer: Toolkit for Visualizing Units in Deep Convolutional Neural Networks

Introduction

This repository contains the codes and results for visualizing the units (or named as neuron or convolutional filters) inside deep CNN. Some of the codes have been used for the ICLR'15 paper Object Detectors Emerge in Deep Scene CNNs. You can use this toolkit with the naive caffe, with matcaffe and pycaffe compiled, or pyTorch. This toolkit includes the following functions:

(NEW!) PyTorch script:

  • pytorch_extract_feature.py: code to extract the CNN features at the selected layers of a CNN model for any given images.
  • pytorch_generate_unitsegments.py: code to generate the visualization of all the units at the selected layer.

Matlab script:

  • extract_features.m: code to extract the CNN activation at the selected layers for any given images.
  • generate_unitsegments.m: code to generate the visualization for all the units at the selected layer.
  • unit_annotation: the results of unit annotation for Places-AlexNet and ImageNet-AlexNet.
  • unit_segmentation: code to generate image segmentation for a single image using the synthetic receptive field.
  • minimal_image: possion removal of the image content, to generate the minimal images.

PyTorch Environment

pip install -r requirement.txt

Download

  • Clone the code from github
    git clone https://github.com/metalbubble/cnnvisualizer.git
    cd unitvisseg
  • Download the image samples and the pretrained models
    sh download_images.sh
    sh download_pretrain.sh

Run

Properly set up the caffe path in the shell scripts, matlab scripts, and python scripts. We show the procedure to probe the unit semantics for alexnet trained on Places205 as follows:

  • Generate the visualization for all the units in one layer of a given CNN. It gets the top ranked images for each unit then segment them using the approximate receptive field of the units. The results are output to result_segments. After it finishes, you could click result_segments/places205_alexnet.html to see the visualization of unit segmentation.
    matlab -nodisplay -r generate_unitsegments

Samples of unit segmentation are shown below. Each row indicates the images segmented by the receptive field of one unit. segmentation

  • Generate the minimal image.
    cd minimal_image
    matlab -nodisplay -r demo_bases

Sample of the bases and images generated from combining the bases: bases

  • Generate image segmentation using the synthetic receptive field of one unit.
    cd unit_segmentation
    matlab -nodisplay -r demo_unitsegments

It generates the image segmentation like this: unitsegmentation

  • Extract the CNN features from any layers of any CNNs for any images. It will output the CNN features for the selected layers.
    matlab -nodisplay -r extract_features

References

If you find the toolkit useful, please cite our ICLR'15 paper:

    Bolei Zhou, Aditya Khosla, Agata Lapedriza, Aude Oliva, and Antonio Torralba
    Object Detectors Emerge in Deep Scene CNNs.
    International Conference on Learning Representations (ICLR), 2015.

More Repositories

1

introRL

Intro to Reinforcement Learning (强化学习纲要)
3,195
star
2

CAM

Class Activation Mapping
MATLAB
1,839
star
3

bolei_awesome_posters

CVPR and NeurIPS poster examples and templates. May we have in-person poster session soon!
1,362
star
4

TRN-pytorch

Temporal Relation Networks
Python
787
star
5

moments_models

The pretrained models trained on Moments in Time Dataset
Python
355
star
6

VQAbaseline

Simple Baseline for Visual Question Answering
Lua
186
star
7

awesome-generative-modeling

Bolei's archive on generative modeling
157
star
8

places_devkit

Development kit for the data of the Places365-Standard and Places365-Challenge
MATLAB
118
star
9

GoSpark

Go
77
star
10

TRN-deprecate

Code for Temporal Relation Networks
24
star
11

awesome-neural-planner

personal paper reading on neural motion planner and controller
24
star
12

collectiveness

The source codes in the CVPR2013 Paper: Measuring Crowd Collectiveness
MATLAB
24
star
13

introGM

Tutorial on Generative Modeling: Interacting with Deep Generative Models for Content Creation
20
star
14

GKLT

The binary code of generalized KLT tracker
C
19
star
15

CohFilter

MATLAB
10
star
16

pytorch_imagecaptioning

Jupyter Notebook
9
star
17

moments_recognition

Python
7
star
18

cuhkcourse_multimedia

Code examples for the IERG4190/IEMS5707 course
Jupyter Notebook
6
star
19

RF_topic

C++
5
star
20

feature_invertion_torch

Lua
4
star
21

cvpr19_textureobjectscene

webpage for the CVPR'19 Tutorial on Textures, Objects, and Scenes
HTML
3
star
22

ierg3050simulation

Example code for the IERG3050 Simulation and Statistical Analysis
Jupyter Notebook
3
star
23

Hello-World

first blood on Github
Objective-C
1
star
24

deepmodel

course project for Advance in Computer Vision
Python
1
star
25

coursera

codes for online courses
Python
1
star
26

deepfeature

The toolkit to evaluate the deep features for visual recognition
1
star