diff --git a/.jules/bolt.md b/.jules/bolt.md new file mode 100644 index 0000000..4d11bf5 --- /dev/null +++ b/.jules/bolt.md @@ -0,0 +1,3 @@ +## 2024-05-24 - Ultralytics YOLO Synchronous Logging Overhead +**Learning:** Calling `model.predict()` in Ultralytics YOLO with the default settings causes synchronous stdout writes that can introduce blocking overhead, especially when called inside loops or handling multiple items. +**Action:** Always explicitly pass `verbose=False` to `model.predict()` unless debugging output is actively required. This prevents unnecessary I/O overhead. diff --git a/commonforms/inference.py b/commonforms/inference.py index 527925f..1f2b1f6 100644 --- a/commonforms/inference.py +++ b/commonforms/inference.py @@ -124,6 +124,8 @@ def extract_widgets( conf=confidence, augment=False, imgsz=ONNX_IMAGE_SIZE, + # Disable verbose to prevent synchronous stdout blocking overhead + verbose=False, ) for p in pages ] @@ -135,6 +137,8 @@ def extract_widgets( augment=True, imgsz=image_size, device=self.device, + # Disable verbose to prevent synchronous stdout blocking overhead + verbose=False, ) widgets = {} diff --git a/plan.md b/plan.md new file mode 100644 index 0000000..b21c169 --- /dev/null +++ b/plan.md @@ -0,0 +1,9 @@ +1. **Optimize YOLO `model.predict` in `commonforms/inference.py`** + - Pass `verbose=False` to `self.model.predict()` in both the fast-mode loop and the batch-mode call. This prevents synchronous stdout blocking overhead when processing many pages, making the inference step measurably faster. + - Add a comment explaining the optimization. +2. **Add a journal entry in `.jules/bolt.md`** + - Create/update `.jules/bolt.md` recording the performance bottleneck caused by Ultralytics YOLO synchronous stdout blocking overhead. +3. **Pre-commit checks** + - Complete pre-commit steps to ensure proper testing, verification, review, and reflection are done. +4. **Submit** + - Create a PR with title `⚡ Bolt: [performance improvement]` and the required description format.