Skip to main content
QUICK REVIEW

[Paper Review] Sketch2Code: Transformation of Sketches to UI in Real-time Using Deep Neural Network

Vanita Jain, Piyush Agrawal|arXiv (Cornell University)|Oct 20, 2019
Interactive and Immersive DisplaysComputer Science13 citations
TL;DR

Sketch2Code proposes a deep learning model that converts hand-drawn UI sketches into platform-independent UI representation objects in real time (average inference: 129 ms), using a custom dataset of 2001 UI elements across 149 sketches. The system detects UI components via a fine-tuned YOLO-based network, resolves overlapping elements, and generates a DOM-like JSON object parsed into platform-specific code, enabling efficient, multi-platform UI prototyping without retraining.

ABSTRACT

User Interface (UI) prototyping is a necessary step in the early stages of application development. Transforming sketches of a Graphical User Interface (UI) into a coded UI application is an uninspired but time-consuming task performed by a UI designer. An automated system that can replace human efforts for straightforward implementation of UI designs will greatly speed up this procedure. The works that propose such a system primarily focus on using UI wireframes as input rather than hand-drawn sketches. In this paper, we put forward a novel approach wherein we employ a Deep Neural Network that is trained on our custom database of such sketches to detect UI elements in the input sketch. Detection of objects in sketches is a peculiar visual recognition task that requires a specific solution that our deep neural network model attempts to provide. The output from the network is a platform-independent UI representation object. The UI representation object is a dictionary of key-value pairs to represent the UI elements recognized along with their properties. This is further consumed by our UI parser which creates code for different platforms. The intrinsic platform-independence allows the model to create a UI prototype for multiple platforms with single training. This two-step approach without the need for two trained models improves over other methods giving time-efficient results (average time: 129 ms) with good accuracy.

Motivation & Objective

  • To automate the time-consuming process of transforming hand-drawn UI sketches into functional code prototypes.
  • To develop a deep neural network capable of recognizing UI elements in unconstrained, freehand sketches, a challenging visual recognition task.
  • To generate a platform-independent UI representation object that enables rapid code generation for multiple platforms without retraining.
  • To improve efficiency and accuracy over existing methods that rely on wireframes or two-stage detection pipelines.
  • To evaluate model robustness under varying lighting conditions and sketch quality, including shadows and over-saturation.

Proposed method

  • A custom dataset of 149 sketches containing 2001 labeled UI elements (e.g., buttons, text fields) was created for training.
  • A YOLO-based single-shot object detection model was fine-tuned to detect UI components in hand-drawn sketches, with input images resized to 416×416.
  • Overlapping detection heuristics were applied to resolve spatially overlapping UI elements by prioritizing larger or more salient components.
  • The model outputs a platform-independent UI representation object in JSON format, structured as a dictionary of key-value pairs encoding element type, position, and properties.
  • A React-based UI parser consumes the JSON representation to generate platform-specific UI code, enabling cross-platform deployment.
  • Inference was accelerated using a NVIDIA GeForce GTX 1060 GPU with cuDNN, and timing excluded image loading to measure pure model inference speed.

Experimental results

Research questions

  • RQ1Can a deep neural network accurately detect UI elements in freehand, hand-drawn sketches despite variations in lighting, sketching style, and background?
  • RQ2How does the model perform under challenging visual conditions such as low-light, shadows, and over-saturation?
  • RQ3Can a single trained model generate platform-independent UI representations that are then parsed into functional code for multiple platforms?
  • RQ4What is the inference speed of the model, and can it achieve real-time performance suitable for interactive prototyping?
  • RQ5How does model performance scale with increased training data, particularly in terms of accuracy and robustness?

Key findings

  • The model achieves an average inference time of 129 ms per image, demonstrating real-time performance suitable for interactive UI prototyping.
  • Performance degrades under low-light and shadowed conditions due to difficulty in distinguishing background from foreground elements, increasing inference time.
  • Over-saturation and reflective backgrounds lead to inaccurate predictions, especially when the background is inconsistent or noisy.
  • The model performs best under optimal lighting with a clean white background, achieving high accuracy and low inference time.
  • The model shows strong generalization on a small dataset of 149 images and 2001 labeled components, suggesting potential for improvement with larger, diverse training data.
  • The two-step pipeline—detection followed by UI representation and parsing—achieves platform independence without requiring separate models per platform.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.