WebRPG: Automatic Web Rendering Parameters Generation for Visual Presentation

Zirui Shao, Feiyu Gao, Hangdi Xing, Zepeng Zhu, Zhi Yu, Jiajun Bu, Qi Zheng, Cong Yao

Introduction

While generative AI has revolutionized text, images, and code, the holistic automation of web design remains a significant challenge. Large Language Models (LLMs) can generate functional HTML, but creating professional-grade visual presentations requires complex CSS to manage layout, typography, and color across hundreds of nested elements. WebRPG addresses this gap by introducing a framework that automatically generates visual styling—defined as Rendering Parameters (RPs)—based solely on a page's HTML structure.

The WebRPG Framework

The authors propose a multi-stage pipeline designed to handle the high dimensionality and hierarchical nature of web design. Instead of generating raw CSS code, which can be verbose and error-prone, the model predicts a standardized set of 13 properties for every element, covering layout, text, and color.

The WebRPG pipeline: transforming raw HTML into well-designed visual presentations via Rendering Parameters.

To manage the complexity of these parameters, WebRPG utilizes a Variational Autoencoder (VAE) to compress the RPs of each element into a compact latent vector. The model processes the HTML using a three-pronged embedding strategy:

  1. Semantic Embedding: Utilizing MarkupLM to interpret the textual meaning.
  2. Hierarchical Embedding: Using XPath embeddings to preserve the element's position within the DOM tree.
  3. Character Count: Providing a heuristic for the physical space an element requires.

Methodology and Dataset

Because no existing benchmark addressed this specific task, the researchers developed the WebRPG Dataset, derived from 20,000 e-commerce pages in the Klarna dataset. They extracted over 88,000 high-quality sub-page samples and introduced a Visual Complexity (VC) metric to filter out broken or overly simplistic designs, ensuring the model learned from sophisticated layouts.

The researchers compared two generative backbones: an Autoregressive (AR) model and a Diffusion Model (DM). A key finding was that Diffusion Models, while excellent for Euclidean image data, struggled with the hierarchical, relational nature of web elements. The Autoregressive model, which processes elements sequentially through the tree, proved far more effective at maintaining structural integrity.

Key Results and Insights

The WebRPG-AR model significantly outperformed both the Diffusion baseline and general-purpose models like GPT-4 across all quantitative metrics:

  • Visual Quality: WebRPG-AR achieved a Fréchet Inception Distance (FID) of 0.1281, compared to GPT-4’s 4.21 and the Diffusion model’s 62.02.
  • Layout Accuracy: In terms of Element IoU (Intersection over Union), WebRPG-AR scored 0.7082, while GPT-4 struggled at 0.0347.
  • Human Preference: In pairwise comparisons, human annotators preferred WebRPG-AR's designs over GPT-4's in 62.7% of cases.
Examples of high-quality, consistent web designs generated by the WebRPG-AR model across various e-commerce categories.

Beyond pixel-matching, the authors introduced a Style Consistency (SC) Score based on Gestalt psychology. This metric evaluates whether similar functional elements (e.g., all buttons or all price tags) are styled uniformly, a hallmark of professional design that WebRPG-AR successfully emulates.

Limitations and Future Directions

Despite its success, WebRPG currently treats images as placeholders without analyzing their content. Future iterations could incorporate image embeddings to harmonize the UI style with product photography. Additionally, while the model excels at moderate complexity, performance can degrade in extremely deep HTML trees where errors may accumulate toward the bottom-right of the page. Integrating the output with modern frameworks like Tailwind CSS remains a promising avenue for making the system more developer-friendly.

Summary updated

BibTeX
@inproceedings{shao2024webrpg,
  author = {Zirui Shao and Feiyu Gao and Hangdi Xing and Zepeng Zhu and Zhi Yu and Jiajun Bu and Qi Zheng and Cong Yao},
  title = {{WebRPG: Automatic Web Rendering Parameters Generation for Visual Presentation}},
  booktitle = {European Conference on Computer Vision},
  year = {2024},
  doi = {10.1007/978-3-031-73242-3\_4},
}
Figure