Image patch or drawing bounding box using feature map


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 image classification tasks without a bounding box label.

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.

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.

Searching for the paper yields this old repository, which you could try to use directly or use as a template.

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. :slight_smile:

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.

I haven’t checked the repository in detail, but are these bounding boxes never created or just not visualized?

They are never created I believe.

Here’s my latest failed attempt


I tried the draw a bounding box by backtracking the most activated neuron until the image pixel layer. Seems like it didn’t work.

Will debug more to see if there’s a bug.