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:'
《python深度学习》可视化热力图
最新推荐文章于 2024-06-27 14:23:30 发布