Skip to main content

Abraia Python SDK

Project description

Build Status Python Package Package Downloads

Abraia Vision SDK

The Abraia Vision SDK helps developers create, customize, and deploy edge-ready vision applications. It unifies image processing, model training, and inference so you can transform visual data into production-ready solutions, including real-time video analysis and object tracking.

Install the Abraia SDK and CLI on Windows, Mac, or Linux:

python -m pip install -U abraia

With Abraia DeepLab, you can annotate images, train custom classification, detection, and segmentation models, and export them for use in this Python SDK.

People monitoring

Abraia SDK provides a set of tools to monitor people flow and waiting time in public spaces or commercial areas. You can easily implement queue monitoring or flow counting applications using the specialized tools available in the abraia.inference.tools module.

from abraia.inference import Model, Tracker
from abraia.inference.tools import LineCounter, RegionTimer
from abraia.utils import Video, render_results, render_counter, render_region

model = Model("multiple/models/yolov8n.onnx")
video = Video('images/people-walking.mp4')
tracker = Tracker(frame_rate=video.frame_rate)
line_counter = LineCounter([(0, 650), (1920, 650)])
region_timer = RegionTimer([(10, 600), (1690, 600), (1690, 700), (10, 700)])

for k, frame in enumerate(video):
    results = model.run(frame)
    results = [result for result in results if result['label'] == 'person']
    results = tracker.update(results)
    in_count, out_count = line_counter.update(results)
    in_objects, out_objects = region_timer.update(results, k / video.frame_rate)
    frame = render_counter(frame, line_counter.line, f"In: {in_count} | Out: {out_count}")
    frame = render_region(frame, region_timer.region, f"Count: {len(in_objects)}")
    frame = render_results(frame, in_objects)
    video.show(frame)

people detected

Face recognition

Identify people on images with face recognition as shown bellow.

import os

from abraia.inference import FaceRecognizer
from abraia.utils import load_image, save_image, render_results

img = load_image('images/rolling-stones.jpg')
out = img.copy()

recognition = FaceRecognizer()

index = []
for src in ['mick-jagger.jpg', 'keith-richards.jpg', 'ronnie-wood.jpg', 'charlie-watts.jpg']:
    img = load_image(f"images/{src}")
    rslt = recognition.identify_faces(img)[0]
    index.append({'name': os.path.splitext(src)[0], 'vector': rslt['vector']})

results = recognition.identify_faces(results, index)
render_results(out, results)
save_image(out, 'images/rolling-stones-identified.jpg')

rolling stones identified

License plates recognition

Automatically recognize car license plates in images and video streams.

from abraia.inference import PlateRecognizer
from abraia.utils import load_image, show_image, render_results

alpr = PlateRecognizer()

img = load_image('images/car.jpg')
results = alpr.detect(img)
results = alpr.recognize(img, results)
results = [result for result in results if len(result['lines'])]
for result in results:
    result['label'] = '\n'.join([line.get('text', '') for line in result['lines']])
    del result['score']
frame = render_results(img, results)
show_image(img)

car license plate recognition

Gender Age estimation

Model to predict gender and age. It can be useful to anonymize minors faces.

from abraia.inference import FaceRecognizer, FaceAttribute
from abraia.utils import load_image, show_image, render_results

recognition = FaceRecognizer()
attribute = FaceAttribute()

img = load_image('images/image.jpg')
results = recognition.detect_faces(img)
faces = recognition.extract_faces(img, results)
for face, result in zip(faces, results):
    gender, age, score = attribute.predict(face)
    result['label'] = f"{gender} {age}"
    result['score'] = score
img = render_results(img, results)
show_image(img)

Blur license plate

Anonymize images automatically bluring car license plates.

from abraia.utils import load_image, save_image
from abraia.inference import PlateDetector
from abraia.editing import build_mask
from abraia.utils.draw import draw_blurred_mask

src = 'images/car.jpg'
img = load_image(src)

detector = PlateDetector()
plates = detector.detect(img)
mask = build_mask(img, plates, [])
out = draw_blurred_mask(img, mask)

save_image(out, 'blur-car.jpg')

blur car license plate

Semantic search

Search on images with embeddings.

from tqdm import tqdm
from glob import glob
from abraia.utils import load_image
from abraia.inference.clip import Clip
from abraia.inference.ops import search_vector

clip_model = Clip()

image_paths = glob('images/*.jpg')
image_index = [{'vector': clip_model.get_image_embeddings([load_image(image_path)])[0]} for image_path in tqdm(image_paths)]

text_query = "full body person"
vector = clip_model.get_text_embeddings([text_query])[0]

idxs, scores = search_vector(vector, image_index)
print(f"Similarity score is {scores[0]} for image {image_paths[idxs[0]]}")

Hyperspectral imaging

The abraia.multiple module simplifies working with multispectral and hyperspectral images, offering HSI analysis and classification workflows.

Hyperspectral data contains many spectral bands, so it cannot be shown directly as a standard RGB image. Instead, extract a few bands and plot them as grayscale images, or apply PCA to generate a 3-channel pseudo-RGB image from the first three principal components.

Use the available Colab notebook to start experimenting with the multispectral tools:

classification

Hyperspectral image analysis and classification

License

This software is licensed under the MIT License. View the license.

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

abraia-0.25.11.tar.gz (63.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

abraia-0.25.11-py3-none-any.whl (1.4 MB view details)

Uploaded Python 3

File details

Details for the file abraia-0.25.11.tar.gz.

File metadata

  • Download URL: abraia-0.25.11.tar.gz
  • Upload date:
  • Size: 63.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for abraia-0.25.11.tar.gz
Algorithm Hash digest
SHA256 e584635540c5e8d1f5190d6ab98480602b74ae0d97db8e6554a872a9572ec2c0
MD5 8839b26254bb1be0d52ee6131954644f
BLAKE2b-256 921d1d7ca898c961cbd8db6170c4ab5c1fdfd4083d2a5b60e2dc324bda394197

See more details on using hashes here.

File details

Details for the file abraia-0.25.11-py3-none-any.whl.

File metadata

  • Download URL: abraia-0.25.11-py3-none-any.whl
  • Upload date:
  • Size: 1.4 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for abraia-0.25.11-py3-none-any.whl
Algorithm Hash digest
SHA256 7298b974214c61cb4335b505fff8b60b31c39e37a210a3ab5f24715bb4fa2c10
MD5 c2fbde199c9a7b89561287bb34a2fd2b
BLAKE2b-256 a6ab8dd64891d4b3b6ec3453519c5dd96222a53ef5f161aa93a1562a2bd5a81a

See more details on using hashes here.

Supported by

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