reference:https://www.jianshu.com/p/45e575555896
背景:目前keras框架使用简单,很容易上手,深得广大算法工程师的喜爱,但是当部署到客户端时,可能会出现各种各样的bug,甚至不支持使用keras,本文来解决的是将keras的h5模型转换为客户端常用的tensorflow的pb模型并使用tensorflow加载pb模型。
h5_to_pb.py
from keras.models import load_model
import tensorflow as tf
import os
import os.path as osp
from keras import backend as K
#路径参数
input_path = 'input path'
weight_file = 'model.h5'
weight_file_path = osp.join(input_path,weight_file)
output_graph_name