From 02e4e984a1cc3e89d305410617db02590c20a83b Mon Sep 17 00:00:00 2001 From: Mohammed Yasin <32206511+Y-T-G@users.noreply.github.com> Date: Thu, 9 Jan 2025 17:29:17 +0800 Subject: [PATCH] Verify dataset >= batch size on INT8 export calibration (#18611) Signed-off-by: Mohammed Yasin <32206511+Y-T-G@users.noreply.github.com> Co-authored-by: UltralyticsAssistant Co-authored-by: Glenn Jocher --- ultralytics/engine/exporter.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ultralytics/engine/exporter.py b/ultralytics/engine/exporter.py index 0b89cfe0..7747b99f 100644 --- a/ultralytics/engine/exporter.py +++ b/ultralytics/engine/exporter.py @@ -452,7 +452,11 @@ class Exporter: batch_size=batch, ) n = len(dataset) - if n < 300: + if n < self.args.batch: + raise ValueError( + f"The calibration dataset ({n} images) must have at least as many images as the batch size ('batch={self.args.batch}')." + ) + elif n < 300: LOGGER.warning(f"{prefix} WARNING ⚠️ >300 images recommended for INT8 calibration, found {n} images.") return build_dataloader(dataset, batch=batch, workers=0) # required for batch loading