Streaming results
Stream inference outputs in real time to displays, message buses, or remote services using PySDK result objects.
Estimated read time: 3 minutes
Streaming keeps inference responsive for dashboards, alerts, and downstream analytics. This page shows how to iterate over streaming APIs, publish lightweight payloads, and monitor latency. Each section includes its own setup so you can copy and run examples independently.
Display a live overlay loop
Use predict_stream for camera feeds, RTSP streams, or looping video files. Each iteration yields an InferenceResults object.
Example
from degirum_tools import ModelSpec, Display, predict_stream, 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()
video_source = remote_assets.traffic # swap in a webcam index or RTSP URL
max_frames = 120 # stop after this many frames for demos
with Display("AI Camera — Live stream") as output_display:
for index, result in enumerate(predict_stream(model, video_source), start=1):
output_display.show(result.image_overlay)
print(f"Rendered frame {index}")
if index >= max_frames:
breakExample output:
Publish lightweight payloads
Structured results serialize well to JSON once you convert NumPy types. Package only the fields you need before sending them across the network.
Example
Example output:
Monitor latency and throughput
Use result.timing to inspect per-frame preprocessing, inference, and postprocessing times. Enable timing in the model specification if needed.
Example
Example output:
Last updated
Was this helpful?

