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

0

Im using sagemaker for train the data It has pre-trained model “tensorflow-od1-ssd-resnet50-v1-fpn-640x640-coco17-tpu-8”

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,
)

Save the deployed model in local

import boto3
s3 = boto3.client('s3')
bucket = 'sagemaker'
key = 'model-tensorflow-od1-ssd-mobilenet/model.tar.gz'
local_file_path = 'new_model.tar.gz'
s3.download_file(bucket, key, local_file_path)

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 in my swift application i got an error Mobile SSD models are expected to have exactly 4 outputs, found 8

没有答案

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则