首页 > 解决方案 > 热图颜色的不一致行为

问题描述

我正在关注这个漂亮的笔记本来了解我的模型正在学习什么: https ://github.com/fchollet/deep-learning-with-python-notebooks/blob/master/5.4-visualizing-what-c​​onvnets-learn.ipynb

问题是当我绘制热图时,我有与 github 上相同类型的图像(即黄色显示模型用于评估类的部分)

heatmap = np.maximum(heatmap, 0) heatmap /= np.max(heatmap)
plt.matshow(heatmap) plt.show()

在此处输入图像描述

但是当我执行以下操作时,就像 github 一样:

# We use cv2 to load the original image
img = img_aug

# We resize the heatmap to have the same size as the original image
heatmap = cv2.resize(heatmap, (img.shape[1], img.shape[0]))

# We convert the heatmap to RGB
heatmap = np.uint8(255 * heatmap)

# We apply the heatmap to the original image
heatmap = cv2.applyColorMap(heatmap, cv2.COLORMAP_JET)

# 0.4 here is a heatmap intensity factor
superimposed_img = heatmap * 0.4 + img
plt.imshow(superimposed_img.astype(int));

我有一张图片,现在网络正在查看的部分是蓝色的(与第一张图片相比颜色相反),而在 github 中它仍然像最初的热图。我想我在那里遗漏了一个细节……有人能给我提示吗?非常感谢!

在此处输入图像描述

标签: pythondeep-learningheatmap

解决方案


推荐阅读