extorch.vision.transforms.transforms
Adaptively randomly crop images with uncertain sizes for a certain size. |
|
Adaptively center-crop images with uncertain sizes for a certain size. |
|
Cutout: Randomly mask out one or more patches from an image (Link). |
- class extorch.vision.transforms.transforms.AdaptiveCenterCrop(cropped_size: Union[int, Tuple[int, int]])[source]
Bases:
torch.nn.modules.module.Module
Adaptively center-crop images with uncertain sizes for a certain size.
- Parameters
cropped_size (Union[int, Tuple[int, int]]) – The Image size to be cropped out.
- forward(img: torch.Tensor) torch.Tensor [source]
- Parameters
img (Tensor) – The image to be cropped.
- Returns
- The cropped image. For example, if the image has size [H, W] and the
cropped size if [h, w], size of output will be [H - h, W - w].
- Return type
img (Tensor)
- training: bool
- class extorch.vision.transforms.transforms.AdaptiveRandomCrop(cropped_size: Union[int, Tuple[int, int]])[source]
Bases:
torch.nn.modules.module.Module
Adaptively randomly crop images with uncertain sizes for a certain size.
- Parameters
cropped_size (Union[int, Tuple[int, int]]) – The Image size to be cropped out.
- forward(img: torch.Tensor) torch.Tensor [source]
- Parameters
img (Tensor) – The image to be cropped.
- Returns
- The cropped image. For example, if the image has size [H, W] and the
cropped size if [h, w], size of output will be [H - h, W - w].
- Return type
img (Tensor)
- training: bool
- class extorch.vision.transforms.transforms.Cutout(length: int, n_holes: int = 1)[source]
Bases:
torch.nn.modules.module.Module
Cutout: Randomly mask out one or more patches from an image (Link).
- Parameters
length (int) – The length (in pixels) of each square patch.
image (Tensor) – Image of size (C, H, W).
n_holes (int) – Number of patches to cut out of each image. Default: 1.
- Examples::
>>> image = torch.ones((3, 32, 32)) >>> Cutout_transform = Cutout(16, 1) >>> image = Cutout_transform(image) # Shape: [3, 32, 32]
- forward(img: torch.Tensor) torch.Tensor [source]
- Parameters
img (Tensor) – Image of size (C, H, W).
- Returns
Image with n_holes of dimension length x length cut out of it.
- Return type
img (Tensor)
- training: bool