Hello,
has anyone tried to convert the SavedModel or tflite Model of EfficientDet-Lite-2 found on tfhub https://tfhub.dev/tensorflow/efficientdet/lite2/detection/1 to MlModel?
on coremltools, it says they accept the path to savedModel directory as an input. But I am having unsupported input type.
import coremltools as ct
mlmodel = ct.convert("efficientdet_lite2_detection_1")
I get this error:
.
.
.
inputs.append(TensorType(name=inp, shape=shape, dtype=dtype))
File "/Users/smurf/miniconda3/envs/coreml_conv/lib/python3.9/site-packages/coremltools/converters/mil/input_types.py", line 215, in __init__
raise TypeError("dtype={} is unsupported for inputs/outputs of the model".format(dtype))
TypeError: dtype=<class 'coremltools.converters.mil.mil.types.type_int.make_int.<locals>.int'> is unsupported for inputs/outputs of the model
I think itâs due to âuint8â input type, and they dont support it.
I try again with ImageType like this:
model = ct.convert(
"efficientdet_lite2_detection_1",
inputs=[ct.ImageType(name="images", shape = (1, 448, 448, 3), scale=1 / 255.0, bias=[0, 0, 0], channel_first=False)],
)
I got this error:
.
.
.
File "/Users/smurf/miniconda3/envs/coreml_conv/lib/python3.9/site-packages/coremltools/converters/mil/frontend/tensorflow/converter.py", line 374, in convert_main_graph
func_inputs[input_type.name] = mb.placeholder(
File "/Users/smurf/miniconda3/envs/coreml_conv/lib/python3.9/site-packages/coremltools/converters/mil/mil/builder.py", line 189, in placeholder
return Placeholder(shape, dtype, allow_rank0_input=allow_rank0_input)
File "/Users/smurf/miniconda3/envs/coreml_conv/lib/python3.9/site-packages/coremltools/converters/mil/mil/program.py", line 163, in __init__
raise ValueError('Rank-0 (input {}) is unsupported'.format(name))
ValueError: Rank-0 (input None) is unsupported
This is probably due to input shape:
import tensorflow as tf
model = tf.saved_model.load("efficientdet_lite2_detection_1")
signature = model.signatures
input_tensors = signature["serving_default"].inputs
output_tensors = signature["serving_default"].outputs
print(input_tensors[0])
>>> Tensor("images:0", shape=(None, None, None, 3), dtype=uint8)
I tried to change input shape:
signature["serving_default"].inputs[0].shape = (1, 448, 448, 3)
>>>
Traceback (most recent call last):
File "/Users/smurf/Desktop/repositories/playground/convert_coreml.py", line 11, in <module>
signature["serving_default"].inputs[0].shape = (1, 448, 448, 3)
AttributeError: can't set attribute
Any ideas to solve this problem ?
Thank you