Views
No views yet

transformers library.transformers library:pip install transformers>=4.57.11from transformers import AutoProcessor, AutoModelForImageTextToText
2import torch
3
4messages = [
5 {
6 "role": "user",
7 "content": [
8 {
9 "type": "image",
10 "url": "https://raw.githubusercontent.com/zheny2751-dotcom/UI2Code-N/main/assets/example.png"
11 },
12 {
13 "type": "text",
14 "text": "Based on the domtree and the page screenshot, please identify which interactive components in the image require interaction. Please note that if similar buttons have been clicked on similar pages in the past, do not click them again, and also do not select buttons that are obscured on the page."
15 }
16 ],
17 }
18]
19processor = AutoProcessor.from_pretrained("zai-org/WebVIA-Agent")
20model = AutoModelForImageTextToText.from_pretrained(
21 pretrained_model_name_or_path="zai-org/WebVIA-Agent",
22 torch_dtype=torch.bfloat16,
23 device_map="auto",
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)
32generated_ids = model.generate(**inputs, max_new_tokens=16384)
33output_text = processor.decode(generated_ids[0][inputs["input_ids"].shape[1]:], skip_special_tokens=False)
34print(output_text)@article{xu2025webvia,
title={WebVIA: A Web-based Vision-Language Agentic Framework for Interactive and Verifiable UI-to-Code Generation},
author={Xu, Mingde and Yang, Zhen and Hong, Wenyi and Pan, Lihang and Fan, Xinyue and Wang, Yan and Gu, Xiaotao and Xu, Bin and Tang, Jie},
year={2025},
journal={arXiv preprint arXiv:2511.06251}
}