API details.
from detection_nbdev.utils import random_bbox, visualize
import numpy as np
bboxA = random_bbox()
bboxB = random_bbox()
iou = bbox_iou(bboxA, bboxB)
print('label:', bboxA)
print('bbox:', bboxB)
print('IoU:', iou)
visualize(
np.zeros((224,224,3)),
[bboxA, bboxB],
[0, 1],
{0:'bboxA', 1:'bboxB'},
)
bboxesA = [random_bbox() for _ in range(2)]
bboxesB = [random_bbox() for _ in range(3)]
loss_iou = hungarian_loss(bboxesA, bboxesB, bbox_iou, maximize=True)
print('Hungarian IoU Loss:', loss_iou)
visualize(
np.zeros((224,224,3)),
bboxesA + bboxesB,
[0]*len(bboxesA) + [1]*len(bboxesB),
{0:'bboxA', 1:'bboxB'},
)