Skip to content
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

Add OpTranspose (not critical) #222

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions fuseimg/data/ops/aug/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,3 +411,26 @@ def __call__(self, sample_dict: NDict, key: str, z_rot: float = 0.0, y_rot: floa

sample_dict[key] = aug_input
return sample_dict


class OpTranspose(OpBase):
"""
Wrapper for torch.transpose: https://pytorch.org/docs/stable/generated/torch.transpose.html
Returns a tensor that is a transposed version of input. The given dimensions dim0 and dim1 are swapped.

Stores the resized image in sample_dict[key]
"""

def __init__(self):
super().__init__()

def __call__(self, sample_dict: NDict, dim0: int, dim1: int, key: str) -> NDict:
"""
:param dim0: the first dimension to be transposed
:param dim1: the second dimension to be transposed
:param key: key to a numpy array or tensor stored in the sample_dict in a H x W x C format.
"""
aug_input = sample_dict[key]
aug_output = torch.transpose(aug_input, dim0, dim1)
sample_dict[key] = aug_output
return sample_dict