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

답변 없음

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠