Views
No views yet
pip install transformers torch torchvision qwen-vl-utils1from transformers import Qwen3VLForConditionalGeneration, AutoProcessor
2from qwen_vl_utils import process_vision_info
3from PIL import Image
4
5# 1. Load model
6model = Qwen3VLForConditionalGeneration.from_pretrained(
7 "Mininglamp-2718/Mano-CUA-2.0-4B",
8 torch_dtype="auto",
9 device_map="auto",
10)
11processor = AutoProcessor.from_pretrained("Mininglamp-2718/Mano-CUA-2.0-4B")
12
13# 2. Load a screenshot
14img = Image.open("screenshot.png")
15ratio = 1280 / img.width
16img = img.resize((1280, int(img.height * ratio)), Image.LANCZOS)
17
18# 3. Build prompt
19task = "Click the search bar and type hello"
20
21prompt_text = f"""You are a GUI agent. You are given a task and your action history, with screenshots. You need to perform the next action to complete the task.
22
23## Output Format
24<action>action</action>
25
26## Action Space
27open_app(app_name='') # Open an application by name.
28open_url(url='') # Open a URL in the browser.
29click(start_box='<|box_start|>(x1,y1)<|box_end|>')
30type(content='') # type the content.
31hotkey(key='') # Trigger a keyboard shortcut.
32scroll(start_box='<|box_start|>(x1,y1)<|box_end|>', direction='down or up or right or left', amount='scroll_amount')
33drag(start_box='<|box_start|>(x1,y1)<|box_end|>', end_box='<|box_start|>(x3,y3)<|box_end|>')
34wait(duration='') # Sleep for specified duration (in seconds).
35finish() # The task is completed.
36stop(reason='') # If the item can not found in the image, give the reason
37
38## User Instruction
39{task}"""
40
41messages = [
42 {{"role": "system", "content": "You are a helpful assistant."}},
43 {{"role": "user", "content": [
44 {{"type": "image", "image": img}},
45 {{"type": "text", "text": prompt_text}},
46 ]}},
47]
48
49# 4. Run inference
50text_input = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
51image_inputs, video_inputs = process_vision_info(messages)
52inputs = processor(
53 text=[text_input], images=image_inputs, videos=video_inputs,
54 padding=True, return_tensors="pt",
55).to(model.device)
56
57output_ids = model.generate(**inputs, max_new_tokens=512, temperature=0.0, do_sample=False)
58output_ids = output_ids[:, inputs.input_ids.shape[1]:]
59output = processor.batch_decode(output_ids, skip_special_tokens=True)[0]
60
61print(output)1<think>The search bar is at the top of the page...</think>
2<action_desp>Click the search bar to focus it</action_desp>
3<action>click(start_box='<|box_start|>(500,38)<|box_end|>')</action>[0, 1000] range. To convert to pixel coordinates:1pixel_x = int(x / 1000 * screen_width)
2pixel_y = int(y / 1000 * screen_height)| Action | Syntax | Description |
|---|---|---|
| open_app | open_app(app_name='') | Open an application |
| open_url | open_url(url='') | Open a URL |
| click | click(start_box='<|box_start|>(x,y)<|box_end|>') | Left click |
| doubleclick | doubleclick(start_box='<|box_start|>(x,y)<|box_end|>') | Double click |
| triple_click | triple_click(start_box='<|box_start|>(x,y)<|box_end|>') | Triple click (select line) |
| right_single | right_single(start_box='<|box_start|>(x,y)<|box_end|>') | Right click |
| hover | hover(start_box='<|box_start|>(x,y)<|box_end|>') | Mouse hover |
| type | type(content='text') | Type text |
| hotkey | hotkey(key='cmd+c') | Keyboard shortcut |
| hotkey_click | hotkey_click(start_box='<|box_start|>(x,y)<|box_end|>', key='shift') | Modifier + click |
| scroll | scroll(start_box='<|box_start|>(x,y)<|box_end|>', direction='down', amount='3') | Scroll |
| drag | drag(start_box='<|box_start|>(x1,y1)<|box_end|>', end_box='<|box_start|>(x2,y2)<|box_end|>') | Drag and drop |
| wait | wait(duration='2') | Wait (seconds) |
| finish | finish() | Task completed |
| stop | stop(reason='...') | Task infeasible |
| call_user | call_user() | Request human help |
| Version | Repo | Description |
|---|---|---|
| fp16 (this) | Mano-CUA-2.0-4B | Full precision, for archival / re-quantization / GPU inference |
| MLX-8bit | Mano-CUA-2.0-4B-MLX-8bit | MLX 8-bit quantized, recommended for Apple Silicon local inference |