生成可转换为.pb文件之前的准备工作
model.fit(self.x_train, self.y_train, batch_size=self.batch_size, epochs=self.epoch_size,
class_weight = 'auto',validation_split=0.1)
print("savemodel---------------")
model.save_weights('tmp/model3_3.h5')
model.save('tmp/model3_3.hdf5')
json_string = model.to_json()
open('tmp/model3.json', 'w').write(json_string)
#输出损失和精确度
score = model.evaluate(self.x_test, self.y_test, batch_size=self.batch_size)
调用此封装模型
import warnings
warnings.filterwarnings("ignore", category=Warning)
warnings.filterwarnings("ignore", category=FutureWarning)
import keras
import cv2 as cv
import numpy as np
from yaotie3.painting import *
from keras.models import model_from_yaml
from keras.preprocessing.image import img_to_array
# from keras import backend as K
# K.clear_session