cutcutcodec.core.nn.loader.ImageDataset

class cutcutcodec.core.nn.loader.ImageDataset(root: str | bytes | Path, shape: tuple[Integral, Integral] | list[Integral], *, dataaug: Callable[[FrameVideo], FrameVideo] | None = None, **kwargs)[source]

A specific dataset for managing images.

Initialise and create the class.

Parameters

rootpathlike

Transmitted to Dataset initialisator.

shapeint and int

The pixel dimensions of the returned image. The image will be random reshaped and random cropped to reach this final shape. The convention adopted is the numpy convention (height, width).

dataaugcallable, optional

If provided, the function is called for each brut readed image before normalization.

**kwargsdict

Transmitted to Datset initialisator.

normalize(image: FrameVideo) Tensor[source]

Pipeline to normalize any image for batching.

The normalization consists in:
  • Resize with deformation to reach the final size.

  • Convertion into torch float32 with good dynamic.

  • Convert into torch tensor.

  • Convert into BGR.

  • Depth channel first: (H, W, C) -> (C, H, W)

Parameters

imagecutcutcodec.core.classes.frame_video.FrameVideo

The input brut image of any shape, channels and dtype.

Returns

normlized_imagetorch.Tensor

The normalized float32 image of shape (3, final_height, final_width).