From 299797ff9eb5b191481e04c1d4a0076927810b6c Mon Sep 17 00:00:00 2001 From: Markham Lee Date: Sun, 5 May 2024 06:03:07 -0700 Subject: [PATCH] Quality of life changes for Benchmarking script (#11216) Co-authored-by: UltralyticsAssistant Co-authored-by: Glenn Jocher --- .gitignore | 4 ++++ ultralytics/utils/benchmarks.py | 7 ++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 0854267a..42eccd65 100644 --- a/.gitignore +++ b/.gitignore @@ -160,7 +160,11 @@ weights/ *_web_model/ *_openvino_model/ *_paddle_model/ +*_ncnn_model/ pnnx* # Autogenerated files for tests /ultralytics/assets/ + +# calibration image +calibration_*.npy diff --git a/ultralytics/utils/benchmarks.py b/ultralytics/utils/benchmarks.py index 4ea89322..6bd8207f 100644 --- a/ultralytics/utils/benchmarks.py +++ b/ultralytics/utils/benchmarks.py @@ -132,16 +132,17 @@ def benchmark( data=data, batch=1, imgsz=imgsz, plots=False, device=device, half=half, int8=int8, verbose=False ) metric, speed = results.results_dict[key], results.speed["inference"] - y.append([name, "✅", round(file_size(filename), 1), round(metric, 4), round(speed, 2)]) + fps = round((1000 / speed), 2) # frames per second + y.append([name, "✅", round(file_size(filename), 1), round(metric, 4), round(speed, 2), fps]) except Exception as e: if verbose: assert type(e) is AssertionError, f"Benchmark failure for {name}: {e}" LOGGER.warning(f"ERROR ❌️ Benchmark failure for {name}: {e}") - y.append([name, emoji, round(file_size(filename), 1), None, None]) # mAP, t_inference + y.append([name, emoji, round(file_size(filename), 1), None, None, None]) # mAP, t_inference # Print results check_yolo(device=device) # print system info - df = pd.DataFrame(y, columns=["Format", "Status❔", "Size (MB)", key, "Inference time (ms/im)"]) + df = pd.DataFrame(y, columns=["Format", "Status❔", "Size (MB)", key, "Inference time (ms/im)", "FPS"]) name = Path(model.ckpt_path).name s = f"\nBenchmarks complete for {name} on {data} at imgsz={imgsz} ({time.time() - t0:.2f}s)\n{df}\n"