Skip to content

fix(augment): align Kornia GaussianBlur/GaussNoise defaults with albumentations - #1395

Merged
Borda merged 7 commits into
roboflow:developfrom
adhavan18:fix/kornia-blur-noise-defaults
Aug 24, 2026
Merged

fix(augment): align Kornia GaussianBlur/GaussNoise defaults with albumentations#1395
Borda merged 7 commits into
roboflow:developfrom
adhavan18:fix/kornia-blur-noise-defaults

Conversation

@adhavan18

Copy link
Copy Markdown
Contributor

What

Aligns two Kornia augmentation-factory defaults with the Albumentations defaults they stand in for. Closes #1351.

Why

For the same aug_config, switching augmentation_backend silently changed augmentation strength, because two Kornia defaults did not match Albumentations':

GaussianBlur sigma. AUG_INDUSTRIAL sets {"GaussianBlur": {"blur_limit": 3, "p": 0.3}} with no sigma, so both backends fall back to their own default:

GPU (kornia)         sigma = (0.1, 2.0)   <- Kornia's convention
CPU (albumentations) sigma = (0.5, 3.0)   <- what the config actually means

The call-site comment claimed it "Match[es] the CPU albumentations default", which was the opposite of what it did.

GaussNoise std_range. Defaulted to rf-detr's own (0.01, 0.05) against the Albumentations default (0.2, 0.44) on the same 0-1 image scale, 4-9x weaker. The divergence warning also reported rf-detr's own [0.01, 0.05] as if it were Albumentations', hiding the gap.

Verified against the pinned albumentations==2.0.8:

>>> A.GaussianBlur().sigma_limit
(0.5, 3.0)
>>> A.GaussNoise().std_range
(0.2, 0.44)

Changes

  • _make_gaussian_blur default sigma (0.1, 2.0) -> (0.5, 3.0), comment corrected.
  • _make_gauss_noise default std_range (0.01, 0.05) -> (0.2, 0.44). An explicit range still wins, and the warning text is unchanged since it is still correct for a non-degenerate explicit range.
  • Doc table in aug_configs.py updated.

This changes only the default used when a config omits the value; any config that sets sigma/std_range explicitly is unaffected. It follows the same "align to Albumentations" direction accepted for the sibling scalar-clip_limit fix (#1350).

Testing

Three regression tests pin both defaults to the live Albumentations values. The two that assert the defaults fail on develop and pass here:

develop:     unspecified GaussianBlur sigma is (0.1, 2.0) ... FAILED
             unspecified GaussNoise std is 0.05 ...          FAILED
this branch: 8 passed (Gauss* subset)

Full augmentation suite: 55 passed. ruff check and ruff format --check clean.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Aligns Kornia Gaussian augmentation defaults with Albumentations while preserving explicit configuration values.

Changes:

  • Updates GaussianBlur and GaussNoise defaults.
  • Adds regression tests against live Albumentations defaults.
  • Updates GPU augmentation documentation.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/rfdetr/datasets/kornia_transforms.py Aligns Gaussian defaults.
src/rfdetr/datasets/aug_configs.py Documents the new blur default.
tests/datasets/test_kornia_transforms.py Tests default alignment and warning behavior.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/rfdetr/datasets/kornia_transforms.py Outdated
Comment thread tests/datasets/test_kornia_transforms.py Outdated
…mentations

Two Kornia factory defaults did not match the Albumentations defaults they
stand in for, so switching augmentation_backend silently changed
augmentation strength for the same aug_config.

GaussianBlur sigma defaulted to Kornia's own (0.1, 2.0) while the
albumentations default is (0.5, 3.0); an unspecified sigma blurred less on
the GPU path, and the call-site comment claimed the opposite. AUG_INDUSTRIAL
reaches this default (it sets blur_limit but no sigma).

GaussNoise std_range defaulted to rf-detr's own (0.01, 0.05) against the
albumentations default (0.2, 0.44) on the same 0-1 image scale, 4-9x weaker.
The default is now the albumentations one.

Doc table updated; regression tests pin both defaults to the live
albumentations values. Rebased onto current develop.
@adhavan18
adhavan18 force-pushed the fix/kornia-blur-noise-defaults branch from 393f01c to a3051e3 Compare August 22, 2026 21:05
@codecov

codecov Bot commented Aug 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86%. Comparing base (207a0bb) to head (4a3e10a).

Additional details and impacted files
@@           Coverage Diff           @@
##           develop   #1395   +/-   ##
=======================================
  Coverage       86%     86%           
=======================================
  Files          112     112           
  Lines        14664   14669    +5     
=======================================
+ Hits         12623   12628    +5     
  Misses        2041    2041           
🚀 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 Aug 23, 2026
Borda
Borda previously approved these changes Aug 23, 2026
Changes:
- Read the installed Albumentations GaussianBlur default when available; retain the Kornia fallback only when the root package is absent and propagate nested import failures.
- Correct GaussianBlur and GaussNoise backend-parity wording, and add branch-specific regression coverage.

Impact:
- Unspecified GPU GaussianBlur settings now match every importable supported Albumentations runtime default.
- Broken optional-dependency installations fail visibly instead of silently selecting GPU-only behavior.

Verification:
- tests/datasets/test_kornia_transforms.py: 113 passed.
- pre-commit run --all-files: passed; git diff --check: passed.

Residual limits:
- No full Albumentations version matrix was run.

---

Co-authored-by: Codex <codex@openai.com>
@adhavan18

Copy link
Copy Markdown
Contributor Author

Thanks for picking this up and polishing it @Borda, the reworded GaussNoise note is exactly right: bounds aligned, but Kornia's fixed std is not the CPU path's sampled range, so "same default, not same distribution" is the precise claim.

Happy to take anything else you'd like on it, otherwise I'll leave it in your hands.

Borda and others added 2 commits August 24, 2026 09:40
Changes:
- Route GaussianBlur default selection through AugmentationBackend.ALBU._is_available().
- Replace import-machinery test doubles with backend-availability test doubles.

Impact:
- Optional augmentation package availability now follows the shared backend contract.
- Tests exercise the same availability seam used by backend selection.

Verification:
- tests/datasets/test_kornia_transforms.py: 112 passed.
- pre-commit run --all-files: passed; git diff --check: passed.

Residual limits:
- No full Albumentations version matrix was run.

---

Co-authored-by: Codex <codex@openai.com>
@Borda
Borda merged commit f7ebc74 into roboflow:develop Aug 24, 2026
41 checks passed
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.

Kornia GaussianBlur and GaussNoise defaults diverge from the Albumentations defaults they stand in for

3 participants