tf-coreml / tf-coreml

TensorFlow to CoreML Converter
Apache License 2.0
1.33k stars 168 forks source link

NotImplementedError: Unsupported Ops of type: Tile #291

Closed Ketsuko closed 5 years ago

Ketsuko commented 5 years ago

Hi everyone, in my quest of converting a tensorflow saved model to a coreml model, I'm facing some issues. So far, I have a TF saved model, I opened it and froze to graph to a single .pb file

Then, I'm trying to convert it into a .mlmodel file However, when I'm running the current line:

tf_converter.convert(tf_model_path='./model.pb', mlmodel_path='my_model.mlmodel', output_feature_names=['descriptor:0'], input_name_shape_dict={'image:0' : [1, 224, 224, 1]})

Python raises this error:

NotImplementedError Traceback (most recent call last)

in () 2 mlmodel_path='my_model.mlmodel', 3 output_feature_names=['descriptor:0'], ----> 4 input_name_shape_dict={'image:0' : [1, 224, 224, 1]}) /Users/ketsuko/PycharmProjects/MobileNetVLAD/venv/lib/python3.6/site-packages/tfcoreml/_tf_coreml_converter.py in convert(tf_model_path, mlmodel_path, output_feature_names, input_name_shape_dict, image_input_names, is_bgr, red_bias, green_bias, blue_bias, gray_bias, image_scale, class_labels, predicted_feature_name, predicted_probabilities_output, add_custom_layers, custom_conversion_functions) 584 predicted_probabilities_output=predicted_probabilities_output, 585 add_custom_layers=add_custom_layers, --> 586 custom_conversion_functions=custom_conversion_functions) /Users/ketsuko/PycharmProjects/MobileNetVLAD/venv/lib/python3.6/site-packages/tfcoreml/_tf_coreml_converter.py in _convert_pb_to_mlmodel(tf_model_path, mlmodel_path, output_feature_names, input_name_shape_dict, image_input_names, is_bgr, red_bias, green_bias, blue_bias, gray_bias, image_scale, class_labels, predicted_feature_name, predicted_probabilities_output, add_custom_layers, custom_conversion_functions) 284 285 if not add_custom_layers: --> 286 _check_unsupported_ops(OPS, output_feature_names, effectively_constant_ops + unused_ops) 287 print('Now starting translation to CoreML graph.') 288 /Users/ketsuko/PycharmProjects/MobileNetVLAD/venv/lib/python3.6/site-packages/tfcoreml/_tf_coreml_converter.py in _check_unsupported_ops(ops, output_feature_names, skip_ops) 120 if len(unsupported_op_types) > 0: 121 raise NotImplementedError("Unsupported Ops of type: %s" % ( --> 122 ','.join(unsupported_op_types))) 123 124 def _convert_pb_to_mlmodel(tf_model_path, NotImplementedError: Unsupported Ops of type: Tile From what I understand, somewhere in my graph there would be (an) unsupported operation(s). My question is the following, what does this error really mean? Is there a way to modify the graph to remove those operations? (I didn't build it and just have the saved model and pb) Thank you for your help!
1duo commented 5 years ago

Hi @Ketsuko , thanks for reporting this issue. The Tile op should be supported (see here). Could you try again with the following setup?

pip install coremltools==3.0b5
pip install tfcoreml==0.4.0b1

You'll need to enable use_coreml_3=True flag when calling tf_converter.convert() method as in the (readme). Let us know if this doesn't work for you. Thanks!