fix(augment): normalise scalar Affine translate_percent and scale for Kornia - #1444
Open
JESUSROYETH wants to merge 1 commit into
Open
fix(augment): normalise scalar Affine translate_percent and scale for Kornia#1444JESUSROYETH wants to merge 1 commit into
JESUSROYETH wants to merge 1 commit into
Conversation
JESUSROYETH
requested review from
Borda,
SkalskiP,
isaacrob and
probicheaux
as code owners
September 8, 2026 22:17
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #1444 +/- ##
=======================================
Coverage 87% 87%
=======================================
Files 117 117
Lines 15260 15263 +3
=======================================
+ Hits 13214 13219 +5
+ Misses 2046 2044 -2 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is wrong
On a real COCO photograph,
translate_percent=0.1moved horizontally in0/200draws on the Kornia backend before this fix. After the fix it moved in138–145/200, exactly matching the existing(-0.1, 0.1)pair across five seeds.The same
Affineconfig can behave differently between RF-DETR's Albumentations and Kornia backends. RF-DETR forwards scalartranslate_percentdirectly to Kornia (source). Kornia reads0.1as[0.0, 0.1], using zero for the horizontal limit and0.1for the vertical limit. Training continues without an error, but one axis is silently disabled.Scalar
scalefails in the same factory. Albumentations acceptsscale=1.1as(1.1, 1.1), while Kornia callslen()on the forwarded float and raisesTypeErrorduring pipeline construction.What changes
_make_affinenow normalises only numeric scalar values before creatingK.RandomAffine:translate_percentbecomes the same non-negative limit for both axes;scalebecomes the fixed range(v, v);The translation path uses
_as_symmetric_range, matchingShiftScaleRotate, before taking the per-axis magnitude. The change does not widen the shared helpers or affect other augmentation factories. The backend mapping table and changelog now document the corrected scalar behaviour.Validation
develop@c301e473: 4 failed, 5 passed.test_kornia_transforms.py: 152 passed, 1 skipped.tests/datasets: 847 passed, 3 skipped.bin/rfdetr_precommit.sh: 19/19 hooks passed, including strictmypy.0/200draws per seed before the fix and138–145/200after it, exactly matching the existing pair.0/76before to76/76after the same scalar normalisation.No mAP or speed change is claimed. The conversion runs once when the augmentation pipeline is built.