Skip to content

fix(rfdetr): accept dict-form checkpoint args in classname extraction#487

Merged
leeclemnet merged 3 commits into
mainfrom
fix/rfdetr-classnames-dict-args
May 29, 2026
Merged

fix(rfdetr): accept dict-form checkpoint args in classname extraction#487
leeclemnet merged 3 commits into
mainfrom
fix/rfdetr-classnames-dict-args

Conversation

@leeclemnet
Copy link
Copy Markdown
Contributor

@leeclemnet leeclemnet commented May 29, 2026

What does this PR do?

In get_classnames_txt_for_rfdetr, normalizes checkpoint["args"] to a dict instead of calling vars() on it directly, and adds tests for both dict and Namespace shapes.

vars(checkpoint["args"]) raises TypeError: vars() argument must have __dict__ attribute when args is a plain dict rather than an argparse.Namespace. rf-detr EMA checkpoints (e.g. checkpoint_best_ema.pth) store args as a dict.

Today this is masked when a class_names.txt already exists in the upload dir (the function short-circuits before reaching vars()), but it breaks for any rf-detr checkpoint with dict-form args that relies on extracting class names from the checkpoint.

Related Issue(s): Companion to the server-side conversion fix roboflow/roboflow-model-conversion#93, which hit the same dict-vs-Namespace assumption on args.resolution and caused real prod upload failures (Medra workspace, rfdetr-seg-medium).

Type of Change

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

Testing

  • I have tested this change locally
  • I have added/updated tests for this change

Test details:

python -m unittest tests.util.test_model_processor → 14 tests pass, including new GetClassnamesTxtForRfdetrTest covering both args shapes. The test_dict_args case reproduces the vars() TypeError against the old code. ruff format --check and ruff check clean on the changed files; pre-commit hooks passed on push.

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

The two normalizations point opposite directions on purpose: this site needs a dict (downstream does args["class_names"]), while the conversion site needs a Namespace (downstream does args.resolution). Each normalizes toward what its own caller expects.

@leeclemnet leeclemnet force-pushed the fix/rfdetr-classnames-dict-args branch from 40d3ff8 to fdbc0d8 Compare May 29, 2026 19:04
@socket-security
Copy link
Copy Markdown

socket-security Bot commented May 29, 2026

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedclick@​8.4.196100100100100
Updatedtyper@​0.26.3 ⏵ 0.25.199 +3100100100100
Updatedfiletype@​1.2.0 ⏵ 0.1.6100 +1100100100100

View full report

@leeclemnet leeclemnet force-pushed the fix/rfdetr-classnames-dict-args branch 2 times, most recently from 51efe63 to 167cf90 Compare May 29, 2026 19:42
leeclemnet and others added 2 commits May 29, 2026 17:17
`get_classnames_txt_for_rfdetr` called `vars(checkpoint["args"])`, which raises
TypeError when `args` is a plain dict rather than an argparse.Namespace (e.g.
rf-detr EMA checkpoints). Normalize to a dict before lookups. Add tests covering
both shapes.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
typer 0.26 vendors its own click as `typer._click` and drops the external click
dependency, so roboflow.cli imports fail (click absent) and _compat.py mistypes
under mypy. typer 0.25.x still depends on external click. Pin typer<0.26 and
declare click explicitly in requirements.txt and requirements-slim.txt so the
build matrix and test-slim pass.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@leeclemnet leeclemnet force-pushed the fix/rfdetr-classnames-dict-args branch from 167cf90 to d2277f6 Compare May 29, 2026 19:47
@leeclemnet leeclemnet marked this pull request as ready for review May 29, 2026 19:56
@leeclemnet leeclemnet requested a review from probicheaux May 29, 2026 19:58
Comment thread requirements-slim.txt
filetype
typer>=0.12.0
typer>=0.12.0,<0.26 # 0.26 vendors click, dropping the external dep the CLI imports
click>=8.0
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

CI broken without this

probicheaux
probicheaux previously approved these changes May 29, 2026
@leeclemnet leeclemnet force-pushed the fix/rfdetr-classnames-dict-args branch 2 times, most recently from 68dd065 to ea61d12 Compare May 29, 2026 20:03
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@leeclemnet leeclemnet force-pushed the fix/rfdetr-classnames-dict-args branch from ea61d12 to 15fec18 Compare May 29, 2026 20:04
@leeclemnet leeclemnet requested a review from probicheaux May 29, 2026 20:05
@leeclemnet leeclemnet merged commit e4c30e1 into main May 29, 2026
15 checks passed
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.

2 participants