object_detection

BoxIou2D

class stardust.metric.object_detection.BoxIou2D[source]

Bases: object

compute_IoU(box1, box2, IoU_mode)[source]

Computing IoU with the given IoU compute method

Args:

box1: Box2D

box2: Box2D

IoU_mode: str

The method to compute IoU, IoU_mode should be chosen from ‘IoU’, ‘GIoU’, ‘DIoU’ and ‘CIoU’

Returns:
float:

IoU of box1 and box2

Examples:
from stardust.metric.object_detection import BoxIou2D
from stardust.components.annotations.box import Box2D
metric = BoxIou2D()
box1 = Box2D(center=[473.07, 395.93], size=[38.65, 28.67])
box2 = Box2D(center=[473.07, 395.93], size=[38.65, 28.67])
IoU = metric.compute_IoU(box1, box2, 'IoU')

BoxIou3D

class stardust.metric.object_detection.BoxIou3D[source]

Bases: object

compute_IoU(box1, box2, IoU_mode)[source]

Computing IoU with the target IoU mode

Args:

box1: Box3D

box2: Box3D

IoU_mode: str

The method to compute IoU, IoU_mode should be chosen from ‘IoU’ and ‘GIoU’

Returns:
float:

IoU of box1 and box2

Examples:
from stardust.metric.object_detection import BoxIou3D
from stardust.components.annotations.box3e import Box3D
metric = BoxIou3D()
box1 = Box3D(center = [4.13, -3.77, 0.78], size=[1, 5, 1], rotation=[0, 0, -1.57], rotation_order="XYZ")
box2 = Box3D(center = [4.13, -3.77, 0.78], size=[1, 5, 1], rotation=[0, 0, -1.57], rotation_order="XYZ")
IoU = metric.compute_IoU(box1, box2, 'IoU')

compute_metric_single_frame

stardust.metric.object_detection.compute_metric_single_frame(gt_boxes, pd_boxes, IoU_thr, box_type, IoU_mode)[source]

Computing metric of all objects in a single frame

Args:
gt_boxes: List

Box list of ground truth, each box should be a Box-like object(Box2D or Box3d)

pd_boxes: List

Box list of predictions, each box should be a Box-like object(Box2D or Box3d)

IoU_thr: float

The iou threshold of tp boxes

box_type: str

Choose which type of objects to be computed, box_type should be chosen from ‘2D’ and ‘3D’

IoU_mode: str

Choose which IoU compute method to be used

Returns:

Tuple: metric of gt, pd, tp, recall, precision and f1

compute_metric

stardust.metric.object_detection.compute_metric(data, IoU_thr, IoU_mode, save_path)[source]

Computing IoU of all objects in all frames

Args:
data (Generator):

A generator object to get all information from all frames

IoU_thr: float

The iou threshold of tp boxes

IoU_mode: str

Which IoU compute method to be used

save_path: str

Local path to save metric results

Returns:
Tuple:

The metric of dataset which include two dict, the first represents metric of every single frame and the second represents metric of all frames

Examples:
from stardust.metric.object_detection import compute_metric
from stardust.rosetta.rosetta_data import RosettaData
project_id = 856
Data(project_id, 'top', input_path, True).export()
json_datas = read_rosetta(project_id=project_id,
                        input_path=input_path,
                        )
metric = compute_metric(json_datas, 0.5, 'IoU', 'local/')