Skip to content

Keep resized results for list and tuple inputs - #146

Merged
FabianIsensee merged 1 commit into
MIC-DKFZ:masterfrom
Don-Yin:fix-resize-sequence-results
Oct 29, 2026
Merged

FabianIsensee merged 1 commit into
MIC-DKFZ:masterfrom
Don-Yin:fix-resize-sequence-results

Conversation

@Don-Yin

@Don-Yin Don-Yin commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

ResizeTransform and ZoomTransform compute resized samples but return the original data when list or tuple inputs use the default concatenate_list=False. For example, resizing a 4×4 sample to 2×2, or zooming it by 0.5, returns 4×4 image and segmentation arrays.

This returns the computed sequences while preserving list/tuple types and the existing ndarray and concatenation paths. The regressions cover 2D/3D batches, mixed image/segmentation containers, optional segmentation, and samples with different sizes.

Measured output sizes for synthetic 4×4 inputs, with both interpolation orders set to zero:

Image and segmentation output side lengths before and after the fix

Validation

Python 3.12.0, NumPy 2.4.2, SciPy 1.17.1, scikit-image 0.25.2:

  • Regression matrix: 56 failing subcases before the fix; all 112 pass after it.
  • Spatial suites: 35 tests pass, including the 112 regression subcases.
  • Broader suite: 79 tests and all 112 subcases pass. The two multiprocessing modules were not run.
python -m pytest -q -p no:cacheprovider tests/test_resize_transforms.py
python -m pytest -q -p no:cacheprovider tests/test_resize_transforms.py tests/test_augment_zoom.py tests/test_spatial_transformations.py tests/test_seg_resampling.py
python -m pytest -q -p no:cacheprovider tests --ignore=tests/test_DataLoader.py --ignore=tests/test_multithreaded_augmenter.py
git diff --check

The spatial and broader suites report the same existing scikit-image warning for the empty-input segmentation test as the baseline.

Return the computed data and segmentation when ResizeTransform and
ZoomTransform do not concatenate their results. Preserve list and tuple
containers and leave the existing ndarray path unchanged.

Cover 2D and 3D batches, mixed containers, optional segmentation,
concatenation, and samples with different sizes.

Signed-off-by: Don Yin <[email protected]>
@FabianIsensee
FabianIsensee merged commit 00676c1 into MIC-DKFZ:master Oct 29, 2026
@FabianIsensee

Copy link
Copy Markdown
Member

thanks!

FabianIsensee added a commit that referenced this pull request Oct 29, 2026
Augmenters (MultiThreadedAugmenter, NonDetMultiThreadedAugmenter):
- With seeds=None, all forked workers drew the same torch random numbers, so transforms that draw from torch (all of
  batchgeneratorsv2, hence nnU-Net's training augmentation) repeated the same augmentation sequence in every worker.
  Workers now reseed torch from the OS.
- With seeds given, workers also seed torch (from a seed derived from the given one) and random (PR #139). numpy
  integer seeds work.
- Workers restore the default SIGTERM handler (PR #127) and stop when their parent is killed, also under fork when
  the parent forked other processes after them.
- next() raises instead of waiting forever when the results thread fails; shutting down with torch tensor batches no
  longer prints tracebacks from the results thread.
- Logging goes through named module loggers instead of the root logger (PR #140).

Augmentations:
- Scale, contrast and gamma ranges that end at or below one are sampled from the range (PR #144, issue #137).
- Random crops can draw the last valid origin (PR #143, issue #142, and the random_crop_* helpers in utils.py).
- ChannelTranslation keeps the batch dimension (PR #145) and the channel order, can shift by +max_shift and accepts
  max_shift 0.
- ResizeTransform and ZoomTransform return their results for list and tuple inputs (PR #146).

Packaging: unittest2 and future are no longer required, numpy>=1.17; requirements.txt and the Makefile are gone.
The CIFAR-10 example runs again.

Seeded runs draw differently for random crops, channel translation, torch-based transforms under the augmenters and
ranges ending at one.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.

2 participants