Skip to content
Snippets Groups Projects

Make square centre-padding a model transform

Merged André Anjos requested to merge issue-23-and-39 into main
@@ -10,7 +10,7 @@ import torchvision.transforms.functional
def square_center_pad(img: torch.Tensor) -> torch.Tensor:
"""Returns a squared version of the image, centered on a canvas padded with
"""Return a squared version of the image, centered on a canvas padded with
zeros.
Parameters
@@ -23,8 +23,7 @@ def square_center_pad(img: torch.Tensor) -> torch.Tensor:
Returns
-------
img
transformed tensor, guaranteed to be square (ie. equal height and
Transformed tensor, guaranteed to be square (ie. equal height and
width).
"""
@@ -129,8 +128,7 @@ def rgb_to_grayscale(img: torch.Tensor) -> torch.Tensor:
class SquareCenterPad(torch.nn.Module):
"""Transforms to a squared version of the image, centered on a canvas
padded with zeros."""
"""Transform to a squared version of the image, centered on a canvas padded with zeros."""
def __init__(self):
super().__init__()
Loading