Skip to content

fix(datasets): require pipeline options instead of substituting wrong defaults - #1413

Open
Maryyyyyyyam142 wants to merge 1 commit into
roboflow:developfrom
Maryyyyyyyam142:fix/N-dataset_builder_option_defaults
Open

fix(datasets): require pipeline options instead of substituting wrong defaults#1413
Maryyyyyyyam142 wants to merge 1 commit into
roboflow:developfrom
Maryyyyyyyam142:fix/N-dataset_builder_option_defaults

Conversation

@Maryyyyyyyam142

Copy link
Copy Markdown

Closes #1412
The four dataset builders derive the same image-pipeline options from args, but disagree on how. build_coco reads most of them directly; build_roboflow_from_coco, build_roboflow_from_yolo and build_o365_raw use getattr with literal fallbacks — five of which contradict the real config default:

option old fallback actual default
square_resize_div_64 False True (TrainConfig)
segmentation_head False True on every seg variant
multi_scale False True (TrainConfig)
expanded_scales False True (TrainConfig)
patch_size 16 variant-dependent — 12 seg/keypoint, 14 base
num_windows 4 2 on every released variant

patch_size and num_windows have no default on ModelConfig, so no constant is correct — and (16, 4) matches no shipped variant.

Change

All four builders now read these seven options directly, so an incomplete namespace raises AttributeError instead of silently building a different pipeline. do_random_resize_via_padding is included for cluster parity; its fallback already matched the default, so that one is a no-op.

The remaining getattr fallbacks are deliberately untouched — aug_config, scale_jitter and augmentation_backend match their config default, and the keypoint fields' absence is meaningful ("detection-only", per the existing comment at coco.py:1301).

Scope

Latent on the RFDETRDataModule path: _namespace_from_configs populates every field, so normal model.train(...) is unaffected. The exposure is the direct-call path, which the builders' re-export from rfdetr.datasets and the comment at coco.py:1318-1322 both document as supported.

Tests

New tests/datasets/test_builder_options.py covers the cross-builder contract:

  • each of the four builders raises on a namespace missing a pipeline option (fails on develop)
  • the configured values reach the transform builder — num_windows=2 not 4, multi_scale=True, seg variants at patch_size=12 with include_masks=True

Four tests in test_coco.py passed partial namespaces and relied on the old fallbacks. They now use a _pipeline_args helper that spells out the values those fallbacks used to produce, so their behavior is unchanged and what they depend on is visible.

674 passed across tests/datasets/ and src/rfdetr/datasets/. ruff, ruff format, docformatter and codespell pass on the changed files; mypy reports nothing in them.

… defaults

The dataset builders read the same image-pipeline options from `args`, but
`build_roboflow_from_coco`, `build_roboflow_from_yolo` and `build_o365_raw`
read them via `getattr` with literal fallbacks that contradict the real
config defaults, while `build_coco` reads most of them directly:

  square_resize_div_64  fallback False, TrainConfig default True
  segmentation_head     fallback False, True on every seg variant
  multi_scale           fallback False, TrainConfig default True
  expanded_scales       fallback False, TrainConfig default True
  patch_size            fallback 16,    variant-dependent (12/14/16)
  num_windows           fallback 4,     2 on every released variant

`patch_size` and `num_windows` have no default on `ModelConfig`, so no
constant is correct; the pair the builders chose, (16, 4), matches no
shipped variant. A caller passing an incomplete namespace — supported and
documented usage, since the builders are re-exported from `rfdetr.datasets`
— silently trained a different pipeline: multi-scale off, and a scale set of
[192..832] instead of [352..672] at resolution 512.

Read these seven options directly in all four builders so an incomplete
namespace fails loudly. The remaining `getattr` fallbacks are left alone:
their values match the config default, or the absence is meaningful
(keypoint fields absent means detection-only, per the comment at coco.py).

This is latent on the `RFDETRDataModule` path, where `_namespace_from_configs`
populates every field.
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.

N-dataset_builder_option_defaults

1 participant