ChenhongyiYang / QueryDet-PyTorch

[CVPR 2022 Oral] QueryDet: Cascaded Sparse Query for Accelerating High-Resolution Small Object Detection
MIT License
423 stars 46 forks source link

请问如何可视化热力图啊 #91

Open liuw20 opened 5 months ago

judycpChen commented 5 months ago

请问你解决了吗?

ChenhongyiYang commented 5 months ago

Hi, you can visualize the heatmap with the following steps:

  1. summing the feature map, e.g., the last layer of the small object classification branch, along its channel dimension
  2. normalize the feature map to (0~1) by normed_feature = (feature.max() - feature) / (feature.max() - feature.min())
  3. resize the feature map to the image size with bilinear interpolation
  4. convert the normalized feature map to an RGB map. Here is a simple example.
  5. combine the computed RGB map with the original image for the final visualization. For example: vis = (0.5 * image + 0.5 * rgb_map).astype(np.uint8)

The above steps are used to visualize intermediate feature maps. However, it's easier and more straightforward to visualize the small object detection heatmap. You can skip the first two steps and use the sigmoid result as the normalized map.