Deep Inside Convolutional Networks - This is a caffe implementation to visualize the learnt model

Overview

Deep Inside Convolutional Networks

This is a caffe implementation to visualize the learnt model.

Part of a class project at Georgia Tech
Problem Statement Pdf

Simonyan, K., Vedaldi, A., Zisserman, A.: Deep inside convolutional networks: Visualising image classification models and saliency maps Pdf

###Results:

Class Model visualization of Cat
In this exercise, we will use the method suggested in the “Deep inside convolutional networks: Visualising image classification models and saliency maps” to visualize the class model learnt by a convolutional network. We will use caffe for this exercise and visualize the class model learnt by the “bvlc_reference_caffenet.caffemodel”. Another aspect pointed out by the paper is that, the unnormalized Image score needs to be maximized instead of the probability. For this reason, we will be drop the final softmax layer(as the output here is the probability) and maximize the score at the inner product layer “fc8”.

Cat

Class Saliency extraction
The core idea behind this approach is to use the gradients at the image layer for a given image and class, to find the pixels which need to be changed the least i.e, the pixels for which the gradients have the smallest values. Also since our image is a 3 channel image, for each pixel, there will three different gradients. The maximum of these three will be considered the class saliency extraction.

Cat

Understanding backpropagation Here we simply visuzlize the gradients at different layers

Cat Cat Cat Cat

Instructions:

  • Install Caffe-rc2 tag
  • Copy the deploy_fc8.prototxt file to /models/bvlc_reference_caffenet/
  • Copy all the py files to /examples/
  • the just run python visualize.py
Comments
  • could not broadcast input array from shape (1000,1,1) into shape (1,1000)

    could not broadcast input array from shape (1000,1,1) into shape (1,1000)

    When i run the visualize.py code, i got the above error as follows:-

    Traceback (most recent call last): File "visualize.py", line 69, in bw = net.backward(**{net.outputs[0]: caffeLabel}) File "../python/caffe/pycaffe.py", line 167, in _Net_backward self.blobs[top].diff[...] = diff ValueError: could not broadcast input array from shape (1000,1,1) into shape (1,1000)

    and when i change the net.backward line as: bw = net.backward(), it runs perfectly. please tell me what is the problem??

    opened by gauticse2015 6
  • IndexError: list index out of range

    IndexError: list index out of range

    Traceback (most recent call last): File "class_saliency_extraction.py", line 25, in image_dims=(224, 224)) File "D:/Projects/caffe-windows/caffe/python\caffe\classifier.py", line 29, in init in_ = self.inputs[0] IndexError: list index out of range

    opened by billhhh 3
  • Absolute value of gradients

    Absolute value of gradients

    As described in Section 3.1 of the paper, you need to take the absolute value of gradients before normalizing it. If you are not doing it, then you are not visualizing those pixels which decrease the class score the most with a small change (this is also a important descriptor).

    opened by saiprabhakar 3
  • ValueError: could not broadcast input array from shape(1000,1,1) into shape (1,1000)

    ValueError: could not broadcast input array from shape(1000,1,1) into shape (1,1000)

    hi, I am trying to use your code for the same purpose. But there is a error in bw=net.backward(**{net.outputs[0]: caffeLabel}) ValueError: could not broadcast input array from shape(1000,1,1) into shape (1,1000). Can you tell me the reason. Thank you. Looking forward to your reply.

    opened by zhoafan 2
  • how to  set the Hyperparameter?

    how to set the Hyperparameter?

    In visualize.py file, I see the learning_rate is 10000,it confused me!why doing this, also,In the optimization procedure,The sentence "caffe_data = caffe_data + learning_rate*diff " seems not used any L2 Paradigm,but in the paper, It is not like this! thanks a lot!

    opened by kilakila-heart 0
  • How to use it with multiple regression outputs.

    How to use it with multiple regression outputs.

    Hi, I am using it for a multi-task model. I am using a customized alexnet for a multi-task model for aesthetics prediction and classification. I have a normalized score ( 0 to 1 ) for aesthetics prediction and a single label for classification. I want to check which areas are more salient for aesthetics. After doing net.forward() I am setting net.blobs['aesthetics'].data[0][0] = 1 Then I am running bw = net.backward() But I am getting only zero values as input image. I have set force_backward: true in my model prototxt file. I think I am messing up the backward function, let me know if you have any idea about how to use it for regression problems.

    opened by gautamMalu 1
Owner
Jigar
Jigar
MMdnn is a set of tools to help users inter-operate among different deep learning frameworks. E.g. model conversion and visualization. Convert models between Caffe, Keras, MXNet, Tensorflow, CNTK, PyTorch Onnx and CoreML.

MMdnn MMdnn is a comprehensive and cross-framework tool to convert, visualize and diagnose deep learning (DL) models. The "MM" stands for model manage

Microsoft 5.7k Jan 9, 2023
Caffe: a fast open framework for deep learning.

Caffe Caffe is a deep learning framework made with expression, speed, and modularity in mind. It is developed by Berkeley AI Research (BAIR)/The Berke

Berkeley Vision and Learning Center 33k Dec 28, 2022
hipCaffe: the HIP port of Caffe

Caffe Caffe is a deep learning framework made with expression, speed, and modularity in mind. It is developed by the Berkeley Vision and Learning Cent

ROCm Software Platform 126 Dec 5, 2022
a reimplementation of LiteFlowNet in PyTorch that matches the official Caffe version

pytorch-liteflownet This is a personal reimplementation of LiteFlowNet [1] using PyTorch. Should you be making use of this work, please cite the paper

Simon Niklaus 365 Dec 31, 2022
The original weights of some Caffe models, ported to PyTorch.

pytorch-caffe-models This repo contains the original weights of some Caffe models, ported to PyTorch. Currently there are: GoogLeNet (Going Deeper wit

Katherine Crowson 9 Nov 4, 2022
Official PyTorch implementation for Generic Attention-model Explainability for Interpreting Bi-Modal and Encoder-Decoder Transformers, a novel method to visualize any Transformer-based network. Including examples for DETR, VQA.

PyTorch Implementation of Generic Attention-model Explainability for Interpreting Bi-Modal and Encoder-Decoder Transformers 1 Using Colab Please notic

Hila Chefer 489 Jan 7, 2023
A PyTorch implementation of " EfficientNet: Rethinking Model Scaling for Convolutional Neural Networks."

EfficientNet A PyTorch implementation of EfficientNet: Rethinking Model Scaling for Convolutional Neural Networks. [arxiv] [Official TF Repo] Implemen

AhnDW 298 Dec 10, 2022
This project is a loose implementation of paper "Algorithmic Financial Trading with Deep Convolutional Neural Networks: Time Series to Image Conversion Approach"

Stock Market Buy/Sell/Hold prediction Using convolutional Neural Network This repo is an attempt to implement the research paper titled "Algorithmic F

Asutosh Nayak 136 Dec 28, 2022
A PyTorch implementation of "Cluster-GCN: An Efficient Algorithm for Training Deep and Large Graph Convolutional Networks" (KDD 2019).

ClusterGCN ⠀⠀ A PyTorch implementation of "Cluster-GCN: An Efficient Algorithm for Training Deep and Large Graph Convolutional Networks" (KDD 2019). A

Benedek Rozemberczki 697 Dec 27, 2022
A PyTorch implementation of Multi-digit Number Recognition from Street View Imagery using Deep Convolutional Neural Networks

SVHNClassifier-PyTorch A PyTorch implementation of Multi-digit Number Recognition from Street View Imagery using Deep Convolutional Neural Networks If

Potter Hsu 182 Jan 3, 2023
Visualize Camera's Pose Using Extrinsic Parameter by Plotting Pyramid Model on 3D Space

extrinsic2pyramid Visualize Camera's Pose Using Extrinsic Parameter by Plotting Pyramid Model on 3D Space Intro A very simple and straightforward modu

JEONG HYEONJIN 106 Dec 28, 2022
Code for our ICASSP 2021 paper: SA-Net: Shuffle Attention for Deep Convolutional Neural Networks

SA-Net: Shuffle Attention for Deep Convolutional Neural Networks (paper) By Qing-Long Zhang and Yu-Bin Yang [State Key Laboratory for Novel Software T

Qing-Long Zhang 199 Jan 8, 2023
Code for paper: Group-CAM: Group Score-Weighted Visual Explanations for Deep Convolutional Networks

Group-CAM By Zhang, Qinglong and Rao, Lu and Yang, Yubin [State Key Laboratory for Novel Software Technology at Nanjing University] This repo is the o

zhql 98 Nov 16, 2022
Generating Anime Images by Implementing Deep Convolutional Generative Adversarial Networks paper

AnimeGAN - Deep Convolutional Generative Adverserial Network PyTorch implementation of DCGAN introduced in the paper: Unsupervised Representation Lear

Rohit Kukreja 23 Jul 21, 2022
PyTorch framework, for reproducing experiments from the paper Implicit Regularization in Hierarchical Tensor Factorization and Deep Convolutional Neural Networks

Implicit Regularization in Hierarchical Tensor Factorization and Deep Convolutional Neural Networks. Code, based on the PyTorch framework, for reprodu

Asaf 3 Dec 27, 2022
Cancer-and-Tumor-Detection-Using-Inception-model - In this repo i am gonna show you how i did cancer/tumor detection in lungs using deep neural networks, specifically here the Inception model by google.

Cancer-and-Tumor-Detection-Using-Inception-model In this repo i am gonna show you how i did cancer/tumor detection in lungs using deep neural networks

Deepak Nandwani 1 Jan 1, 2022
CoSMA: Convolutional Semi-Regular Mesh Autoencoder. From Paper "Mesh Convolutional Autoencoder for Semi-Regular Meshes of Different Sizes"

Mesh Convolutional Autoencoder for Semi-Regular Meshes of Different Sizes Implementation of CoSMA: Convolutional Semi-Regular Mesh Autoencoder arXiv p

Fraunhofer SCAI 10 Oct 11, 2022
This is a model made out of Neural Network specifically a Convolutional Neural Network model

This is a model made out of Neural Network specifically a Convolutional Neural Network model. This was done with a pre-built dataset from the tensorflow and keras packages. There are other alternative libraries that can be used for this purpose, one of which is the PyTorch library.

null 9 Oct 18, 2022
Allows including an action inside another action (by preprocessing the Yaml file). This is how composite actions should have worked.

actions-includes Allows including an action inside another action (by preprocessing the Yaml file). Instead of using uses or run in your action step,

Tim Ansell 70 Nov 4, 2022