Click4Ai

491.

Medium

Saliency Maps

In this problem, you will be implementing a function to generate saliency maps from a given input image and a pre-trained model. Saliency maps are used to visualize the importance of different regions of the input image for a specific class. Your function should take in an input image, a pre-trained model, and a class index, and return a heatmap representation of the saliency scores.

Example:

Suppose we have an input image x, a pre-trained model model, and a class index class_idx. The function should return a heatmap with the saliency scores plotted.

Constraints:

* The input image should be a 3D numpy array with shape (height, width, channels).

* The pre-trained model should be a Keras model.

* The class index should be an integer.

Test Cases

Test Case 1
Input: [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
Expected: Heatmap of saliency scores
Test Case 2
Input: [[10, 20, 30], [40, 50, 60], [70, 80, 90]]
Expected: Heatmap of saliency scores
+ 3 hidden test cases