Saving results
Capture inference outputs as structured data or images so you can reuse them in downstream tools, dashboards, or datasets.
Save structured detections as JSON
Example
from pathlib import Path
import json
from degirum_tools import ModelSpec, remote_assets
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"]},
)
model = model_spec.load_model()
result = model(remote_assets.three_persons)
output_dir = Path("saved-results")
output_dir.mkdir(parents=True, exist_ok=True)
def detection_to_dict(det):
return {
"label": det.get("label"),
"score": float(det.get("score", 0)),
"bbox": [float(x) for x in det.get("bbox", [])],
"category_id": det.get("category_id"),
}
json_path = output_dir / "three-persons.json"
with json_path.open("w", encoding="utf-8") as f:
json.dump([detection_to_dict(det) for det in result.results], f, indent=2)
print(f"Wrote {json_path}")Export detections as CSV
Example
Save overlay images
Example
Batch saves with predict_dir
Example
Last updated
Was this helpful?

