《python深度学习》可视化热力图

import numpy as np
import matplotlib.pyplot as plt
import tensorflow as tf
from tensorflow.keras import models
import tensorflow.keras.backend as K
import cv2
from tensorflow.keras.applications.vgg16 import preprocess_input, decode_predictions

VGG16_model = tf.keras.applications.VGG16(include_top=True)
VGG16_model.summary()
def prepocess(x):
    x = tf.io.read_file(x)
    x = tf.image.decode_jpeg(x, channels=3)
    x = tf.image.resize(x, [224,224])
    print('x_shape1',x.shape)
    x = tf.expand_dims(x, 0) # 扩维
    print('x_shape2',x.shape)
    x = preprocess_input(x)
    return x

img_path='E:/zbx_code/74.jpg'

img=prepocess(img_path)
print('img.shape',img.shape)

# plt.figure("Image") # 图像窗口名称
# plt.imshow(img)
# plt.axis('on') # 关掉坐标轴为 off
# plt.title('image') # 图像题目
# plt.show()

# Predictions = VGG16_model.predict(img)
# print('Predicted:'
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值