Skip To Main Content
Support Knowledge Base

How to Generate a Heatmap Using OpenVINO™

Content Type: Troubleshooting   |   Article ID: 000056835   |   Last Reviewed: 03/05/2026

Environment

OpenVINO™ 2022.1 or later Python 3.8+ OpenCV NumPy C++ PackageCNN

Description

Can a heatmap generation techniques such as layer-wise relevance propagation or Grad-CAM be implemented using OpenVINO™?

Resolution

Heatmaps can be used to visualize the decision-making process of neural networks.

In order to generate heatmaps in OpenVINO™, it is necessary to:

  1. Access the output feature maps of the target convolutional layer and the corresponding weights.

    NoteThis can be done through the model.add_outputs() function call when initializing the network in OpenVINO™ 2.0+ API (replaces the deprecated CNNNetwork: addOutput()).
  2. After running the inference, calculate the weighted sum of the weights with the feature maps to generate the Class Activation Map.

  3. For Grad-CAM implementation, compute gradients of the target class with respect to the feature maps, then multiply the gradients by the feature maps.

  4. Apply ReLU activation to remove negative values and normalize the resulting heatmap.

  5. Resize the heatmap to match the input image dimensions and overlay it on the original image for visualization.

Additional steps:

  • Use model.get_ops() to identify available layer names.
  • Apply color mapping (e.g., cv2.COLORMAP_JET) for better visualization.
  • Normalize heatmap values between 0-1 before visualization.

Related Information

OpenVINO™ Python* API Documentation, Model Optimization Guide

Related Products

This article applies to 1 products.