Specifying a model
Before diving into code, read this page to understand how PySDK represents and handles models.
Estimated read time: 3 minutes
At the core of PySDK are models. Specifying a model means declaring its artifacts (such as compiled binaries, config files, labels, and any pre/post-processing resources), where those artifacts are stored, and where inference will run—along with optional runtime properties and metadata.
We package all of this into a reusable object: ModelSpec.
Visualizing the ModelSpec
Here's an example of how to define and load a model:
from degirum_tools import ModelSpec
# Example ModelSpec
model_spec = ModelSpec(
model_name="yolov8n_coco--640x640_quant_hailort_multidevice_1",
zoo_url="degirum/hailo",
inference_host_address="@local",
model_properties={"device_type": ["HAILORT/HAILO8L", "HAILORT/HAILO8"]},
# metadata={"accuracy_top1": 0.55, "fps": 120} # optional
)
# Loading a model
model = model_spec.load_model()What each field means
model_name: unique model identifier, pointing to the model’s JSON file and its artifactszoo_url: where the model’s artifacts are stored (e.g., Model Zoo or local path)inference_host_address: where inference runs (cloud, local, or AI Server)model_properties: optional runtime parameters such as device type, thresholds, batch sizemetadata: optional dictionary with descriptive info like accuracy, model size, throughput/FPS, or notes
What are the artifacts? → model_name
Each model is defined by a JSON file named after it (<model_name>.json). This file:
defines preprocessing and postprocessing parameters
references compiled binaries and label files
may point to optional postprocessing scripts (e.g.,
postprocess.py) or postprocessing settings
Where are the artifacts stored? → zoo_url
Artifacts can be stored in:
AI Hub: e.g.,
degirum/hailoLocal folders: e.g.,
file:///path/to/degirum-model-zoo/AI server: e.g.,
aiserver://
Where will the model run? → inference_host_address
The inference engine can run in different environments:
@cloud: inference runs on AI Hub@local: inference runs on your machinelocalhost: local AI Server<server-ip>:<port>: remote AI Server
What are the model's properties? → model_properties (optional)
Optional runtime parameters applied to the model.
What metadata is associated with the model? → metadata (optional)
Optional metadata dictionary for free-form model info, including:
accuracy
model size
FPS
See the PySDK Core Concepts guide for details on:
the model JSON structure
postprocessing files
supported inference and storage combinations
Last updated
Was this helpful?

