Spaces:
Runtime error
Runtime error
Commit History
-
fix(deploy): align INFERENCE_SIZE with the baked ONNX graph
The VPS deploy crashed inside lifespan with RuntimeError: Got invalid dimensions for input: images index: 2 Got: 960 Expected: 640 because the .env.vps overlay declared INFERENCE_SIZE=768 while the Dockerfile bakes the ONNX graph at YOLO_EXPORT_IMGSZ=640. ONNX exports write a STATIC input shape into the .onnx file, so the runtime imgsz must equal the baked shape verbatim — onnxruntime cannot rescale at inference. Two changes so this can not happen silently again: 1. .env.vps sets INFERENCE_SIZE=640 and explains the constraint in a comment. To raise inference resolution, the image has to be rebuilt with --build-arg YOLO_EXPORT_IMGSZ=<N> AND the profile value updated to N. The two are now visibly coupled. 2. Detector now introspects the ONNX session's input shape at construction and raises a self-explanatory RuntimeError before warmup if the runtime imgsz disagrees with the baked one. Dynamic shapes (symbolic dims) are skipped — they tolerate any …9756463 -
feat(deploy): HF Spaces / CPU production stack
Stack the changes required to ship cakra to a CPU-only host (HF Spaces basic, generic VPS without GPU) cleanly: • app/config.py — profile loader. CAKRA_PROFILE=<name> (set in shell *or* in .env itself) loads `.env.<name>` after the base .env and overrides matching keys. The HF Spaces overlay is auto-applied when the runtime is detected via SPACE_ID, so a Space deploy needs no extra config beyond the secret list. • .env.hfspace — committed overlay tuning HF basic's shared 2 vCPU: INFERENCE_SIZE=640, TARGET_INFER_FPS=3, FRAME_SKIP=2, output 854x480, MAX_STREAMS=1, MODEL_PATH=./models/yolo-world-id.onnx. No secrets in the file — DATABASE_URL stays in .env or the Space Secrets UI. • app/main.py — boot log surfaces the active profile + the resource knobs so HF and local-simulation runs are auditable in one log line. • app/services/detector.py — dispatch backend by MODEL_PATH suffix (.pt → pytorch, .onnx → onnx, .xml → openvino, .engine…ed450db
-
feat: real-time CCTV YOLO analytics with bbox-baked HLS
Per-camera worker decoupled into four stages: - capture (StreamReader): decodes upstream HLS, tags frames with capture timestamp, pushes to a bounded ring (drop-oldest) - pace: monotonic-clock thread ticks at HLS_FPS, pops the next frame from the ring, annotates with the detection that was current at that capture time (bbox stays glued to the visible frame even with ring delay) - encode: ffmpeg in true CFR (-r N -fps_mode cfr), libx264 or videotoolbox; segments split on exact second boundaries - inference: YOLO + ByteTrack on its own thread at TARGET_INFER_FPS; never blocks the capture / pace / encode chain Detection coords scaled from source space (e.g. 1920x1080) to output space (e.g. 1280x720) before annotation. Persistent state in a single cctv_session_metrics row per camera (UPSERT each tick, started_at frozen across reconnects). Realtime WS pushes analytics + geo-tagged detections with per-camera coverage polygon. Embed-ready: any client drops <video src=playlist.m3u…40e0b51