Skip to content

Commit 72c4f1b

Browse files
JSabadinkozlov721
andauthored
Sort classes alphabetically (#245)
Co-authored-by: Martin Kozlovsky <[email protected]>
1 parent 05b36c3 commit 72c4f1b

File tree

18 files changed

+830
-359
lines changed

18 files changed

+830
-359
lines changed

luxonis_ml/data/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
LuxonisComponent,
1313
LuxonisDataset,
1414
LuxonisSource,
15+
Metadata,
1516
UpdateMode,
1617
)
1718
from .loaders import LOADERS_REGISTRY, BaseLoader, LuxonisLoader
@@ -45,6 +46,7 @@ def load_loader_plugins() -> None: # pragma: no cover
4546
"DatasetIterator",
4647
"DATASETS_REGISTRY",
4748
"Category",
49+
"Metadata",
4850
"LOADERS_REGISTRY",
4951
"ImageType",
5052
"LuxonisComponent",

luxonis_ml/data/datasets/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
)
1111
from .base_dataset import DATASETS_REGISTRY, BaseDataset, DatasetIterator
1212
from .luxonis_dataset import LuxonisDataset, UpdateMode
13+
from .metadata import Metadata
1314
from .source import LuxonisComponent, LuxonisSource
1415

1516
__all__ = [
@@ -28,4 +29,5 @@
2829
"Detection",
2930
"ArrayAnnotation",
3031
"UpdateMode",
32+
"Metadata",
3133
]

luxonis_ml/data/datasets/base_dataset.py

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
from abc import ABC, abstractmethod
2-
from typing import Dict, Iterator, List, Optional, Sequence, Tuple, Type, Union
2+
from typing import (
3+
Dict,
4+
Iterator,
5+
List,
6+
Optional,
7+
Sequence,
8+
Tuple,
9+
Type,
10+
Union,
11+
)
312

413
from semver.version import Version
514
from typing_extensions import TypeAlias
@@ -60,13 +69,19 @@ def update_source(self, source: LuxonisSource) -> None:
6069

6170
@abstractmethod
6271
def set_classes(
63-
self, classes: List[str], task: Optional[str] = None
72+
self,
73+
classes: Union[List[str], Dict[str, int]],
74+
task: Optional[str] = None,
6475
) -> None:
65-
"""Sets the names of classes for the dataset. This can be across
66-
all CV tasks or certain tasks.
67-
68-
@type classes: List[str]
69-
@param classes: List of class names to set.
76+
"""Sets the classes for the dataset. This can be across all CV
77+
tasks or certain tasks.
78+
79+
@type classes: Union[List[str], Dict[str, int]]
80+
@param classes: Either a list of class names or a dictionary
81+
mapping class names to class IDs. If list is provided, the
82+
class IDs will be assigned I{alphabetically} starting from
83+
C{0}. If the class names contain the class C{"background"},
84+
it will be assigned the class ID C{0}.
7085
@type task: Optional[str]
7186
@param task: Optionally specify the task where these classes
7287
apply.

0 commit comments

Comments
 (0)