Skip to main content

Lightweight package for managing bounding boxes that works seamlessly with most computing frameworks.

Project description

Logo

Lightweight package for managing bounding boxes that works seamlessly with most computing frameworks.

CI/CD CI Pipeline Release interrogate codecov
Meta linting - Ruff code style - Black imports - isort pre-commit License
Package PyPI - Python Version PyPI - Version

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

anyboxes-0.1.1.tar.gz (43.5 kB view details)

Uploaded Source

Built Distribution

anyboxes-0.1.1-py3-none-any.whl (11.6 kB view details)

Uploaded Python 3

File details

Details for the file anyboxes-0.1.1.tar.gz.

File metadata

  • Download URL: anyboxes-0.1.1.tar.gz
  • Upload date:
  • Size: 43.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.3

File hashes

Hashes for anyboxes-0.1.1.tar.gz
Algorithm Hash digest
SHA256 849ba3011865a118d53cac8879313dfd434fd38dcfdef6c0a07fc163e2cf1c88
MD5 f866060d9c7af08e1747fdb6ccd8c836
BLAKE2b-256 12bbf4bb52156bd818b76721576421aa9cb9fdc0f507b6f80c659d739ca9d1c5

See more details on using hashes here.

File details

Details for the file anyboxes-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: anyboxes-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 11.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.3

File hashes

Hashes for anyboxes-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3b406ec86aa74036e004dc634b5fd7646031d1af5063b068c617c9271fa36013
MD5 8db07e9fc8a7b96182a672cf763a68d5
BLAKE2b-256 d870de411de8b3708049f9035aa6e5c9b9849f7abf67548c4003637cdcce2f59

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page