如何在(.pb)训练模型中加载输入?

时间:2019-07-05 23:59:44

标签: opencv tensorflow keras face-recognition

实际上,我正在开发面部表情检测应用程序。我已经使用keras在FER2013数据集上训练了模型。因此,为了预测面部表情,我这样做

from keras.preprocessing import image

from keras.preprocessing.image import ImageDataGenerator
import numpy as np
import matplotlib.pyplot as plt


file = 'photo.jpg'
true_image = image.load_img(file)
img = image.load_img(file, grayscale=True, target_size=(48, 48))

x = image.img_to_array(img)
x = np.expand_dims(x, axis = 0)

x /= 255

custom = model.predict(x)
emotion_analysis(custom[0])

x = np.array(x, 'float32')
x = x.reshape([48, 48]);

plt.gray()
plt.imshow(true_image)
plt.show()

之后,我将模型另存为.pb文件。现在,我不知道如何加载该模型并通过.jpg文件预测情绪。训练后的图像为48X48灰度。请帮帮我。

0 个答案:

没有答案
相关问题