Skip to main content

rectiou: vectorized 2d rectangle intersection with pytorch

Project description

rectiou

Rectiou is a pytorch implementation of the intersection over union (IoU) between two rotated rectangles.

Supports:

  • ✅ Works with rotated rectangles: can handle rectangles with any angle.
  • ✅ Batched computation: No for loops, if statements, or other control flow. Can have as many batch dimensions as you want.
  • ✅ Fast: faster than OpenCV's implementation.
  • ✅ Differentiable: Can be used in a pytorch model and backpropagated through.
  • ✅ GPU: can be run on the GPU.
  • ✅ No weird stuff: everything is implemented in plain pytorch, no weird custom CUDA kernels or anything like that.

Example

Usage is simple:

import torch
import rectiou

# Rectangles: [x, y, w, h, radians]
rect_a = torch.tensor([0.0, 0.0, 1.0, 1.0, 0.0])
rect_b = torch.tensor([0.2, 0.1, 1.1, 0.8, torch.pi / 4])

# Intersection over union
iou = rectiou.compute_iou(rect_a, rect_b)

Installation

pip install rectiou

To test that everything is working correctly, run:

pip install rectiou[tests]
pytest

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

rectiou-0.0.1.tar.gz (8.3 kB view details)

Uploaded Source

Built Distribution

rectiou-0.0.1-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file rectiou-0.0.1.tar.gz.

File metadata

  • Download URL: rectiou-0.0.1.tar.gz
  • Upload date:
  • Size: 8.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for rectiou-0.0.1.tar.gz
Algorithm Hash digest
SHA256 f709f629aaae6bc52e740d67ce01cb3595703bbad98811a147af9ec2a156f502
MD5 bd2d5a9ddb8e2ff42ef278bfa05537ac
BLAKE2b-256 ecae1c9f2871c5df46fe7f3f890fd440402a1805512a4444782854cf6ce3d8a3

See more details on using hashes here.

File details

Details for the file rectiou-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: rectiou-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 5.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for rectiou-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 af4527a25d84ff696d143d69a7696c2d281ae261f349026a0127b1b8f3e22916
MD5 9604e8a4ee20a0c362869b59621804d0
BLAKE2b-256 6d9616588180abc14a69f1d99ec2ac24750b5e0f088cca9cd119bd2e3f7cac6b

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