pipert.utils.structures.image_list

Module Contents

Classes

ImageList

Structure that holds a list of images (of possibly

class pipert.utils.structures.image_list.ImageList(tensor: torch.Tensor, image_sizes: List[Tuple[int, int]])[source]

Bases: object

Structure that holds a list of images (of possibly varying sizes) as a single tensor. This works by padding the images to the same size, and storing in a field the original sizes of each image

Attributes:

image_sizes (list[tuple[int, int]]): each tuple is (h, w)

__len__(self)int[source]
__getitem__(self, idx: Union[int, slice])torch.Tensor[source]

Access the individual image in its original size.

Returns:

Tensor: an image of shape (H, W) or (C_1, …, C_K, H, W) where K >= 1

to(self, *args: Any, **kwargs: Any)pipert.utils.structures.image_list.ImageList[source]
static from_tensors(tensors: Sequence[torch.Tensor], size_divisibility: int = 0, pad_value: float = 0.0)pipert.utils.structures.image_list.ImageList[source]
Args:
tensors: a tuple or list of torch.Tensors, each of shape (Hi, Wi) or

(C_1, …, C_K, Hi, Wi) where K >= 1. The Tensors will be padded with pad_value so that they will have the same shape.

size_divisibility (int): If size_divisibility > 0, also adds padding to ensure

the common height and width is divisible by size_divisibility

pad_value (float): value to pad

Returns:

an ImageList.