Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
kozlov721 committed Nov 8, 2024
1 parent 9268747 commit 78ba320
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 27 deletions.
30 changes: 20 additions & 10 deletions luxonis_ml/data/datasets/annotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class Annotation(ABC, BaseModelExtraForbid):
@ivar instance_id: The instance id of the annotation. This
determines the order in which individual instances are loaded in
L{luxonis_ml.data.LuxonisLoader}.
@type _label_type: ClassVar[L{LabelType}]
@type _label_type: ClassVar[LabelType]
@ivar _label_type: The label type of the annotation.
"""

Expand Down Expand Up @@ -110,7 +110,17 @@ def combine_to_numpy(
width: int,
) -> np.ndarray:
"""Combines multiple instance annotations into a single numpy
array."""
array.
@type annotations: List[Annotation]
@param annotations: List of annotations to combine.
@type class_mapping: Dict[str, int]
@param class_mapping: Mapping of class names to class indices.
@type height: int
@param height: The height of the image.
@type width: int
@param width: The width of the image.
"""
pass


Expand Down Expand Up @@ -138,14 +148,14 @@ class BBoxAnnotation(Annotation):
@type x: float
@ivar x: The top-left x coordinate of the bounding box. Normalized
to [0, 1].
to M{[0, 1]}.
@type y: float
@ivar y: The top-left y coordinate of the bounding box. Normalized
to [0, 1].
to M{[0, 1]}.
@type w: float
@ivar w: The width of the bounding box. Normalized to [0, 1].
@ivar w: The width of the bounding box. Normalized to M{[0, 1]}.
@type h: float
@ivar h: The height of the bounding box. Normalized to [0, 1].
@ivar h: The height of the bounding box. Normalized to M{[0, 1]}.
"""

type_: Literal["boundingbox"] = Field("boundingbox", alias="type")
Expand Down Expand Up @@ -211,11 +221,11 @@ def combine_to_numpy(
class KeypointAnnotation(Annotation):
"""Keypoint annotation.
Values are normalized to [0, 1] based on the image size.
Values are normalized to M{[0, 1]} based on the image size.
@type keypoints: List[Tuple[float, float, L{KeypointVisibility}]]
@ivar keypoints: List of keypoints. Each keypoint is a tuple of (x, y, visibility).
x and y are normalized to [0, 1]. visibility is one of {0, 1, 2} where:
x and y are normalized to M{[0, 1]}. visibility is one of M{0}, M{1}, or M{2} where:
- 0: Not visible / not labeled
- 1: Occluded
- 2: Visible
Expand Down Expand Up @@ -430,8 +440,8 @@ class PolylineSegmentationAnnotation(SegmentationAnnotation):
@type points: List[Tuple[float, float]]
@ivar points: List of points that define the polyline. Each point is
a tuple of (x, y). x and y are normalized to [0, 1] based on the
image size.
a tuple of (x, y). x and y are normalized to M{[0, 1]} based on
the image size.
"""

type_: Literal["polyline"] = Field("polyline", alias="type")
Expand Down
6 changes: 3 additions & 3 deletions luxonis_ml/data/datasets/base_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def update_source(self, source: LuxonisSource) -> None:
LuxonisSource.
@type source: L{LuxonisSource}
@param source: The new L{LuxonisSource} to replace the old one.
@param source: The new C{LuxonisSource} to replace the old one.
"""
pass

Expand Down Expand Up @@ -122,8 +122,8 @@ def add(
@type generator: L{DatasetIterator}
@param generator: A Python iterator that yields either instances
of L{DatasetRecord} or a dictionary that can be converted to
L{DatasetRecord}.
of C{DatasetRecord} or a dictionary that can be converted to
C{DatasetRecord}.
@type batch_size: int
@param batch_size: The number of annotations generated before
processing. This can be set to a lower value to reduce
Expand Down
21 changes: 14 additions & 7 deletions luxonis_ml/data/datasets/luxonis_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ def __init__(
@type bucket_type: BucketType
@param bucket_type: Whether to use external cloud buckets
@type bucket_storage: BucketStorage
@param bucket_storage: Underlying bucket storage from local, S3,
or GCS
@param bucket_storage: Underlying bucket storage. Can be one of
C{local}, C{S3}, or C{GCS}.
@type delete_existing: bool
@param delete_existing: Whether to delete a dataset with the
same name if it exists
Expand Down Expand Up @@ -283,8 +283,8 @@ def update_source(self, source: LuxonisSource) -> None:
"""Updates underlying source of the dataset with a new
L{LuxonisSource}.
@type source: L{LuxonisSource}
@param source: The new L{LuxonisSource} to replace the old one.
@type source: LuxonisSource
@param source: The new C{LuxonisSource} to replace the old one.
"""

self.metadata["source"] = source.to_document()
Expand Down Expand Up @@ -826,7 +826,7 @@ def exists(
@type bucket: Optional[str]
@param bucket: Name of the bucket. Default is C{None}.
@rtype: bool
@return: Whether the dataset exists
@return: Whether the dataset exists.
"""
return dataset_name in LuxonisDataset.list_datasets(
team_id, bucket_storage, bucket
Expand All @@ -840,8 +840,15 @@ def list_datasets(
) -> List[str]:
"""Returns a dictionary of all datasets.
@rtype: Dict
@return: Dictionary of all datasets
@type team_id: Optional[str]
@param team_id: Optional team identifier
@type bucket_storage: BucketStorage
@param bucket_storage: Underlying bucket storage from C{local},
C{S3}, or C{GCS}. Default is C{local}.
@type bucket: Optional[str]
@param bucket: Name of the bucket. Default is C{None}.
@rtype: List[str]
@return: List of all dataset names.
"""
base_path = environ.LUXONISML_BASE_PATH

Expand Down
2 changes: 1 addition & 1 deletion luxonis_ml/data/loaders/base_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def __getitem__(self, idx: int) -> LuxonisLoaderOutput:
@type idx: int
@param idx: Index of the sample to load.
@rtype: L{LuxonisLoaderOutput}
@return: Sample's data in L{LuxonisLoaderOutput} format.
@return: Sample's data in C{LuxonisLoaderOutput} format.
"""
pass

Expand Down
11 changes: 5 additions & 6 deletions luxonis_ml/data/loaders/luxonis_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ def __init__(
"""A loader class used for loading data from L{LuxonisDataset}.
@type dataset: LuxonisDataset
@param dataset: LuxonisDataset to use
@param dataset: Instance of C{LuxonisDataset} to use.
@type view: Union[str, List[str]]
@param view: What splits to use. Can be either a single split or
a list of splits. Defaults to "train".
a list of splits. Defaults to C{"train"}.
@type stream: bool
@param stream: Flag for data streaming. Defaults to C{False}.
@type augmentations: Optional[luxonis_ml.loader.Augmentations]
Expand Down Expand Up @@ -141,7 +141,7 @@ def __len__(self) -> int:
"""Returns length of the dataset.
@rtype: int
@return: Length of dataset.
@return: Length of the loader.
"""
return len(self.instances)

Expand All @@ -150,9 +150,8 @@ def __getitem__(self, idx: int) -> LuxonisLoaderOutput:
annotations.
@type idx: int
@param idx: The (often random) integer index to retrieve a
sample from the dataset.
@rtype: LuxonisLoaderOutput
@param idx: The integer index of the sample to retrieve.
@rtype: L{LuxonisLoaderOutput}
@return: The loader ouput consisting of the image and a
dictionary defining its annotations.
"""
Expand Down

0 comments on commit 78ba320

Please sign in to comment.