Mobile SSD models are expected to have exactly 4 outputs, found 8

Im using sagemaker to train the data it has pretrained model
“tensorflow-od1-ssd-resnet50-v1-fpn-640x640-coco17-tpu-8”

For Training:

Create the SageMaker model instance. Note that we need to pass Predictor class when we deploy model through Model class,

for being able to run inference through the sagemaker API.

model = Model(
image_uri=deploy_image_uri,
source_dir=deploy_source_uri,
model_data=base_model_uri,
entry_point=“inference.py”,
role=aws_role,
predictor_cls=Predictor,
name=endpoint_name,
)

# deploy the Model.

base_model_predictor = model.deploy(
initial_instance_count=1,
instance_type=inference_instance_type,
endpoint_name=endpoint_name,
)

Load the saved model

model = tf.saved_model.load(saved_model_dir)

Convert the model to a TFLite model

converter = tf.lite.TFLiteConverter.from_saved_model(saved_model_dir)
converter.optimizations = [tf.lite.Optimize.DEFAULT]
converter.target_spec.supported_ops = [tf.lite.OpsSet.TFLITE_BUILTINS]
converter.target_spec.supported_ops = [
tf.lite.OpsSet.TFLITE_BUILTINS, # enable TensorFlow Lite ops.
tf.lite.OpsSet.SELECT_TF_OPS # enable TensorFlow ops.
]
tflite_model = converter.convert()

Save the TFLite model to disk

with open(tflite_model_file, ‘wb’) as f:
f.write(tflite_model)

I trained and converting it to .tflite file and using it my swift application it got an error
Mobile SSD models are expected to have exactly 4 outputs, found 8

Hi @AjithKumar,

Please ensure you have populated the correct metadata and try with ssd_mobilenet_v2_320x320_coco17_tpu-8 as well. If the problem still persists please provide us a reproducible code.

Thank You