Add RTMLib CUDA backends and staged timing
This commit is contained in:
@@ -26,22 +26,28 @@ def run_offline_benchmark(models, threshold: float, max_people: int) -> None:
|
||||
one = cv2.imdecode(encoded, cv2.IMREAD_COLOR)
|
||||
if one is None:
|
||||
raise RuntimeError("official demo image decode failed")
|
||||
images = {1: one, 2: np.concatenate([one, one], axis=1),
|
||||
images = {0: np.zeros_like(one), 1: one, 2: np.concatenate([one, one], axis=1),
|
||||
4: np.concatenate([np.concatenate([one, one], axis=1)] * 2, axis=0)}
|
||||
for _ in range(50):
|
||||
for _ in range(100):
|
||||
models.infer(one, threshold, max_people)
|
||||
report = {"source_url": DEMO_URL, "warmup_iterations": 50, "measured_iterations": 60,
|
||||
report = {"source_url": DEMO_URL, "warmup_iterations": 100, "measured_iterations": 300,
|
||||
"image_retained": False, "profiles": {}}
|
||||
for requested, image in images.items():
|
||||
samples = []; counts = []
|
||||
for _ in range(60):
|
||||
samples = []; counts = []; stages = {}
|
||||
for _ in range(300):
|
||||
started = time.perf_counter_ns()
|
||||
people, det_ms, pose_ms = models.infer(image, threshold, max_people)
|
||||
people, timing = models.infer(image, threshold, max_people)
|
||||
samples.append((time.perf_counter_ns() - started) / 1e6); counts.append(len(people))
|
||||
for name, value in timing.items():
|
||||
stages.setdefault(name, []).append(value)
|
||||
report["profiles"][str(requested)] = {
|
||||
"requested_people": requested, "detected_people_min": min(counts), "detected_people_max": max(counts),
|
||||
"p50_ms": round(percentile(samples, .50), 3), "p95_ms": round(percentile(samples, .95), 3),
|
||||
"p99_ms": round(percentile(samples, .99), 3), "fps_from_p50": round(1000 / percentile(samples, .50), 3)}
|
||||
"p99_ms": round(percentile(samples, .99), 3), "fps_from_p50": round(1000 / percentile(samples, .50), 3),
|
||||
"stages": {name: {"p50_ms": round(percentile(vals, .50), 3),
|
||||
"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)
|
||||
except Exception as exc:
|
||||
|
||||
Reference in New Issue
Block a user