PowerBoxes
Powerboxes is a package containing utility functions for transforming bounding boxes and computing metrics. It is implemented in both Python and Rust. It shows a significant speedup over the equivalent numpy implementations in Python, or other libraries such as shapely or torchvision.
See source code here
Installation
Example Usage
import powerboxes as pb
import numpy as np
# Create bounding boxes in xyxy format
boxes = np.array([[0, 0, 1, 1], [2, 2, 3, 3]], dtype=np.float64)
# Compute areas
areas = pb.boxes_areas(boxes)
# Compute pairwise IoU distance matrix
iou = pb.iou_distance(boxes, boxes)
# Non-maximum suppression
scores = np.array([0.9, 0.8])
keep = pb.nms(boxes, scores, iou_threshold=0.5, score_threshold=0.3)
# Draw boxes on an image (CHW format, uint8)
image = np.zeros((3, 100, 100), dtype=np.uint8)
draw_boxes = np.array([[10.0, 10.0, 50.0, 50.0]])
result = pb.draw_boxes(image, draw_boxes)
supported dtypes by most functions