Image patch or drawing bounding box using feature map

abask61: <p>Hi,</p>
<p>I am new to CV. I am trying to draw a bounding box or get the image patch that maximally activates a neuron in the feature map for <strong>image classification tasks</strong> without a bounding box label.</p>
<p>My plan is to create a map that records the positions of output and input block positions during the conv and pooling operations. Then after training, I can get the maximally activated neuron from a feature map and use the map to backtrack the positions in the original image. There might be multiple regions and I have to sort that out.</p>
<p>This is based on the paper “Visualizing and Understanding Convolutional Networks” by Zeiler.  They show the image patches (not gray scales) that maximally activate a neuron in the feature map. But they don’t have any code for that.</p>

ptrblck: <p>Searching for the paper yields <a href="https://github.com/huybery/VisualizingCNN">this old repository</a>, which you could try to use directly or use as a template.</p>

abask61: <p>Thanks! Actually, there were a couple of repo I found and this was the most helpful one. So, you shared the most helpful one with me. <img src="https://discuss.pytorch.org/images/emoji/apple/slight_smile.png?v=12" title=":slight_smile:" class="emoji" alt=":slight_smile:" loading="lazy" width="20" height="20"></p>
<p>But it does not draw the bounding boxes (that maximizes a feature map activation) that it shows in the repository. And that’s what I am trying to achieve. If I have the bounding box I can use that on a original image too to get the image patch.  It only reconstructs using deconvnet.</p>

ptrblck: <p>I haven’t checked the repository in detail, but are these bounding boxes never created or just not visualized?</p>

abask61: <p>They are never created I believe.</p>

abask61: <p>Here’s my latest failed attempt<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/7/6/76a73081debd3537881085f31d404585bc0e62e2.jpeg" data-download-href="https://discuss.pytorch.org/uploads/default/76a73081debd3537881085f31d404585bc0e62e2" title="result_box"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/7/6/76a73081debd3537881085f31d404585bc0e62e2_2_666x500.jpeg" alt="result_box" data-base62-sha1="gVExGxFciL6uNR5blkKG0l0nvYS" width="666" height="500" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/7/6/76a73081debd3537881085f31d404585bc0e62e2_2_666x500.jpeg, https://discuss.pytorch.org/uploads/default/optimized/3X/7/6/76a73081debd3537881085f31d404585bc0e62e2_2_999x750.jpeg 1.5x, https://discuss.pytorch.org/uploads/default/original/3X/7/6/76a73081debd3537881085f31d404585bc0e62e2.jpeg 2x" data-dominant-color="F7F7F8"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">result_box</span><span class="informations">1280×960 27.7 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div><br>
:</p>
<p>I tried the draw a bounding box by backtracking the most activated neuron until the image pixel layer. Seems like it didn’t work.</p>
<p>Will debug more to see if there’s a bug.</p>