Open ximu1211 opened 3 years ago
For the heatmap, we first average a feature map in the channel dimension and then visualize it.
For example,
feature = torch.mean(feature,1)[0,:,:]
The "0" in [0,:,:] means we use the first image of a batch.
Then we can just use matplotlib to visualize it:
plt.matshow(feature)
plt.axis('off')
For the heatmap, we first average a feature map in the channel dimension and then visualize it.
For example,
feature = torch.mean(feature,1)[0,:,:]
The "0" in [0,:,:] means we use the first image of a batch.
Then we can just use matplotlib to visualize it:
plt.matshow(feature) plt.axis('off')
Can the heatmap in the paper be realized in this way? Usually this way is achieved as shown in the figure below. I prefer to produce this result:
By using the above code, most of the generated is similar to the The third row. I don’t know which module to add to the heat map can generate the first row or second row of results.
In addition, it seems that the picture is cropped into several blocks during the running of the program. Where is this part of the code? Can it be cropped?
Can the visualization code of feature map be published?
As mentioned in the paper:
The white area in the feature map indicates zero values, the red area indicates positive values, and the blue area indicates negative values.
You can try this:
# feature [h, w]
max_ = float(feature.max()) # > 0
min_ = float(feature.min()) # < 0
# make white color represent 0 value
m = -max(abs(max_), abs(min_))
feature[0,0] = m
plt.matshow(feature, interpolation='nearest', cmap='seismic')
plt.colorbar()
@q760019473 @ximu1211
thnks sir! have 1 doubt, can you please let me know that why the feature maps are of green color.
Because the default setting of plt.matshow
is green, you can change the color by setting cmap=
, like plt.matshow(feature, cmap='seismic')
@nan-rock
This type of heatmap has rarely been seen before. If possible, is there a code?