Skip to content

[feat] YOLO detection head: export merged (boxes, class_scores) ONNX outputs#9

Open
Go-MinSeong wants to merge 3 commits intodevfrom
feature/yolo-export-merged-output
Open

[feat] YOLO detection head: export merged (boxes, class_scores) ONNX outputs#9
Go-MinSeong wants to merge 3 commits intodevfrom
feature/yolo-export-merged-output

Conversation

@Go-MinSeong
Copy link
Collaborator

@Go-MinSeong Go-MinSeong commented Mar 17, 2026

Summary

  • YOLO detection head에서 boxes와 class_scores를 merged output으로 ONNX export하는 기능 추가
  • 분산된 ONNX export 스크립트를 onnx_convert.py로 통합 (refactor)
  • CODEOWNERS, .gitignore, Dockerfile 업데이트

Changes

  • src/netspresso_trainer/heads/detection/experimental/yolo_head.py — YOLO head에 merged (boxes, class_scores) ONNX output 지원 추가
  • src/netspresso_trainer/utils/onnx.py — ONNX 유틸리티 개선
  • tools/onnx_convert.py — ONNX export 스크립트 통합 및 개선
  • .github/CODEOWNERS — CODEOWNERS 수정
  • .gitignore — gitignore 항목 추가
  • Dockerfile — Dockerfile 수정

Test plan

  • YOLO detection head ONNX export (merged output) 동작 확인
  • onnx_convert.py 통합 스크립트 정상 동작 확인

🤖 Generated with Claude Code

Go-MinSeong and others added 3 commits March 16, 2026 08:16
…outputs

Previously the ONNX export produced three separate 4-D feature-map outputs
(one per detection scale).  Downstream inference pipelines expect a single
decoded pair of 3-D tensors:
  - output        : (B, total_anchors, 4)  xyxy box coordinates
  - class_scores  : (B, total_anchors, C)  per-class probabilities (sigmoid)

Changes
-------
* yolo_head.py
  - Add `prepare_export(input_size, feat_sizes)` to `YOLODetectionHead`.
    When `feat_sizes` is supplied, anchor grids are pre-computed and stored
    as constant buffers so no Range/Cast ONNX ops appear in the graph.
  - Add `_decode_outputs()`: concatenates all scales, applies a *single*
    Anchor2Vec (one Softmax + Conv3d), decodes ltrb distances to xyxy, and
    returns `(boxes, class_scores)`.
  - `forward()` delegates to `_decode_outputs()` when `_export` flag is set.

* utils/onnx.py
  - `_save_onnx` now accepts a list of output names and builds dynamic-axes
    entries for each output automatically.
  - `save_onnx` detects export mode via `head._export` and passes
    `output_names=['output', 'class_scores']` accordingly.

* tools/onnx_convert_its.py
  - Before calling `prepare_export`, run backbone+neck once with a dummy
    input to obtain per-scale feature map sizes; pass them to
    `prepare_export` so anchor buffers are baked as ONNX constants.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Merge prepare_export logic from onnx_convert_its.py into onnx_convert.py
- Replace hardcoded TEMP_NUM_CLASSES with --num-classes CLI argument (default 80)
- Fix --sample-size to use nargs=2 / int for correct parsing
- Remove onnx_convert_its.py (duplicate) and tools/model_eval.yaml (local config)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Go-MinSeong Go-MinSeong requested a review from Dain-Jeong March 17, 2026 02:33
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.

1 participant