Skip to content

Fix: resolution kwarg silently ignored in RFDETR.train()#933

Draft
Copilot wants to merge 3 commits intodevelopfrom
copilot/fix-image-size-resolution-argument
Draft

Fix: resolution kwarg silently ignored in RFDETR.train()#933
Copilot wants to merge 3 commits intodevelopfrom
copilot/fix-image-size-resolution-argument

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 8, 2026

TrainConfig extends plain BaseModel (extra fields ignored), so passing resolution=N to .train() was silently dropped — the model always trained at the default config resolution regardless of what the user set.

Changes

  • RFDETR.train() now absorbs resolution before forwarding remaining kwargs to get_train_config():
    • Validates divisibility by patch_size × num_windows (raises ValueError if not)
    • Applies directly to self.model_config.resolution
    • Recomputes positional_encoding_size = resolution // patch_size
  • Docstring updated to document resolution as a first-class .train() kwarg

Usage

from rfdetr import RFDETRMedium

# RFDETRMedium: patch_size=16, num_windows=2 → resolution must be divisible by 32
model = RFDETRMedium()
model.train(dataset_dir="...", resolution=672)  # now correctly uses 672 instead of 576

Invalid resolutions raise immediately with a clear message:

ValueError: resolution=570 is not divisible by patch_size (16) × num_windows (2) = 32.
Choose a resolution that is a multiple of 32.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://storage.googleapis.com/rfdetr/nano_coco/checkpoint_best_regular.pth
    • Triggering command: /usr/bin/python python -m pytest tests/training/ src/ -x -v -m not gpu --ignore=tests/training/test_metrics_csv.py (http block)
    • Triggering command: /usr/bin/python python -m pytest src/rfdetr/detr.py::rfdetr.detr.RFDETR.optimize_for_inference -v (http block)
    • Triggering command: /usr/bin/python python -m pytest src/rfdetr/detr.py::rfdetr.detr.RFDETR.optimize_for_inference -v --tb=short (http block)
  • https://storage.googleapis.com/rfdetr/rf-detr-seg-n-ft.pth
    • Triggering command: /usr/bin/python python -m pytest tests/ src/ -v -m not gpu --ignore=tests/training/test_metrics_csv.py --ignore=src/rfdetr/detr.py --ignore=tests/try_instantiate_all_models.py (http block)
  • huggingface.co
    • Triggering command: /usr/bin/python python -m pytest tests/ src/ -v -m not gpu --ignore=tests/training/test_metrics_csv.py --ignore=src/rfdetr/detr.py --ignore=tests/try_instantiate_all_models.py (dns block)
  • images.cocodataset.org
    • Triggering command: /usr/bin/python python -m pytest tests/ src/ -v -m not gpu --ignore=tests/training/test_metrics_csv.py --ignore=src/rfdetr/detr.py --ignore=tests/try_instantiate_all_models.py (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI linked an issue Apr 8, 2026 that may be closed by this pull request
2 tasks
Copilot AI changed the title [WIP] Fix image size not changing with resolution argument Fix: resolution kwarg silently ignored in RFDETR.train() Apr 8, 2026
Copilot AI requested a review from Borda April 8, 2026 07:36
Copilot finished work on behalf of Borda April 8, 2026 07:36
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.

Image size doesn't appear to change with resolution argument

2 participants