OS-Atlas: A Foundation Action Model For Generalist GUI Agents
Overview
OS-Atlas provides a series of models specifically designed for GUI agents.
For GUI grounding tasks, you can use:
For generating single-step actions in GUI agent tasks, you can use:
OS-Atlas-Pro-7B
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
).
Note that the released 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.
Installation
To use OS-Atlas-Pro-7B
, first install the necessary dependencies:
pip install transformers
pip install qwen-vl-utils
Example Inference Code
First download the example image and save it to the current directory.
Below is an example of how to perform inference using the model:
from transformers import Qwen2VLForConditionalGeneration, AutoProcessor
from qwen_vl_utils import process_vision_info
# Load the model and processor
model = Qwen2VLForConditionalGeneration.from_pretrained(
"/nas/shared/NLP_A100/wuzhenyu/ckpt/241029-qwen-stage2", torch_dtype="auto", device_map="auto"
)
processor = AutoProcessor.from_pretrained(
"/nas/shared/NLP_A100/wuzhenyu/ckpt/20240928_finetune_qwen_7b_3m_imgsiz_1024_bs_1024_lr_1e-7_wd_1e-3_mixture"
)
# Define the system prompt
sys_prompt = """
You 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:
1. Basic Actions
Basic actions are standardized and available across all platforms. They provide essential functionality and are defined with a specific format, ensuring consistency and reliability.
Basic Action 1: CLICK
- purpose: Click at the specified position.
- format: CLICK <point>[[x-axis, y-axis]]</point>
- example usage: CLICK <point>[[101, 872]]</point>
Basic Action 2: TYPE
- purpose: Enter specified text at the designated location.
- format: TYPE [input text]
- example usage: TYPE [Shanghai shopping mall]
Basic Action 3: SCROLL
- purpose: SCROLL in the specified direction.
- format: SCROLL [direction (UP/DOWN/LEFT/RIGHT)]
- example usage: SCROLL [UP]
2. Custom Actions
Custom 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.
Custom Action 1: LONG_PRESS
- purpose: Long press at the specified position.
- format: LONG_PRESS <point>[[x-axis, y-axis]]</point>
- example usage: LONG_PRESS <point>[[101, 872]]</point>
Custom Action 2: OPEN_APP
- purpose: Open the specified application.
- format: OPEN_APP [app_name]
- example usage: OPEN_APP [Google Chrome]
Custom Action 3: PRESS_BACK
- purpose: Press a back button to navigate to the previous screen.
- format: PRESS_BACK
- example usage: PRESS_BACK
Custom Action 4: PRESS_HOME
- purpose: Press a home button to navigate to the home page.
- format: PRESS_HOME
- example usage: PRESS_HOME
Custom Action 5: PRESS_RECENT
- purpose: Press the recent button to view or switch between recently used applications.
- format: PRESS_RECENT
- example usage: PRESS_RECENT
Custom Action 6: ENTER
- purpose: Press the enter button.
- format: ENTER
- example usage: ENTER
Custom Action 7: WAIT
- purpose: Wait for the screen to load.
- format: WAIT
- example usage: WAIT
Custom Action 8: COMPLETE
- purpose: Indicate the task is finished.
- format: COMPLETE
- example usage: COMPLETE
In 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.
Thoughts: Clearly outline your reasoning process for current step.
Actions: Specify the actual actions you will take based on your reasoning. You should follow action format above when generating.
Your current task instruction, action history, and associated screenshot are as follows:
Screenshot:
"""
# Define the input message
messages = [
{
"role": "user",
"content": [
{
"type": "text", "text": sys_prompt,
},
{
"type": "image",
"image": "./action_example_1.jpg",
},
{"type": "text", "text": "Task instruction: to allow the user to enter their first name\nHistory: null" },
],
}
]
# Prepare the input for the model
text = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
image_inputs, video_inputs = process_vision_info(messages)
inputs = processor(
text=[text],
images=image_inputs,
videos=video_inputs,
padding=True,
return_tensors="pt",
)
inputs = inputs.to("cuda")
# Generate output
generated_ids = model.generate(**inputs, max_new_tokens=128)
# Post-process the output
generated_ids_trimmed = [
out_ids[len(in_ids):] for in_ids, out_ids in zip(inputs.input_ids, generated_ids)
]
output_text = processor.batch_decode(
generated_ids_trimmed, skip_special_tokens=False, clean_up_tokenization_spaces=False
)
print(output_text)
# ['actions:\nCLICK <point>[[493,544]]</point><|im_end|>']
Citation
If you find this repository helpful, feel free to cite our paper:
@article{wu2024atlas,
title={OS-ATLAS: A Foundation Action Model for Generalist GUI Agents},
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},
journal={arXiv preprint arXiv:2410.23218},
year={2024}
}
- Downloads last month
- 106
Model tree for OS-Copilot/OS-Atlas-Pro-7B
Base model
Qwen/Qwen2-VL-7B-Instruct