Update README.md
Browse files
README.md
CHANGED
|
@@ -10,4 +10,159 @@ pipeline_tag: visual-question-answering
|
|
| 10 |
|
| 11 |
This repository contains the model presented in [UI-R1: Enhancing Action Prediction of GUI Agents by Reinforcement Learning](https://huggingface.co/papers/2503.21620).
|
| 12 |
|
| 13 |
-
Project page: https://github.com/lll6gg/UI-R1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
This repository contains the model presented in [UI-R1: Enhancing Action Prediction of GUI Agents by Reinforcement Learning](https://huggingface.co/papers/2503.21620).
|
| 12 |
|
| 13 |
+
Project page: https://github.com/lll6gg/UI-R1
|
| 14 |
+
|
| 15 |
+
New version: [UI-R1-E-3B](https://huggingface.co/LZXzju/Qwen2.5-VL-3B-UI-R1-E)
|
| 16 |
+
|
| 17 |
+
## Benchmark 1: ScreenSpotV2
|
| 18 |
+
|
| 19 |
+
| ScreenSpotV2 | inference mode | Mobile-T | Mobile-I | Desktop-T | Desktop-I | Web-T | Web-I | Avg↑ / Len↓ |
|
| 20 |
+
| ------------- | -------------- | -------- | -------- | --------- | --------- | -------- | -------- | ----------------- |
|
| 21 |
+
| OS-ATLAS-7B | w/o thinking | 95.2 | 75.8 | 90.7 | 63.6 | 90.6 | 77.3 | 84.1 / |
|
| 22 |
+
| UI-TARS-7B | w/o thinking | 95.2 | 79.1 | 90.7 | 68.6 | 90.6 | 78.3 | 84.7 / |
|
| 23 |
+
| UI-R1-3B (v1) | w/ thinking | 96.2 | **84.3** | 92.3 | 63.6 | 89.2 | 75.4 | 85.4 / 67 |
|
| 24 |
+
| GUI-R1-3B | w/ thinking | 97.6 | 78.2 | 94.3 | 64.3 | 91.0 | 72.4 | 85.0 / 80 |
|
| 25 |
+
| UI-R1-3B (v2) | w/ thinking | 97.6 | 79.6 | 92.3 | 67.9 | 88.9 | 77.8 | 85.8 / 60 |
|
| 26 |
+
| **UI-R1-E-3B** | w/o thinking | **98.2** | 83.9 | **94.8** | **75.0** | **93.2** | **83.7** | **89.5** / **28** |
|
| 27 |
+
## Benchmark 2: ScreenSpot-Pro
|
| 28 |
+
|
| 29 |
+
| ScreenSpot-Pro | inference mode | Average Length↓ | Average Accuracy↑ |
|
| 30 |
+
| -------------- | -------------- | --------------- | ---------------- |
|
| 31 |
+
| UGround-7B | w/o thinking | - | 16.5 |
|
| 32 |
+
| OS-ATLAS-7B | w/o thinking | - | 18.9 |
|
| 33 |
+
| UI-R1-3B (v1) | w/ thinking | 102 | 17.8 |
|
| 34 |
+
| GUI-R1-3B | w/ thinking | 114 | 26.6 |
|
| 35 |
+
| UI-R1-3B (v2) | w/ thinking | 129 | 29.8 |
|
| 36 |
+
| **UI-R1-E-3B** | w/o thinking | **28** | **33.5** |
|
| 37 |
+
## Leaderboard: UI-I2E-Bench
|
| 38 |
+
| Model | ScreenSpot | UI-I2E-Bench Avg | ScreenSpot-Pro | Avg |
|
| 39 |
+
| :------------: | :--------: | :--------------: | :------------: | :--: |
|
| 40 |
+
| UI-TARS-1.5-7B | 88.1 | 73.2 | 42.2 | 67.8 |
|
| 41 |
+
| Uground-V1-72B | 89.7 | 76.3 | 34.3 | 66.8 |
|
| 42 |
+
| UI-TARS-72B | 88.4 | 73.7 | 38.1 | 66.7 |
|
| 43 |
+
| **UI-R1-E-3B** | 89.2 | 69.1 | 33.5 | 63.9 |
|
| 44 |
+
| Uground-V1-7B | 87.1 | 70.3 | 31.1 | 62.8 |
|
| 45 |
+
| InfiGUI-R1 | 87.5 | 69.7 | 29.6 | 62.3 |
|
| 46 |
+
| UI-TARS-7B | 89.5 | 61.4 | 35.7 | 62.2 |
|
| 47 |
+
| Qwen2.5-VL-72B | 87.1 | 51.4 | 43.6 | 60.7 |
|
| 48 |
+
| UI-I2E-VLM-7B | 82.5 | 69.5 | 23.6 | 58.5 |
|
| 49 |
+
| UI-TARS-2B | 82.3 | 62 | 27.7 | 57.3 |
|
| 50 |
+
| Qwen2.5-VL-7B | 84.7 | 53.8 | 29 | 55.8 |
|
| 51 |
+
| OmniParser-V2 | 72 | 54.8 | 39.6 | 55.5 |
|
| 52 |
+
| Uground-V1-2B | 78.8 | 57.4 | 26.6 | 54.3 |
|
| 53 |
+
| OS-Atlas-7B | 82.5 | 58.6 | 18.9 | 53.3 |
|
| 54 |
+
| **UI-R1-3B** | 83.3 | 58.5 | 17.8 | 53.2 |
|
| 55 |
+
| UGround-7B | 74.1 | 54.2 | 16.5 | 48.3 |
|
| 56 |
+
| UI-I2E-VLM-4B | 70.4 | 53.4 | 12.2 | 45.3 |
|
| 57 |
+
| OmniParser | 73.9 | 53.1 | 8.3 | 45.1 |
|
| 58 |
+
| ShowUI-2B | 76.8 | 41.5 | 7.7 | 42 |
|
| 59 |
+
| Qwen2.5-VL-3B | 55.5 | 41.7 | 23.9 | 41.3 |
|
| 60 |
+
| Aguvis-7B | 84.4 | 53.2 | 22.9 | 40.4 |
|
| 61 |
+
| OS-Atlas-4B | 70.1 | 44.3 | 3.7 | 39.4 |
|
| 62 |
+
| Qwen2-VL-7B | 42.6 | 48.7 | 1.6 | 31 |
|
| 63 |
+
| Seeclick | 55.8 | 26.4 | 1.1 | 27.8 |
|
| 64 |
+
| InternVL2-4B | 4.2 | 0.9 | 0.3 | 1.8 |
|
| 65 |
+
|
| 66 |
+
## Evaluation Code for GUI Grounding
|
| 67 |
+
|
| 68 |
+
1. Generation for UI-R1-E-3B:
|
| 69 |
+
|
| 70 |
+
```python
|
| 71 |
+
model = Qwen2_5_VLForConditionalGeneration.from_pretrained(
|
| 72 |
+
args.model_path,
|
| 73 |
+
torch_dtype=torch.bfloat16,
|
| 74 |
+
attn_implementation="flash_attention_2",
|
| 75 |
+
device_map="cpu",
|
| 76 |
+
)
|
| 77 |
+
model = model.to(torch.device(rank))
|
| 78 |
+
model = model.eval()
|
| 79 |
+
processor = AutoProcessor.from_pretrained(ori_processor_path)
|
| 80 |
+
question_template = (
|
| 81 |
+
f"In this UI screenshot, I want to perform the command '{task_prompt}'.\n"
|
| 82 |
+
"Please provide the action to perform (enumerate in ['click', 'scroll']) and the coordinate where the cursor is moved to(integer) if click is performed.\n"
|
| 83 |
+
"Output the thinking process in <think> </think> and final answer in <answer> </answer> tags."
|
| 84 |
+
"The output answer format should be as follows:\n"
|
| 85 |
+
"<think> ... </think> <answer>[{'action': enum['click', 'scroll'], 'coordinate': [x, y]}]</answer>\n"
|
| 86 |
+
"Please strictly follow the format."
|
| 87 |
+
)
|
| 88 |
+
query = '<image>\n' + question_template
|
| 89 |
+
messages = [
|
| 90 |
+
{
|
| 91 |
+
"role": "user",
|
| 92 |
+
"content": [
|
| 93 |
+
{"type": "image", "image": image_path}
|
| 94 |
+
] + [{"type": "text", "text": query}],
|
| 95 |
+
}
|
| 96 |
+
]
|
| 97 |
+
text = processor.apply_chat_template(
|
| 98 |
+
messages, tokenize=False, add_generation_prompt=True
|
| 99 |
+
)
|
| 100 |
+
image_inputs, video_inputs = process_vision_info(messages)
|
| 101 |
+
inputs = processor(
|
| 102 |
+
text=[text],
|
| 103 |
+
images=image_inputs,
|
| 104 |
+
videos=video_inputs,
|
| 105 |
+
padding=True,
|
| 106 |
+
return_tensors="pt",
|
| 107 |
+
)
|
| 108 |
+
generated_ids = model.generate(**inputs, max_new_tokens=1024)
|
| 109 |
+
generated_ids_trimmed = [
|
| 110 |
+
out_ids[len(in_ids) :] for in_ids, out_ids in zip(inputs.input_ids, generated_ids)
|
| 111 |
+
]
|
| 112 |
+
response = processor.batch_decode(
|
| 113 |
+
generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False
|
| 114 |
+
)
|
| 115 |
+
response = response[0]
|
| 116 |
+
pred_coord, _ = extract_coord(response)
|
| 117 |
+
```
|
| 118 |
+
|
| 119 |
+
|
| 120 |
+
|
| 121 |
+
2. Rescale the predicted coordinate according to the image resize (especially image_size > 12845056)
|
| 122 |
+
|
| 123 |
+
```python
|
| 124 |
+
image = Image.open(image_path)
|
| 125 |
+
origin_width, origin_height = image.size
|
| 126 |
+
resized_height,resized_width = smart_resize(origin_height,origin_width,max_pixels=12845056)
|
| 127 |
+
scale_x = origin_width / resized_width
|
| 128 |
+
scale_y = origin_height / resized_height
|
| 129 |
+
pred_coord[0] = int(pred_coord[0] * scale_x)
|
| 130 |
+
pred_coord[1] = int(pred_coord[1] * scale_y)
|
| 131 |
+
```
|
| 132 |
+
|
| 133 |
+
Function smart_resize is from Qwen2VL:
|
| 134 |
+
|
| 135 |
+
```python
|
| 136 |
+
import math
|
| 137 |
+
def smart_resize(
|
| 138 |
+
height: int, width: int, factor: int = 28, min_pixels: int = 56 * 56, max_pixels: int = 14 * 14 * 4 * 1280
|
| 139 |
+
):
|
| 140 |
+
"""Rescales the image so that the following conditions are met:
|
| 141 |
+
|
| 142 |
+
1. Both dimensions (height and width) are divisible by 'factor'.
|
| 143 |
+
|
| 144 |
+
2. The total number of pixels is within the range ['min_pixels', 'max_pixels'].
|
| 145 |
+
|
| 146 |
+
3. The aspect ratio of the image is maintained as closely as possible.
|
| 147 |
+
|
| 148 |
+
"""
|
| 149 |
+
if height < factor or width < factor:
|
| 150 |
+
raise ValueError(f"height:{height} or width:{width} must be larger than factor:{factor}")
|
| 151 |
+
elif max(height, width) / min(height, width) > 200:
|
| 152 |
+
raise ValueError(
|
| 153 |
+
f"absolute aspect ratio must be smaller than 200, got {max(height, width) / min(height, width)}"
|
| 154 |
+
)
|
| 155 |
+
h_bar = round(height / factor) * factor
|
| 156 |
+
w_bar = round(width / factor) * factor
|
| 157 |
+
if h_bar * w_bar > max_pixels:
|
| 158 |
+
beta = math.sqrt((height * width) / max_pixels)
|
| 159 |
+
h_bar = math.floor(height / beta / factor) * factor
|
| 160 |
+
w_bar = math.floor(width / beta / factor) * factor
|
| 161 |
+
elif h_bar * w_bar < min_pixels:
|
| 162 |
+
beta = math.sqrt(min_pixels / (height * width))
|
| 163 |
+
h_bar = math.ceil(height * beta / factor) * factor
|
| 164 |
+
w_bar = math.ceil(width * beta / factor) * factor
|
| 165 |
+
return h_bar, w_bar
|
| 166 |
+
```
|
| 167 |
+
|
| 168 |
+
|