keras保存的模型用来做预测
程序员文章站
2022-05-19 08:56:16
...
from keras.models import load_model
from keras.preprocessing import image
import numpy as np
file_path='4d.jpg' ##随便啥图都可以.
img=image.load_img(file_path,target_size=(32,32))
x=image.img_to_array(img)
x=np.expand_dims(x,axis=0)
##保存权重model.save_weights(),保存模型model.save()
model=load_model('model_weight.h5')
y=model.predict(x)
print(y)