Exporting YOLOv8 to ONNX

Hello, I’m wondering if my procedure to use a YOLOv8 model in Sentis is correct. I export the model to ONNX format with Ultralytics package like this:

model = YOLO('weights/best.pt')  # load an official model
path = model.export(format="onnx", opset=15)  # export the model to ONNX format, opset_version=15 is the ONNX version Unity needs

Then I load the model (“Optimize Model” = true) into a Sentis 1.0.3 project and I have no errors:

Clicking on “Serialize to StreamingAssets”, I now have a .sentis model in my StreamingAssets folder which I use.


Unfortunately, the detections do not work. Using the example in HuggingFace, I get IndexOutOfRangeException when drawing the bounding box:

//Draw the bounding boxes
        for (int n = 0; n < output.shape[0]; n++)
        {
            var box = new BoundingBox
            {
                centerX = ((output[n, 1] + output[n, 3])*scaleX - displayWidth) / 2,
                centerY = ((output[n, 2] + output[n, 4])*scaleY - displayHeight) / 2,
                width = (output[n, 3] - output[n, 1])*scaleX,
                height = (output[n, 4] - output[n, 2])*scaleY,
                label = labels[(int)output[n, 5]],
                confidence = Mathf.FloorToInt(output[n, 6] * 100 + 0.5f)
            };
            DrawBox(box, n);
        }

Hi, looks like you exported the model correctly. The code is for YOLOv7, the equivalent would be model YOLOv8n. We haven’t tested for compatibility with this yet but hope to have more model examples soon. (The output is likely to be slightly different for the different versions). An easy way to check for compatibility is look at the output shape size. For the YOLOv7 model we used the output shape size is a rank 2 shape whereas this is rank 3.

(We are also encouraging people to publish their own model examples on Hugging Face to help the community :slightly_smiling_face:).

I’d like to contribute and expedite the creation of a sample YOLOv8 detection example for release on Hugging Face.


I have the YOLOv8n model converted to ONNX, along with a sample video for a wildfire prediction task featuring two classes: 0 for smoke and 1 for fire. If you’d find it helpful, I’m more than happy to provide these resources for your evaluation and use, so as to enhance the accessibility of this model for the community.

1 Like

We would certainly welcome real-world examples of using the models in Sentis. And if you are happy to share your models with the community that is even better!

In fact, we also have this form which we are encouraging people to use to get extra help for their projects. (Don’t worry about the ‘company’ section if it is just an individual project)

Alternatively, just post or message me the links to your resources and I’ll take a look to see if I get a YOLOv8 example up soon.

Thanks! Sent you a dm

1 Like

Hi you can try out our latest YOLOv8 example to see if it works for your purposes. For your cases you’ll probably want to set the number of classes to 2.

3 Likes