diff --git a/.jules/bolt.md b/.jules/bolt.md new file mode 100644 index 0000000..d8bc73c --- /dev/null +++ b/.jules/bolt.md @@ -0,0 +1,3 @@ +## 2024-05-24 - Ultralytics YOLO verbose Output Blocking +**Learning:** For performance optimization with Ultralytics YOLO models, `model.predict()` can have significant synchronous stdout blocking overhead during loops. +**Action:** Pass `verbose=False` to `model.predict()` to avoid synchronous stdout blocking overhead when processing multiple items or looping. diff --git a/commonforms/inference.py b/commonforms/inference.py index 527925f..d4741dd 100644 --- a/commonforms/inference.py +++ b/commonforms/inference.py @@ -117,6 +117,7 @@ def extract_widgets( """ if self.fast: # ONNX models are compiled with a fixed input size + # ⚡ Bolt optimization: pass verbose=False to avoid synchronous stdout blocking overhead results = [ self.model.predict( p.image, @@ -124,10 +125,12 @@ def extract_widgets( conf=confidence, augment=False, imgsz=ONNX_IMAGE_SIZE, + verbose=False, ) for p in pages ] else: + # ⚡ Bolt optimization: pass verbose=False to avoid synchronous stdout blocking overhead results = self.model.predict( [p.image for p in pages], iou=DEFAULT_IOU_THRESHOLD, @@ -135,6 +138,7 @@ def extract_widgets( augment=True, imgsz=image_size, device=self.device, + verbose=False, ) widgets = {}