欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

keras 模型读取和预测

程序员文章站 2022-05-19 08:56:04
...
from keras.preprocessing import image
import numpy as np
from keras.models import load_model

img_path = "data2/train/dogs/3046.jpg"
img = image.load_img(img_path, target_size=(113, 113))
x = image.img_to_array(img)
x = np.expand_dims(x, axis=0)
x = preprocess_input(x)
model = load_model('model_weight.h5') 
preds = model.predict(x)
print(preds)
相关标签: keras