生成可转换为.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()
np.set_printoptions(suppress=True)
dir = "test/L518.jpg"
yaml_string = open('tmp/model3.js

这篇博客介绍了如何将Keras模型进行封装,然后将其转换为TensorFlow的.pb格式文件,并详细阐述了转换过程。同时,还讲解了如何生成.pbtxt文件,以便于模型的后续使用和理解。
最低0.47元/天 解锁文章
1345

被折叠的 条评论
为什么被折叠?



