Skip to main content

A Python package for data structures

Project description

Sparrow Datums

Sparrow Datums is a Python package for vision AI data structures, related operations and serialization/deserialization. Specifically, it makes it easier to work with bounding boxes, key points (TODO), and segmentation masks (TODO). It supports individual objects, frames of objects, multiple frames of objects, objects augmented with class labels and confidence scores, and more.

Sparrow Datums also supports object tracking where the identity of the object is maintained. And that data can be streamed instead of keeping it all in a single file.

Quick Start Example

Installation

pip install -U sparrow-datums

Switching between box parameterizations

import numpy as np
from sparrow_datums import FrameBoxes, PType

boxes = FrameBoxes(np.ones((4, 4)), PType.absolute_tlwh)
boxes.to_tlbr()

# Expected result
# FrameBoxes([[1., 1., 2., 2.],
#             [1., 1., 2., 2.],
#             [1., 1., 2., 2.],
#             [1., 1., 2., 2.]])

Slicing

Notice that all "chunk" objects override basic NumPy arrays. This means that some filtering operations work as expected:

boxes[:2]

# Expected result
# FrameBoxes([[1., 1., 1., 1.],
#             [1., 1., 1., 1.]])

But sub-types do their own validation. For example, FrameBoxes must be a (n, 4) array. Therefore, selecting a single column throws an error:

boxes[:, 0]

# Expected exception
# ValueError: A frame boxes object must be a 2D array

Instead, chunks expose different subsets of the data as properties. For example, you can get the x coordinate as an array:

boxes.x

# Expected result
# array([1., 1., 1., 1.])

Or the width of the boxes:

boxes.w

# Expected result
# array([1., 1., 1., 1.])

If you need to access the raw data, you can do that with a chunk's array property:

boxes.array[0, 0]

# Expected result
# 1.0

Operations

Sparrow Datums comes with common operations for data types. For example, you can compute the pairwise IoU of two sets of FrameBoxes:

from sparrow_datums import pairwise_iou

pairwise_iou(boxes, boxes + 0.1)

# array([[0.57857143, 0.57857143, 0.57857143, 0.57857143],
#        [0.57857143, 0.57857143, 0.57857143, 0.57857143],
#        [0.57857143, 0.57857143, 0.57857143, 0.57857143],
#        [0.57857143, 0.57857143, 0.57857143, 0.57857143]])

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

sparrow-datums-0.8.4.dev1658507644.tar.gz (22.2 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file sparrow-datums-0.8.4.dev1658507644.tar.gz.

File metadata

  • Download URL: sparrow-datums-0.8.4.dev1658507644.tar.gz
  • Upload date:
  • Size: 22.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.14 CPython/3.8.13 Linux/5.15.0-1014-azure

File hashes

Hashes for sparrow-datums-0.8.4.dev1658507644.tar.gz
Algorithm Hash digest
SHA256 d61509ca18993c83dce81c4c51f8e9bc79767bbbe8351bd3298fee7ab4913819
MD5 78428ea592b54aea4f5170a93dbac562
BLAKE2b-256 001fed18acf26323ef299e579e04620e3d8d385a4da39d908626e294cb17f721

See more details on using hashes here.

File details

Details for the file sparrow_datums-0.8.4.dev1658507644-py3-none-any.whl.

File metadata

File hashes

Hashes for sparrow_datums-0.8.4.dev1658507644-py3-none-any.whl
Algorithm Hash digest
SHA256 811de826c3e1e93e69d4e8aa03e75f36ed4099149d7c7269ca6aeb61b8f74fd8
MD5 549f1f7b81e65d8917ec14b66b6e6b99
BLAKE2b-256 7c2cec8cb02508e461d2e1540f935d866bde5cdc1206c492d3b49972a26a111e

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