simulation.utils.machine_learning.data.labeled_dataset module

Summary

Classes:

LabeledDataset

Dataset of images with labels.

Reference

class LabeledDataset(transform_properties: Dict[str, Any] = <factory>, attributes: Optional[Sequence[str]] = None, classes: Dict[int, str] = <factory>, labels: Dict[str, List[Sequence[Any]]] = <factory>, _base_path: Optional[str] = None)[source]

Bases: Generic[torch.utils.data.dataset.T_co]

Dataset of images with labels.

attributes: Sequence[str] = None

Description of what each label means.

Similar to headers in a table.

classes: Dict[int, str]

Description of what the class ids represent.

labels: Dict[str, List[Sequence[Any]]]

Collection of all labels structured as a dictionary.

_base_path: str = None

Path to the root of the dataset.

Only needs to be set if the dataset is used to load data.

property available_files
filter_labels()[source]

Remove labels that have no corresponding image.

append_label(key: str, label: Any)[source]

Add a new label to the dataset.

A single image (or any abstract object) can have many labels.

save_as_yaml(file_path)[source]

Save to file as yaml.

This dumps the complete class dict to a yaml file.

Parameters

file_path – Path to file.

classmethod from_yaml(file)[source]

Load instance from a yaml file.

Only fields that are defined within the __init__ are loaded.

Parameters

file_path – Location of the yaml file.