Lightweight package for managing bounding boxes that works seamlessly with most computing frameworks.
Project description
Lightweight package for managing bounding boxes that works seamlessly with most computing frameworks.
CI/CD | |
Meta | |
Package |
This package provides a simple API for managing bounding boxes. It allows you to perform transformation to your Numpy's ndarray
, JAX's Array
, PyTorch Tensor
or Tensorflow Tensor
from one orientation to another.
️️⚙️ Installation
Install the package from the PyPI registry. You may need to specify the framework that you want to managed. Numpy is enabled by default.
pip install anyboxes
# or
pip install "anyboxes[torch]" # or jax, tensorflow
Install the package from the latest commit of the repository.
pip install git+https://github.com/VDuchauffour/anyboxes
⚡ Usage
Example
from anyboxes import TorchBoxes
import torch
detections = torch.randint(0, 1000, (10, 4))
boxes = TorchBoxes.from_bottom_left_corner(detections)
boxes = boxes.to_center()
boxes.as_tensor
In a nutshell, using a Boxes
involve 3 stages:
# | Stage | Methods that can be used |
---|---|---|
1 | Instantiate a Boxes object with one of the from classmethods |
from_top_left_corner , from_bottom_left_corner , from_two_corners , from_center |
2 | Apply a transformation with a to inplace methods |
to_top_left_corner , to_bottom_left_corner , to_two_corners , to_center |
3 | Retrieve the modified data with one of the as properties |
as_dict , as_tuple , as_numpy , as_array , as_tf_tensor , as_tensor |
To be more specific, when a Boxes
is instantiated, the following attribute are created:
Attribute | Purpose |
---|---|
corners_coordinates |
A tuple of coordinates from top to bottom and from left to right |
center_coordinates |
A object that contains center coordinates |
size |
A object that contains width and height attributes |
origin |
Origin of the coordinates, can be equal to top-left or bottom-left |
⛏️ Development
Clone the project
git clone https://github.com/VDuchauffour/anyboxes
In order to install all development dependencies, run the following command:
pip install -e ".[all,dev]"
To ensure that you follow the development workflow, please setup the pre-commit hooks:
pre-commit install
🧭 Roadmap
- Implementations
- PyTorch
- Numpy
- JAX
- Tensorflow
- Dispatch implementation using a metaclass
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.