ENH: Add intensity modes (to01 | 0mean | none) to the LAMNr trainers. - #66
Merged
Merged
Conversation
Signed or absolute-valued inputs (decoded optical flow (u, v), CT in HU)
were forced through a per-sample min-max, which destroys the sign, the
u/v ratio and absolute scale. Default behavior ("to01") is unchanged.
Shared:
* misc.ChannelNormalizer (moved out of the hybrid trainer): per-channel
z-score / min-max with streaming float64 fit, sample (C, ...) and
batch (B, C, ...) transforms, checkpoint-safe state. SignalNormalizer
remains an alias.
Hybrid trainer:
* Per-view "intensity" for image views; "0mean" fits a ChannelNormalizer
on the training split, saves it in the checkpoint and exports
reconstructions in original units. Rejected on tabular/signal1d views.
Glow 2D/3D trainers:
* --intensity {to01,0mean,none} and --intensity-fit-batches. Non-to01
modes disable augmentation (flip, noise, clamp, ANTs spatial/intensity)
and ImageDataset's per-image min-max; "0mean" fits per-view normalizers
before ActNorm priming, saves them in the checkpoint, restores them on
resume and refuses a resume with a different mode.
* 2D trainer reads channels-first .npy/.pt arrays (C, H, W).
* _build_args(argv=None) for testability.
ImageDataset:
* normalize_intensity=True option (False skips iMath_normalize).
* BUG: the no-augmentation path used Euler3DTransform for 2D images.
Inference tools:
* lamnr_glow_tool_base refuses non-to01 checkpoints with a clear error
until the tools apply the stored normalizers.
BUG: _prime_if_needed treated 2-channel 2D batches (B, 2, H, W) as
channel-less 3D volumes; it now accepts spatial_dims and the sampling
and preview call sites pass it.
Tests: tests/test_glow_intensity.py (normalizer forms, ImageDataset
absolute intensities, .npy loading without augmentation, 2D end-to-end
0mean run with checkpoint/resume guard, 3D extract_view modes, priming,
tool guard) and hybrid intensity tests.
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.
Signed or absolute-valued inputs (decoded optical flow (u, v), CT in HU) were forced through a per-sample min-max, which destroys the sign, the u/v ratio and absolute scale. Default behavior ("to01") is unchanged.
Shared:
Hybrid trainer:
Glow 2D/3D trainers:
ImageDataset:
Inference tools:
BUG: _prime_if_needed treated 2-channel 2D batches (B, 2, H, W) as channel-less 3D volumes; it now accepts spatial_dims and the sampling and preview call sites pass it.
Tests: tests/test_glow_intensity.py (normalizer forms, ImageDataset absolute intensities, .npy loading without augmentation, 2D end-to-end 0mean run with checkpoint/resume guard, 3D extract_view modes, priming, tool guard) and hybrid intensity tests.