You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -64,7 +72,7 @@ Returns a 3-tuple: `tuple[PipelineResult, Image.Image, str]`
64
72
|`FileNotFoundError`| The input image does not exist, or the Swift Vision tool cannot be found. |
65
73
|`RuntimeError`| The Apple Vision subprocess fails (e.g., not on macOS, corrupt image). |
66
74
67
-
Exceptions from Florence-2 model loading (network errors, missing dependencies) propagate directly from `mlx_vlm`.
75
+
When `use_yolo=True`, a `FileNotFoundError` is raised if the YOLO model weights are not found. An `ImportError` propagates if `ultralytics` is not installed (`pip install uitag[yolo]`). Florence-2 exceptions propagate from `mlx_vlm`.
68
76
69
77
### Example
70
78
@@ -95,22 +103,24 @@ A single detected UI element. Defined as a dataclass in `uitag/types.py`.
95
103
96
104
| Field | Type | Description |
97
105
|-------|------|-------------|
98
-
|`label`|`str`| Element label -- text content (for Vision text) or detection class name (for Florence-2). |
106
+
|`label`|`str`| Element label — text content (for Vision text), class name (for Florence-2), or grouped text (for text blocks). |
99
107
|`x`|`int`| Left edge of bounding box in pixels. |
100
108
|`y`|`int`| Top edge of bounding box in pixels. |
101
109
|`width`|`int`| Bounding box width in pixels. |
102
110
|`height`|`int`| Bounding box height in pixels. |
103
-
|`confidence`|`float`| Detection confidence score (0.0--1.0). Florence-2 detections are always`0.5` (the model does not emit per-box scores). |
104
-
|`source`|`str`| Detection source identifier. One of: `"vision_text"`, `"vision_rect"`, `"florence2"`. |
111
+
|`confidence`|`float`| Detection confidence score (0.0--1.0). Vision provides real scores; YOLO provides model confidence; Florence-2 detections default to`0.5`. |
|`som_id`|`int \| None`| SoM marker number (1-indexed). `None` until `merge_detections()` assigns sequential IDs sorted by position (top-to-bottom, left-to-right). |
106
114
107
-
**Source values:**
115
+
__Source values:__
108
116
109
117
| Value | Origin |
110
118
|-------|--------|
111
119
|`"vision_text"`| Apple Vision text recognition |
112
120
|`"vision_rect"`| Apple Vision rectangle detection |
113
-
|`"florence2"`| Florence-2 object detection via MLX |
121
+
|`"vision_text_block"`| Grouped adjacent text lines (paragraph-level) |
122
+
|`"yolo"`| YOLO tiled detection (only with `--yolo`) |
123
+
|`"florence2"`| Florence-2 object detection via MLX (only with `--florence`, legacy) |
114
124
115
125
### `PipelineResult`
116
126
@@ -127,18 +137,24 @@ Output of the full detection pipeline. Defined as a dataclass in `uitag/types.py
127
137
|`image_height`|`int`| Height of the input image in pixels. |
128
138
|`timing_ms`|`dict`| Pipeline timing breakdown. Defaults to an empty dict. |
129
139
130
-
**`timing_ms`keys** (populated by `run_pipeline`):
140
+
__`timing_ms`keys__ (populated by `run_pipeline`):
131
141
132
142
| Key | Type | Description |
133
143
|-----|------|-------------|
134
144
|`vision_ms`|`float`| Total Apple Vision stage wall time. |
135
-
|`split_x`|`int`| Vertical cut X coordinate chosen by object-aware tiling. |
136
-
|`split_y`|`int`| Horizontal cut Y coordinate chosen by object-aware tiling. |
137
-
|`split_x_clean`|`bool`| Whether the X split avoided all bounding boxes. |
138
-
|`split_y_clean`|`bool`| Whether the Y split avoided all bounding boxes. |
139
-
|`florence_total_ms`|`float`| Total Florence-2 inference time across all quadrants. |
140
-
|`florence_backend`|`str`| Name of the backend used (e.g. `"mlx"`). |
141
-
|`florence_per_quadrant_ms`|`list[float]`| Per-quadrant inference times (if the backend provides them). |
145
+
|`yolo_ms`|`float`| Total YOLO tiled inference time (only with `--yolo`). |
146
+
|`yolo_tiles`|`int`| Number of 640x640 tiles processed (only with `--yolo`). |
147
+
|`yolo_raw_dets`|`int`| Raw detections before cross-tile NMS (only with `--yolo`). |
148
+
|`yolo_nms_dets`|`int`| Detections after NMS (only with `--yolo`). |
149
+
|`merge_ms`|`float`| Merge and deduplication stage time. |
|`florence_total_ms`|`float`| Total Florence-2 inference time (only with `--florence`). |
157
+
|`florence_backend`|`str`| Backend used for Florence-2 (only with `--florence`). |
142
158
143
159
---
144
160
@@ -226,7 +242,7 @@ detect_on_quadrant(
226
242
227
243
`list[Detection]` -- Detections with coordinates translated to full-image space. All have `source="florence2"` and `confidence=0.5`.
228
244
229
-
**Note:**This function saves the PIL Image to a temporary file (mlx_vlm requires a file path), runs inference, then deletes the temp file. The model is lazy-loaded as a singleton on the first call to any Florence-2 detection function.
245
+
This function saves the PIL Image to a temporary file (mlx_vlm requires a file path), runs inference, then deletes the temp file. The model is lazy-loaded as a singleton on the first call to any Florence-2 detection function.
230
246
231
247
#### Example
232
248
@@ -264,7 +280,7 @@ merge_detections(
264
280
265
281
| Name | Type | Default | Description |
266
282
|------|------|---------|-------------|
267
-
|`detections`|`list[Detection]`|*(required)*| All detections from all sources (Vision + Florence-2), unmerged. |
283
+
|`detections`|`list[Detection]`|*(required)*| All detections from all sources (Vision + YOLO + Florence-2), unmerged. |
268
284
|`iou_threshold`|`float`|`0.5`| When two detections overlap above this IoU threshold, the lower-priority one is discarded. |
269
285
270
286
#### Source Priority
@@ -273,9 +289,11 @@ When overlapping detections are found, the higher-priority source is kept:
273
289
274
290
| Source | Priority | Rationale |
275
291
|--------|----------|-----------|
276
-
|`"vision_text"`| 3 (highest) | Apple Vision text is the most precise for text elements. |
277
-
|`"vision_rect"`| 2 | Apple Vision rectangles are accurate but less specific. |
278
-
|`"florence2"`| 1 (lowest) | Florence-2 detections fill gaps not caught by Vision. |
292
+
|`"vision_text"`| 3 (highest) | Apple Vision text has OCR content — most useful for labeling. |
293
+
|`"vision_text_block"`| 3 (highest) | Grouped text inherits Vision text priority. |
294
+
|`"vision_rect"`| 2 | Apple Vision rectangles are accurate but lack semantic labels. |
295
+
|`"yolo"`| 2 | YOLO detections have class labels (Button, Menu, etc.) but no OCR. |
296
+
|`"florence2"`| 1 (lowest) | Florence-2 detections fill gaps (legacy, superseded by YOLO). |
279
297
280
298
#### Returns
281
299
@@ -324,7 +342,7 @@ render_som(
324
342
325
343
#### Returns
326
344
327
-
`PIL.Image.Image` -- A **copy** of the input image (converted to RGB) with bounding boxes and numbered markers drawn. The original image is not modified.
345
+
`PIL.Image.Image` -- A copy of the input image (converted to RGB) with bounding boxes and numbered markers drawn. The original image is not modified.
328
346
329
347
Colors cycle through 8 values in `SOM_COLORS`: red, green, blue, orange, purple, cyan, yellow, pink. The color for each detection is determined by `(som_id - 1) % 8`.
330
348
@@ -454,7 +472,7 @@ Each entry in `elements`:
454
472
|`label`|`string`| Element label (text content or detection class). |
0 commit comments