From e73bd95677816149b4bd21c940beb17f846a3d4f Mon Sep 17 00:00:00 2001 From: Siwat Sirichai Date: Tue, 14 Jan 2025 23:35:51 +0700 Subject: [PATCH] tensor conversion --- app.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 = {