pytorch-convis
pytorch-convis copied to clipboard
A tool to visualize convolutional layer activations on an input image.
convis
A tool to visualize convolutional, ReLU, and pooling layer activations on an input image. This is a PyTorch implementation of htoyryla's convis.


An output image from a single channel (left), and a layer heatmap (right):
Dependencies:
Setup:
After installing the dependencies, you'll need to run the following script to download the default VGG and NIN models:
python models/download_models.py
You can also place convis.py
or convis_heatmap.py
in your neural-style-pt directory, in order to more easily work with models and input images.
Usage:
convis.py
will create an output image for every channel in the specified layer:
python convis.py -input_image examples/inputs/tubingen.jpg -model_file models/vgg19-d01eb7cb.pth -layer conv2_2 -output_dir output
convis_heatmap.py
will create a single output image composed of every channel in the specified layer:
python convis_heatmap.py -input_image examples/inputs/tubingen.jpg -model_file models/vgg19-d01eb7cb.pth -layer relu4_2
Parameters:
-
-input_image
: Path to the input image. -
-image_size
: Maximum side length (in pixels) of the generated image. Default is 512. -
-layer
: The target layer. Default isrelu4_2
-
-pooling
: The type of pooling layers to use; one ofmax
oravg
. Default ismax
. -
-model_file
: Path to the.pth
file for the VGG or NIN model. -
-output_image
: Name of the output image. Default isout.png
. -
-output_dir
: Name of the output image directory. Default isoutput
.
The output files will be named like output/tubingen-conv3_2-69.png