Official Python SDK for the Perceptra Hub Computer Vision MLOps platform
Project description
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
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
perceptra-1.1.0.tar.gz
(17.4 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
perceptra-1.1.0-py3-none-any.whl
(31.3 kB
view details)
File details
Details for the file perceptra-1.1.0.tar.gz.
File metadata
- Download URL: perceptra-1.1.0.tar.gz
- Upload date:
- Size: 17.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0cab7eccd72cc2bb6b2ddf17da6184b9cedc2b027cc764fd946c7b0055dd679d
|
|
| MD5 |
ee8e8d121953cc8629f975ed253635b4
|
|
| BLAKE2b-256 |
277cb7af0a7e194dee6bdfab11c71032a29be5edcaf5332822f078759d6beefa
|
File details
Details for the file perceptra-1.1.0-py3-none-any.whl.
File metadata
- Download URL: perceptra-1.1.0-py3-none-any.whl
- Upload date:
- Size: 31.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e251eed935be946de525975b8b92b2873068ca61da4306c72029ff312f612584
|
|
| MD5 |
449d593156c34b39b77e63f6221c2afc
|
|
| BLAKE2b-256 |
754f7b0744d2987191f240fc66b732fed84767f18baeae29a63e6affb4626780
|