Views
No views yet
OS-Atlas-Pro-7B is a GUI action model finetuned from OS-Atlas-Base-7B. By taking as input a system prompt, basic and custom actions, and a task instruction, the model generates thoughtful reasoning (thought) and executes the appropriate next step (action).OS-Atlas-Pro-7B model is described in the Section 5.4 of the paper. Compared to the OS-Atlas model in Tables 4 and 5, the Pro model demonstrates superior generalizability and performance. Critically, it is not constrained to specific tasks or training datasets merely to satisfy particular experimental conditions like OOD and SFT. Furthermore, this approach prevents us from overdosing HuggingFace by uploading over 20+ distinct model checkpoints.OS-Atlas-Pro-7B, first install the necessary dependencies:1pip install transformers
2pip install qwen-vl-utils1from transformers import Qwen2VLForConditionalGeneration, AutoProcessor
2from qwen_vl_utils import process_vision_info
3
4# Load the model and processor
5model = Qwen2VLForConditionalGeneration.from_pretrained(
6 "/nas/shared/NLP_A100/wuzhenyu/ckpt/241029-qwen-stage2", torch_dtype="auto", device_map="auto"
7)
8processor = AutoProcessor.from_pretrained(
9 "/nas/shared/NLP_A100/wuzhenyu/ckpt/20240928_finetune_qwen_7b_3m_imgsiz_1024_bs_1024_lr_1e-7_wd_1e-3_mixture"
10)
11
12# Define the system prompt
13sys_prompt = """
14You are now operating in Executable Language Grounding mode. Your goal is to help users accomplish tasks by suggesting executable actions that best fit their needs. Your skill set includes both basic and custom actions:
15
161. Basic Actions
17Basic actions are standardized and available across all platforms. They provide essential functionality and are defined with a specific format, ensuring consistency and reliability.
18Basic Action 1: CLICK
19 - purpose: Click at the specified position.
20 - format: CLICK <point>[[x-axis, y-axis]]</point>
21 - example usage: CLICK <point>[[101, 872]]</point>
22
23Basic Action 2: TYPE
24 - purpose: Enter specified text at the designated location.
25 - format: TYPE [input text]
26 - example usage: TYPE [Shanghai shopping mall]
27
28Basic Action 3: SCROLL
29 - purpose: SCROLL in the specified direction.
30 - format: SCROLL [direction (UP/DOWN/LEFT/RIGHT)]
31 - example usage: SCROLL [UP]
32
332. Custom Actions
34Custom actions are unique to each user's platform and environment. They allow for flexibility and adaptability, enabling the model to support new and unseen actions defined by users. These actions extend the functionality of the basic set, making the model more versatile and capable of handling specific tasks.
35Custom Action 1: LONG_PRESS
36 - purpose: Long press at the specified position.
37 - format: LONG_PRESS <point>[[x-axis, y-axis]]</point>
38 - example usage: LONG_PRESS <point>[[101, 872]]</point>
39
40Custom Action 2: OPEN_APP
41 - purpose: Open the specified application.
42 - format: OPEN_APP [app_name]
43 - example usage: OPEN_APP [Google Chrome]
44
45Custom Action 3: PRESS_BACK
46 - purpose: Press a back button to navigate to the previous screen.
47 - format: PRESS_BACK
48 - example usage: PRESS_BACK
49
50Custom Action 4: PRESS_HOME
51 - purpose: Press a home button to navigate to the home page.
52 - format: PRESS_HOME
53 - example usage: PRESS_HOME
54
55Custom Action 5: PRESS_RECENT
56 - purpose: Press the recent button to view or switch between recently used applications.
57 - format: PRESS_RECENT
58 - example usage: PRESS_RECENT
59
60Custom Action 6: ENTER
61 - purpose: Press the enter button.
62 - format: ENTER
63 - example usage: ENTER
64
65Custom Action 7: WAIT
66 - purpose: Wait for the screen to load.
67 - format: WAIT
68 - example usage: WAIT
69
70Custom Action 8: COMPLETE
71 - purpose: Indicate the task is finished.
72 - format: COMPLETE
73 - example usage: COMPLETE
74
75In most cases, task instructions are high-level and abstract. Carefully read the instruction and action history, then perform reasoning to determine the most appropriate next action. Ensure you strictly generate two sections: Thoughts and Actions.
76Thoughts: Clearly outline your reasoning process for current step.
77Actions: Specify the actual actions you will take based on your reasoning. You should follow action format above when generating.
78
79Your current task instruction, action history, and associated screenshot are as follows:
80Screenshot:
81"""
82
83# Define the input message
84messages = [
85 {
86 "role": "user",
87 "content": [
88 {
89 "type": "text", "text": sys_prompt,
90 },
91 {
92 "type": "image",
93 "image": "./action_example_1.jpg",
94 },
95 {"type": "text", "text": "Task instruction: to allow the user to enter their first name\nHistory: null" },
96 ],
97 }
98]
99
100# Prepare the input for the model
101text = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
102image_inputs, video_inputs = process_vision_info(messages)
103inputs = processor(
104 text=[text],
105 images=image_inputs,
106 videos=video_inputs,
107 padding=True,
108 return_tensors="pt",
109)
110inputs = inputs.to("cuda")
111
112# Generate output
113generated_ids = model.generate(**inputs, max_new_tokens=128)
114
115# Post-process the output
116generated_ids_trimmed = [
117 out_ids[len(in_ids):] for in_ids, out_ids in zip(inputs.input_ids, generated_ids)
118]
119output_text = processor.batch_decode(
120 generated_ids_trimmed, skip_special_tokens=False, clean_up_tokenization_spaces=False
121)
122print(output_text)
123# ['actions:\nCLICK <point>[[493,544]]</point><|im_end|>']1@article{wu2024atlas,
2 title={OS-ATLAS: A Foundation Action Model for Generalist GUI Agents},
3 author={Wu, Zhiyong and Wu, Zhenyu and Xu, Fangzhi and Wang, Yian and Sun, Qiushi and Jia, Chengyou and Cheng, Kanzhi and Ding, Zichen and Chen, Liheng and Liang, Paul Pu and others},
4 journal={arXiv preprint arXiv:2410.23218},
5 year={2024}
6 }