otx.algorithms.detection.utils#

Collection of utils for task implementation in Detection Task.

Functions

get_det_model_api_configuration(...)

Get ModelAPI config.

load_dataset_items_coco_format(...[, ...])

Load dataset from CocoDataset.

get_sizes_from_dataset_entity(dataset, target_wh)

Function to get sizes of instances in DatasetEntity and to resize it to the target size.

get_anchor_boxes(wh_stats, group_as)

Get anchor box widths & heights.

format_list_to_str(value_lists)

Decrease floating point digits in logs.

generate_label_schema(label_names[, ...])

Generating label_schema function.

create_detection_shapes(pred_results, width, ...)

Create prediction detection shapes.

create_mask_shapes(pred_results, width, ...)

Create prediction mask shapes.

otx.algorithms.detection.utils.create_detection_shapes(pred_results: List[ndarray], width: int, height: int, confidence_threshold: float, use_ellipse_shapes: bool, labels: List)[source]#

Create prediction detection shapes.

Parameters:
  • pred_results (list(np.ndarray)) – per class predicted boxes

  • width (int) – image width

  • height (int) – image height

  • confidence_threshold (float) – confidence threshold for filtering predictions

  • use_ellipse_shapes (bool) – if True, use ellipse shapes

  • labels (list) – dataset labels

Returns:

list of prediction shapes (Annotation)

Return type:

shapes

otx.algorithms.detection.utils.create_mask_shapes(pred_results: Tuple, width: int, height: int, confidence_threshold: float, use_ellipse_shapes: bool, labels: List, rotated_polygon: bool = False)[source]#

Create prediction mask shapes.

Parameters:
  • pred_results (tuple) – tuple of predicted boxes and masks for each dataset item

  • width (int) – image width

  • height (int) – image height

  • confidence_threshold (float) – confidence threshold for filtering predictions

  • use_ellipse_shapes (bool) – if True, use ellipse shapes

  • labels (list) – dataset labels

  • rotated_polygon (bool, optional) – if True, use rotated polygons for mask shapes

Returns:

list of prediction shapes (Annotation)

Return type:

shapes

otx.algorithms.detection.utils.format_list_to_str(value_lists: list)[source]#

Decrease floating point digits in logs.

otx.algorithms.detection.utils.generate_label_schema(label_names: Sequence[str], label_domain: Domain = Domain.DETECTION)[source]#

Generating label_schema function.

otx.algorithms.detection.utils.get_anchor_boxes(wh_stats: List[tuple], group_as: List[int])[source]#

Get anchor box widths & heights.

otx.algorithms.detection.utils.get_det_model_api_configuration(label_schema: LabelSchemaEntity, task_type: TaskType, confidence_threshold: float, tiling_parameters: Any, use_ellipse_shapes: bool, nms_iou_threshold: float)[source]#

Get ModelAPI config.

otx.algorithms.detection.utils.get_sizes_from_dataset_entity(dataset: DatasetEntity, target_wh: List[int])[source]#

Function to get sizes of instances in DatasetEntity and to resize it to the target size.

Parameters:
  • dataset – DatasetEntity in which to get statistics

  • target_wh – target width and height of the dataset

Return list:

tuples with width and height of each instance

otx.algorithms.detection.utils.load_dataset_items_coco_format(ann_file_path: str, data_root_dir: str, domain: Domain, subset: Subset = Subset.NONE, labels_list: List[LabelEntity] | None = None, with_mask: bool = False)[source]#

Load dataset from CocoDataset.