I'm currently working on converting a TensorFlow object detection model to a TensorFlow Lite format for inference on imx8mplus. I used the EIQ Toolkit for the conversion which is installed in ubuntu 20.04. The base model used is ssd_mobilenet_v2_fpnlite_640x640_coco17_tpu-8.
Here are the steps I followed using the EIQ Model Tool:
Selected Model Tool in the EIQ GUI.
Loaded the TensorFlow saved_model.pb file of the model.
Converted the model to TensorFlow Lite (.tflite) using the eiq-converter-tflite.
Enabled quantization with the following settings:
Quantization type: Per Tensor
Input type: uint8
Output type: uint8
Quantization normalization: Unsigned
Calibration dataset: 10 samples from the COCO dataset
Provided a compatible labels.txt file.
After the conversion, when running inference with the TFLite model, I encountered the following error:
IndexError: list index out of range
Post-processing Inference Code:
interpreter.invoke()
labels = load_labels(args.label_file)
scores = np.squeeze(interpreter.get_tensor(output_details[0]['index']))
boxes = np.squeeze(interpreter.get_tensor(output_details[1]['index'])[0])
num_detections = np.squeeze(interpreter.get_tensor(output_details[2]['index'])[0])
classes = np.squeeze(interpreter.get_tensor(output_details[3]['index'])[0])
for i in range(10):
if scores[i] > 0.7:
ymin, xmin, ymax, xmax = boxes[i]
xmin = int(xmin * w0)
ymin = int(ymin * h0)
xmax = int(xmax * w0)
ymax = int(ymax * h0)
class_id = classes[i]
cv2.rectangle(frame, (xmin, ymin), (xmax, ymax), (0, 255, 0), 2)
label = f"{labels[class_id]} {scores[i]:.2f}"
cv2.putText(frame, label, (xmin, max(10, ymin - 5)), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (255, 0, 0), 2)
Is there anything incorrect or missing in the conversion process or the inference/post-processing code that could be causing this IndexError?
I would appreciate any insights or suggestions on how to debug or fix this issue.
Thank you!