sportslabkit.metrics.object_detection#
Overview#
|
Calculate 11-point interpolated average precision. |
|
- |
|
- |
|
Convert bbox to x1y1x2y2 format. |
|
Convert bboxes to tuples of (xmin, ymin, width, height, confidence, class_id, image_name). |
|
- |
|
Calculate average precision. |
|
Calculate average precision in the specified range. |
|
Calculate mean average precision. |
|
Calculate mean average precision. |
- |
|
- |
|
- |
|
- |
|
- |
|
- |
|
- |
Functions#
- sportslabkit.metrics.object_detection.ElevenPointInterpolatedAP(rec: Any, prec: Any) list[Any][source]#
Calculate 11-point interpolated average precision.
- Parameters:
rec (np.ndarray[np.float64]) – recall array
prec (np.ndarray[np.float64]) – precision array
- Returns:
List containing information necessary for ap calculation
- Return type:
Interp_ap_info (list[Any])
- sportslabkit.metrics.object_detection.iou_score(bbox_det: list[int], bbox_gt: list[int]) float[source]#
- sportslabkit.metrics.object_detection.iou_scores(bbox_dets: list[int] | list[list[int]], bbox_gts: list[int] | list[list[int]], xywh: bool = False, average: bool = True) list[float][source]#
- sportslabkit.metrics.object_detection.convert_to_x1y1x2y2(bbox: list[int]) list[int][source]#
Convert bbox to x1y1x2y2 format.
- sportslabkit.metrics.object_detection.convert_bboxes(bboxes: pd.DataFrame | BBoxDataFrame | list | tuple) list[float, float, float, float, float, str, str][source]#
Convert bboxes to tuples of (xmin, ymin, width, height, confidence, class_id, image_name).
- sportslabkit.metrics.object_detection.validate_bboxes(bboxes: list[float, float, float, float, float, str, str], is_gt=False) None[source]#
- sportslabkit.metrics.object_detection.ap_score(bboxes_det_per_class: list[list[float, float, float, float, float, str, str]], bboxes_gt_per_class: list[list[float, float, float, float, float, str, str]], iou_threshold: float) dict[str, Any][source]#
Calculate average precision.
- Parameters:
- Returns:
dict containing information about average precision
- Return type:
ap(dict)
Note
bboxes_det_per_class: [bbox_det_1, bbox_det_2, …] bboxes_gt_per_class: [bbox_gt_1, bbox_gt_2, …]
#The elements of each bbox variable are as follows, each element basically corresponding to a property of the BoundingBox class of Object-Detection-Metrics. https://github.com/rafaelpadilla/Object-Detection-Metrics/blob/master/lib/BoundingBox.py
bbox_det_n(tuple): (xmin, ymin, width, height, confidence, class_id, image_name) bbox_gt_n(tuple): (xmin, ymin, width, height, 1.0, class_id, image_name)
xmin(float): xmin ymin(float): ymin width(float): width height(float): height confidence(float): class confidence class_id(str): class id image_name(str): image name
#index variable, this is written as a global variable in the def main() function. X_INDEX = 0 Y_INDEX = 1 W_INDEX = 2 H_INDEX = 3 CONFIDENCE_INDEX = 4 CLASS_ID_INDEX = 5 IMAGE_NAME_INDEX = 6
- sportslabkit.metrics.object_detection.ap_score_range(bboxes_det_per_class: list[float, float, float, float, float, str, str], bboxes_gt_per_class: list[float, float, float, float, float, str, str], start_threshold: float = 0.5, end_threshold: float = 0.95, step: float = 0.05) float[source]#
Calculate average precision in the specified range.
- Parameters:
bboxes_det_per_class (list) – bbox of detected object per class.
bboxes_gt_per_class (list) – bbox of ground truth object per class.
start_threshold (float) – start threshold of IOU. default is 0.5.
end_threshold (float) – end threshold of IOU. default is 0.95.
step (float) – step of updating threshold. default is 0.05.
- Returns:
list of average precision in the specified range. ap_range(float): average of ap in the specified range.
- Return type:
ap_results(list)
- sportslabkit.metrics.object_detection.map_score(bboxes_det: pd.DataFrame | BBoxDataFrame | list | tuple, bboxes_gt: pd.DataFrame | BBoxDataFrame | list | tuple, iou_threshold: float) float[source]#
Calculate mean average precision.
- sportslabkit.metrics.object_detection.map_score_range(bboxes_det: pd.DataFrame | BBoxDataFrame | list | tuple, bboxes_gt: pd.DataFrame | BBoxDataFrame | list | tuple, start_threshold: float = 0.5, end_threshold: float = 0.95, step: float = 0.05) float[source]#
Calculate mean average precision.
- Parameters:
- Returns:
average of map in the specified range. (0.5 to 0.95 in increments of 0.05)
- Return type:
map_range(float)