python - 热图颜色的不一致行为
问题描述
我正在关注这个漂亮的笔记本来了解我的模型正在学习什么: https ://github.com/fchollet/deep-learning-with-python-notebooks/blob/master/5.4-visualizing-what-convnets-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 中它仍然像最初的热图。我想我在那里遗漏了一个细节……有人能给我提示吗?非常感谢!
解决方案
推荐阅读
- r - 删除 geom_tile 中的空白并匹配 geom_vline&hline 位置
- c# - 无法解析“Jabberwocky.Core.Caching.ICacheProvider”类型的服务
- python - 根据行相关和列相关条件设置数据框值
- python - Python:我有一个日期列表。我想计算到当前日期的天数
- sql - 仅匹配 Redshift Regex 中的百分比值
- mysql - 安装 MySQL 服务器 8.0.14 失败
- bookshelf.js - Strapi:查询图像
- r - 在数据框中创建一个新列,其值基于另一列
- php - 如何提取像 &\#1071; 这样的 Unicode 字符 来自羽毛笔编辑器的 INNERHTML 的“Я”?
- html - 为什么 ui-dialog z-index 不改变?