pad_to_ratio

hybrid_learning.datasets.transforms.image_transforms.pad_to_ratio(img_t, ratio=1.0, pad_value=0)[source]

Pad image with constant pad_value to obtain given image size ratio.

Parameters
  • img_t (Tensor) – 2D pytorch tensor

  • ratio (float) – the desired ratio (width / height)

  • pad_value (float) – constant value to use for padding area

Returns

tensor representing padded 2D image (batch)

Return type

Tuple[Tensor, Tuple[int, int, int, int]]