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
under
dataset_root
all input imagesunder
annotations_root
all 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
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
.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
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
ispath/split_RGB
andannotations_root
ispath/split_Labels
part (Optional[Union[FASSEGParts, Tuple[int, int, int]]]) – the
FASSEGParts
instance to use the color of or the color tuplepart_name (Optional[str]) – the string name of the
part
that is extracted; overridden bypart.name
ifpart
features 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
i
and select binary part mask.Used for
__getitem__()
. The value of the return tuple(input_img, part_mask)
aretorch.Tensor
representations ofPIL.Image.Image
image 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_root
and annotations inannotations_root
. These are used forgetitem()
.
- part
Part of the face and its color to select mask of.