tensorflow - 如何将 onnx 模型转换为 tensorflow 保存的模型?
问题描述
我正在尝试使用 tf-serving 来部署我的火炬模型。我已将我的手电筒模型导出到 onnx。如何为 tf-serving 生成 pb 模型?
解决方案
使用onnx/onnx-tensorflow转换器工具作为 ONNX 的 TensorFlow 后端。
安装 onnx-tensorflow:
pip install onnx-tf
使用命令行工具进行转换:
onnx-tf convert -t tf -i /path/to/input.onnx -o /path/to/output.pb
或者,您可以通过 python API 进行转换。
import onnx
from onnx_tf.backend import prepare
onnx_model = onnx.load("input_path") # load onnx model
tf_rep = prepare(onnx_model) # prepare tf representation
tf_rep.export_graph("output_path") # export the model
推荐阅读
- gitlab - 如何从 gitlab 运行/调度 testng.xml
- typescript - 如何使用 SVG.js 进行批量 SVG 操作
- swagger-2.0 - @ApiParam 类型不支持字符串以外的其他类型
- azure - 如果我没有添加,Web App 从哪里获取证书?
- java - 使用 SonarQube Scanner 分析 java 代码时出错
- python - Influx DB Python'列表索引必须是整数而不是str'
- pdf - 使用 Ghostscript 从 PDF 转换为 PCL 时重音字的错误字符
- javascript - 实现npm包自定义组件VueJS
- spring-boot - 成功请求后,Mono 获取 OnCancel 而不是 OnSuccessOrError
- ios - 更新 PromiseKit 后出错:无法将“PMKFinalizer”类型的值转换为预期的参数类型“Promise”
'