一 tensorflow
01:
通過saver.save函數將TensorFlow模型保存到了model/model.ckpt文件中,這里代碼中指定路徑為"model/model.ckpt",也就是保存到了當前程序所在文件夾里面的model文件夾中。
TensorFlow模型會保存在后綴為.ckpt的文件中。保存后在save這個文件夾中實際會出現3個文件,因為TensorFlow會將計算圖的結構和圖上參數取值分開保存。
model.ckpt.meta文件保存了TensorFlow計算圖的結構,可以理解為神經網絡的網絡結構model.ckpt文件保存了TensorFlow程序中每一個變量的取值checkpoint文件保存了一個目錄下所有的模型文件列表
--
02:.pb
constant_graph = graph_util.convert_variables_to_constants(sess, sess.graph_def, ["output"])
with tf.gfile.FastGFile(pb_file_path, mode='wb') as f:
f.write(constant_graph.SerializeToString())
這兩句是重要的代碼,用來把訓練好的模型保存為pb文件。運行完之后就會發現應該的文件夾多出了一個pb文件。
def recognize(jpg_path, pb_file_path):
with tf.Graph().as_default():
output_graph_def = tf.GraphDef()
with open(pb_file_path, "rb") as f:
output_graph_def.ParseFromString(f.read())
_ = tf.import_graph_def(output_graph_def, name="")
打開相應的pb文件。
TensorFlow 自定義模型導出:將 .ckpt 格式轉化為 .pb 格式
二 caffee
生成模型文件 .h5,
.hdf5
;
在使用OpenCV的人臉檢測之前,需要一個人臉訓練模型,格式是xml的
--
--
