MCPcopy Index your code
hub / github.com/explainingai-code/FasterRCNN-PyTorch / get_iou

Function get_iou

tools/infer.py:16–33  ·  view source on GitHub ↗
(det, gt)

Source from the content-addressed store, hash-verified

14
15
16def get_iou(det, gt):
17 det_x1, det_y1, det_x2, det_y2 = det
18 gt_x1, gt_y1, gt_x2, gt_y2 = gt
19
20 x_left = max(det_x1, gt_x1)
21 y_top = max(det_y1, gt_y1)
22 x_right = min(det_x2, gt_x2)
23 y_bottom = min(det_y2, gt_y2)
24
25 if x_right < x_left or y_bottom < y_top:
26 return 0.0
27
28 area_intersection = (x_right - x_left) * (y_bottom - y_top)
29 det_area = (det_x2 - det_x1) * (det_y2 - det_y1)
30 gt_area = (gt_x2 - gt_x1) * (gt_y2 - gt_y1)
31 area_union = float(det_area + gt_area - area_intersection + 1E-6)
32 iou = area_intersection / area_union
33 return iou
34
35
36def compute_map(det_boxes, gt_boxes, iou_threshold=0.5, method='area'):

Callers 1

compute_mapFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected