Repository navigation
Align center cropping with centered padding for odd size differences - #134
Open
sylvesterkaczmarek wants to merge 2 commits into
Open
sylvesterkaczmarek wants to merge 2 commits into
sylvesterkaczmarek wants to merge 2 commits into
Conversation
claudiofantacci
requested changes
Oct 18, 2026
| import tensorflow as tf | ||
|
|
||
|
|
||
| class CropAlignmentTest(parameterized.TestCase): |
Collaborator
There was a problem hiding this comment.
Move this tests under dm_pix/_src/augment_test.py.
Contributor
Author
There was a problem hiding this comment.
Moved to augment_test.py. The 31 new cases and 78 adjacent tests pass on current master.
Signed-off-by: Sylvester Kaczmarek <16242628+sylvesterkaczmarek@users.noreply.github.com>
sylvesterkaczmarek
force-pushed
the
fix/center-crop-parity-alignment-20261006
branch
from
October 19, 2026 15:50
b29a93a to
80ca824
Compare
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.
Summary
Fixes #133.
Compute crop offsets from half the size difference rather than subtracting two separately rounded centers. This preserves the bottom/right convention already used by centered padding and prevents a padding/cropping round trip from discarding source pixels. Updated the docstring to specify which side loses the extra pixel. Channel layouts, batch handling and oversized-target behavior are unchanged.
Validation
python -m pytest -q dm_pix/_src/augment_test.pyCurrent rebased head: 31 crop-alignment regressions and 78 adjacent augmentation tests passed. The earlier full augmentation run passed 883 tests. Seventeen new cases fail on unchanged upstream; fourteen controls pass. References include direct integer-margin slices and TensorFlow crop-or-pad output. Eager/JIT results, multiple layouts, round-trip pixel identity and gradients are covered. The independent Gaussian-blur PRs are untouched.
Tested locally on macOS CPU using real module imports. New-test formatting, scoped static checks, syntax checks and
git diff --checkpass. No dependency or workflow changes. The full repository suite was not run.