[英]error PlaceholderWithDefault when converting Tensorflow model to CoreML model
I am trying to convert a tensorflow model i trained with tensorflow for poets to a CoreML model so i can run it on my iphone. 我正在尝试将我为诗人使用过的tensorflow训练过的tensorflow模型转换为CoreML模型,以便可以在iphone上运行它。 But when i tried to convert it using this python script:
但是,当我尝试使用此python脚本进行转换时:
import tfcoreml as tf_converter
tf_model_path = 'retrained_graph.pb'
mlmodel_path = 'mobilenet_v1_1.0_224.mlmodel'
mlmodel = tf_converter.convert(
tf_model_path = tf_model_path,
mlmodel_path = mlmodel_path,
output_feature_names = ['MobilenetV1/Predictions/Softmax:0'],
input_name_shape_dict = {'input:0':[1,224,224,3]},
image_input_names = ['input:0'],
red_bias = -1,
green_bias = -1,
blue_bias = -1,
image_scale = 2.0/255.0)
It gives me this error: 它给了我这个错误:
dyld: warning, LC_RPATH $ORIGIN/../../_solib_darwin_x86_64/_U_S_Stensorflow_Spython_C_Upywrap_Utensorflow_Uinternal.so___Utensorflow in /Library/Python/2.7/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so being ignored in restricted program because it is a relative path
2018-01-04 19:47:30.977648: I tensorflow/core/platform/cpu_feature_guard.cc:137] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.2 AVX
Traceback (most recent call last):
File "co.py", line 15, in <module>
image_scale = 2.0/255.0)
File "/Library/Python/2.7/site-packages/tfcoreml/_tf_coreml_converter.py", line 478, in convert
predicted_probabilities_output=predicted_probabilities_output)
File "/Library/Python/2.7/site-packages/tfcoreml/_tf_coreml_converter.py", line 143, in _convert_pb_to_mlmodel
_check_unsupported_ops(OPS, output_feature_names)
File "/Library/Python/2.7/site-packages/tfcoreml/_tf_coreml_converter.py", line 111, in _check_unsupported_ops
','.join(unsupported_op_types)))
NotImplementedError: Unsupported Ops of type: PlaceholderWithDefault
I am using a mac with MacOS Sierra. 我在MacOS Sierra上使用Mac。
Hope someone can help. 希望有人能帮忙。
Greetings Sieuwe 问候Sieuwe
EDIT: 编辑:
I eventually got it working. 我终于让它工作了。 I am not 100% sure what fixed it but it was probably something to do with that i hve 2 python versions.
我不是100%知道是什么修复了它,但可能与我拥有2个python版本有关。 I did was:
我做的是:
Uninstalling tensorflow and tfcoreml from pip and from pip3. 从pip和pip3卸载tensorflow和tfcoreml。 Installing tfcoreml and tensorflow with pip not pip3 Uninstalling and installing numpy with pip(this gave me some errors while doing but got it eventually uninstalled)
用pip而不是pip3安装tfcoreml和tensorflow用pip卸载和安装numpy(这样做虽然给了我一些错误,但最终将其卸载了)
If it still wont work mayby try to build tfcoreml and tensorflow from source. 如果仍然无法正常工作,可以尝试从源代码构建tfcoreml和tensorflow。
I haven't used tfcoreml yet, but the error "Unsupported Ops of type: PlaceholderWithDefault" means that your TF graph uses an operation that is not supported by the converter. 我还没有使用过tfcoreml,但是错误“类型不支持的Ops:PlaceholderWithDefault”意味着您的TF图使用了转换器不支持的操作。
If you look at the list of supported ops at https://github.com/tf-coreml/tf-coreml you'll see that Placeholder is supported but not PlaceholderWithDefault. 如果您在https://github.com/tf-coreml/tf-coreml上查看受支持的操作列表,则会看到支持占位符,但不支持PlaceholderWithDefault。
In the TensorFlow for Poets 2 tutorial there is a step that lets you optimize the model for mobile. 在TensorFlow for Poets 2教程中,有一个步骤可让您优化移动设备的模型。 I'm not 100% sure but this might replace the PlaceholderWithDefault with a regular Placeholder.
我不确定100%,但是这可能会将PlaceholderWithDefault替换为常规的Placeholder。 It's worth doing anyway.
无论如何都是值得的。 :-)
:-)
i see that you've submitted a github ticket: https://github.com/tf-coreml/tf-coreml/issues/99 for this issue as well... i had the same issue you saw, but by following the responder's advice and got it to work. 我看到您已经提交了一个github票: https : //github.com/tf-coreml/tf-coreml/issues/99也是针对此问题的...我遇到了与您看到的相同的问题,但是通过遵循响应者的建议并使其起作用。 can you update your answer if that helped?
如果有帮助,您可以更新答案吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.