├── demo ├── __init__.py ├── asgi.py ├── wsgi.py ├── urls.py └── settings.py ├── grad_cam ├── __init__.py ├── tests.py ├── static │ ├── images │ │ ├── img1.jpg │ │ ├── img2.jpg │ │ ├── img3.jpg │ │ ├── img4.jpg │ │ ├── img5.jpg │ │ ├── img6.jpg │ │ ├── network.png │ │ └── team │ │ │ ├── devi.jpg │ │ │ ├── rama.jpeg │ │ │ ├── abhishek.jpg │ │ │ ├── deshraj.png │ │ │ ├── michael.jpg │ │ │ ├── stefan.jpg │ │ │ └── dhruv_batra.jpg │ └── css │ │ └── style.css ├── templates │ ├── form.html │ ├── upload_image_url.html │ ├── header_content.html │ ├── result.html │ ├── index_new.html │ ├── home.html │ ├── home_new.html │ ├── index.html │ ├── captioning │ │ └── captioning.html │ ├── base.html │ ├── classification │ │ └── classification.html │ └── vqa │ │ └── vqa.html ├── routing.py ├── consumers.py ├── urls.py ├── utils.py ├── admin.py ├── models.py ├── constants.py ├── home.html ├── sender.py └── views.py ├── Docker ├── deploy.sh ├── run_server.sh └── GradCAM │ └── Dockerfile ├── .gitignore ├── .gitmodules ├── uwsgi.ini ├── requirements.txt ├── manage.py ├── uwsgi_params ├── misc ├── DeconvReLU.lua ├── GuidedBackpropReLU.lua ├── prepro_ques.py └── utils.lua ├── models └── download_models.sh ├── gradcam_nginx.conf ├── INSTALLATION.md ├── README.md ├── worker_captioning.py ├── worker_classify.py ├── worker_vqa.py ├── classification.lua ├── captioning.lua └── visual_question_answering.lua /demo/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /grad_cam/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Docker/deploy.sh: -------------------------------------------------------------------------------- 1 | python manage.py runserver 0.0.0.0:8000 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | models/ 2 | !models/download_models.sh 3 | *.pyc 4 | media/ 5 | -------------------------------------------------------------------------------- /grad_cam/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /grad_cam/static/images/img1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cloud-CV/Grad-CAM/HEAD/grad_cam/static/images/img1.jpg -------------------------------------------------------------------------------- /grad_cam/static/images/img2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cloud-CV/Grad-CAM/HEAD/grad_cam/static/images/img2.jpg -------------------------------------------------------------------------------- /grad_cam/static/images/img3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cloud-CV/Grad-CAM/HEAD/grad_cam/static/images/img3.jpg -------------------------------------------------------------------------------- /grad_cam/static/images/img4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cloud-CV/Grad-CAM/HEAD/grad_cam/static/images/img4.jpg -------------------------------------------------------------------------------- /grad_cam/static/images/img5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cloud-CV/Grad-CAM/HEAD/grad_cam/static/images/img5.jpg -------------------------------------------------------------------------------- /grad_cam/static/images/img6.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cloud-CV/Grad-CAM/HEAD/grad_cam/static/images/img6.jpg -------------------------------------------------------------------------------- /Docker/run_server.sh: -------------------------------------------------------------------------------- 1 | docker build -t cloudcv/grad-cam ./GradCAM/ 2 | docker run -d --name cloudcv_grad_cam GradCAM 3 | 4 | -------------------------------------------------------------------------------- /grad_cam/static/images/network.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cloud-CV/Grad-CAM/HEAD/grad_cam/static/images/network.png -------------------------------------------------------------------------------- /grad_cam/static/images/team/devi.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cloud-CV/Grad-CAM/HEAD/grad_cam/static/images/team/devi.jpg -------------------------------------------------------------------------------- /grad_cam/static/images/team/rama.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cloud-CV/Grad-CAM/HEAD/grad_cam/static/images/team/rama.jpeg -------------------------------------------------------------------------------- /grad_cam/static/images/team/abhishek.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cloud-CV/Grad-CAM/HEAD/grad_cam/static/images/team/abhishek.jpg -------------------------------------------------------------------------------- /grad_cam/static/images/team/deshraj.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cloud-CV/Grad-CAM/HEAD/grad_cam/static/images/team/deshraj.png -------------------------------------------------------------------------------- /grad_cam/static/images/team/michael.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cloud-CV/Grad-CAM/HEAD/grad_cam/static/images/team/michael.jpg -------------------------------------------------------------------------------- /grad_cam/static/images/team/stefan.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cloud-CV/Grad-CAM/HEAD/grad_cam/static/images/team/stefan.jpg -------------------------------------------------------------------------------- /grad_cam/static/images/team/dhruv_batra.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cloud-CV/Grad-CAM/HEAD/grad_cam/static/images/team/dhruv_batra.jpg -------------------------------------------------------------------------------- /demo/asgi.py: -------------------------------------------------------------------------------- 1 | import os 2 | from channels.asgi import get_channel_layer 3 | 4 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "demo.settings") 5 | 6 | channel_layer = get_channel_layer() 7 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "VQA_LSTM_CNN"] 2 | path = VQA_LSTM_CNN 3 | url = https://github.com/VT-vision-lab/VQA_LSTM_CNN.git 4 | [submodule "neuraltalk2"] 5 | path = neuraltalk2 6 | url = https://github.com/karpathy/neuraltalk2.git 7 | -------------------------------------------------------------------------------- /grad_cam/templates/form.html: -------------------------------------------------------------------------------- 1 | 2 |
3 |

Drop files here or click to upload.

4 |
-------------------------------------------------------------------------------- /uwsgi.ini: -------------------------------------------------------------------------------- 1 | [uwsgi] 2 | 3 | chdir = /home/ubuntu/Projects/Grad-CAM 4 | module = demo.wsgi:application 5 | master = true 6 | processes = 10 7 | socket = 0.0.0.0:8001 8 | vaccum = true 9 | python-autoreload = 1 10 | # buffer-size=32768 11 | daemonize = /var/log/uwsgi/gradcam.log 12 | -------------------------------------------------------------------------------- /grad_cam/static/css/style.css: -------------------------------------------------------------------------------- 1 | .brand-logo{ 2 | font-weight: 300; 3 | } 4 | 5 | .demo_img{ 6 | height: 300px !important; 7 | padding: 6px; 8 | } 9 | 10 | #inputImage{ 11 | max-width: 100% !important; 12 | } 13 | 14 | #result{ 15 | font-family: Roboto !important; 16 | } 17 | 18 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | numpy==1.11.1 2 | Django==1.9.8 3 | Pillow==3.3.0 4 | h5py==2.6.0 5 | nltk==3.2.1 6 | scipy==0.17.1 7 | channels==0.17.2 8 | asgi-redis==0.14.1 9 | pika==0.10.0 10 | pyyaml==3.12 11 | uwsgi==2.0.13.1 12 | websocket-client==0.37.0 13 | daphne==0.15.0 14 | requests==2.11.1 15 | -------------------------------------------------------------------------------- /manage.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import os 3 | import sys 4 | 5 | if __name__ == "__main__": 6 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "demo.settings") 7 | 8 | from django.core.management import execute_from_command_line 9 | 10 | execute_from_command_line(sys.argv) 11 | -------------------------------------------------------------------------------- /grad_cam/routing.py: -------------------------------------------------------------------------------- 1 | from channels.routing import route, include 2 | from grad_cam.consumers import ws_message, ws_connect 3 | 4 | ws_routing = [ 5 | route("websocket.receive", ws_message), 6 | route("websocket.connect", ws_connect), 7 | ] 8 | 9 | channel_routing = [ 10 | include(ws_routing, path=r"^/chat"), 11 | ] 12 | -------------------------------------------------------------------------------- /grad_cam/templates/upload_image_url.html: -------------------------------------------------------------------------------- 1 |
2 | 3 |
4 | 31 | CloudCV 32 | 33 | 45 | 46 | 47 | 48 | 49 | 76 | 77 | {% block header_content %} 78 | 79 |
80 |

Grad-CAM: Gradient-weighted Class Activation Mapping

81 |
82 | 83 | {% endblock %} 84 | 85 | {% block slider %} 86 | 87 | {% endblock %} 88 | 89 | {% block abstract%} 90 |
91 |

Abstract

92 |

In recent research conducted by our lab (Machine Learning & Perception group), we have developed novel techniques for making CNN more 'transparent' by producing visual explanations i.e visualizations showing what evidence in the image supports a prediction. Research conducted in our lab has shown that models that explain their behavior are considered more trustworthy than typical "black-box" models.

93 | 94 | 95 |
96 | {% endblock %} 97 | 98 | {% block demo_links %} 99 | 100 |
101 |

Demonstration Links

102 |
103 |
104 |
105 |

Visual Question Answering

106 |

Some randome text description about the demo goes here.

107 | Try Visual Question Answering Demo 108 |
109 |
110 | 111 |
112 |
113 |

Classification

114 |

Some randome text description about the demo goes here.

115 | Try Classification Demo 116 |
117 |
118 | 119 |
120 |
121 |

Captioning

122 |

Some randome text description about the demo goes here.

123 | Try Captioning Demo 124 |
125 |
126 | 127 |
128 |
129 | 130 | {% endblock %} 131 | 132 | {% block team %} 133 |
134 |

Grad-CAM Team

135 |
136 |
137 | Cinque Terre 138 | 139 |
140 |
141 | Cinque Terre 142 | 143 |
144 |
145 | Cinque Terre 146 | 147 |
148 |
149 | Cinque Terre 150 | 151 |
152 |
153 | 154 |
155 |
156 | Cinque Terre 157 | 158 |
159 |
160 | Cinque Terre 161 | 162 |
163 |
164 | Cinque Terre 165 | 166 |
167 |
168 | Cinque Terre 169 | 170 |
171 |
172 | 173 |
174 | {% endblock%} 175 | 176 | {% block footer %} 177 | 192 | 193 | {% endblock %} 194 | 204 | 205 | 206 | -------------------------------------------------------------------------------- /grad_cam/templates/home_new.html: -------------------------------------------------------------------------------- 1 | {% load static %} 2 | 3 | 4 | 5 | Grad-CAM: Gradient-weighted Class Activation Mapping 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 47 | 48 | 49 | 90 | 91 | {% block header_content %} 92 | 93 |
94 |

Grad-CAM: Gradient-weighted Class Activation Mapping

95 |
96 | 97 | {% endblock %} 98 | 99 | {% block slider %} 100 | 101 | {% endblock %} 102 | 103 | {% block abstract%} 104 |
105 |

Abstract

106 |

In recent research conducted by our lab (Machine Learning & Perception group), we have developed novel techniques for making CNN more 'transparent' by producing visual explanations i.e visualizations showing what evidence in the image supports a prediction. Research conducted in our lab has shown that models that explain their behavior are considered more trustworthy than typical "black-box" models.

107 | 108 | 109 |
110 | {% endblock %} 111 | 112 | {% block demo_links %} 113 | 114 |
115 |

Demonstration Links

116 |
117 |
118 |
119 |

Visual Question Answering

120 |

Some randome text description about the demo goes here.

121 | Try Visual Question Answering Demo 122 |
123 |
124 | 125 |
126 |
127 |

Classification

128 |

Some randome text description about the demo goes here.

129 | Try Classification Demo 130 |
131 |
132 | 133 |
134 |
135 |

Captioning

136 |

Some randome text description about the demo goes here.

137 | Try Captioning Demo 138 |
139 |
140 | 141 |
142 |
143 | 144 | {% endblock %} 145 | 146 | {% block team %} 147 |
148 |

Grad-CAM Team

149 |
150 |
151 | Cinque Terre 152 | 153 |
154 |
155 | Cinque Terre 156 | 157 |
158 |
159 | Cinque Terre 160 | 161 |
162 |
163 | Cinque Terre 164 | 165 |
166 |
167 | 168 |
169 |
170 | Cinque Terre 171 | 172 |
173 |
174 | Cinque Terre 175 | 176 |
177 |
178 | Cinque Terre 179 | 180 |
181 |
182 | Cinque Terre 183 | 184 |
185 |
186 | 187 |
188 | {% endblock%} 189 | 190 | {% block footer %} 191 | 206 | 207 | {% endblock %} 208 | 218 | 219 | 220 | -------------------------------------------------------------------------------- /grad_cam/templates/index.html: -------------------------------------------------------------------------------- 1 | {% load static %} 2 | 3 | 4 | 5 | Grad-CAM: Gradient-weighted Class Activation Mapping 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 53 | 54 | 55 | 103 | 104 | {% block header_content %} 105 | 106 |
107 |

Grad-CAM: Gradient-weighted Class Activation Mapping

108 |
109 | 110 | {% endblock %} 111 | 112 | {% block slider %} 113 | 114 | {% endblock %} 115 | 116 | {% block abstract%} 117 |
118 |

Abstract

119 |

We propose a technique for making Convolutional Neural Network (CNN)-based models more transparent by visualizing the regions of input that are "important" for predictions from these models - or visual explanations. Our approach, called Gradient-weighted Class Activation Mapping (Grad-CAM), uses the class-specific gradient information flowing into the final convolutional layer of a CNN to produce a coarse localization map of the important regions in the image. Grad-CAM is a strict generalization of the Class Activation Mapping. Unlike CAM, Grad-CAM requires no re-training and is broadly applicable to any CNN-based architectures. We also show how Grad-CAM may be combined with existing pixel-space visualizations to create a high-resolution class-discriminative visualization (Guided Grad-CAM). We generate Grad-CAM and Guided Grad-CAM visual explanations to better understand image classification, image captioning, and visual question answering (VQA) models. In the context of image classification models, our visualizations (a) lend insight into their failure modes showing that seemingly unreasonable predictions have reasonable explanations, and (b) outperform pixel-space gradient visualizations (Guided Backpropagation and Deconvolution) on the ILSVRC-15 weakly supervised localization task. For image captioning and VQA, our visualizations expose the somewhat surprising insight that common CNN + LSTM models can often be good at localizing discriminative input image regions despite not being trained on grounded image-text pairs. Finally, we design and conduct human studies to measure if Guided Grad-CAM explanations help users establish trust in the predictions made by deep networks. Interestingly, we show that Guided Grad-CAM helps untrained users successfully discern a "stronger" deep network from a "weaker" one even when both networks make identical predictions.

120 |

Arxiv Paper link: https://arxiv.org/abs/1610.02391

121 | 122 |
123 | {% endblock %} 124 | 125 | {% block demo_links %} 126 | 127 |
128 |

Demonstration Links

129 |
130 |
131 |
132 |

Visual Question Answering

133 | Try Visual Question Answering Demo 134 |
135 |
136 | 137 |
138 |
139 |

Classification

140 | Try Classification Demo 141 |
142 |
143 | 144 |
145 |
146 |

Captioning

147 | Try Captioning Demo 148 |
149 |
150 | 151 |
152 |
153 | 154 | {% endblock %} 155 | 156 | {% block team %} 157 |
158 |

Grad-CAM Team

159 |
160 |
161 | Cinque Terre 162 | 163 |
164 |
165 | Cinque Terre 166 | 167 |
168 |
169 | Cinque Terre 170 | 171 |
172 |
173 | Cinque Terre 174 | 175 |
176 |
177 | 178 |
179 |
180 | Cinque Terre 181 | 182 |
183 |
184 | Cinque Terre 185 | 186 |
187 |
188 | Cinque Terre 189 | 190 |
191 |
192 | Cinque Terre 193 | 194 |
195 |
196 | 197 |
198 | {% endblock%} 199 | 200 | {% block footer %} 201 | 202 | {% endblock %} 203 | 213 | 214 | 215 | -------------------------------------------------------------------------------- /grad_cam/templates/captioning/captioning.html: -------------------------------------------------------------------------------- 1 | {% extends 'base.html' %} 2 | 3 | {% block header_content %} 4 | 5 | Fork me on GitHub 6 | 7 |
8 | 17 |
18 | 19 | {% endblock %} 20 | 21 | {% block demo_images %} 22 | 23 |
24 | 72 |
73 | 74 | 75 | {% endblock %} 76 | 77 | {% block form %} 78 | 124 | 125 |
126 | 129 | {% block url_content %} 130 | {% include 'upload_image_url.html' %} 131 | {% endblock %} 132 |
133 |

OR

134 |
135 |
136 |
138 | 139 | 140 | 141 | {% csrf_token %} 142 | 143 | {% include 'form.html' %} 144 |
145 |
146 | 147 | {% endblock %} 148 | 149 | {% block result %} 150 | 176 | 177 | 288 |
289 | 292 | 301 | 302 | 331 | {% endblock %} 332 | 333 | {% block credits %} 334 | 335 | 336 | Code for Neuraltalk2
337 | Built by @deshraj 338 |

339 |
340 |
341 |
342 | 343 | 344 | 345 | {% endblock %} 346 | -------------------------------------------------------------------------------- /grad_cam/templates/base.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Grad-CAM: Gradient-weighted Class Activation Mapping 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 51 | 52 | 53 | 94 | 95 | 109 | 110 | {% block header_content %} 111 | 112 |
113 | 125 |
126 | 127 | {% endblock %} 128 | 129 | {% block demo_images %} 130 | 131 |
132 | 180 |
181 | 182 | 183 | {% endblock %} 184 | 185 | {% block form %} 186 | {% endblock %} 187 | 188 | {% block terminal %} 189 | 190 |
191 |

Terminal:

192 | 193 |
195 | 197 |
198 |
199 | 200 |
201 |

How it works

202 | 203 |
    204 |
  1. You upload an image.
  2. 205 |
  3. Your request is sent to our servers with GPUs courtesy NVIDIA.
  4. 206 |
  5. Our servers run our deep-learning based algorithm.
  6. 207 |
  7. Results and updates are shown in real-time.
  8. 208 |
209 |


210 |
211 | 212 | {% endblock %} 213 | 214 | {% block result %} 215 | 216 | {% endblock %} 217 | 218 | {% block credits %} 219 | 220 |
221 |

Credits

222 | 223 | Sample Credit Link Section
224 | Deshraj Yadav, Harsh Agarwal, Dhruv Batra 225 |

226 |
227 |
228 |
229 | {% endblock %} 230 | 231 |
232 | 233 | 238 | 262 | 263 | 298 | 299 | 322 | 323 | 354 | 364 | 365 | 366 | -------------------------------------------------------------------------------- /grad_cam/templates/classification/classification.html: -------------------------------------------------------------------------------- 1 | {% extends 'base.html' %} 2 | 3 | {% block header_content %} 4 | 5 | Fork me on GitHub 6 | 7 |
8 | 17 |
18 | 19 | {% endblock %} 20 | 21 | 22 | {% block demo_images %} 23 | 24 |
25 | 73 |
74 | 75 | 76 | {% endblock %} 77 | 78 | 79 | {% block form %} 80 | 81 |
82 | 85 | {% block url_content %} 86 | {% include 'upload_image_url.html' %} 87 | {% endblock %} 88 |
89 |

OR

90 |
91 |
92 |
94 | {% csrf_token %} 95 | 96 | 97 | 98 | {% include 'form.html' %} 99 |
100 |
101 | 102 | {% endblock %} 103 | 104 | {% block result %} 105 | 149 | 150 | 290 | 291 | 314 | 315 | 318 |
319 | 322 | 332 | 358 | {% endblock %} 359 | 360 | {% block credits %} 361 | 362 | 363 | Built by @deshraj 364 |

365 |
366 | 367 |
368 |
369 | 370 | 371 | 372 | 373 | 374 | {% endblock %} 375 | -------------------------------------------------------------------------------- /grad_cam/templates/vqa/vqa.html: -------------------------------------------------------------------------------- 1 | {% extends 'base.html' %} 2 | 3 | 4 | {% block header_content %} 5 | 6 | Fork me on GitHub 7 | 8 |
9 | 18 |
19 | 20 | {% endblock %} 21 | 22 | {% block form %} 23 | 63 | 64 |
65 | 68 | {% block url_content %} 69 | {% include 'upload_image_url.html' %} 70 | {% endblock %} 71 |
72 |

OR

73 |
74 | 75 |
76 |
77 | 78 | 79 | {% csrf_token %} 80 | 81 | {% include 'form.html' %} 82 |
83 |
84 | 85 | {% endblock %} 86 | 87 | 88 | {% block result %} 89 | 90 | 91 | 1128 | 1129 | 1251 |
1252 | 1255 |
1256 | 1266 | 1294 | {% endblock %} 1295 | 1296 | {% block credits %} 1297 | 1298 | 1299 | Code for VQA Model
1300 | Built by @deshraj
1301 |

1302 |
1303 |
1304 |
1305 | 1306 | 1307 | 1308 | 1309 | {% endblock %} 1310 | --------------------------------------------------------------------------------