Torch extension for calculating IoU(Intersection over Union) for quadrilaterals(MxN)
Project description
IoU(Intersection over Union) Calculation for Quadrilaterals(Torch extension)
Torch extension for calculating IoU (Intersection over Union) for quadrilaterals. It can calculate IoU either for a 1-to-1 match or an M-to-N match, returning an IoU matrix with M rows and N columns. Torch CUDA/CPP extensions are used for binding the code to Torch.
Example usage:
import torch
import quad_iou
# NxM quadrilaterals
a = torch.rand((200, 4, 2)).cuda() # Can also be without cuda
b = torch.rand((300, 4, 2)).cuda()
# sort_input_quads indicate whether kernel should sort the quadrilateral corners
# clockwise before calculating iou
iou_matrix = quad_iou.calculate_iou(a, b, sort_input_quads=True) # returns tensor of shape [200, 300]
# 1x1 case
a = torch.tensor([0.0, 0, 300, 0, 300, 300, 0, 300]).cuda() # Can also be without cuda
b = torch.tensor([0.0, 0, 150, 0, 150, 150, 0, 150]).cuda()
# Module expects tensor of shape [N, 4, 2], so we reshape the tensors
a = a.reshape(-1, 4, 2)
b = b.reshape(-1, 4, 2)
iou = quad_iou.calculate_iou(a, b, sort_input_quads=True)
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.
Source Distribution
quad_iou-0.2.0.tar.gz
(10.5 kB
view details)
File details
Details for the file quad_iou-0.2.0.tar.gz.
File metadata
- Download URL: quad_iou-0.2.0.tar.gz
- Upload date:
- Size: 10.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d3acf4de3ec679e4d58e550c5b09036cf61ad24b433b584afb6966b3945c032c
|
|
| MD5 |
6af433c605ef0daebeeb433c4131f247
|
|
| BLAKE2b-256 |
5063fd6ea3fb0e12c2dbc4ee52fed8a83a0c0887619dacc69d7aa6893b4380e2
|