Skip to main content

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)

Metadata

Release files for quad-iou 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for quad-iou 0.2.0
File Size Uploaded
quad_iou-0.2.0.tar.gz 10.5 kB Details

Release files / quad_iou-0.2.0.tar.gz

Download URL quad_iou-0.2.0.tar.gz
Size 10.5 kB
Tags Source
SHA-256 checksum
How to use checksums
d3acf4de3ec679e4d58e550c5b09036cf61ad24b433b584afb6966b3945c032c
BLAKE2b-256 checksum
How to use checksums
5063fd6ea3fb0e12c2dbc4ee52fed8a83a0c0887619dacc69d7aa6893b4380e2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.11.5

Release history Release notifications | RSS feed

This release

0.2.0 This release

1 release file

0.1.0

1 release file

0.0.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page