ScreenCoder: Advancing Visual-to-Code Generation for Front-End Automation via Modular Multimodal Agents
ScreenCoder通过模块化多智能体框架,实现了从视觉UI设计到前端代码的自动化转换,提高了代码生成的准确性和可解释性。
更新于 2025-07-31。作者:Yilei Jiang、Yaozhi Zheng、Yuxuan Wan、Jiaming Han、Qunzhong Wang、Michael R. Lyu、Xiangyu Yue。
中文摘要
自动化将用户界面(UI)设计转换为前端代码具有加速软件开发和民主化设计流程的巨大潜力。尽管最近的大型语言模型(LLMs)在文本到代码生成方面取得了进展,但许多现有方法仅依赖于自然语言提示,这限制了它们在捕捉空间布局和视觉设计意图方面的有效性。相比之下,实际中的UI开发本质上是多模态的,通常从视觉草图或原型开始。为了解决这一差距,我们引入了一个模块化多智能体框架,该框架通过三个可解释的阶段进行UI到代码的生成:定位、规划和生成。定位智能体使用视觉语言模型来检测和标记UI组件,规划智能体使用前端工程先验构建层次布局,生成智能体通过自适应提示合成生成HTML/CSS代码。这种设计在鲁棒性、可解释性和保真度方面优于端到端黑盒方法。此外,我们将该框架扩展为一个可扩展的数据引擎,能够自动生成大规模图像-代码对。使用这些合成示例,我们微调和强化了一个开源的VLM,在UI理解和代码质量方面取得了显著的提升。广泛的实验表明,我们的方法在布局精度、结构连贯性和代码正确性方面达到了最先进的性能。我们的代码已在https://github.com/leigest519/ScreenCoder上公开。
英文摘要
Automating the transformation of user interface (UI) designs into front-end code holds significant promise for accelerating software development and democratizing design workflows. While recent large language models (LLMs) have demonstrated progress in text-to-code generation, many existing approaches rely solely on natural language prompts, limiting their effectiveness in capturing spatial layout and visual design intent. In contrast, UI development in practice is inherently multimodal, often starting from visual sketches or mockups. To address this gap, we introduce a modular multi-agent framework that performs UI-to-code generation in three interpretable stages: grounding, planning, and generation. The grounding agent uses a vision-language model to detect and label UI components, the planning agent constructs a hierarchical layout using front-end engineering priors, and the generation agent produces HTML/CSS code via adaptive prompt-based synthesis. This design improves robustness, interpretability, and fidelity over end-to-end black-box methods. Furthermore, we extend the framework into a scalable data engine that automatically produces large-scale image-code pairs. Using these synthetic examples, we fine-tune and reinforce an open-source VLM, yielding notable gains in UI understanding and code quality. Extensive experiments demonstrate that our approach achieves state-of-the-art performance in layout accuracy, structural coherence, and code correctness. Our code is made publicly available at https://github.com/leigest519/ScreenCoder.
解读
一句话总结
ScreenCoder通过模块化多智能体框架,实现了从视觉UI设计到前端代码的自动化转换,提高了代码生成的准确性和可解释性。
问题1:这篇论文想要解决什么具体问题?
- 问题背景:自动化将UI设计转换为前端代码对于加速软件开发和简化设计流程具有重要意义。然而,现有的基于文本的生成方法在捕捉空间布局和视觉设计意图方面存在局限性。
- 现有方案不足:基于文本的生成方法需要非常长的描述来捕捉组件结构、样式和空间关系,这对用户来说负担很重,并且模型的性能容易受到破坏。此外,仅使用语言难以精确指定视觉设计细节,如组件比例、间距或对齐方式。
- 研究目标:提出一种模块化多智能体框架,通过三个可解释的阶段(grounding, planning, and generation)来实现UI到代码的生成,从而提高代码生成的准确性和可解释性。
问题2:论文的核心创新点是什么?
- 技术创新:提出了一种模块化多智能体框架,将UI到代码的任务分解为三个阶段,包括grounding、planning和generation,每个阶段由专门的智能体执行。
- 方法改进:引入了vision-language model来检测和标记UI组件,使用前端工程先验知识构建分层布局,并通过自适应提示合成生成HTML/CSS代码。
- 优势:与端到端黑盒方法相比,该设计提高了鲁棒性、可解释性和忠实度。
问题3:实验结果如何验证了方法的有效性?
- 关键实验:在多个UI设计数据集上进行了实验,包括3,000个UI图像/代码对。
- 性能提升:在布局准确性、结构一致性和代码正确性方面取得了最先进的性能。
- 对比结果:与现有的视觉语言模型相比,ScreenCoder在所有五个评估指标(块匹配、文本相似性、位置对齐、颜色一致性和基于CLIP的视觉相似性)上都表现更好。
问题4:这个研究的实际应用价值是什么?
- 应用场景:ScreenCoder可以应用于自动化前端开发、UI设计自动化和代码生成等场景。
- 实施建议:将ScreenCoder集成到现有的UI设计工具和开发环境中,以实现无缝的工作流程。
- 局限与展望:虽然ScreenCoder在UI到代码生成方面取得了显著进展,但未来还需要进一步研究以解决噪声或低分辨率输入截图的鲁棒性问题,并优化推理延迟。此外,可以探索将ScreenCoder应用于更广泛的领域,如移动应用、桌面界面或游戏UI的代码生成。