ParticleDetection.modelling.annotations

Collection of function to manipulate training dataset metadata in json format. These functions are mainly to cleanup the metadata, but also to transfer it into a form for different detection tasks, i.e. keypoint detection.

Author: Adrian Niemann (adrian.niemann@ovgu.de)

Date: 31.10.2022

change_class(file: str) None[source]

Changes all class labels to 0 in a file of keypoint training data.

Parameters:

file (str) – Path to the annotations file that’s changed.

change_visibiliy(file: str) None[source]

Changes the visibility flag for all keypoints in a file of keypoint training data.

Parameters:

file (str) – Path to the annotations file that’s changed.

create_keypoints(file_name: str, single_class=True, order_x=True) None[source]

Creates rod keypoints from segmentation data.

Creates rod endpoints as key points from segmentation, adds it to the metadata and saves that as a new file.

Keypoints (List[float]) in the format of [x1, y1, v1,…, xn, yn, vn].

v=0: not labeled (in which case x=y=0),

v=1: labeled but not visible, and

v=2: labeled and visible.

See https://cocodataset.org/#format-data for more details.

Parameters:
  • file_name (str) – Path to the annotations file that’s changed.

  • single_class (bool) – Has currently no effect. Default is True.

  • order_x (bool) – Has currently no effect. Default is True.

delete_len_0(file_name: str) None[source]

Deletes annotations with keypoints resulting in 0 lenght rods.

Parameters:

file_name (str) – Path to the annotations file that’s changed.

order_by_x(file: str) None[source]

Adjust keypoints, such that the more left one is always the first point.

Parameters:

file (str) – Path to the annotations file that’s changed.

remove_duplicate_regions(dataset: DataSet) None[source]

Remove duplicate regions from the dataset’s metadata.

Parameters:

dataset (DataSet) – Dataset to be cleaned from duplicate annotations.