简体   繁体   English

将 tensorflow .pb 模型转换为 .mlmodel 时出错

[英]Error converting tensorflow .pb model to .mlmodel

I am trying to convert a tensorflow graph ( .pb file ) into a .mlmodel我正在尝试将张量流图( .pb 文件)转换为.mlmodel

import tfcoreml
coreml_model = tfcoreml.convert(tf_model_path='optimized_model.pb', mlmodel_path='FaceImages.mlmodel', output_feature_names=['final_result'], input_name_shape_dict={'ResizeBilinear': {'images': None, 'size': {None, None}}}, minimum_ios_deployment_target='13')

but I am getting following error:但我收到以下错误:

/usr/local/lib/python3.6/dist-packages/coremltools/converters/nnssa/frontend/tensorflow/graphdef_to_ssa.py in load_tf_graph(graph_file) /usr/local/lib/python3.6/dist-packages/coremltools/converters/nnssa/frontend/tensorflow/graphdef_to_ssa.py in load_tf_graph(graph_file)

 21 with tf.io.gfile.GFile(graph_file, "rb") as f: 22 graph_def = tf.compat.v1.GraphDef()

---> 23 graph_def.ParseFromString(f.read())

 24 25 # Then, we import the graph_def into a new Graph and returns it

DecodeError: Error parsing message解码错误:解析消息时出错

Could anybody help with this pls?有人可以帮忙解决这个问题吗?

Here is the colab project where I have attached the tensorflow model and the associated code for conversion这是colab 项目,我在其中附加了 tensorflow 模型和相关的转换代码

https://colab.research.google.com/drive/1S7nf7pnX15UuswFZaTih5pHhfDFwG5Xa https://colab.research.google.com/drive/1S7nf7pnX15UuswFZaTih5pHhfDFwG5Xa

Have you checked that the version of Tensorflow your are using is compatible with those libraries?您是否检查过您使用的 Tensorflow 版本与这些库兼容? This is just a guess, but you could try running这只是一个猜测,但你可以尝试运行

!pip install tensorflow --upgrade

at the top of the notebook to see if it resolves the issue.在笔记本的顶部,看看它是否解决了问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM