Git Product home page Git Product logo

cnnvisualizer's Introduction

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.

Download

  • Clone the code from github
    git clone https://github.com/metalbubble/unitvisseg.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.

cnnvisualizer's People

Contributors

zhoubolei avatar

Stargazers

Thomas Milox avatar

Watchers

James Cloos avatar Marouan  avatar

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.