FASSEGHandle

class hybrid_learning.datasets.custom.fasseg.FASSEGHandle(dataset_root, annotations_root=None, part=None, part_name=None, **kwargs)[source]

Bases: BaseDataset

Handle for FASSEG-like datasets.

Note

The original FASSEG dataset is not required for this handle. Any dataset with a format following that of the FASSEG dataset is supported (folder structure, file types, color codes).

The FASSEG dataset can be found here:: https://github.com/massimomauro/FASSEG-repository

The required structure for supported datasets is very simple

Once a handle is instantiated, its __getitem__ yields tuples of input image and binary part segmentation mask (possibly transformed by hybrid_learning.datasets.base.BaseDataset.transforms). For details see getitem().

Public Data Attributes:

part_name

The string name of the part that is extracted from the masks.

Inherited from : py: class:BaseDataset

settings

Settings of the instance.

Public Methods:

getitem(i)

Load image and its mask at index i and select binary part mask.

descriptor(i)

Return the image file name for index i.

image_filepath(i)

Provide the path to the image at index i.

mask_filepath(i)

Provide the path to the mask at index i.

Inherited from : py: class:BaseDataset

getitem(i)

Load image and its mask at index i and select binary part mask.

descriptor(i)

Return the image file name for index i.

Special Methods:

__init__(dataset_root[, annotations_root, ...])

Init.

__len__()

Number of data points in the dataset; to be implemented in subclasses.

Inherited from : py: class:BaseDataset

__init__(dataset_root[, annotations_root, ...])

Init.

__len__()

Number of data points in the dataset; to be implemented in subclasses.

__getitem__(idx)

Get item from idx in dataset with transformations applied.

__repr__()

Nice printing function.

Inherited from : py: class:Dataset

__getitem__(idx)

Get item from idx in dataset with transformations applied.

__add__(other)


__init__(dataset_root, annotations_root=None, part=None, part_name=None, **kwargs)[source]

Init.

Parameters
  • dataset_root (str) – the directory under which to find the images;

  • annotations_root (Optional[str]) –

    the directory under which to find the segmentation masks; assumes as default that

    • dataset_root is path/split_RGB and

    • annotations_root is path/split_Labels

  • part (Optional[Union[FASSEGParts, Tuple[int, int, int]]]) – the FASSEGParts instance to use the color of or the color tuple

  • part_name (Optional[str]) – the string name of the part that is extracted; overridden by part.name if part features such an attribute

  • kwargs – parameters for BaseDataset

__len__()[source]

Number of data points in the dataset; to be implemented in subclasses.

descriptor(i)[source]

Return the image file name for index i. This is unique throughout a FASSEG like dataset and can be used for e.g. image IDs for caching.

Parameters

i (int) –

Return type

str

getitem(i)[source]

Load image and its mask at index i and select binary part mask.

Used for __getitem__(). The value of the return tuple (input_img, part_mask) are torch.Tensor representations of PIL.Image.Image image instances.

Parameters

i (int) –

Return type

Tuple[Image, Image]

image_filepath(i)[source]

Provide the path to the image at index i.

mask_filepath(i)[source]

Provide the path to the mask at index i.

__parameters__ = ()
annotations_root: str

Path to the annotations root folder under which to find the annotation files.

img_fns: List[str]

List of file names of images (and their annotations) handled by this instance. Images can be found in the dataset_root and annotations in annotations_root. These are used for getitem().

part

Part of the face and its color to select mask of.

property part_name: Optional[str]

The string name of the part that is extracted from the masks.