GAN-CNN Model for Automated UI Image to HTML Code Generation
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Current automatic code generation methods for software development are inefficient, require significant learning, and have limited universality, making them unsuitable for rapid and widespread adoption in software development.
Innovation Solution
A method utilizing a generative adversarial network (GAN) and convolutional neural network (CNN) to generate web codes for user interfaces by constructing a mapping relationship between HTML element display effects and source codes, performing object recognition, and iteratively refining the generated codes to achieve high accuracy and wide applicability.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Extent of automation
If traditional automatic code generation methods (template-based, model-driven, etc.) are used, then code generation can be partially automated, but the methods require significant learning and have limited universality
Solution Approach 1:
The patent replaces traditional mechanical code generation systems (templates, model-driven approaches) with a deep learning-based neural network system. The GAN and CNN models automatically learn code generation patterns from training data, eliminating the need for manual template configuration and model definition, thereby achieving both high automation and broad adaptability across different UI scenarios
Solution Approach 2:
The patent transforms the code generation problem into a parameter optimization problem by training neural network models on large datasets. The system learns optimal parameters (weights, biases, network architecture) through iterative training, enabling the model to generalize to unseen UI designs and achieve high universality without requiring method-specific configuration
2Extent of automation
If traditional automatic code generation methods are used, then some code generation can be automated, but the development process remains heavy and inefficient
Solution Approach 1:
The patent implements a self-service code generation system where the trained GAN-CNN model automatically generates complete, production-ready HTML and CSS code from UI design images without human intervention. The system handles the entire code generation pipeline including structure extraction, style transfer, and code output, eliminating the need for developers to manually write or configure generation rules
Solution Approach 2:
The patent performs preliminary training of the neural network models on large datasets of UI designs and their corresponding code before actual code generation. This pre-training phase enables the model to learn complex patterns and relationships, so that during actual use, code can be generated rapidly and accurately without requiring developers to perform time-consuming setup or configuration
3Extent of automation
If traditional automatic code generation methods are used, then code generation can be performed, but the use threshold is relatively high and they are not friendly to most developers
Solution Approach 1:
The patent introduces a trained neural network model as an intermediary between UI design images and target code. Instead of requiring developers to directly work with complex generation rules and templates, the system uses the learned model to translate visual designs into code automatically, significantly lowering the skill threshold and making the tool accessible to developers of all skill levels
4Adaptability or versatility
If more learning is required to master traditional methods, then the methods can be applied, but the learning curve increases and adoption is limited
Solution Approach 1:
The patent replaces manual, rule-based code generation systems with an automated neural network system that learns from data rather than requiring users to learn complex rules. The model is trained offline on diverse UI examples, and during deployment, it automatically adapts to different design styles and patterns without requiring users to learn or configure anything, thereby eliminating the learning curve while maintaining broad applicability
Data Source
AI summary
Provided is a method for generating web codes for a user interface (UI) based on a generative adversarial network (GAN) and a convolutional neural network (CNN). The method includes steps described below. A mapping relationship between display effects of a HyperText Markup Language (HTML) element and source codes of the HTML element is constructed. A location of an HTML element in an image I is recognized. Complete HTML codes of the image I are generated. The similarity between manually-written HTML codes and the generated complete HTML codes and the similarity between the image I and an image I1 generated by the generated complete HTML codes are obtained. After training, an image-to-HTML-code generation model M is obtained. A to-be-processed UI image is input into the model M so as to obtain corresponding HTML codes. According to the method of the present disclosure, an image-to-HTML-code generation model M can be obtained.


