0

**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

Im trying to detect my object it failed

  • The Model object in the SageMaker SDK is used for defining the SageMaker Model parameters that will be used for deployment not training. What exactly are you trying to do? – Marc Karp Apr 10 '23 at 15:13
  • After deploying 1. I downloaded model.tar.gz into local 2. Extract that model.tar.gz file 3. Convert that saved_model.pb to .tflite 4. Using that .tflite in my swift application By using Detector from "TensorFlowLiteTaskVision" detector = try ObjectDetector.detector(options: options) while predicting it shows an error Mobile SSD models are expected to have exactly 4 outputs, found 8 – ML Begginer Apr 11 '23 at 05:51
  • take a look [here](https://github.com/tensorflow/tensorflow/issues/47595) – rok Apr 11 '23 at 09:15
  • Yeah i searched i dont know where my issue was? – ML Begginer Apr 11 '23 at 09:33

0 Answers0