discopat.core.entities.annotation

Functions

annotation_factory(annotation_as_dict)

Classes

Annotation(label, score)

Abstract class to represent annotations and model predictions.

Box(label, x, y, width, height, score)

Class to represent bounding boxes.

Keypoint(label, point_list, score)

Class to represent keypoint annotations (e.g., for pose estimation).

Track(track_id, box_list)

Class to represent object tracks accross frames in a movie.

class discopat.core.entities.annotation.Annotation(label, score)[source]

Bases: Metadata

Abstract class to represent annotations and model predictions.

Parameters:
  • label (str)

  • score (float)

classmethod printable_fields()[source]

List of the relevant fields to serialise the object.

Return type:

list[str]

abstractmethod rescale(w_ratio, h_ratio)[source]

Rescale object.

Parameters:
  • w_ratio (float) – Width ratio.

  • h_ratio (float) – Height ratio.

Return type:

None

to_dict()[source]

Serialise object to a dictionary.

Return type:

dict

property type: str

Handle for annotation types (box, keypoint, track, …).

class discopat.core.entities.annotation.Box(label, x, y, width, height, score)[source]

Bases: Annotation

Class to represent bounding boxes.

Parameters:
  • label (str)

  • x (float)

  • y (float)

  • width (float)

  • height (float)

  • score (float)

classmethod from_dict(data_as_dict)[source]

Make object from a dictionary.

Parameters:

data_as_dict (dict)

Return type:

Self

classmethod printable_fields()[source]

List of the relevant fields to serialise the object.

Return type:

list[str]

rescale(w_ratio, h_ratio)[source]

Rescale object.

Parameters:
  • w_ratio (float) – Width ratio.

  • h_ratio (float) – Height ratio.

Return type:

None

property xmax: float

Xmax for XYXY format.

property xmin: float

Xmin for XYXY format.

property ymax: float

Ymax for XYXY format.

property ymin: float

Ymin for XYXY format.

class discopat.core.entities.annotation.Keypoint(label, point_list, score)[source]

Bases: Annotation

Class to represent keypoint annotations (e.g., for pose estimation).

Parameters:
  • label (str)

  • point_list (list[tuple[float, float]])

  • score (float)

classmethod from_dict(data_as_dict)[source]

Make object from a dictionary.

Parameters:

data_as_dict (dict)

Return type:

Self

classmethod printable_fields()[source]

List of the relevant fields to serialise the object.

Return type:

list[str]

rescale(w_ratio, h_ratio)[source]

Rescale object.

Parameters:
  • w_ratio (float) – Width ratio.

  • h_ratio (float) – Height ratio.

Return type:

None

class discopat.core.entities.annotation.Track(track_id, box_list)[source]

Bases: Annotation

Class to represent object tracks accross frames in a movie.

Parameters:
  • track_id (int)

  • box_list (list[tuple[int, Box]])

discopat.core.entities.annotation.annotation_factory(annotation_as_dict)[source]
Parameters:

annotation_as_dict (dict)

Return type:

Annotation