Skip to content

fix: correct ONNX export output names for segmentation models#508

Open
lixiaolei1982 wants to merge 4 commits intoroboflow:developfrom
lixiaolei1982:fix/onnx-export-output-names
Open

fix: correct ONNX export output names for segmentation models#508
lixiaolei1982 wants to merge 4 commits intoroboflow:developfrom
lixiaolei1982:fix/onnx-export-output-names

Conversation

@lixiaolei1982
Copy link

  • Modified export() method in rfdetr/main.py
  • Added dynamic output name configuration
  • Segmentation models now include 'masks' output
  • Backward compatible with detection and backbone models

Description

Fix an inconsistency in the ONNX export function where segmentation models were not correctly configured with three output names.

Issue

When exporting segmentation models to ONNX format, the third output (masks) is not properly named in the output specification, which could lead to:

  • Missing mask outputs in the exported ONNX model
  • Potential export errors or warnings
  • Incorrect behavior when loading the model in inference engines

Changes Made

  1. Modified the output name configuration logic in export() method
  2. Added proper model type detection using self.args.segmentation_head
  3. Dynamic output names based on model type:
    • Backbone-only: ['features']
    • Segmentation: ['dets', 'labels', 'masks']
    • Detection: ['dets', 'labels']

Type of change

  • Bug fix (non-breaking change which fixes an issue)

- Modified export() method in rfdetr/main.py
- Added dynamic output name configuration
- Segmentation models now include 'masks' output
- Backward compatible with detection and backbone models
@CLAassistant
Copy link

CLAassistant commented Dec 21, 2025

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request fixes an issue where segmentation models were not correctly configured with three output names during ONNX export. The fix adds dynamic output name configuration based on model type, ensuring that segmentation models include the 'masks' output while maintaining backward compatibility with detection and backbone-only models.

Changes:

  • Modified the export() method to use conditional logic for output name configuration
  • Added support for segmentation models to include 'masks' in the output names list
  • Maintained backward compatibility for backbone-only and detection models

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Borda
Copy link
Member

Borda commented Jan 21, 2026

@lixiaolei1982, I like your fix; however, could you please provide sample code or ideally add a test to prove it works now as expected?

@codecov
Copy link

codecov bot commented Jan 21, 2026

Codecov Report

❌ Patch coverage is 0% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 17%. Comparing base (968b301) to head (f93ffef).
⚠️ Report is 79 commits behind head on develop.

❌ Your patch check has failed because the patch coverage (0%) is below the target coverage (95%). You can increase the patch coverage or adjust the target coverage.
❌ Your project check has failed because the head coverage (17%) is below the target coverage (95%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files
@@          Coverage Diff           @@
##           develop   #508   +/-   ##
======================================
- Coverage       17%    17%   -0%     
======================================
  Files           42     42           
  Lines         5578   5582    +4     
======================================
  Hits           925    925           
- Misses        4653   4657    +4     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Borda Borda added the bug Something isn't working label Jan 22, 2026
@sh1man999
Copy link

When will you approve ?

@Borda Borda self-assigned this Jan 23, 2026
@Borda
Copy link
Member

Borda commented Jan 26, 2026

When will you approve ?

Just when we have added a test to prove that it really fixes the issue 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants