Skip to content

Get shape for each output from the ONNX and infer layout + YOLO26 changes + output field re-names#207

Merged
dtronmans merged 14 commits intomainfrom
feat/output-shapes-and-layout
Apr 2, 2026
Merged

Get shape for each output from the ONNX and infer layout + YOLO26 changes + output field re-names#207
dtronmans merged 14 commits intomainfrom
feat/output-shapes-and-layout

Conversation

@dtronmans
Copy link
Copy Markdown
Contributor

@dtronmans dtronmans commented Feb 23, 2026

Purpose

Shape and layout:

  • Re-load the saved ONNX and use it to retrieve the output shapes
  • For the output layout I found no other way than to infer it from the dim length, at some points it might be incorrect for example if NCD is supposed to be NDC instead but I don't see anywhere where the layout field is used, for example in depthai-nodes, to decide how to post-process the output

Renaming output names:

Yolo26 conversion with one2one head:

  • tools yolo26n.pt --imgsz "640" --version yolov26_nms
  • Since this is the first time the same .pt file can have two different export branches, I had to add cli_version flag to the tests

ReduceMax in graph:

Specification

Dependencies & Potential Impact

Deployment Plan

Testing & Validation

yolov8n:

"outputs": [
    {
        "name": "output1_yolov6r2",
        "dtype": "float32",
        "shape": [
            1,
            85,
            80,
            80
        ],
        "layout": "NCHW"
    },
    {
        "name": "output2_yolov6r2",
        "dtype": "float32",
        "shape": [
            1,
            85,
            40,
            40
        ],
        "layout": "NCHW"
    },
    {
        "name": "output3_yolov6r2",
        "dtype": "float32",
        "shape": [
            1,
            85,
            20,
            20
        ],
        "layout": "NCHW"
    }
],

yolo26n:

"outputs": [
    {
        "name": "output",
        "dtype": "float32",
        "shape": [
            1,
            8400,
            84
        ],
        "layout": "NCD"
    }
],

yolo26n-seg:

"outputs": [
    {
        "name": "output",
        "dtype": "float32",
        "shape": [
            1,
            8400,
            84
        ],
        "layout": "NCD"
    },
    {
        "name": "mask_output",
        "dtype": "float32",
        "shape": [
            1,
            8400,
            32
        ],
        "layout": "NCD"
    },
    {
        "name": "protos_output",
        "dtype": "float32",
        "shape": [
            1,
            32,
            160,
            160
        ],
        "layout": "NCHW"
    }
],

yolo26n-pose:

"outputs": [
    {
        "name": "output",
        "dtype": "float32",
        "shape": [
            1,
            8400,
            5
        ],
        "layout": "NCD"
    },
    {
        "name": "kpt_output",
        "dtype": "float32",
        "shape": [
            1,
            8400,
            51
        ],
        "layout": "NCD"
    }
],

@github-actions
Copy link
Copy Markdown

github-actions bot commented Feb 23, 2026

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
30404 6515 21% 0% 🟢

New Files

No new covered files...

Modified Files

File Coverage Status
tools/main.py 86% 🟢
tools/modules/exporter.py 84% 🟢
tools/modules/heads.py 51% 🟢
tools/version_detection/version_detection.py 47% 🟢
tools/yolo/yolo26_exporter.py 0% 🟢
tools/yolo/yolov8_exporter.py 63% 🟢
TOTAL 55% 🟢

updated for commit: cddb0f6 by action🐍

@github-actions
Copy link
Copy Markdown

github-actions bot commented Feb 23, 2026

Test Results

  6 files    6 suites   23m 44s ⏱️
 26 tests  26 ✅ 0 💤 0 ❌
156 runs  156 ✅ 0 💤 0 ❌

Results for commit cddb0f6.

♻️ This comment has been updated with latest results.

@aljazkonec1
Copy link
Copy Markdown

aljazkonec1 commented Feb 23, 2026

I've been testing pose model and the keypoint layer output shape differs compared to say Yolo v8 pose:

                "layout": "NCD",
                "name": "kpt_output1",
                "shape": [
                    1,
                    51,
                    3520
                ]
            },

Here you see C dimension is 51, having the order be:

        "name": "kpt_output",
        "dtype": "float32",
        "shape": [
            1,
            8400,
            51
        ],
        "layout": "NCD"
    }

breaks the current implementation of DetectionParser as it assumes data is flattened as [1, 51, 3520]. Which is the "correct" shape? Are both valid shapes?

@dtronmans dtronmans changed the title Get shape for each output from the ONNX and infer layout based on dims Get shape for each output from the ONNX and infer layout based on dims + YOLO26 ReduceMax in graph + YOLO26 with NMS in graph option Feb 25, 2026
@dtronmans dtronmans changed the title Get shape for each output from the ONNX and infer layout based on dims + YOLO26 ReduceMax in graph + YOLO26 with NMS in graph option Get shape for each output from the ONNX and infer layout based on dims + YOLO26 changes Feb 25, 2026
@dtronmans dtronmans changed the title Get shape for each output from the ONNX and infer layout based on dims + YOLO26 changes Get shape for each output from the ONNX and infer layout + YOLO26 changes + output field re-names Feb 25, 2026
@aljazkonec1
Copy link
Copy Markdown

I have added depthai-core support for YOLO26 here. I tested the PR against the nnarchives @dtronmans generated with this PR and all looks good.

The only thing I would change in the NNarchives is the parser is listed as "YOLOExtendedParser" and I would change it to "YOLO" so ParsingNeuralNetwork automatically switches to depthai-core DetectionParser?

@dtronmans
Copy link
Copy Markdown
Contributor Author

I have added depthai-core support for YOLO26 here. I tested the PR against the nnarchives @dtronmans generated with this PR and all looks good.

The only thing I would change in the NNarchives is the parser is listed as "YOLOExtendedParser" and I would change it to "YOLO" so ParsingNeuralNetwork automatically switches to depthai-core DetectionParser?

@aljazkonec1 good point, done

@dtronmans dtronmans merged commit a2d1871 into main Apr 2, 2026
16 checks passed
@dtronmans dtronmans deleted the feat/output-shapes-and-layout branch April 2, 2026 15:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants