我使用以下教程训练了自定义模型:https://github.com/EdjeElectronics/TensorFlow-Object-Detection-API-Tutorial-Train-Multiple-Objects-Windows-10
作为输出,我得到检查点文件,例如model.ckpt-41288.data-00000-of-00001或.data或.meta。
我可以将其导出为冻结图,但是Tensorflow.js不再支持冻结图的转换。我尝试使用旧版,但无法转换。
我查看了Tensorflow的文档,发现它令人困惑。
有人可以给我一个简单的解决方案,用于将训练有素的Tensorflow模型转换为tensorflow.js吗?
答案 0 :(得分:1)
运行saved_model
后,您是否得到一个名称为export_inference_graph.py
的目录(如所述here)?在目录中,它是SavedModel格式的模型。
使用最新的tensorflowjs版本(v2.0及更高版本),您应该能够将模型从SavedModel格式转换为tfjs格式。输出文件应该是group1-shardxofx.bin
文件和model.json
文件。
tensorflowjs_converter --input_format=tf_saved_model --output_node_names='detection_boxes,detection_classes,detection_features,detection_multiclass_scores,detection_scores,num_detections,raw_detection_boxes,raw_detection_scores' --saved_model_tags=serve --output_format=tfjs_graph_model path_to_your_exported_inference_model_dir/saved_model path_to_save_your_tfjs_model