Prototype2Code:从 UI 设计原型到前端代码的端到端代码生成
Prototype2Code: End-to-end Front-end Code Generation from UI Design Prototypes
AI总结:
本文提出 Prototype2Code,通过设计检查、层级优化、UI 元素识别和 flexbox 响应式布局,实现从设计原型到前端代码的端到端生成,并在视觉指标与工程师评估中优于 CodeFun 和 GPT-4V 方案。
摘要:
UI 到代码技术已经简化了前端开发流程,减少了工程师的重复性任务。先前研究主要将设计原型作为输入,生成代码的有效性严重依赖这些原型的质量,从而导致鲁棒性受损。此外,这些方法在代码质量方面也存在不足,包括 UI 结构混乱以及无法支持响应式布局等问题。为应对这些挑战,我们提出 Prototype2Code,它能够结合业务需求实现端到端前端代码生成。对于 Prototype2Code,我们将设计 linting(代码/设计检查)纳入工作流,解决碎片化元素和感知分组的检测问题,增强生成结果的鲁棒性。通过优化层级结构并智能识别 UI 元素类型,Prototype2Code 生成的代码更具可读性且结构更清晰。为满足响应式设计需求,Prototype2Code 主要支持 flexbox 布局模型,确保代码在各种设备尺寸上的兼容性。为验证有效性,我们将 Prototype2Code 与商业代码生成平台 CodeFun 以及基于具备视觉能力的 GPT-4 的 Screenshot-to-code 进行比较。采用结构相似性指数(SSIM)、峰值信噪比(PSNR)和均方误差(MSE)进行视觉相似性评估,Prototype2Code 渲染出的 UI 效果与设计原型最为一致,并表现出最小误差。我们还开展了一项用户研究,邀请五名经验丰富的前端工程师审查并修改由三种方法生成的代码。结果表明,Prototype2Code 在可读性、可用性和可维护性方面均优于其他方法,能够更好地满足工业开发的业务需求。
英文摘要:
UI-to-code technology has streamlined the front-end development process, reducing repetitive tasks for engineers. prior research mainly use design prototypes as inputs, with the effectiveness of the generated code heavily dependent on these prototypes' quality, leading to compromised robustness. Moreover, these approaches also exhibit shortcomings in code quality, including issues such as disorganized UI structures and the inability to support responsive layouts. To address these challenges, we introduce Prototype2Code, which achieves end-to-end front-end code generation with business demands. For Prototype2Code, we incorporate design linting into the workflow, addressing the detection of fragmented elements and perceptual groups, enhancing the robustness of the generated outcomes. By optimizing the hierarchical structure and intelligently recognizing UI element types, Prototype2Code generates code that is more readable and structurally clearer. To meet responsive design requirements, Prototype2Code primarily supports flexbox layout model, ensuring code compatibility across various device sizes. To validate the efficacy, we compare Prototype2Code with the commercial code generation platform CodeFun and Screenshot-to-code based on GPT-4 with vision. Employing structural similarity index measure (SSIM), peak signal-to-noise ratio (PSNR), and mean squared error (MSE) for visual similarity assessment, Prototype2Code's rendered UI effects align most closely with the design prototypes, exhibiting the minimal errors. We also conduct a user study with five experienced front-end engineers, inviting them to review and revise code generated by the three methods. As a result, Prototype2Code surpasses other methods in readability, usability, and maintainability, better meeting the business needs of industrial development.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。