From d77e45668502ddbb85d6b205ab165ca8b8200998 Mon Sep 17 00:00:00 2001 From: Codex Date: Sat, 15 Aug 2026 11:19:48 -0700 Subject: [PATCH] Run RTMLib benchmark outside production startup --- .../unraid/tail2-pose-server/app/tail2/ndi.py | 1 + .../app/tail2/offline_benchmark.py | 9 ++++-- servers/unraid/tail2-pose-server/compose.yaml | 32 +++++++++++++++++++ 3 files changed, 39 insertions(+), 3 deletions(-) diff --git a/servers/unraid/tail2-pose-server/app/tail2/ndi.py b/servers/unraid/tail2-pose-server/app/tail2/ndi.py index 92a38ac..bbacf3d 100644 --- a/servers/unraid/tail2-pose-server/app/tail2/ndi.py +++ b/servers/unraid/tail2-pose-server/app/tail2/ndi.py @@ -65,6 +65,7 @@ class NDIReceiver(threading.Thread): if self.source_name in names: source = finder.get_source(self.source_name) break + time.sleep(0.05) if source is None: raise RuntimeError(f"configured NDI source not discovered; last_sources={names}") receiver = Receiver(color_format=RecvColorFormat.BGRX_BGRA, diff --git a/servers/unraid/tail2-pose-server/app/tail2/offline_benchmark.py b/servers/unraid/tail2-pose-server/app/tail2/offline_benchmark.py index 0de2ccc..ef72585 100644 --- a/servers/unraid/tail2-pose-server/app/tail2/offline_benchmark.py +++ b/servers/unraid/tail2-pose-server/app/tail2/offline_benchmark.py @@ -18,7 +18,7 @@ def percentile(values: list[float], p: float) -> float: def run_offline_benchmark(models, threshold: float, max_people: int) -> None: - path = "/logs/offline-benchmark-" + os.getenv("BENCHMARK_PROFILE", "unknown") + ".json" + path = os.getenv("BENCHMARK_OUTPUT", "/logs/offline-benchmark-" + os.getenv("BENCHMARK_PROFILE", "unknown") + ".json") if os.path.exists(path): return try: @@ -48,9 +48,12 @@ def run_offline_benchmark(models, threshold: float, max_people: int) -> None: "p95_ms": round(percentile(vals, .95), 3), "p99_ms": round(percentile(vals, .99), 3)} for name, vals in stages.items()}} - with open(path, "x", encoding="utf-8") as fh: - json.dump(report, fh, indent=2) + with open(path, "w", encoding="utf-8") as fh: + json.dump(report, fh, indent=2) + print(f"benchmark profile people={requested} complete", flush=True) + os.chmod(path, 0o666) except Exception as exc: with open(path, "w", encoding="utf-8") as fh: json.dump({"error": f"{type(exc).__name__}: {str(exc)[:240]}", "source_url": DEMO_URL, "image_retained": False}, fh, indent=2) + os.chmod(path, 0o666) diff --git a/servers/unraid/tail2-pose-server/compose.yaml b/servers/unraid/tail2-pose-server/compose.yaml index cac1829..2a5544c 100644 --- a/servers/unraid/tail2-pose-server/compose.yaml +++ b/servers/unraid/tail2-pose-server/compose.yaml @@ -166,6 +166,38 @@ services: } > "$$out/process-map.csv" chmod -R a+rX,u+w "$$out" + benchmark-rtmlib-body: + image: tail2-pose-server:0.1.0 + container_name: tail2-pose-benchmark-rtmlib-body + gpus: all + restart: "no" + entrypoint: ["/bin/bash", "-lc"] + depends_on: + models: + condition: service_completed_successfully + volumes: + - /mnt/user/appdata/tail2-pose-server/app:/app:ro + - /mnt/user/appdata/tail2-pose-server/models:/models:ro + - ./validation:/validation + environment: + PYTHONPATH: /app + CUDA_VISIBLE_DEVICES: "1" + MODEL_BACKEND: rtmlib_body + BENCHMARK_PROFILE: rtmlib_body_yolox-m_rtmpose-m_gpu1_threads2 + BENCHMARK_OUTPUT: /validation/benchmark-rtmlib-body.json + DETECTION_THRESHOLD: "0.35" + NMS_IOU_THRESHOLD: "0.60" + MAX_PEOPLE: "4" + DET_CHECKPOINT: /models/yolox-m-humanart.onnx + POSE_CHECKPOINT: /models/rtmpose-m-body17.onnx + OMP_NUM_THREADS: "2" + MKL_NUM_THREADS: "2" + OPENBLAS_NUM_THREADS: "2" + CV2_NUM_THREADS: "2" + command: + - | + python -c 'from tail2.models import Models; from tail2.offline_benchmark import run_offline_benchmark; m=Models(); m.load(); run_offline_benchmark(m, .35, 4)' + validate: profiles: ["validation"] image: tail2-pose-server:0.1.0