Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .jules/bolt.md
Original file line number Diff line number Diff line change
@@ -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.
4 changes: 4 additions & 0 deletions commonforms/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,24 +117,28 @@ 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,
iou=FAST_MODE_IOU_THRESHOLD,
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,
conf=confidence,
augment=True,
imgsz=image_size,
device=self.device,
verbose=False,
)

widgets = {}
Expand Down