Repository navigation
fix(s3): make grounding clicks land correctly on screens that aren't 1920x1080 - #231
Open
sahiljagtap08 wants to merge 5 commits into
Open
sahiljagtap08 wants to merge 5 commits into
sahiljagtap08 wants to merge 5 commits into
Conversation
…image space Qwen2.5-VL based grounding models such as UI-TARS-1.5 return absolute pixel coordinates in the space of the image after the processor's smart_resize step. Porting the reference implementation lets Agent S map coordinates back from the exact space the model used. Refs simular-ai#175
…ually saw resize_coordinates assumed every grounding model answers in a fixed grounding_width x grounding_height space. UI-TARS-1.5 and other Qwen2.5-VL based models answer in absolute pixels of the (smart-resized) screenshot they were shown, so on any screen that is not 1920x1080 the clicks landed hundreds of pixels off, or off-screen entirely on 1440p and 4K displays. The grounding agent now records the size of the screenshot it sent and, for pixel-space models, maps coordinates back through smart_resize. A square grounding box (e.g. 1000x1000) is auto-detected as a normalized space and used as before; grounding_coordinate_space can force either mode explicitly. Fixes simular-ai#175
…xels highlight_text_span used pytesseract box coordinates directly, which are in screenshot pixels. When the CLI downsizes the screenshot (screens wider than 2400px) the drag landed at the wrong place. Refs simular-ai#175
Defaults to auto so existing commands keep working; lets users force image or fixed interpretation for grounding models the detection does not cover. Refs simular-ai#175
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #175
What was going wrong
Agent S3 asks the grounding model where an element is, then converts the answer into screen pixels. That conversion assumes the model always answers in a fixed
grounding_width x grounding_heightbox, which the README says to set to 1920x1080 for UI-TARS-1.5.UI-TARS-1.5 doesn't work that way. Like every model built on Qwen2.5-VL, it answers in pixels of the image it was actually shown, after the model's own resizing step. ByteDance documents this and ships the exact resize rule in their coordinate processing guide.
So the conversion is only right when the screenshot happens to be 1920x1080. That is true on OSWorld, which is why benchmarks never showed it. On a laptop or a high-resolution monitor the screenshot is a different size, and every click is scaled by the wrong factor. The error grows toward the bottom right of the screen, which is where most "OK", "Save" and dock icons live.
Here is what happens today versus with this change, for an element at 90% across and 95% down the screen, with the coordinates UI-TARS-1.5 would return for each case. "Before" and "after" are produced by the real
OSWorldACIcode:On a 1440p or 4K display the click is off the screen entirely. On a MacBook it is a few hundred pixels off. Even on 1080p it is 11 pixels off, because the model rounds the image to multiples of 28 pixels before answering and that was never accounted for. That small drift is enough to miss a small icon, which is exactly what the issue describes.
The fix
The grounding agent now remembers the size of the screenshot it sent, and converts the model's answer back from that image's space using the same resize rule the model uses. Nothing is assumed about the screen.
Not every grounding model answers in image pixels. UI-TARS-72B answers in a fixed 0 to 1000 space no matter the image. So there are two modes, and the default picks one from the shape of the grounding box you already pass:
That means every existing command keeps working with no flag changes. For anything unusual,
--grounding_coordinate_space image|fixedforces a mode.I also fixed
highlight_text_spanwhile I was here. It used OCR box positions straight from the screenshot as screen positions, so it was wrong whenever the CLI downsized the screenshot.Changes
smart_resizeported from the UI-TARS reference intogui_agents/s3/utils/common_utils.pyOSWorldACIrecords the screenshot size ingenerate_coords, andresize_coordinatesmaps from the right space. Newgrounding_output_sizeandscreenshot_to_screenhelpers--grounding_coordinate_spaceCLI option, defaultautoTests
tests/test_grounding_coordinates.pycovers the resize rule against the reference values, each screen size in the table above, the square-box detection, both explicit modes, the fallback before any grounding call, and the OCR scaling. 19 tests pass with the existing suite andblack --check gui_agentsis clean.Things worth knowing
max_pixelsof the Qwen2.5-VL processor. If a deployment overrides it to something smaller, the screenshot would need to be capped to match. The CLI's existing 2400px cap stays well under the default.