python - 如何将 Tensorflow 模型转换为 tensorflow.js 模型?

标签 python tensorflow tensorflow.js

我使用本教程训练了一个自定义模型: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?

最佳答案

在运行 export_inference_graph.py 后,您是否得到一个名为 saved_model 的目录(如前所述 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

关于python - 如何将 Tensorflow 模型转换为 tensorflow.js 模型?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62547466/

相关文章:

python - 如何在 Tensorflow 2.0 中应用 Guided BackProp?

tensorflow - Keras:layers.Input 和 layers.InputLayer 有什么区别?

tensorflow.js - 如何为 TensorFlow.js 设置 tSNE?

python - 小数点后各占一行的值。使用 Python 3+ 实现 CSV

python - 如何检查 Python Tools for Visual Studio 的调试器是否附加到当前进程?

python - 如何在我的案例中使用 tensorflow 中的 gather_nd 收集数据?

node.js - 警告 : N-API is an experimental feature and could change at any time

tensorflow - 为 Tensorflow.js 保存 TensorFlow 模型

对于单个 Unicode 字符串,Python 返回长度为 2

python - 检测红色和绿色圆圈