Difficulties Retraining YOLOv5

Hi @limzhiyong2002

It seems you are encountering several issues with retraining and deploying your YOLOv5 model on Hailo8L. Let’s go through the potential solutions step-by-step:


1. MisspellNodeError: Unable to Find End Node Names

This error occurs when the end node names in your ONNX model do not match what the Hailo SDK expects.

Solution:

  • Use Netron (https://netron.app) to inspect the structure of your ONNX model.
  • From the screenshot you shared, it looks like the final output node is labeled output0. Try using this node name in your YAML configuration.

Here’s the updated YAML configuration:

start_node_names:
  - 'images'
end_node_names:
  - 'output0'

If there are additional output nodes, identify them using Netron and update the YAML accordingly.


2. StopIteration Error During Calibration

This error suggests that the calibration dataset may not be accessible or recognized properly.

Solutions:

  1. Check File Permissions:

    • Ensure all images in the ./calib/ directory have the correct read permissions.
  2. Validate Image Format:

    • Make sure your calibration images are in a valid format, like JPEG or PNG. If needed, try with fewer images first to test the setup.
  3. Use Random Calibration as a Temporary Fix:

    hailo optimize modifiedyolov5s.har --hw-arch hailo8l --use-random-calib-set
    

    If this works but later leads to inference issues, it indicates that your calibration dataset might need adjustments.

  4. Create a TFRecord Calibration Dataset:

    • If using TensorFlow, create the calibration dataset in TFRecord format as recommended by Hailo.

3. No Detections in Inference

This issue may result from improper calibration or missing post-processing steps like Non-Maximum Suppression (NMS).

Solutions:

  1. Apply NMS to the Model Output:
    After inference, use NMS to filter overlapping detections:

    boxes, scores, classes = yolov5_inference(model_output)
    filtered_boxes = apply_nms(boxes, scores, classes)
    
  2. Ensure Calibration Completeness:
    If random calibration works but gives no detections, it might be a quantization issue. Try calibrating again with:

    hailo optimize modifiedyolov5s.har --hw-arch hailo8l --calib-set-path ./calib/
    

    Confirm that the YAML file correctly matches your input and output nodes.

  3. Test with a Pre-Trained Model:
    To ensure the issue isn’t with the model itself, try running a pre-trained YOLOv5 model from the Hailo Model Zoo and confirm it performs as expected.


Next Steps

  1. Update YAML: Use the correct node name (output0), or validate with Netron if other nodes are required.
  2. Fix Calibration: Verify your calibration dataset or try using fewer images to test access.
  3. Post-Processing: Ensure NMS is applied to filter detections effectively.

Let me know if these steps help resolve your issues, or if you need further assistance!