Yolov8 custom dataset retraining - label mismatch

Hi there, I’ve been using the Hailo Suite to retrain a Yolov8 model with a custom dataset, to run on a RPi5+Hailo8l, but when I run the model, the object is detected but label showed on the bounding box is incorrect.

My custom dataset has a small set of images of flame from a lighter. Labels were created on Roboflow platform and downloaded in Yolov8 format. The dataset has only one label, “flame”, on index 0, as example below:

“0 0.48203125 0.490625 0.1140625 0.28125”

The sequence of steps used for retraining are:

  1. yolo detect train data=data.yaml model=yolov8m.pt name=retrain_yolov8m epochs=200 batch=16
  2. yolo export model=/path/to/trained/best.pt imgsz=640 format=onnx opset=11 # export at 640x640
  3. hailomz compile --ckpt fire_yolov8m.onnx --hw-arch hailo8l --calib-path ./test/images/ --yaml ./yolov8m.yaml --classes 1

My data.yaml has:

train: ./flame/train/images
val: ./flame/valid/images
test: ./flame/test/images

nc: 1
names: [flame]

I am testing using the rpicam postprocessing, as:
rpicam-hello --post-processing-file flame.json

and my flame.json file has:

{
    "rpicam-apps":
    {
        "lores":
        {
            "width": 640,
            "height": 640,
            "format": "rgb"
        }
    },

    "hailo_yolo_inference":
    {
        "hef_file": "flame.hef",
        "max_detections": 20,
        "threshold": 0.4,

        "temporal_filter":
        {
            "tolerance": 0.1,
            "factor": 0.75,
            "visible_frames": 6,
            "hidden_frames": 3
        }
    },

    "object_detect_draw_cv":
    {
        "line_thickness" : 2
    }
}

But when I run the model, the label showed around the bouding box is “person”, which I noticed is normally the first label of the list on some object detection models.

From ChatGPT I learned that the .hef file does not contain any labels, so, I wonder where is that label coming from when I execute the model?

Does it come from the yolov8.pt model used on the “yolo detect train” step?

What can I change to enforce label 0 as being “flame” and not “person”?

Hey @lucas.l,

It seems like there are two possible sources for the label mismatch you’re experiencing:

  1. The RPi camera app might not be reading or using the provided label file correctly.
  2. The hailo_yolo_inference block in your JSON configuration might not have the class labels explicitly defined. As a result, it could be falling back to a standard or previously cached list of labels (such as the COCO dataset labels where “person” is class 0) or a different label file.

If this is your first time testing the HEF (Hailo Executable Format) file, I highly recommend using our dedicated examples for a smoother experience. You can find them in the Hailo RPi5 examples repository: GitHub - hailo-ai/hailo-rpi5-examples

To run the examples with your custom HEF, follow the instructions in the “Using Retrained Models” section of the basic pipelines documentation: hailo-rpi5-examples/doc/basic-pipelines.md at main · hailo-ai/hailo-rpi5-examples · GitHub

This will ensure that you’re using a setup that’s optimized for testing custom models with Hailo.

Feel free to let me know if you have any further questions or need additional guidance!

Hi @omria, thank you for your help.

I used the example suggested in your link, and it worked with some changes.
The json format that I was using was not compatible with this example, so I used the one in /resources as a template.

The command I used:
python basic_pipelines/detection.py --labels-json labels.json --hef my.hef --input rpi

What I noticed though is that it ran much slower than the rpicam postprocessing example. Would you know the reason for that?