All Projects → InFoCusp → Tf_cnnvis

InFoCusp / Tf_cnnvis

Licence: mit
CNN visualization tool in TensorFlow

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Tf cnnvis

Livianet
This repository contains the code of LiviaNET, a 3D fully convolutional neural network that was employed in our work: "3D fully convolutional networks for subcortical segmentation in MRI: A large-scale study"
Stars: ✭ 143 (-81.4%)
Mutual labels:  convolutional-neural-networks, cnn, convolutional-networks
Gtsrb
Convolutional Neural Network for German Traffic Sign Recognition Benchmark
Stars: ✭ 65 (-91.55%)
Mutual labels:  convolutional-neural-networks, cnn, convolutional-networks
Tf Adnet Tracking
Deep Object Tracking Implementation in Tensorflow for 'Action-Decision Networks for Visual Tracking with Deep Reinforcement Learning(CVPR 2017)'
Stars: ✭ 162 (-78.93%)
Mutual labels:  convolutional-neural-networks, cnn, convolutional-networks
Keras transfer cifar10
Object classification with CIFAR-10 using transfer learning
Stars: ✭ 120 (-84.4%)
Mutual labels:  convolutional-neural-networks, cnn, convolutional-networks
Pytorch Image Classification
Tutorials on how to implement a few key architectures for image classification using PyTorch and TorchVision.
Stars: ✭ 272 (-64.63%)
Mutual labels:  convolutional-neural-networks, cnn, convolutional-networks
Pytorchinsight
a pytorch lib with state-of-the-art architectures, pretrained models and real-time updated results
Stars: ✭ 713 (-7.28%)
Mutual labels:  cnn, convolutional-networks
Deeplogo
A brand logo detection system using tensorflow object detection API.
Stars: ✭ 388 (-49.54%)
Mutual labels:  convolutional-neural-networks, cnn
Caffenet Benchmark
Evaluation of the CNN design choices performance on ImageNet-2012.
Stars: ✭ 700 (-8.97%)
Mutual labels:  convolutional-neural-networks, convolutional-networks
Deepface
Deep Learning Models for Face Detection/Recognition/Alignments, implemented in Tensorflow
Stars: ✭ 409 (-46.81%)
Mutual labels:  convolutional-neural-networks, cnn
Rmdl
RMDL: Random Multimodel Deep Learning for Classification
Stars: ✭ 375 (-51.24%)
Mutual labels:  convolutional-neural-networks, cnn
Neuralnetwork.net
A TensorFlow-inspired neural network library built from scratch in C# 7.3 for .NET Standard 2.0, with GPU support through cuDNN
Stars: ✭ 392 (-49.02%)
Mutual labels:  convolutional-neural-networks, cnn
Tensorflow Tutorial
TensorFlow and Deep Learning Tutorials
Stars: ✭ 748 (-2.73%)
Mutual labels:  convolutional-neural-networks, cnn
Tensorflow cookbook
Code for Tensorflow Machine Learning Cookbook
Stars: ✭ 5,984 (+678.15%)
Mutual labels:  cnn, tensorboard
Human Activity Recognition Using Cnn
Convolutional Neural Network for Human Activity Recognition in Tensorflow
Stars: ✭ 382 (-50.33%)
Mutual labels:  convolutional-neural-networks, cnn
Torchio
Medical image preprocessing and augmentation toolkit for deep learning
Stars: ✭ 708 (-7.93%)
Mutual labels:  convolutional-neural-networks, cnn
Espnetv2
A light-weight, power efficient, and general purpose convolutional neural network
Stars: ✭ 377 (-50.98%)
Mutual labels:  convolutional-neural-networks, cnn
Tf Pose Estimation
Deep Pose Estimation implemented using Tensorflow with Custom Architectures for fast inference.
Stars: ✭ 3,856 (+401.43%)
Mutual labels:  convolutional-neural-networks, cnn
Numpycnn
Building Convolutional Neural Networks From Scratch using NumPy
Stars: ✭ 436 (-43.3%)
Mutual labels:  convolutional-neural-networks, cnn
Fast Srgan
A Fast Deep Learning Model to Upsample Low Resolution Videos to High Resolution at 30fps
Stars: ✭ 417 (-45.77%)
Mutual labels:  cnn, tensorboard
Food Recipe Cnn
food image to recipe with deep convolutional neural networks.
Stars: ✭ 448 (-41.74%)
Mutual labels:  convolutional-neural-networks, cnn

tf_cnnvis

DOI

A blog post describing the library: https://medium.com/@falaktheoptimist/want-to-look-inside-your-cnn-we-have-just-the-right-tool-for-you-ad1e25b30d90

tf_cnnvis is a CNN visualization library which you can use to better understand your own CNNs. We use the TensorFlow library at the backend and the generated images are displayed in TensorBoard. We have implemented 2 CNN visualization techniques so far:

  1. Based on the paper Visualizing and Understanding Convolutional Networks by Matthew D. Zeiler and Rob Fergus. The goal here is to reconstruct the input image from the information contained in any given layers of the convolutional neural network. Here are a few examples

Figure 1: Original image and the reconstructed versions from maxpool layer 1,2 and 3 of Alexnet generated using tf_cnnvis.

  1. CNN visualization based on Deep dream by Google. Here's the relevant blog post explaining the technique. In essence, it attempts to construct an input image that maximizes the activation for a given output. We present some samples below:
Carbonara Ibex Elephant Ostrich
Cheese burger Tennis ball Fountain pen Clock tower
Cauliflower Baby Milk bottle Sea lion Dolphin

Requirements:

  • Tensorflow (>= 1.8)
  • numpy
  • scipy
  • h5py
  • wget
  • Pillow
  • six
  • scikit-image

If you are using pip you can install these with

pip install tensorflow numpy scipy h5py wget Pillow six scikit-image

Setup script

Clone the repository

#!bash

git clone https://github.com/InFoCusp/tf_cnnvis.git

And run

#!bash
sudo pip install setuptools
sudo pip install six
sudo python setup.py install
sudo python setup.py clean

Citation

If you use this library in your work, please cite

  @misc{tf_cnnvis,
    author = {Bhagyesh Vikani, Falak Shah},
    title = {CNN Visualization},
    year = {2017},
    howpublished = {\url{https://github.com/InFoCusp/tf_cnnvis/}},
    doi = {10.5281/zenodo.2594491}
  }

API

tf_cnnvis.activation_visualization(graph_or_path, value_feed_dict, input_tensor=None, layers='r', path_logdir='./Log', path_outdir='./Output')

The function to generate the activation visualizations of the input image at the given layer.

Parameters

  • graph_or_path (tf.Graph object or String) – TF graph or [Path-to-saved-graph] as String containing the CNN.

  • value_feed_dict (dict) – Values of placeholders to feed while evaluating the graph

    • dict : {placeholder1 : value1, ...}
  • input_tensor (tf.tensor object (Default = None)) – tf.tensor (input tensor to the model - where images enter into the models) Note: This is not a standalone tensor/placeholder separate from the model

  • layers (list or String (Default = 'r')) –

    • layerName : Reconstruction from a layer specified by name
    • ‘r’ : Reconstruction from all the relu layers
    • ‘p’ : Reconstruction from all the pooling layers
    • ‘c’ : Reconstruction from all the convolutional layers
  • path_outdir (String (Default = "./Output")) – [path-to-dir] to save results into disk as images

  • path_logdir (String (Default = "./Log")) – [path-to-log-dir] to make log file for TensorBoard visualization

Returns

  • is_success (boolean) – True if the function ran successfully. False otherwise

tf_cnnvis.deconv_visualization(graph_or_path, value_feed_dict, input_tensor=None, layers='r', path_logdir='./Log', path_outdir='./Output')

The function to generate the visualizations of the input image reconstructed from the feature maps of a given layer.

Parameters

  • graph_or_path (tf.Graph object or String) – TF graph or [Path-to-saved-graph] as String containing the CNN.

  • value_feed_dict (dict) – Values of placeholders to feed while evaluating the graph

    • dict : {placeholder1 : value1, ...}
  • input_tensor (tf.tensor object (Default = None)) – tf.tensor (input tensor to the model - where images enter into the models) Note: This is not a standalone tensor/placeholder separate from the model

  • layers (list or String (Default = 'r')) –

    • layerName : Reconstruction from a layer specified by name
    • ‘r’ : Reconstruction from all the relu layers
    • ‘p’ : Reconstruction from all the pooling layers
    • ‘c’ : Reconstruction from all the convolutional layers
  • path_outdir (String (Default = "./Output")) – [path-to-dir] to save results into disk as images

  • path_logdir (String (Default = "./Log")) – [path-to-log-dir] to make log file for TensorBoard visualization

Returns

  • is_success (boolean) – True if the function ran successfully. False otherwise

tf_cnnvis.deepdream_visualization(graph_or_path, value_feed_dict, layer, classes, input_tensor=None, path_logdir='./Log', path_outdir='./Output')

The function to generate the visualizations of the input image reconstructed from the feature maps of a given layer.

Parameters

  • graph_or_path (tf.Graph object or String) – TF graph or [Path-to-saved-graph] as String containing the CNN.

  • value_feed_dict (dict) – Values of placeholders to feed while evaluating the graph

    • dict : {placeholder1 : value1, ...}
  • layer (String) - name of a layer in TF graph

  • classes (List) - list featuremap index for the class classification layer

  • input_tensor (tf.tensor object (Default = None)) – tf.tensor (input tensor to the model - where images enter into the models) Note: This is not a standalone tensor/placeholder separate from the model

  • path_outdir (String (Default = "./Output")) – [path-to-dir] to save results into disk as images

  • path_logdir (String (Default = "./Log")) – [path-to-log-dir] to make log file for TensorBoard visualization

Returns

  • is_success (boolean) – True if the function ran successfully. False otherwise

To visualize in TensorBoard

To start Tensorflow, run the following command on the console

#!bash

tensorboard --logdir=./Log

and on the TensorBoard homepage look under the Images tab

Additional helper functions

tf_cnnvis.utils.image_normalization(image, ubound=255.0, epsilon=1e-07)

Performs Min-Max image normalization. Transforms the pixel intensity values to range [0, ubound]

Parameters

  • image (3-D numpy array) – A numpy array to normalize
  • ubound (float (Default = 255.0)) – upperbound for a image pixel value

Returns

  • norm_image (3-D numpy array) – The normalized image

tf_cnnvis.utils.convert_into_grid(Xs, padding=1, ubound=255.0)

Convert 4-D numpy array into a grid of images for display

Parameters

  • Xs (4-D numpy array (first axis contations an image)) – The 4D array of images to put onto grid
  • padding (int (Default = 1)) – Spacing between grid cells
  • ubound (float (Default = 255.0)) – upperbound for a image pixel value

Returns

  • (3-D numpy array) – A grid of input images
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].