FASSEGHandle
- class hybrid_learning.datasets.custom.fasseg.FASSEGHandle(dataset_root, annotations_root=None, part=None, part_name=None, **kwargs)[source]
Bases:
BaseDatasetHandle 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
under
dataset_rootall input imagesunder
annotations_rootall annotation files with the same file name as the corresponding input image
Once a handle is instantiated, its
__getitem__yields tuples of input image and binary part segmentation mask (possibly transformed byhybrid_learning.datasets.base.BaseDataset.transforms). For details seegetitem().Public Data Attributes:
The string name of the part that is extracted from the masks.
Inherited from : py: class:BaseDataset
settingsSettings of the instance.
Public Methods:
getitem(i)Load image and its mask at index
iand select binary part mask.descriptor(i)Return the image file name for index
i.Provide the path to the image at index
i.Provide the path to the mask at index
i.Inherited from : py: class:BaseDataset
getitem(i)Load image and its mask at index
iand 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
idxin dataset with transformations applied.__repr__()Nice printing function.
Inherited from : py: class:Dataset
__getitem__(idx)Get item from
idxin 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_rootispath/split_RGBandannotations_rootispath/split_Labels
part (Optional[Union[FASSEGParts, Tuple[int, int, int]]]) – the
FASSEGPartsinstance to use the color of or the color tuplepart_name (Optional[str]) – the string name of the
partthat is extracted; overridden bypart.nameifpartfeatures such an attributekwargs – parameters for
BaseDataset
- 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.
- getitem(i)[source]
Load image and its mask at index
iand select binary part mask.Used for
__getitem__(). The value of the return tuple(input_img, part_mask)aretorch.Tensorrepresentations ofPIL.Image.Imageimage instances.
- __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_rootand annotations inannotations_root. These are used forgetitem().
- part
Part of the face and its color to select mask of.