Skip to main content

Build Status Python Package Package Downloads License: MIT

Abraia Vision SDK

Abraia is a Python SDK and command-line tool for computer vision and image processing. Use it to run vision models on images and video, combine inference with tracking and counting, edit images, and manage files in Abraia storage. Inference runs through ONNX Runtime or a compatible Hailo accelerator.

Contents

Installation

Install the SDK and its abraia command:

python -m pip install -U abraia

Enable shell completion after installing. Abraia detects Bash, Zsh, or Fish from the SHELL environment variable; pass the shell name to override it:

abraia configure --completion
# or: abraia configure --completion --shell fish

For remote file operations, configure your Abraia API key:

abraia configure

The command shows where to obtain your key and saves it for future commands. You can also set the ABRAIA_KEY environment variable. Python applications use the same credentials or accept a key through Abraia(abraia_key="...").

Quick start

Run object detection on a local video and save the rendered result:

abraia run demo detect input.mp4 --output result.avi

List connected local cameras, then run detection with the camera index shown:

abraia discover cameras
abraia run demo detect 0

To use an ONVIF camera on the local network, discover its RTSP URL and pass it as the demo source:

abraia discover streams
abraia run demo detect 'rtsp://camera-address/stream'

Run abraia run demo to start the default detection demo. Use abraia run demo list to browse workflows and model demos. Model variants can be selected for compatible workflows; for example:

abraia run demo apple
abraia run demo apple --model yolov8n-seg
abraia run demo people --model yolo9t

Demo inputs download automatically when needed. The detect and pose demos use camera 0 by default; other demos use their configured video or camera. A workflow's model task must match the selected model. Use the model's canonical variant name after --model.

--output saves rendered video locally. --accelerator selects auto, onnx, cpu, gpu, or hailo; the default is auto. See Hardware acceleration for backend setup.

Command-line usage

Use abraia --help or abraia COMMAND --help for available options. In the command reference below, uppercase names are placeholders and brackets mark optional arguments.

Camera and stream discovery

abraia discover cameras lists local camera indexes. abraia discover streams finds RTSP URLs advertised by ONVIF cameras on the local network.

Remote files

abraia configure
abraia list [FOLDER]
abraia upload LOCAL_PATH [REMOTE_FOLDER]
abraia download REMOTE_PATH [LOCAL_FOLDER]
abraia remove REMOTE_PATH

upload accepts a file or directory. remove lists matching files and asks for confirmation before deleting them. configure saves the Abraia API key for remote file operations.

Demos and saved projects

abraia run demo [DEMO_NAME] [SOURCE] [--model MODEL]
  [--accelerator auto] [--output FILE]
abraia run PROJECT [SOURCE] [--accelerator auto] [--output FILE]

Run abraia run demo to start detection, or use abraia run demo list to browse demos and compatible model variants. Append a local path, camera index, or RTSP URL to use it as the source. Sample videos download automatically when needed. The pi-camera demo publishes a Raspberry Pi camera stream without inference.

A project run loads PROJECT/pipeline.json from Abraia storage. First create a pipeline configuration, then upload it to your project:

abraia upload pipeline.json my-project/
abraia run my-project input.mp4 --output result.avi

The project must contain pipeline.json; a project run does not select a trained model automatically. Omit the source to use the one saved in the pipeline.

Search a remote project's images using a text query or a local reference image:

abraia search my-project "man with red shirt"
abraia search my-project reference.jpg

Python API

The public entry points are:

Module Entry points Purpose
abraia Abraia, APIError, config Remote files, metadata, image transforms, and credentials
abraia.editing Image editing functions Background removal, cropping, upscaling, anonymization, and inpainting
abraia.inference load_model, register_model_factory Load configured models or register an adapter
abraia.media Image helpers, input source classes, VideoWriter Image and media I/O
abraia.media.display Window, Sketcher, show_image Interactive windows and image viewing
abraia.runtime Pipeline, run_pipeline, source discovery helpers Run configured workflows and discover local video sources
abraia.utils render_results, compatibility exports Shared array, filesystem, and rendering helpers

Remote files and image transforms

from abraia import Abraia

client = Abraia()
remote_path = client.upload_file("input.jpg", "examples/input.jpg")
files, folders = client.list_files("examples/")
local_path = client.download_file(remote_path, "downloads/input.jpg")
client.transform_image(
    remote_path,
    "downloads/input-small.jpg",
    params={"width": 640},
)

list_files() returns (files, folders). upload_file() returns the remote path, and download_file() returns a local path. transform_image() writes the transformed image to its local destination. Remote API failures raise APIError, whose code attribute contains the HTTP status code.

The client also provides check_file, move_file, remove_file, metadata operations, and load/save methods for JSON and images.

Image editing

Editing functions accept RGB NumPy arrays. For example, remove an image's background and save the transparent result:

from abraia.editing import remove_background
from abraia.media import load_image, save_image

image = load_image("input.jpg")
result = remove_background(image)
save_image(result, "cutout.png")

load_image() applies EXIF orientation, returns an RGB array by default, and limits the longest edge to 2048 pixels. Pass max_size=None to keep the full resolution, or mode="RGBA" to preserve transparency. save_image(image, path) creates missing parent directories. Use encode_image() for encoded bytes and image_base64() for a data URL. abraia.media.display.show_image() opens an image in the system viewer; abraia.utils.show_image() remains available as a compatibility alias.

Other editing functions are anonymize_image, blur_background, clean_image, inpaint_image, smartcrop_image, and upscale_image. Model-backed operations load their models when first used.

Inference on an image

Load a configured detector and pass it an RGB image:

from abraia.inference import load_model
from abraia.media import load_image

image = load_image("input.jpg")
with load_model({"kind": "yolov8", "task": "detection", "size": "small"}) as model:
    results = model.run(image, conf_threshold=0.35)
print(results)

Use a pipeline when you also need video input, tracking, counting, or rendered output.

Runtime helpers

abraia.runtime also provides helpers for applications that manage their own pipeline UI or source selection. run_pipeline() accepts a pipeline configuration dictionary and can report frame events to a callback. It returns the total frame count and the most recent events requested by max_events:

from abraia.runtime import run_pipeline

# configuration is a loaded version-two pipeline dictionary.
def handle_frame(event):
    print(event["frame"], event["detections"])

result = run_pipeline(
    configuration,
    frame_callback=handle_frame,
    max_events=100,
    accelerator="auto",
)

discover_cameras() probes local camera indices, discover_streams() asks ONVIF devices on the local network for RTSP stream URLs, and discover_genicam_devices() lists devices exposed by GenTL Producers. The GenICam helper requires the optional harvesters package and a compatible Producer.

Pipelines

A pipeline is a version-two JSON document containing a source, ordered steps, and optional display and output settings. A model step performs inference; later steps can process its results. Sources can be images, image sequences, videos, local cameras, network streams, or GenICam cameras. Reusable source classes and media outputs are available from abraia.media; abraia.runtime handles pipeline configuration, execution, and preview display.

Raspberry Pi camera stream

Run the demo on Raspberry Pi OS Bookworm or Trixie:

abraia run demo pi-camera

The demo starts a local RTSP stream and prints its URL. Stop it with Ctrl+C. On another computer, run detection with the printed URL:

abraia run demo detect 'PASTE_THE_PRINTED_RTSP_URL_HERE'

The stream allows anonymous read access, so anyone who can reach the RTSP port can view it. RTSP does not encrypt video; use the stream on a trusted LAN or VPN.

Detection, tracking, and counting

Save the following as pipeline.json. It detects people, tracks them across frames, counts crossings of a line, and writes a rendered video:

{
  "version": 2,
  "source": {"type": "video", "src": "input.mp4"},
  "steps": [
    {
      "type": "model",
      "model": {
        "kind": "yolov8",
        "task": "detection",
        "size": "small",
        "labels": ["person"],
        "conf_threshold": 0.35
      }
    },
    {"type": "tracker"},
    {"type": "line_counter", "line": [[100, 360], [1180, 360]]}
  ],
  "display": {"show": true, "dest": "result.avi"}
}

Line and polygon coordinates are in source-image pixels. Adjust them to your video's resolution and the area you want to monitor.

Run the local configuration from Python:

from abraia.runtime import Pipeline

with Pipeline.from_file("pipeline.json") as pipeline:
    pipeline.run()

GenICam cameras

GenICam acquisition is optional. Install the Python consumer and the camera vendor's compatible GenTL Producer:

python -m pip install 'abraia[genicam]'

Set the vendor GenTL Producer path once in the environment:

export GENICAM_GENTL64_PATH=/opt/vendor/lib

The path can be a directory containing the vendor .cti file or the file itself. Then select the camera by serial number (or numeric device index):

{
  "version": 2,
  "source": {
    "type": "genicam",
    "src": "CAMERA_SERIAL_NUMBER"
  },
  "steps": [
    {
      "type": "model",
      "model": {
        "kind": "yolov8",
        "task": "detection",
        "size": "small"
      }
    }
  ],
  "display": {"show": true}
}

Use a serial number for a stable device selection. Abraia uses the camera's current feature settings and pixel format; if the format is unsupported, select an unpacked Mono, Bayer, RGB, or BGR format with the camera vendor's configuration tool. Abraia converts unpacked Mono, Bayer, RGB, and BGR frames to RGB; packed formats are unsupported.

People detected and counted

Use Pipeline.from_dict(config) to supply a Python dictionary instead of a file. For processing without a display window, set display.show to false; display.dest can still save the rendered video.

Pipelines also support filter, count, decision, region_filter, and region_timer. Filters select detections; count and decision steps produce counts and threshold results. Applications can register custom measure steps to extract configured features. Region steps restrict or time activity inside a polygon. Tracking must precede line-crossing counts and region timing.

Additional inference models

The following model adapters can also be selected in load_model() or a pipeline configuration:

kind task Model selection
clip classification Explicit ONNX model uri with its JSON metadata sidecar
anomaly anomaly Explicit ONNX or Hailo HEF uri; exported metadata supplies thresholds
rfdetr detection, segmentation Built-in small, medium, or large preset, or explicit uri
dfine detection, segmentation Built-in small, medium, or large preset, or explicit uri

Anomaly models return an image-level normal or anomaly result and defect regions. In a pipeline, the renderer overlays the calibrated anomaly map. Anomaly exports must include the task, algorithm, and threshold metadata expected by the adapter.

For example, classify an image with an exported CLIP model:

from abraia.inference import load_model

with load_model({
    "kind": "clip",
    "task": "classification",
    "uri": "classifier.onnx",
}) as model:
    predictions = model.run(image, top_k=3)

The DINOv2 image encoder is available for embedding workflows. Its default model is downloaded and cached when first used:

from abraia.inference.models.dinov2 import DinoV2ImageEncoder

with DinoV2ImageEncoder(batch_size=8) as encoder:
    embeddings = encoder.get_image_embeddings(images)

embeddings contains one 768-value vector for each input image. Pass an explicit model_uri to use another compatible DINOv2 ONNX export.

Combining two models

A pipeline can contain up to two model steps. The second model processes regions from the preceding results and attaches its output to the matching detections. For example, save this configuration as plate_ocr.json to detect license plates and read their text:

{
  "version": 2,
  "source": {"type": "video", "src": "traffic.mp4"},
  "steps": [
    {
      "type": "model",
      "model": {"kind": "license_plate", "task": "detection"}
    },
    {
      "type": "model",
      "model": {"kind": "ocr", "task": "recognition"}
    }
  ],
  "display": {"show": true}
}

Run it with Pipeline.from_file("plate_ocr.json").run().

License plate recognition

For wide plate crops, the built-in plate recognizer reads text directly and skips a second text detector. Narrow crops and crops with no direct recognition result use the full text detection path.

Choosing a model

Each model configuration uses kind for the model family and task for the operation. Common combinations include:

kind task Model selection
yolov8 detection, segmentation, pose Built-in small, medium, or large preset, or explicit uri
yolo9 detection Built-in small, medium, or large preset, or explicit uri
yolov5, yolo11 detection, segmentation, pose Explicit uri
rtmdet detection, segmentation Built-in small, medium, or large preset, or explicit uri
resnet classification Explicit model uri
grounding_dino detection Built-in model with labels or a text prompt
face detection, recognition Built-in models; recognition can use a face index
license_plate detection, recognition Built-in plate detection or recognition workflow
ocr recognition Built-in text detection and recognition

Built-in OCR uses the PP-OCRv6 tiny detector and recognizer with RapidOCR's text-line orientation stage, implemented with the SDK's existing ONNX Runtime and OpenCV dependencies. Select it as a regular OCR model:

{
  "kind": "ocr",
  "task": "recognition"
}

The orientation stage uses RapidOCR's PP-OCRv4 mobile classifier. On first use, the SDK downloads and caches the detector, classifier, recognizer, and character dictionary from the Abraia models repository. No RapidOCR Python package is required.

size selects small, medium, or large where presets are available. An explicit uri selects your own model. It can refer to a local file or an Abraia storage path. Managed model assets are downloaded and cached as needed.

To use Grounding DINO, replace a detection step's model object with:

{
  "kind": "grounding_dino",
  "task": "detection",
  "labels": ["person", "red car"],
  "conf_threshold": 0.35,
  "text_threshold": 0.25
}

For face recognition, use kind: "face", task: "recognition", and params: {"index": "faces.json", "threshold": 0.45}. The index contains name and vector entries.

Face recognition results

The full pipeline schema is packaged at abraia/runtime/pipeline-v2.schema.json.

Hardware acceleration

ONNX Runtime: CPU and GPU

The default installation includes the CPU build of ONNX Runtime. --accelerator cpu forces CPU execution; onnx uses the available ONNX Runtime providers. The default auto prefers a compatible Hailo device and model, then falls back to ONNX Runtime.

For an NVIDIA GPU on Linux, replace the CPU package in the same environment:

python -m pip uninstall -y onnxruntime
python -m pip install onnxruntime-gpu
python -c "import onnxruntime as ort; print(ort.get_available_providers())"

Check that the provider list includes CUDAExecutionProvider, then run:

abraia run demo detect input.mp4 --accelerator gpu

The GPU package must match the host's CUDA and cuDNN versions. See the ONNX Runtime CUDA provider requirements for compatibility details.

Hailo and Raspberry Pi

Install the Hailo platform runtime and connect a compatible device. A model must be compiled for the device's architecture, such as Hailo-8 or Hailo-8L. The SDK accepts local HEF files, Hailo export directories, and Abraia storage paths. Model metadata uses JSON sidecars; YAML metadata is no longer read.

For a supported demo, select Hailo explicitly:

abraia run demo people input.mp4 --accelerator hailo

Hailo-compiled YOLOv9 detection models are also supported by the pipeline runtime when supplied as explicit HEF artifacts with the Multiple YOLOv9 metadata sidecar.

For a custom pipeline, replace its model object with a compatible HEF, for example:

{
  "kind": "yolov8",
  "task": "detection",
  "uri": "multiple/models/yolov8n_hailo8.hef",
  "conf_threshold": 0.3
}

This example targets Hailo-8. Choose a HEF matching your own device. On a Raspberry Pi, the counting pipeline above can use a camera source such as {"type": "camera", "src": 0, "resolution": [1280, 720], "fps": 30}.

The same Python entry point runs the pipeline:

from abraia.runtime import Pipeline

with Pipeline.from_file("pipeline.json", accelerator="hailo") as pipeline:
    pipeline.run()

Hailo bundles use abraia.json for the model family (kind), operation (task), labels (classes), and host-side decoding settings. For example:

{
  "kind": "rtmdet",
  "task": "segmentation",
  "classes": ["tomato", "leaf"],
  "confidenceThreshold": 0.25,
  "iouThreshold": 0.7
}

Use kind in ONNX sidecars as well. Move model-family values such as "backend": "rtmdet" to "kind": "rtmdet". Decoder selection follows kind and task; model_type overrides are no longer needed in pipeline parameters. A pipeline's explicit kind takes precedence over the sidecar.

License

This project is licensed under the MIT License.

Metadata

Release files for abraia 0.28.2

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

Source distribution (sdist)

Source distribution for abraia 0.28.2
File Size Uploaded Provenance Actions
abraia-0.28.2.tar.gz 223.7 kB Without provenance Details for abraia-0.28.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for abraia 0.28.2
File Interpreter ABI Platform Actions
abraia-0.28.2-py3-none-any.whl Python 3 none any Details for abraia-0.28.2-py3-none-any.whl

Total release size: 427.1 kB

Release files / abraia-0.28.2.tar.gz

Download URL abraia-0.28.2.tar.gz
Size 223.7 kB
Tags Source
SHA-256 checksum
How to use checksums
531e68a729362dc7df8757f7b9a8a23975c3579ca02eda445b99a9ce032421d4
BLAKE2b-256 checksum
How to use checksums
8b8124dcd31c8d74a1b81952f12a7e4cffd1b9f60bbf5f18c1a600e407795ca1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / abraia-0.28.2-py3-none-any.whl

Download URL abraia-0.28.2-py3-none-any.whl
Size 203.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2dbaca25cb91421331754963be9d33c93bb03c4ae17e57fc485815c38f74ed7d
BLAKE2b-256 checksum
How to use checksums
1143fd074965ee27d1c282a1e10ae64b471a04f85e32a7486e9bc981c762f7c4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for abraia 0.28.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.28.2 This release

2 release files No provenance

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