diff --git a/app.py b/app.py index b6f9bee..bde8d83 100644 --- a/app.py +++ b/app.py @@ -64,11 +64,14 @@ async def detect(websocket: WebSocket): boxes = [] for r in model.track(frame, stream=False, persist=True): for box in r.boxes: + track_id = None + if hasattr(box, "id") and box.id is not None: + track_id = box.id.item() box_cpu = box.cpu() boxes.append({ "class": model.names[int(box_cpu.cls[0])], "confidence": float(box_cpu.conf[0]), - "id": box_cpu.id, + "id": track_id, }) # Broadcast to all subscribers of this URL detection_data = {