Client SDK for connecting Colab or local YOLO training runs to VisionHub AI.
Project description
visionhub-client
Python SDK de ket noi Google Colab hoac may local ve VisionHub AI trong luc train model computer vision. Thu vien nay duoc viet moi theo dac ta chuc nang, khong copy source code, endpoint rieng, logo hay tai san cua Ultralytics HUB/hub-sdk.
Install
pip install -U visionhub-client
Neu train YOLO bang Ultralytics:
pip install -U "visionhub-client[yolo]"
Trong repo nay co the cai local:
pip install -e ./visionhub-client
Google Colab quickstart
!pip install -U visionhub-client ultralytics
from visionhub_client import VisionHubClient
from ultralytics import YOLO
client = VisionHubClient(
api_url="https://hub.example.com",
job_id="job_123",
token="vhc_xxxxx",
)
client.connect()
client.start_heartbeat(interval=30)
dataset_yaml = client.download_dataset()
config = client.get_training_config()
checkpoint = client.download_latest_checkpoint()
model = YOLO(checkpoint or config["base_model"])
client.attach_ultralytics_callbacks(model)
model.train(
data=dataset_yaml,
epochs=config["epochs"],
imgsz=config["imgsz"],
batch=config["batch"],
optimizer=config.get("optimizer", "auto"),
lr0=config.get("lr0", 0.01),
patience=config.get("patience", 50),
resume=bool(checkpoint),
)
client.upload_final_model()
client.finish()
Env-based usage
export VISIONHUB_API_URL="https://hub.example.com"
export VISIONHUB_JOB_ID="job_123"
export VISIONHUB_TOKEN="vhc_xxxxx"
export VISIONHUB_RUNTIME_ID="runtime_456"
from visionhub_client import VisionHubClient
client = VisionHubClient.from_env()
client.connect()
client.prepare()
client.train_yolo()
client.finish()
Resume from a specific checkpoint
from visionhub_client import VisionHubClient
from ultralytics import YOLO
client = VisionHubClient.from_env()
client.connect()
checkpoint_path = client.download_checkpoint("ckpt_abc123")
config = client.get_training_config()
model = YOLO(checkpoint_path)
client.attach_ultralytics_callbacks(model)
model.train(
data=client.download_dataset(),
epochs=config["epochs"],
imgsz=config["imgsz"],
batch=config["batch"],
resume=True,
)
client.finish()
Mock training
Dung de test Hub UI khi chua co Colab/training that:
from visionhub_client import VisionHubClient
client = VisionHubClient(
api_url="http://localhost:4010",
job_id="job-colab-traffic",
token="dev-token",
)
client.simulate_training(
epochs=20,
disconnect_at_epoch=8,
checkpoint_every_epoch=True,
)
CLI
visionhub connect --api-url http://localhost:4010 --job-id job-colab-traffic --token dev-token
visionhub heartbeat --api-url http://localhost:4010 --job-id job-colab-traffic --token dev-token
visionhub download-dataset --api-url http://localhost:4010 --job-id job-colab-traffic --token dev-token
visionhub download-checkpoint --api-url http://localhost:4010 --job-id job-colab-traffic --token dev-token
visionhub upload-checkpoint --api-url http://localhost:4010 --job-id job-colab-traffic --token dev-token --file last.pt --epoch 10
visionhub train-yolo --api-url http://localhost:4010 --job-id job-colab-traffic --token dev-token --simulate --epochs 5
API endpoints used
POST /api/colab/connectPOST /api/colab/heartbeatPOST /api/colab/disconnectPOST /api/colab/finishPOST /api/colab/failPOST /api/colab/statusGET /api/colab/jobs/:jobId/configGET /api/colab/jobs/:jobId/datasetGET /api/colab/jobs/:jobId/base-modelGET /api/colab/jobs/:jobId/checkpoints/latestGET /api/colab/jobs/:jobId/checkpoints/:checkpointId/downloadPOST /api/colab/jobs/:jobId/logsPOST /api/colab/jobs/:jobId/metricsPOST /api/colab/jobs/:jobId/system-metricsPOST /api/colab/jobs/:jobId/checkpoints/init-uploadPUT /api/colab/jobs/:jobId/checkpoints/:checkpointId/chunks/:chunkIndexPOST /api/colab/jobs/:jobId/checkpoints/:checkpointId/completePOST /api/colab/jobs/:jobId/checkpoints/:checkpointId/abort
Security notes
- Do not use user passwords in Colab.
- Use job-scoped tokens with narrow permissions.
- Tokens are sent as
Authorization: Bearer <token>. - The SDK masks tokens in summaries and never logs the full token intentionally.
- Checkpoints become usable only after the server verifies checksum.
- Metric/log upload failures are buffered and should not stop training.
Local state
The SDK writes local state under /content/visionhub/state/{job_id}.json in Colab, or .visionhub/state/{job_id}.json locally. This helps resume or debug interrupted sessions.
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
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
File details
Details for the file visionhub_client-0.1.0.tar.gz.
File metadata
- Download URL: visionhub_client-0.1.0.tar.gz
- Upload date:
- Size: 18.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f1cea906f9b5d1ede563c730c4a6ee088c741eea6b02e343828770194d3583e7
|
|
| MD5 |
6d1b93627664e7cc4b93a0d3d2d06288
|
|
| BLAKE2b-256 |
bcee0bf0c41c1e40893cf804720a85bc87e1443cebcc2a9f81775a66881aa3a4
|
File details
Details for the file visionhub_client-0.1.0-py3-none-any.whl.
File metadata
- Download URL: visionhub_client-0.1.0-py3-none-any.whl
- Upload date:
- Size: 21.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
371c3d4ac51ac397e46874a7960155cdea9bd0fac825bfbe1a35b90e1267bd45
|
|
| MD5 |
bd9aba20a023484533ee91322c74170e
|
|
| BLAKE2b-256 |
3fa10f935e4c59e79191e8a16941c07f91183efb5cc2b7d8c89ea48b248cd8e0
|