datumaro.components.merge.union_merge#
Classes
|
Merge several datasets with "union" policy: |
- class datumaro.components.merge.union_merge.UnionMerge(**options)[source]#
Bases:
Merger
Merge several datasets with “union” policy:
Label categories are merged according to the union of their label names.
For example, if Dataset-A has {“car”, “cat”, “dog”} and Dataset-B has {“car”, “bus”, “truck”} labels, the merged dataset will have {“bust”, “car”, “cat”, “dog”, “truck”} labels.
If there are two or more dataset items whose (id, subset) pairs match each other,
both are included in the merged dataset. At this time, since the same (id, subset) pair cannot be duplicated in the dataset, we add a suffix to the id of each source item. For example, if Dataset-A has DatasetItem(id=”magic”, subset=”train”) and Dataset-B has also DatasetItem(id=”magic”, subset=”train”), the merged dataset will have DatasetItem(id=”magic-0”, subset=”train”) and DatasetItem(id=”magic-1”, subset=”train”).
- merge(sources: Sequence[IDataset]) DatasetItemStorage [source]#
- class datumaro.components.merge.union_merge.AnnotationType(value)[source]#
Bases:
IntEnum
An enumeration.
- unknown = 0#
- label = 1#
- mask = 2#
- points = 3#
- polygon = 4#
- polyline = 5#
- bbox = 6#
- cuboid_3d = 8#
- super_resolution_annotation = 9#
- depth_annotation = 10#
- ellipse = 11#
- hash_key = 12#
- feature_vector = 13#
- tabular = 14#
- rotated_bbox = 15#
- cuboid_2d = 16#
- class datumaro.components.merge.union_merge.DatasetItem(id: str, *, subset: str | None = None, media: str | MediaElement | None = None, annotations: List[Annotation] | None = None, attributes: Dict[str, Any] | None = None)[source]#
Bases:
object
- media: MediaElement | None#
- annotations: Annotations#
- class datumaro.components.merge.union_merge.DatasetItemStorage[source]#
Bases:
object
- put(item: DatasetItem) bool [source]#
- get(id: str | DatasetItem, subset: str | None = None, dummy: Any | None = None) DatasetItem | None [source]#
- class datumaro.components.merge.union_merge.IDataset[source]#
Bases:
object
- subsets() Dict[str, IDataset] [source]#
Enumerates subsets in the dataset. Each subset can be a dataset itself.
- categories() Dict[AnnotationType, Categories] [source]#
Returns metainfo about dataset labels.
- get(id: str, subset: str | None = None) DatasetItem | None [source]#
Provides random access to dataset items.
- media_type() Type[MediaElement] [source]#
Returns media type of the dataset items.
All the items are supposed to have the same media type. Supposed to be constant and known immediately after the object construction (i.e. doesn’t require dataset iteration).
- ann_types() List[AnnotationType] [source]#
Returns available task type from dataset annotation types.
- class datumaro.components.merge.union_merge.LabelCategories(items: List[str] = _Nothing.NOTHING, label_groups: List[LabelGroup] = _Nothing.NOTHING, *, attributes: Set[str] = _Nothing.NOTHING)[source]#
Bases:
Categories
Method generated by attrs for class LabelCategories.
- class Category(name, parent: str = '', attributes: Set[str] = _Nothing.NOTHING)[source]#
Bases:
object
Method generated by attrs for class LabelCategories.Category.
- class LabelGroup(name, labels: List[str] = [], group_type: GroupType = GroupType.EXCLUSIVE)[source]#
Bases:
object
Method generated by attrs for class LabelCategories.LabelGroup.
- label_groups: List[LabelGroup]#
- classmethod from_iterable(iterable: Iterable[str | Tuple[str] | Tuple[str, str] | Tuple[str, str, List[str]]]) LabelCategories [source]#
Creates a LabelCategories from iterable.
- Parameters:
iterable –
This iterable object can be:
a list of str - will be interpreted as list of Category names
a list of positional arguments - will generate Categories with these arguments
Returns: a LabelCategories object
- class datumaro.components.merge.union_merge.Merger(**options)[source]#
Bases:
IMergerContext
,CliPlugin
Merge multiple datasets into one dataset
- static merge_categories(sources: Sequence[Dict[AnnotationType, Categories]]) Dict [source]#
- class datumaro.components.merge.union_merge.defaultdict#
Bases:
dict
defaultdict(default_factory=None, /, […]) –> dict with default factory
The default factory is called without arguments to produce a new value when a key is not present, in __getitem__ only. A defaultdict compares equal to a dict with the same items. All remaining arguments are treated the same as if they were passed to the dict constructor, including keyword arguments.
- copy() a shallow copy of D. #
- default_factory#
Factory for default value called by __missing__().