Skip to main content

Perceptra Python SDK

Official Python SDK for the Perceptra Hub Computer Vision MLOps platform.

Installation

pip install perceptra

Quick Start

import perceptra

# Initialize with your API key
client = perceptra.Perceptra(api_key="ph_live_abc123...")

# Or set PERCEPTRA_API_KEY environment variable
client = perceptra.Perceptra()

# Create a project
project = client.projects.create(
    name="Hard Hat Detection",
    project_type_id=1,
)

# Upload images
from pathlib import Path
for path in Path("./images").glob("*.jpg"):
    client.images.upload(file=path, project_id=project.project_id)

# Add annotations
client.annotations.create(
    project_id=project.project_id,
    image_id="...",
    annotation_type="bbox",
    annotation_class_id=0,
    data=[0.1, 0.2, 0.5, 0.8],
)

# Split dataset
client.projects.split_dataset(project.project_id, 0.7, 0.2, 0.1)

# Create a dataset version
version = client.versions.create(project.project_id, "v1.0")

# Create and train a model
model = client.models.create(
    project_id=project.project_id,
    name="YOLOv8 Hard Hat",
    task="object-detection",
    framework="yolo",
)

result = client.models.train(
    model_id=model.id,
    dataset_version_id=version.id,
    config={"epochs": 100, "batch_size": 16},
)

# Stream training logs
for line in client.training.stream_logs(result.training_session_id):
    print(line, end="")

Async Support

import asyncio
import perceptra

async def main():
    async with perceptra.AsyncPerceptra(api_key="ph_live_abc123...") as client:
        projects = await client.projects.list()
        for p in projects:
            print(p["name"])

asyncio.run(main())

Error Handling

from perceptra import NotFoundError, RateLimitError, AuthenticationError

try:
    project = client.projects.retrieve("nonexistent-id")
except NotFoundError:
    print("Project not found")
except RateLimitError as e:
    print(f"Rate limited. Retry after {e.retry_after}s")
except AuthenticationError:
    print("Invalid API key")

Available Resources

Resource Description
client.projects Project CRUD, image management, dataset splitting
client.images Image upload, listing, bulk operations
client.annotations Annotation CRUD, batch operations
client.models ML model CRUD, training triggers
client.training Training session monitoring, log streaming
client.versions Dataset version management, export
client.organizations Organization details, members
client.jobs Annotation job management
client.classes Annotation class management
client.tags Image tag management
client.api_keys API key management, rotation
client.storage Storage profile management

Configuration

Parameter Default Environment Variable
api_key — PERCEPTRA_API_KEY
base_url http://localhost:29082 PERCEPTRA_BASE_URL
timeout 30.0 —
max_retries 3 —

License

MIT

Metadata

Release files for perceptra 1.1.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 perceptra 1.1.0
File Size Uploaded
perceptra-1.1.0.tar.gz 17.4 kB Details

Built distribution (wheel)

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

Total release size: 48.7 kB

Release files / perceptra-1.1.0.tar.gz

Download URL perceptra-1.1.0.tar.gz
Size 17.4 kB
Tags Source
SHA-256 checksum
How to use checksums
0cab7eccd72cc2bb6b2ddf17da6184b9cedc2b027cc764fd946c7b0055dd679d
BLAKE2b-256 checksum
How to use checksums
277cb7af0a7e194dee6bdfab11c71032a29be5edcaf5332822f078759d6beefa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release files / perceptra-1.1.0-py3-none-any.whl

Download URL perceptra-1.1.0-py3-none-any.whl
Size 31.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e251eed935be946de525975b8b92b2873068ca61da4306c72029ff312f612584
BLAKE2b-256 checksum
How to use checksums
754f7b0744d2987191f240fc66b732fed84767f18baeae29a63e6affb4626780
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files

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