Skip to content

Better normalization supporting different normalization transforms for input/target and different normalization per channel#34

Open
wli51 wants to merge 2 commits into
WayScience:mainfrom
wli51:better-normalization
Open

Better normalization supporting different normalization transforms for input/target and different normalization per channel#34
wli51 wants to merge 2 commits into
WayScience:mainfrom
wli51:better-normalization

Conversation

@wli51

@wli51 wli51 commented Jun 10, 2026

Copy link
Copy Markdown
Collaborator

Useful for training models whose input and target takes different ranges and experimenting with input engineering combining multiple channels of different value ranges

wli51 added 2 commits June 10, 2026 09:29
…eDataset and CropImageDataset for training with input and target that can take different value ranges
self,
transforms: Optional[Sequence[LoggableTransform]],
name: str,
) -> Sequence[LoggableTransform]:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Consider adding docstrings to help describe this and other parts of this work.

Comment on lines +162 to +176
def _apply_input_transforms(
self,
image: np.ndarray,
) -> np.ndarray:
for transform in self.input_transforms:
image = transform.apply(img=image)
return image

def _apply_target_transforms(
self,
image: np.ndarray,
) -> np.ndarray:
for transform in self.target_transforms:
image = transform.apply(img=image)
return image

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

These feel mostly duplicative. Is there an abstraction you could use for both cases?

## Overview

This subpackage consists of three modules:
This subpackage consists of four modules:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Consider avoiding specific numeric documentation to help reduce the diff over time.

)

channelwise_transform = ChannelwiseTransform(
transforms=[

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm liking how the transforms are listed in this PR, nice!


class ChannelwiseTransform(LoggableTransform):
"""
Apply a list of transforms to a channel-first image, one transform per channel.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Consider providing a simple example of an image set and transforms along with how they'd be transformed.

f"channels={len(self._transforms)}, p={self.p})"
)

def to_config(self) -> dict:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Consider being more descriptive with this function name - for ex. what kind of config?

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