Skip to main content
QUICK REVIEW

[Paper Review] Automatic Graphics Program Generation using Attention-Based Hierarchical Decoder

Zhihao Zhu, Xue Zhan|arXiv (Cornell University)|Oct 26, 2018
Advanced Neural Network ApplicationsComputer Science8 citations
TL;DR

This paper proposes an attention-based hierarchical decoder for automatic GUI-to-code generation, modeling code structure hierarchically to improve long-sequence dependency handling and structural accuracy. It outperforms state-of-the-art methods on both benchmark and newly created complex GUI datasets, especially on longer, more intricate code sequences.

ABSTRACT

Recent progress on deep learning has made it possible to automatically transform the screenshot of Graphic User Interface (GUI) into code by using the encoder-decoder framework. While the commonly adopted image encoder (e.g., CNN network), might be capable of extracting image features to the desired level, interpreting these abstract image features into hundreds of tokens of code puts a particular challenge on the decoding power of the RNN-based code generator. Considering the code used for describing GUI is usually hierarchically structured, we propose a new attention-based hierarchical code generation model, which can describe GUI images in a finer level of details, while also being able to generate hierarchically structured code in consistency with the hierarchical layout of the graphic elements in the GUI. Our model follows the encoder-decoder framework, all the components of which can be trained jointly in an end-to-end manner. The experimental results show that our method outperforms other current state-of-the-art methods on both a publicly available GUI-code dataset as well as a dataset established by our own.

Motivation & Objective

  • Address the challenge of generating semantically accurate, hierarchically structured code from GUI screenshots.
  • Overcome limitations of existing RNN-based decoders in handling long-term dependencies and rigid sequence length constraints.
  • Improve code generation fidelity by explicitly modeling the hierarchical layout of GUI elements and their corresponding code structure.
  • Demonstrate superior performance on both standard and newly constructed, more complex GUI-code datasets.

Proposed method

  • Adopts an encoder-decoder framework with a CNN-based image encoder to extract visual features from GUI screenshots.
  • Employs a two-stage hierarchical decoder: a first-stage LSTM generates block-level representations, and a second-stage LSTM generates code tokens per block.
  • Integrates an attention mechanism that dynamically selects relevant visual features from the CNN features based on the first-stage LSTM's hidden state.
  • Uses the attended visual features as context for the second-stage LSTM to generate code tokens, enabling better alignment between GUI regions and code blocks.
  • Trains all components end-to-end using backpropagation, enabling joint optimization of image understanding and code generation.
  • Applies beam search (beam size 3 and 5) during inference to improve generation quality over greedy decoding.

Experimental results

Research questions

  • RQ1Can a hierarchical decoding strategy with attention improve code generation accuracy for complex GUIs compared to flat sequence models?
  • RQ2How does the model perform on longer code sequences typical of iOS and Android GUIs compared to baseline methods?
  • RQ3To what extent does the attention mechanism enhance alignment between visual regions and code blocks in the generated program?
  • RQ4Does the model generalize better to more complex GUIs with diverse layouts and richer visual elements than existing methods?
  • RQ5How does the hierarchical structure of the decoder affect the model's ability to preserve structural and semantic details in generated code?

Key findings

  • The proposed model achieves state-of-the-art performance on the PixCo benchmark dataset, outperforming pix2code and baseline methods across all sub-datasets: iOS (26.10 vs. 27.20), Android (27.20 vs. 27.25), and Web (18.31 vs. 17.25) in classification error.
  • On the more complex PixCo-e dataset, the model significantly outperforms baselines, with lower error rates on longer sequences (e.g., 109 tokens/GUI for iOS, 112 for Android), demonstrating improved handling of long-term dependencies.
  • Beam search (beam size 5) yields better performance than greedy decoding, with error rates dropping to 25.78 on iOS, 26.95 on Android, and 17.12 on Web.
  • Qualitative results show that the model preserves more visual details and correctly reconstructs complex GUI layouts, while pix2code fails to recover many elements on the PixCo-e dataset.
  • The attention mechanism enables the model to learn meaningful alignments between code blocks and their corresponding spatial regions in the GUI, as visualized in attention heatmaps.
  • The hierarchical decoder with attention significantly improves performance over a non-attention hierarchical baseline, confirming the value of attention in guiding context selection.

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.