Skip to content

armgit / cua

Public Imported from GitHub
0

Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.

included detection bboxes in label collision check

Dillon DuPont1e7d6795060a
diff --git a/libs/som/som/visualization.py b/libs/som/som/visualization.py
index 4212379c36..5c270c2825 100644
--- a/libs/som/som/visualization.py
+++ b/libs/som/som/visualization.py
@@ -112,10 +112,18 @@ class BoxAnnotator:
# Keep track of used label areas to check for collisions
used_areas = []
- # Store label information for second pass
+ # Store label information for third pass
labels_to_draw = []
- # First pass: Draw all bounding boxes
+ # First pass: Initialize used_areas with all bounding boxes
+ for detection in detections:
+ box = detection["bbox"]
+ x1, y1, x2, y2 = [
+ int(coord * dim) for coord, dim in zip(box, [image.width, image.height] * 2)
+ ]
+ used_areas.append((x1, y1, x2, y2))
+
+ # Second pass: Draw all bounding boxes
for idx, detection in enumerate(detections, 1):
# Get box coordinates
box = detection["bbox"]
@@ -233,7 +241,7 @@ class BoxAnnotator:
}
)
- # Second pass: Draw all labels on top
+ # Third pass: Draw all labels on top
for label_info in labels_to_draw:
# Draw background box with white outline
draw.rectangle(