iaa_od.utils

iaa_od.utils.collapse_categories_interactive(gts)[source]

An interactive function which allows the user to select which categories to collapse into single macro-categories for the computation of the scale complexity metric.

Returns:

A dictionary mapping macro-category names to lists of category IDs

Return type:

dict[str, list[int]]

iaa_od.utils.extract_fatigue_data(result, timing_files)[source]

Extracts fatigue data from the provided timing files and computes annotation sessions for each Ground Truth (GT).

Parameters:
  • result (Result) – The Result object containing the Ground Truths and Units.

  • timing_files (list[str]) – A list of strings representing the paths to the JSON timing files

Returns:

A dictionary where the keys are GT names (strings) and the values are dictionaries mapping session IDs (integers) to lists of AnnotationTimestamp objects.

Return type:

dict[str, dict[int, list]]

iaa_od.utils.find_all_contained_bboxes(annotation, all_annotations, iom_thr)[source]

Returns a list of all annotations which are considered “contained” within the provided annotation, based on an IoM threshold.

Parameters:
  • annotation (AnnotationProtocol) – The annotation to check containment against.

  • all_annotations (list[AnnotationProtocol]) – A list of all annotations to check for containment.

  • iom_thr (float) – The IoM threshold to consider an annotation as “contained” within the provided annotation.

Returns:

A list of annotations that are considered “contained” within the provided annotation.

Return type:

list[AnnotationProtocol]

iaa_od.utils.get_min_max_bbox_size(gts, /, *, filename=None)[source]

Computes the minimum and maximum bounding box sizes (areas) across all annotations in the provided Ground Truths.

Parameters:
  • gts (list) – A list of Ground Truth objects.

  • filename (Optional[str]) – If provided, only annotations from the specified image filename will be considered. If None, all annotations from all images will be considered.

Returns:

A tuple containing the minimum and maximum bounding box sizes (areas) across the specified annotations.

Return type:

tuple[float, float]

iaa_od.utils.json_to_int_list(json_input)[source]

Converts a JSON string or a list of integers into a list of integers.

Parameters:

json_input (Union[str, list]) – A JSON string representing a list of integers or a list of integers.

Returns:

A list of integers extracted from the JSON input.

Return type:

list[int]

iaa_od.utils.load_categories_dictionary(filepath)[source]

Load categories from a JSON file and return a dictionary mapping category IDs to names.

Parameters:

filepath (str) – Path to the JSON file containing categories.

Returns:

A dictionary mapping category IDs to category names.

Return type:

dict

iaa_od.utils.per_image_fatigue_granularities(result)[source]

Compute per-image count and size granularities for the whole dataset, normalised against the dataset-wide benchmark so the values are comparable across images.

This is the granularity counterpart to result.alpha_per_image: it is what show_annotator_fatigue_granularity plots against the normalised timestamps. The dataset-wide benchmark (rather than each image’s own median) is essential here, since a temporal view is only meaningful if a value of, say, 1.4 means the same thing on the first image of a session as it does on the last.

The returned mapping is keyed by image filename, matching AnnotationTimestamp.image_filename. Images whose units are all singletons, and annotators that did not contribute to any non-singleton unit on a given image, are simply absent from the corresponding entry; the plotting code treats those as missing (NaN) data points.

Parameters:

result (Result) – The Result object containing the Ground Truths and Units.

Returns:

A mapping from image filename to that image’s Granularities.

Return type:

dict[str, Granularities]

iaa_od.utils.sample_avg_bbox_size(gt, /)[source]

Computes the average bounding box size (area) across all annotations in the given Ground Truth.

Parameters:

gt – The Ground Truth object containing images and annotations.

Returns:

The average bounding box size (area) across all annotations.

Return type:

float

iaa_od.utils.sample_avg_bboxes_per_image(gt, /)[source]

Computes the average number of bounding boxes per image in the given Ground Truth.

Parameters:

gt – The Ground Truth object containing images and annotations.

Returns:

The average number of bounding boxes per image.

Return type:

float

iaa_od.utils.sample_global_avg_bbox_size(gts, /)[source]

Computes the global average bounding box size (area) across all provided Ground Truths.

Parameters:

gts (list) – A list of Ground Truth objects.

Returns:

The global average bounding box size (area) across all provided Ground Truths.

Return type:

float

iaa_od.utils.sample_global_avg_bboxes_per_image(gts, /)[source]

Computes the global average number of bounding boxes per image across all provided Ground Truths.

Parameters:

gts (list) – A list of Ground Truth objects.

Returns:

The global average number of bounding boxes per image across all provided Ground Truths.

Return type:

float

iaa_od.utils.validate_macrocats(gts, macro_categories)[source]

Validates the provided macro-categories dictionary against the categories in the ground truth objects.

Parameters:
  • gts – The ground truth segmentation objects

  • macro_categories (dict[str, list[int]]) – A dictionary mapping macro-category names to lists of category IDs

Returns:

A dictionary mapping macro-category names to lists of category IDs

Return type:

dict[str, list[int]]

Modules

collapse_categories

fatigue_evaluation

find_contained

json_to_int_list(json_input)

Converts a JSON string or a list of integers into a list of integers.

load_categories

sample_gts