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.
🦀 Rust documentation
🐍 Python documentation
pip install powerboxes
cargo add powerboxesrs
import powerboxes as pb
import numpy as np
# Create a bounding box
box = np.array([[0, 0, 1, 1]])
# Compute the area of the box
area = pb.box_areas(box)
# Compute the intersection of the box with itself
intersection = pb.iou_distance(box, box)
Here is a simple example:
use ndarray::array;
use powerboxesrs::boxes::box_areas;
let boxes = array![[1., 2., 3., 4.], [0., 0., 10., 10.]];
let areas = box_areas(&boxes);
assert_eq!(areas, array![4., 100.]);
Some benchmarks of powerboxes against various open source alternatives, not all functions are benchmarked. Notice that we use log scales, all differences are major ! Benchmarks can be found in this google colab notebook
Here it's torchvision vs powerboxes vs numpy
Here it's torchvision vs powerboxes
Torchvision vs numpy vs powerboxes
Torchvision vs powerboxes vs lsnms vs numpy