I created a tflite model:
yolo export model=yolov8n.pt data=coco128.yaml format=tflite int8
Ran a test
Load the TFLite model
interpreter = tf.lite.Interpreter(model_path=“/content/drive/MyDrive/Model/yolov8n_saved_model/yolov8n_full_integer_quant.tflite”)
interpreter.allocate_tensors()
Get input and output tensors.
input_details = interpreter.get_input_details()
output_details = interpreter.get_output_details()
Load and preprocess an image
image = Image.open(“/content/dog.jpeg”)
image = image.resize((640, 640)) # Resize to the model’s expected input size
Convert image to INT8 data type
input_data = np.array(image, dtype=np.int8) # Convert image data to INT8
input_data = np.expand_dims(input_data, axis=0) # Add batch dimension
Run inference
interpreter.set_tensor(input_details[0][‘index’], input_data)
interpreter.invoke()
Get the output results
output_data = [interpreter.get_tensor(output_details[i][‘index’]) for i in range(len(output_details))]
Print the shape of the output data
print(“Output Shape:”, output_data[0].shape)
output_data = interpreter.get_tensor(output_details[0][‘index’])
I’m unsure how to interpret the output data. Is there any guidance on this?