Machine Learning-Based Prototyping of Graphical User Interfaces for Mobile Apps

Kevin Moran, Carlos Bernal-Cárdenas, Michael Curcio, Richard Bonett, Denys PoshyvanykIEEE Trans. Software Eng 2018

Abstract

It is common practice for developers of user-facing software to transform a mock-up of a graphical user interface (GUI) into code. This process takes place both at an application's inception and in an evolutionary context as GUI changes keep pace with evolving features. Unfortunately, this practice is challenging and time-consuming. In this paper, we present an approach that automates this process by enabling accurate prototyping of GUIs via three tasks: detection, classification, and assembly. First, logical components of a GUI are detected from a mock-up artifact using either computer vision techniques or mock-up metadata. Then, software repository mining, automated dynamic analysis, and deep convolutional neural networks are utilized to accurately classify GUI-components into domain-specific types (e.g., toggle-button). Finally, a data-driven, K-nearest-neighbors algorithm generates a suitable hierarchical GUI structure from which a prototype application can be automatically assembled. We implemented this approach for Android in a system called ReDraw. Our evaluation illustrates that ReDraw achieves an average GUI-component classification accuracy of 91% and assembles prototype applications that closely mirror target mock-ups in terms of visual affinity while exhibiting reasonable code structure. Interviews with industrial practitioners illustrate ReDraw's potential to improve real development workflows.

Introduction

In modern software development, a persistent "abstraction gap" exists between designers and developers. Designers create high-fidelity mock-ups in tools like Photoshop or Sketch, which developers must then manually translate into platform-specific code (e.g., Android XML). This process is notoriously tedious, time-consuming, and prone to "design violations" where the final application fails to match the original vision. As apps evolve through iterative feedback loops, keeping the code in sync with design changes becomes a significant bottleneck.

To address this, researchers developed REDRAW, a system designed to automate the design-to-code pipeline. By combining computer vision, deep learning, and repository mining, REDRAW allows teams to move from a static image to a running prototype with minimal manual effort.

The REDRAW Methodology

The REDRAW system decomposes the prototyping problem into three distinct tasks: Detection, Classification, and Assembly.

Overview of the automated REDRAW pipeline, illustrating the flow from data mining to functional prototype generation.

1. Detection

To locate components on a screen, REDRAW utilizes two primary methods. It can parse metadata from design tools (such as the Marketch plugin for Sketch) or employ traditional Computer Vision (CV) techniques, including Canny edge detection and contour analysis, to identify components within a raw screenshot.

2. Classification

Once a component is detected, REDRAW identifies its type (e.g., button, toggle, or text view) using a Deep Convolutional Neural Network (CNN). Unlike previous heuristic-based methods, the CNN learns abstract visual features from a massive dataset of real-world examples mined from the Google Play Store.

The Convolutional Neural Network architecture used by REDRAW for feature extraction and GUI-component classification.

3. Assembly

The final stage involves organizing detected components into a logical hierarchy. Rather than relying on simple heuristics, REDRAW uses a K-Nearest Neighbors (KNN) algorithm. It searches a database of thousands of professionally developed apps to find similar layouts and uses their underlying code structure as a template to assemble the new GUI hierarchy. This ensures the generated code is not only visually accurate but also structurally sound.

Evaluation and Key Results

The researchers evaluated REDRAW using a custom dataset extracted from 8,878 top-rated Android apps, comprising over 191,000 labeled GUI components. Key findings include:

  • High Classification Precision: The CNN classifier achieved a 91% top-1 average precision across 15 component classes, significantly outperforming traditional "Bag of Visual Words" baselines (64.7%).
  • Visual and Structural Fidelity: Automated metrics and user studies confirmed that REDRAW-generated apps were more visually similar to original mock-ups than those created by competitors like pix2code. Furthermore, the KNN-based assembly produced code hierarchies that closely mirrored ground-truth developer code.
  • Industry Validation: Interviews with professionals at companies such as Google, Huawei, and Facebook confirmed that REDRAW has the potential to significantly reduce the time spent on "boilerplate" UI coding.

Conclusion and Future Work

While REDRAW represents a significant step forward, several challenges remain. Currently, the tool focuses on single-screen prototyping and does not yet infer the "flow" or transitions between multiple screens. Additionally, while it captures basic styles like colors and font sizes, finer details like complex animations or shadows are not yet supported. Future work aims to expand the system to cross-platform frameworks and incorporate hierarchical CNNs to further streamline the detection and classification process.

Summary updated

BibTeX
@article{moran2018machine,
  author = {Kevin Moran and Carlos Bernal-Cárdenas and Michael Curcio and Richard Bonett and Denys Poshyvanyk},
  title = {{Machine Learning-Based Prototyping of Graphical User Interfaces for Mobile Apps}},
  journal = {IEEE Trans. Software Eng.},
  year = {2018},
  url = {https://openreview.net/forum?id=BrlV3dxHWW9},
}
Figure