Skip to content

Conversation

@Matvezy
Copy link
Contributor

@Matvezy Matvezy commented Jan 22, 2026

What does this PR do?

For seg models models when calling deploy_to_roboflow and deploy, this error occurs:

File "/app/app.py", line 371, in process_versioned_model_upload
    conversions = prepare_files_and_convert(cache_dir, model_type, f"{workspace_id}/{dataset_id}/{version_id}")
  File "/app/app_rfdetr.py", line 44, in convert
    model.export(output_dir=cache_dir)
  File "/usr/local/lib/python3.10/dist-packages/rfdetr/detr.py", line 123, in export
    self.model.export(**kwargs)
  File "/usr/local/lib/python3.10/dist-packages/rfdetr/main.py", line 581, in export
    print(f"PyTorch inference output shapes - Boxes: {dets.shape}, Labels: {labels.shape}, Masks: {masks.shape}")
AttributeError: 'dict' object has no attribute 'shape'

Type of Change

  • Bug Fix

Fixing this by calling .eval() on the right model object.

Testing

  • I have tested this change locally

Test details:
N/A

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code where necessary, particularly in hard-to-understand areas
  • My changes generate no new warnings or errors
  • I have updated the documentation accordingly (if applicable)

Additional Context

@codecov
Copy link

codecov bot commented Jan 22, 2026

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 22%. Comparing base (978de68) to head (3cdf0b1).

Additional details and impacted files
@@          Coverage Diff           @@
##           develop   #578   +/-   ##
======================================
  Coverage       22%    22%           
======================================
  Files           46     46           
  Lines         6181   6181           
======================================
  Hits          1342   1342           
  Misses        4839   4839           
🚀 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
@Borda Borda requested review from Copilot and removed request for isaacrob-roboflow January 26, 2026 17:41
@Borda
Copy link
Member

Borda commented Jan 26, 2026

@Matvezy could we add a test, pls

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

Fixes ONNX export for segmentation models when using deploy_to_roboflow / deploy by ensuring the correct model instance is put into evaluation mode prior to inference during export.

Changes:

  • Switches the .eval() call in export() from self.model to the locally-copied model used for inference/export.

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

dynamic_axes = None
self.model.eval()

model.eval()

Choose a reason for hiding this comment

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

👍

@taharh taharh mentioned this pull request Feb 2, 2026
6 tasks
@jrdalenberg
Copy link

This circumvents the problem in one scenario but the same bug also appears when just exporting to onxx.

The problem occurs one line before the print statement:

masks = outputs['pred_masks']

outputs['pred_masks'] is a dict and has attributes ['query_features'] and ['spatial_features']. This dict has no shape attribute, hence the error.

Depending on which needs to be printed out, the line should be updated to:

masks = outputs['pred_masks']['query_features'] # or ['spatial_features']

Then the export works successfully.

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.

5 participants