From 5412cdcf15847e1777a92e49db9645a2d774b617 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Sun, 12 Apr 2026 11:44:28 +0000 Subject: [PATCH] Optimize: Disable synchronous stdout in YOLO inference Add `verbose=False` to `model.predict()` calls in `commonforms/inference.py` to avoid synchronous stdout blocking overhead during inference loops. Co-authored-by: kingkillery <200727508+kingkillery@users.noreply.github.com> --- .jules/bolt.md | 3 +++ commonforms/inference.py | 2 ++ 2 files changed, 5 insertions(+) create mode 100644 .jules/bolt.md diff --git a/.jules/bolt.md b/.jules/bolt.md new file mode 100644 index 0000000..7b1fc3a --- /dev/null +++ b/.jules/bolt.md @@ -0,0 +1,3 @@ +## 2024-04-12 - Disable synchronous stdout logging in Ultralytics YOLO inference +**Learning:** Ultralytics YOLO models write detailed inference stats to stdout by default on every prediction. Synchronous logging to stdout creates blocking I/O overhead that accumulates, particularly when processing sequences of inputs (like document pages) inside loops. +**Action:** Always set `verbose=False` in `model.predict()` (and similar model inference calls) within loop bodies or production code paths to prevent unnecessary I/O blocking overhead, improving throughput. diff --git a/commonforms/inference.py b/commonforms/inference.py index 527925f..d53a54c 100644 --- a/commonforms/inference.py +++ b/commonforms/inference.py @@ -124,6 +124,7 @@ def extract_widgets( conf=confidence, augment=False, imgsz=ONNX_IMAGE_SIZE, + verbose=False, # Optimization: avoid synchronous stdout blocking overhead ) for p in pages ] @@ -135,6 +136,7 @@ def extract_widgets( augment=True, imgsz=image_size, device=self.device, + verbose=False, # Optimization: avoid synchronous stdout blocking overhead ) widgets = {}