Views
No views yet
1from transformers import Qwen3VLForConditionalGeneration, AutoProcessor
2from PIL import Image
3
4model = Qwen3VLForConditionalGeneration.from_pretrained(
5 "BLR2/qwen3-vl-4b-gui-agent1",
6 torch_dtype="auto",
7 device_map="auto",
8)
9processor = AutoProcessor.from_pretrained("BLR2/qwen3-vl-4b-gui-agent1")
10
11# Load your screenshot
12image = Image.open("screenshot.png")
13instruction = "Click on the search button"
14
15messages = [
16 {
17 "role": "user",
18 "content": [
19 {"type": "image", "image": image},
20 {"type": "text", "text": instruction},
21 ],
22 }
23]
24
25inputs = processor.apply_chat_template(
26 messages,
27 tokenize=True,
28 add_generation_prompt=True,
29 return_dict=True,
30 return_tensors="pt"
31).to(model.device)
32
33outputs = model.generate(**inputs, max_new_tokens=50)
34response = processor.decode(outputs[0], skip_special_tokens=True)
35print(response) # Outputs coordinates like "0.5234 0.7891"vllm serve BLR2/qwen3-vl-4b-gui-agent1 --dtype bfloat161from openai import OpenAI
2
3client = OpenAI(base_url="http://localhost:8000/v1", api_key="dummy")
4
5# For vLLM with vision, encode image as base64
6response = client.chat.completions.create(
7 model="BLR2/qwen3-vl-4b-gui-agent1",
8 messages=[
9 {
10 "role": "user",
11 "content": [
12 {"type": "image_url", "image_url": {"url": "data:image/png;base64,{base64_image}"}},
13 {"type": "text", "text": "Click on the search button"}
14 ]
15 }
16 ],
17 max_tokens=50
18)
19print(response.choices[0].message.content)x y where both values are in range [0, 1].1x_norm, y_norm = map(float, output.split())
2x_pixel = int(x_norm * image_width)
3y_pixel = int(y_norm * image_height)