Skip to content

Temporal transform: rearrange temporal and channel dimensions #2477

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

yichiac
Copy link
Contributor

@yichiac yichiac commented Dec 18, 2024

This PR is to add a temporal transform: rearrange temporal and channel dimensions, as mentioned in #2382.

@github-actions github-actions bot added the transforms Data augmentation transforms label Dec 18, 2024
@adamjstewart adamjstewart marked this pull request as draft December 18, 2024 17:03
@adamjstewart
Copy link
Collaborator

Would be better to have a single PR for each transform instead of multiple in 1 PR.

@adamjstewart adamjstewart mentioned this pull request Jan 8, 2025
37 tasks
@yichiac yichiac changed the title Add Temporal Transforms [WIP] temporal transform: rearrange temporal and channel dimensions Feb 26, 2025
@github-actions github-actions bot added the testing Continuous integration testing label May 16, 2025
@yichiac yichiac marked this pull request as ready for review May 16, 2025 20:49
@yichiac yichiac changed the title [WIP] temporal transform: rearrange temporal and channel dimensions Temporal transform: rearrange temporal and channel dimensions May 16, 2025
@yichiac
Copy link
Contributor Author

yichiac commented May 16, 2025

Not sure if the class names and functions are good. Tagging @adamjstewart for review.

@adamjstewart adamjstewart added this to the 0.8.0 milestone May 17, 2025
Copy link
Collaborator

@adamjstewart adamjstewart left a comment

Choose a reason for hiding this comment

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

My vote would be for a single class that simply wraps around einops.rearrange like so:

class Rearrange(GeometricAugmentationBase2D):
    def __init__(self, *args: Any, **kwargs: Any) -> None:
        super().__init__(p=1)
        self.flags = {'args': args, 'kwargs': kwargs}

    def apply_transform(
      self, input: Tensor, params: Dict[str, Tensor], flags: Dict[str, Any], transform: Optional[Tensor] = None
   ) -> Tensor:
        return rearrange(input, *flags['args'], **flags['kwargs'])

Note that GeometricAugmentationBase2D has additional functions that need to be overridden, see https://kornia.readthedocs.io/en/latest/augmentation.base.html#custom-augmentation-classes for details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
testing Continuous integration testing transforms Data augmentation transforms
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants