Hello,

I'm currently stuck to compile my custom YOLOV11 or YOLOV8 model to FP16 precision for RCV4 platform. I archieved to compile to INT8 precision with hub.luxonis.com, but when I'm trying to it offline the outputs of my onnx model seems to be different of the one that were used for the compilation on hub.luxonis.com.

So my question is how to know the outputs ( and their attributes: data_type, shape, layout ) with my .onnx model that I have to put in the config file ?

My current config file for compilation :

input_model: ./models/rt-tray.onnx

mean_values:

- 0

- 0

- 0

scale_values:

- 255

- 255

- 255

keep_intermediate_outputs: true

calibration:

path: ./calibration_data

max_images: 200

inputs:

- name: images

data_type: float32

shape:

- 1

- 3

- 640

- 640

layout: NCHW

outputs:

- name: output1_yolov11

data_type: float32

shape:

- 1

- 80

- 80

- 93

layout: NDEC

- name: output2_yolov11

data_type: float32

shape:

- 1

- 40

- 40

- 93

layout: NDEC

- name: output3_yolov11

data_type: float32

shape:

- 1

- 20

- 20

- 93

layout: NDEC

rvc4:

snpe_onnx_to_dlc_args: []

snpe_dlc_quant_args: []

snpe_dlc_graph_prepare_args: []

keep_raw_images: false

use_per_channel_quantization: true

use_per_row_quantization: false

htp_socs:

- sm8550

compress_to_fp16: true

Hi @PierreCAM ,
if I understand you correctly you are were unable to convert your custom YOLO model to FP16 using hub.luxonis.com? Could you share the error you get when you try to convert it through Hub? You can find the logs if you click on the failed conversion.
Regarding the output information of your onnx model: The easiest way to figure this out is by using Netron web app where you can upload your ONNX file and then when you click on the first input block you'll see on the right information about all the inputs and outputs.
If this doesn't answer your question feel free to ask again.
Best,
Klemen

    4 days later

    Hello KlemenSkrlj,
    Thank you for your response, I have succesfully compiled my yolov11 to FP16 precision for my OAK4 using the hub modelconverter. Currently I'm trying to do it offline, to integrate my custom calibration datas, using your advice I have seen that my model is taking a input named 'images', and with a tensor shape of float32[1,3,640,640] and has an output named 'output0' of shape float32[1,93,8400]. Could explain to me why this values change from the one that are given by the config.json in the NN archive that I can download after my yolov11 model is converted with the hub modelconverter, see the config:

    {

    "config_version": "1.0",
    
    "model": {
    
        "metadata": {
    
            "name": "best",
    
            "path": "best.dlc",
    
            "precision": "float32"
    
        },
    
        "inputs": [
    
            {
    
                "name": "images",
    
                "dtype": "float32",
    
                "input_type": "image",
    
                "shape": [
    
                    1,
    
                    640,
    
                    640,
    
                    3
    
                ],
    
                "layout": "NHWC",
    
                "preprocessing": {
    
                    "mean": [
    
                        0\.0,
    
                        0\.0,
    
                        0\.0
    
                    ],
    
                    "scale": [
    
                        1\.0,
    
                        1\.0,
    
                        1\.0
    
                    ],
    
                    "reverse_channels": false,
    
                    "interleaved_to_planar": true,
    
                    "dai_type": "BGR888i"
    
                }
    
            }
    
        ],
    
        "outputs": [
    
            {
    
                "name": "output1_yolov6r2",
    
                "dtype": "float32",
    
                "shape": [
    
                    1,
    
                    80,
    
                    80,
    
                    94
    
                ],
    
                "layout": "NDEC"
    
            },
    
            {
    
                "name": "output2_yolov6r2",
    
                "dtype": "float32",
    
                "shape": [
    
                    1,
    
                    40,
    
                    40,
    
                    94
    
                ],
    
                "layout": "NDEC"
    
            },
    
            {
    
                "name": "output3_yolov6r2",
    
                "dtype": "float32",
    
                "shape": [
    
                    1,
    
                    20,
    
                    20,
    
                    94
    
                ],
    
                "layout": "NDEC"
    
            }
    
        ],
    
        "heads": [
    
            {
    
                "name": null,
    
                "parser": "YOLO",
    
                "metadata": {
    
                    "postprocessor_path": null,
    
                    "classes": [
    
                        .....
    
                    ],
    
                    "n_classes": 89,
    
                    "is_softmax": null,
    
                    "iou_threshold": 0.5,
    
                    "conf_threshold": 0.5,
    
                    "max_det": 300,
    
                    "anchors": null,
    
                    "yolo_outputs": [
    
                        "output1_yolov6r2",
    
                        "output2_yolov6r2",
    
                        "output3_yolov6r2"
    
                    ],
    
                    "mask_outputs": null,
    
                    "protos_outputs": null,
    
                    "keypoints_outputs": null,
    
                    "angles_outputs": null,
    
                    "subtype": "yolov8",
    
                    "n_prototypes": null,
    
                    "n_keypoints": null
    
                },
    
                "outputs": [
    
                    "output1_yolov6r2",
    
                    "output2_yolov6r2",
    
                    "output3_yolov6r2"
    
                ]
    
            }
    
        ]
    
    }

    }

    When you are converting a pytroch YOLO model we automatically edit it a bit. This edit is so that we can make the exported model work on devices and so it is out-of-the-box compatible with native DepthAI DetectionNetwork node. Effectively this means that we export it without some of the "postprocessing layers" and that postprocessing then happens inside the parser itself. So if your intended use of the model is within DepthAI pipeline then we strongly suggest you keep it that way and use DepthAI DetectionNetwork directly.

    But if you for some reason specifically don't want to use DetectionNetwork and maybe rather NeuralNetworknode to get raw outputs then you can do a "general" model conversion from ONNX instead of "YOLO" conversion in Hub. But note that in that case it is not guaranteed that your ONNX will be convertable, there might be some limitations in which ops are supported on device.

    Currently I'm trying to do it offline, to integrate my custom calibration datas

    At this point we don't yet offer calibration with custom dataset through HubAI. But you can do it locally with Modelconverter. You already have a ONNX archive (the .tar.xz file you can download from Hub).

    Save this into shared_with_container/models folder and save your data under shared_with_container/calibration_data folder and the conversion command should look something like this:
    modelconverter convert rvc4 --path models/<name of .tar.xz> calibration.path calibration_data/<name of calibration folder>

    Let me know if this works,
    Klemen

    Thank you very much, I archieve to compile it with custom calibration datas and with modified onnx on the hub. Thank you for your support.
    Best regards,

    Pierre