Method for automatically generating front-end view component code based on machine learning and image recognition

Through machine learning and image recognition technology, UI elements are automatically recognized and front-end view component code is generated, which solves the problems of cumbersome UI design drafts and unstable code quality in front-end development, and realizes efficient and flexible code generation, improving development Efficiency and code consistency.

CN118963736APending Publication Date: 2024-11-15ZHONGKE ZHIHE DIGITAL TECH (BEIJING) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411228395.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-02
Publication Date
2024-11-15

AI Technical Summary

Technical Problem

Manually parsing UI design drafts in existing front-end development is cumbersome and error-prone, the code quality is unstable, the generated code is single and does not meet the actual application scenarios, and the lack of fine-grained component support, resulting in low development efficiency, poor flexibility and inconsistent code.

Method used

Using automated methods based on machine learning and image recognition, through image preprocessing, convolutional neural network, generation adversarial network and intelligent optimization algorithm, accurately identify UI elements, generate customized front-end view component code, reduce human errors, and improve code consistency and quality.

Benefits of technology

It realizes efficient and flexible code generation of front-end view components, reduces developer workload, improves code quality and development efficiency, ensures code consistency and maintainability, and saves time and costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118963736A_ABST
    Figure CN118963736A_ABST
Patent Text Reader

Abstract

The invention relates to the field of computers, the field of image recognition and the field of machine learning, and provides a method for automatically generating front-end view component codes based on machine learning and image recognition. The method aims at solving the problem that in a front-end development scene, the process of manually analyzing the UI design draft is tedious and prone to making mistakes, and the main scheme comprises the steps of analyzing the UI design draft, analyzing the UI design draft through the image recognition technology and recognizing UI elements. Carrying out model selection and training on the processed UI elements, generating front-end view component codes by using a generative adversarial network (GAN), and carrying out model verification and deployment to realize automatic generation of codes corresponding to front-end view components; user feedback collection and demand modeling are carried out on front-end view component codes, then an intelligent optimization algorithm is designed for optimization, an optimization result is evaluated and iteratively improved, and the code quality is improved; and according to the trained machine learning model and the optimization algorithm, automatically generating a highly-customized front-end view component code, and outputting the highly-customized front-end view component code to a development environment.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the fields of computer, image recognition and machine learning, and provides a method for automatically generating front-end view component code based on machine learning and image recognition. Background Art

[0002] Developers manually write front-end component codes based on UI design drafts, including HTML structure, CSS style, and JavaScript logic. Based on existing front-end frameworks and libraries, such as React, Vue.js, Angular, etc., developers can use packaged components to achieve view componentization.

[0003] Some front-end development tools provide visual interfaces and drag-and-drop operations to help developers quickly create and adjust UI interfaces, but they still need to manually write and configure component code. In the front-end development process, manually writing and adjusting view component code is a tedious and time-consuming task, which often requires developers to spend a lot of time and energy. In addition, due to the intervention of human factors, problems such as unstable code quality and inconsistent styles are prone to occur. Template engines and automated code generation tools, this method uses predefined templates and rules to automatically generate front-end code based on design drafts. For example, tools such as Vue CLI or Angular CLI can quickly generate basic front-end project structures and component codes through command line tools. However, these tools can usually only generate basic code frameworks, which cannot meet the needs of complex design drafts or view components.

[0004] Existing componentization solutions do not provide sufficiently fine-grained componentization support, and cannot accurately decompose and combine front-end views, resulting in the generated components being inflexible and incustomizable. Therefore, a method that can automatically generate front-end view components is needed to improve development efficiency and flexibility, reduce human errors, and ensure code consistency and quality. Summary of the invention

[0005] The present invention aims to solve the problems of cumbersome and error-prone manual parsing of UI design drafts in front-end development scenarios, unstable code quality and inconsistent styles when manually writing and adjusting view component codes, and the problem that the codes generated by traditional code generation methods are single and do not conform to actual application scenarios. Through machine learning and image recognition technology, a method for accurately identifying UI elements and customizing the generation of standardized and stable front-end codes is realized.

[0006] In order to achieve the above-mentioned purpose, the present invention adopts the following technical means:

[0007] The present invention provides a method for automatically generating front-end view component code based on machine learning and image recognition, comprising the following steps:

[0008] Step 1: Analyze UI design drafts, use image recognition technology to analyze UI design drafts and identify UI elements;

[0009] Step 2: Select and train the model of the processed UI elements, use the generative adversarial network (GAN) to generate the front-end view component code, perform model verification and deployment, and automatically generate the code of the corresponding front-end view component;

[0010] Step 3: Collect user feedback and model requirements for the front-end view component code, then design an intelligent optimization algorithm for optimization, evaluate and iterate the optimization results to improve code quality;

[0011] Step 4: Based on the trained machine learning model and optimization algorithm, highly customized front-end view component code is automatically generated and output to the development environment.

[0012] The UI design draft may have noise, complex background and overlapping problems between UI elements. To solve this problem, the present invention further provides a specific implementation scheme of the following step 1:

[0013] Step 1.1: Image preprocessing, converting the color design draft into a grayscale image, simplifying the processing process, using filtering technology to remove noise in the image, improving the accuracy of subsequent processing, and segmenting each UI element in the design draft for separate identification and processing. This solves the problems that may exist in the UI design draft, such as noise, complex background, and overlap between UI elements, and ensures the accuracy of subsequent processing.

[0014] Step 1.1.1: Calculate the horizontal and vertical gradients, and take the weighted average of the red, green, and blue channel values ​​of each pixel of the RGB image to obtain a grayscale image. Use the Sobel operator Obtain the gradient images in the horizontal and vertical directions respectively;

[0015] Step 1.1.2: Edge detection: merge the horizontal and vertical gradient images to obtain the gradient magnitude and direction of each pixel. The gradient magnitude indicates the degree of change in pixel intensity, while the gradient direction indicates the direction of change. A threshold is set to determine which pixels are considered edge pixels. If the gradient magnitude is greater than the threshold, the pixel is marked as an edge pixel, otherwise it is marked as a non-edge pixel.

[0016] Step 1.1.3: Non-maximum suppression: Perform non-maximum suppression on the detected edges to refine the edges, so as to ensure that only local maximum points in the gradient direction are retained, while non-maximum points are suppressed, thereby obtaining a more refined edge.

[0017] Step 1.1.4: Double threshold edge connection: perform edge connection based on two thresholds of gradient amplitude to obtain the position and shape of UI elements;

[0018] Step 1.1.5: Overlapping processing: The detected UI elements are represented as binary images, where the pixel value of the UI element is 1 and the background pixel value is 0. A logical AND operation is performed pixel by pixel on the two UI elements. In the result image of the logical AND operation, if the pixel value is 1, it means that the two UI elements overlap at the pixel position. A threshold is set. If the pixels in the overlapping area exceed the threshold, it is determined that the two UI elements overlap. Finally, the overlapping UI elements are distinguished and segmented based on pixel intensity, color, and texture features.

[0019] Step 1.1.6: Post-processing, remove unreasonable segmentation and merge adjacent areas to obtain more accurate UI element segmentation results, and finally obtain the segmented elements in the UI design draft.

[0020] Step 1.2: UI element recognition: use convolutional neural network (CNN) to extract UI element features from the preprocessed image, use OCR technology to convert text content, mark UI element type, position, size, and structure data, train classifiers for classification and recognition, and use YOLO model for target detection;

[0021] Step 1.2.1: Use a convolutional neural network (CNN) to extract the size, shape, and color features of each UI element in the image to obtain the visual features of the UI element;

[0022] Step 1.1, normalize the pixel values ​​of the grayscale image so that its value is in the range of [0, 1];

[0023] Step 1.2: Gradually extract high-level features of the image by stacking multiple convolutional layers and pooling layers;

[0024] Step 1.3: Use cross-validation and network structure search to determine the optimal combination of parameters and structure;

[0025] Step 1.4: The CNN model learns to extract the features of various UI elements in the image during training;

[0026] Step 1.5: Input the image into the trained CNN model, fuse the feature maps extracted from different layers, and obtain the representation of the visual features of the UI element.

[0027] Step 1.2.2: For text content, use OCR (optical character recognition) technology to convert the text in the design draft into recognizable strings to provide text features of UI elements for subsequent steps;

[0028] Step 1.2.3: Combine the visual features of step 1.2.1 and the text features of step 1.2.2 to obtain key features, mark the type, position, and size information of the UI elements, and structure the identified UI elements and their key features into JSON and XML data formats;

[0029] Step 1.2.3.1, use the size, shape, color features, and text features of UI elements to form key features;

[0030] Step 1.2.3.2, mark the type, position and size information of each UI element;

[0031] Step 1.2.3..2, convert the identified UI elements and their key features into JSON and XML data formats;

[0032] Step 1.2.4: Use support vector machine (SVM) to train a classifier to classify and identify each UI element;

[0033] Step 1.2.4.1. Prepare a training dataset, including the features and category labels of UI elements;

[0034] Step 1.2.4.2, select appropriate kernel function and parameters to configure support vector machine;

[0035] Step 1.2.4.3: Train the support vector machine model to classify UI elements based on feature vectors.

[0036] Step 1.2.4..4. Find the optimal decision boundary to separate elements of different categories through model training.

[0037] Step 1.2.5: Use the YOLO model to perform object detection and identify the positions and boundaries of various UI elements in the design draft;

[0038] Step 1.3: Model validation and optimization.

[0039] In the above technical solution, step 2 specifically includes the following steps:

[0040] Step 2.1: Select support vector machine and generative adversarial network (GAN) as classification model and generation model, and perform model training and optimization;

[0041] Step 2.1.1: Prepare the dataset required for training GAN, including UI element feature representation and corresponding target generation code;

[0042] Step 2.1.2: Use the generator network to accept the UI element feature encoding and output the front-end view component code;

[0043] Step 2.1.3, use CNN as the discriminator network to distinguish the data generated by the generator from the real data;

[0044] Step 2.1.4: Train the GAN model and optimize the generator and discriminator through adversarial training. During the training process, the generator network tries to generate realistic front-end view component code, while the discriminator network tries to distinguish the code generated by the generator from the real code. The adversarial training method is used to continuously optimize until a dynamic equilibrium state is reached.

[0045] Step 2.1.5: Use the validation dataset to evaluate the performance of the GAN model and adjust the model parameters;

[0046] Step 2.2: Deploy the trained model to the generation system to automatically generate the front-end view component code;

[0047] Step 2.2.1, deploy the trained model to the production system;

[0048] Step 2.2.2: Input the identified UI element features into the model and generate the front-end code;

[0049] Step 2.2.3: Output the generated front-end code for developers to use;

[0050] Step 2.3: Collect feedback data, evaluate the quality of generated code, and perform model iteration and optimization.

[0051] In the above technical solution, step 3 specifically includes the following steps:

[0052] Step 3.1. Collect user feedback and requirements on the generated front-end view component code, including satisfaction and suggestions on component style, layout, and functionality, analyze and determine optimization aspects, including style adjustment and layout improvement, and model the feedback and requirements into quantifiable optimization goals and constraints.

[0053] Step 3.2: Based on the requirements analysis results, design a particle swarm optimization algorithm to automatically adjust the code to meet user feedback and requirements, implement the algorithm and integrate it into the generation system to optimize the front-end view component code;

[0054] Step 3.3: Evaluate the optimized code, compare the differences and improvements with the original version, use user feedback data to evaluate the practicality and effectiveness of the optimization results, adjust the parameters and strategies of the optimization algorithm based on the evaluation results and user feedback, improve code quality and meet user needs.

[0055] The present invention solves the technical problem of traditional developers manually parsing UI design drafts by using image recognition, achieving the effect of accurately identifying UI elements, reducing the burden on developers, and reducing potential errors; through the generation of adversarial network technology, it solves the problem of inconsistent front-end styles and unstable code quality, achieving the effect of stable customized automatic generation of front-end code. By collecting user feedback information, the system iteration problem is solved, achieving the effect of satisfying users and meeting the market.

[0056] High degree of automation: Compared with traditional manual development methods, our method has a higher degree of automation, which greatly reduces the workload of developers.

[0057] Intelligent Optimization: By combining machine learning and intelligent optimization algorithms, our approach can intelligently adjust and optimize the generated component code according to project requirements, improving code quality and maintainability.

[0058] Unity and consistency: The generated component code maintains a consistent style and structure, avoiding human errors and style inconsistencies, and ensuring the unity and consistency of the project.

[0059] Save time and cost: By automatically generating front-end view component code, our method can greatly save development time and cost, and improve the development efficiency and competitiveness of the project. BRIEF DESCRIPTION OF THE DRAWINGS

[0060] Figure 1 It is a simplified flow chart of the present invention. DETAILED DESCRIPTION

[0061] The following is a detailed description of the embodiments of the present invention. Although the present invention will be described and illustrated in conjunction with some specific embodiments, it should be noted that the present invention is not limited to these embodiments. On the contrary, modifications or equivalent substitutions made to the present invention should all be included in the scope of the claims of the present invention.

[0062] In addition, in order to better illustrate the present invention, numerous specific details are given in the following specific embodiments. It will be understood by those skilled in the art that the present invention can also be implemented without these specific details.

[0063] The present invention provides a method for automatically generating front-end view component code based on machine learning and image recognition, comprising the following steps:

[0064] Step 1: UI design draft analysis: Use image recognition technology to analyze the UI design draft and identify UI elements.

[0065] Step 2: Based on the UI elements identified in step 1, train the machine learning model and automatically generate the corresponding front-end view component code.

[0066] Step 3: Design and implement intelligent optimization algorithms based on user feedback and needs.

[0067] Step 4: Based on the trained machine learning model and optimization algorithm, highly customized front-end view component code is automatically generated and output to the development environment.

[0068] The above step 1 specifically includes the following steps:

[0069] Step 1.1: Image preprocessing. Convert the color design draft into a grayscale image to simplify the processing process, use filtering technology to remove noise in the image, improve the accuracy of subsequent processing, and separate each UI element in the design draft for separate identification and processing. This solves the problems that may exist in the UI design draft, such as noise, complex background, and overlap between UI elements, and ensures the accuracy of subsequent processing.

[0070] Step 1.2: UI element identification. Use convolutional neural networks (CNN) to extract the size, shape, color, and text content features of each UI element in the image. For text content, use OCR (optical character recognition) technology to convert the text in the design draft into a recognizable string, mark the type, position, and size information of the UI element, and structure the identified UI elements and their key features into JSON and XML data formats for subsequent processing analysis, model training, and code generation. Use support vector machines to train classifiers to classify and identify each UI element. The model will learn how to classify UI elements based on feature vectors and find an optimal decision boundary to segment elements of different categories. At the same time, use the YOLO model to detect targets and detect the positions and boundaries of various UI elements in the design draft.

[0071] When using a convolutional neural network to extract the features of each UI element in an image, use The formula normalizes the grayscale image pixel values ​​to the range of [0, 1] so that they can be input into the CNN model. It uses a stack of multiple convolutional layers and pooling layers to gradually extract high-level features of the image, and then uses cross-validation and network structure search methods to determine the optimal parameter and structure combination. During the training process, the CNN model learns to extract the features (i.e., weights) of various UI elements in the image. After that, the image is input into the trained CNN model, and the feature maps extracted from different layers are fused to obtain a more comprehensive and richer representation of UI element features. The multi-faceted feature information of each UI element is obtained, providing an important data foundation for subsequent model training and code generation.

[0072] Step 1.3: Model verification and optimization. Verify the identified and extracted UI elements to evaluate the accuracy and robustness of the model; adjust the feature extraction method and optimize the classifier parameters based on the verification results to optimize the model.

[0073] Step 2 specifically includes the following steps:

[0074] Step 2.1: Model selection and training. Select support vector machine and generative adversarial network (GAN) as classification model and generation model, divide the prepared data set into training set and test set, train the selected machine learning model with the training set, optimize the model parameters so that it can accurately generate the corresponding front-end view component code according to the input UI element features, and then use the test set to verify the accuracy and generalization ability of the model, and perform model tuning and performance evaluation.

[0075] In the process of using generative adversarial networks (GAN) to generate front-end view component codes, the dataset required for training GAN is first prepared. The dataset includes the feature representation of UI elements and the corresponding target generated codes. The generator network is used to accept the feature encoding of UI elements as input and output the corresponding front-end view component codes. CNN is used as the discriminator network to distinguish the data generated by the generator from the real data. The front-end view component codes are accepted as input and a probability value is output to indicate whether the input code is real or generated. The prepared data is input into the GAN model for training. During the training process, the generator network attempts to generate realistic front-end view component codes, while the discriminator network attempts to distinguish the codes generated by the generator from the real codes. The two networks are continuously optimized through adversarial training until a dynamic equilibrium state is reached. The validation dataset is used to evaluate the performance of the trained GAN model. The evaluation indicators are the accuracy, grammatical correctness and semantic consistency of the generated codes. Finally, the trained generator network is used to generate the front-end view component codes. High-quality front-end view component codes are generated, which improves development efficiency and reduces the workload of developers to write codes manually.

[0076] Step 2.2: Model application. Deploy the trained model to the generation system to automatically generate the corresponding front-end view component code based on the identified UI elements; in actual applications, input the identified UI element features into the model, and the model will generate the corresponding front-end code output for developers to use.

[0077] Step 2.3: Iteration and optimization. Continuously collect feedback data to evaluate the quality and practicality of the generated front-end code; adjust and optimize the model based on the feedback data to improve the accuracy and compliance of the generated code.

[0078] Step 3 specifically includes the following steps:

[0079] Step 3.1: User feedback collection and demand modeling. Collect user feedback and requirements on the generated front-end view component code, including user satisfaction and suggestions on component style, layout, functions, etc. Analyze user feedback and requirements, determine aspects that need to be optimized, such as style adjustment, layout improvement, etc., and model user feedback and requirements into quantifiable optimization goals and constraints for subsequent algorithm optimization. Solve how to effectively collect user feedback and requirements on the generated front-end code for further optimization.

[0080] Step 3.2: Design and implementation of intelligent optimization algorithm. Based on the results of the demand analysis, a particle swarm optimization algorithm is designed to automatically adjust the generated front-end view component code to meet user feedback and needs; the algorithm is also used to search for the optimal component parameter configuration, implement the designed optimization algorithm, and integrate it into the generation system to ensure that the algorithm can receive user feedback and needs as input and output the optimized front-end view component code. It solves the problem of how to design and implement intelligent optimization algorithms based on user feedback and needs, automatically adjust the code to meet user expectations and needs, improve the quality and compliance of the generated code, reduce errors caused by human intervention, and improve the practicality and effectiveness of the code.

[0081] Step 3.3: Evaluation of optimization results and iterative optimization. Evaluate the optimized front-end view component code, compare its differences and improvements with the original version, use user feedback data to evaluate the practicality and effectiveness of the optimization results, and determine whether it meets user expectations and needs. Based on the evaluation results and user feedback, continuously adjust the parameters and strategies of the particle swarm optimization algorithm to further improve the quality of the generated front-end view component code and the degree to which it meets user needs.

Claims

1. A method for automatically generating front-end view component code based on machine learning and image recognition, It is characterized in that The following steps are involved: Step 1: Analyze UI design drafts, use image recognition technology to analyze UI design drafts and identify UI elements; Step 2: Select and train the model of the processed UI elements, use the generative adversarial network (GAN) to generate the front-end view component code, perform model verification and deployment, and automatically generate the code of the corresponding front-end view component; Step 3: Collect user feedback and model requirements for the front-end view component code, then design an intelligent optimization algorithm for optimization, evaluate and iterate the optimization results to improve code quality; Step 4: Based on the trained machine learning model and optimization algorithm, highly customized front-end view component code is automatically generated and output to the development environment.

2. According to claim 1, a method for automatically generating front-end view component code based on machine learning and image recognition, It is characterized in that Step 1 specifically includes the following steps: Step 1.1: Image preprocessing, converting the color design draft into a grayscale image, simplifying the processing process, using filtering technology to remove noise in the image, improving the accuracy of subsequent processing, and segmenting each UI element in the design draft for separate identification and processing. This solves the problems that may exist in the UI design draft, such as noise, complex background, and overlap between UI elements, and ensures the accuracy of subsequent processing. Step 1.1.1: Calculate the horizontal and vertical gradients, and obtain a grayscale image by weighted averaging the red, green, and blue channel values ​​of each pixel in the RGB image. Obtain the gradient images in the horizontal and vertical directions respectively; Step 1.1.2: Edge detection: merge the horizontal and vertical gradient images to obtain the gradient magnitude and direction of each pixel. The gradient magnitude indicates the degree of change in pixel intensity, while the gradient direction indicates the direction of change. A threshold is set to determine which pixels are considered edge pixels. If the gradient magnitude is greater than the threshold, the pixel is marked as an edge pixel, otherwise it is marked as a non-edge pixel. Step 1.1.3: Non-maximum suppression: Perform non-maximum suppression on the detected edges to refine the edges, so as to ensure that only local maximum points in the gradient direction are retained, while non-maximum points are suppressed, thereby obtaining a more refined edge. Step 1.1.4: Double threshold edge connection: perform edge connection based on two thresholds of gradient amplitude to obtain the position and shape of UI elements; Step 1.1.5: Overlapping processing: The detected UI elements are represented as binary images, where the pixel value of the UI element is 1 and the background pixel value is 0. A logical AND operation is performed pixel by pixel on the two UI elements. In the result image of the logical AND operation, if the pixel value is 1, it means that the two UI elements overlap at the pixel position. A threshold is set. If the pixels in the overlapping area exceed the threshold, it is determined that the two UI elements overlap. Finally, the overlapping UI elements are distinguished and segmented based on pixel intensity, color, and texture features. Step 1.1.6: Post-processing, remove unreasonable segmentation and merge adjacent areas to obtain more accurate UI element segmentation results, and finally obtain the segmented elements in the UI design draft. Step 1.2: UI element recognition: use convolutional neural network (CNN) to extract UI element features from the preprocessed image, use OCR technology to convert text content, mark UI element type, position, size, and structure data, train classifiers for classification and recognition, and use YOLO model for target detection; Step 1.2.1: Use a convolutional neural network (CNN) to extract the size, shape, and color features of each UI element in the image to obtain the visual features of the UI element; Step 1.1, normalize the pixel values ​​of the grayscale image so that its value is in the range of [0, 1]; Step 1.2: Gradually extract high-level features of the image by stacking multiple convolutional layers and pooling layers; Step 1.3: Use cross-validation and network structure search to determine the optimal combination of parameters and structure; Step 1.4: The CNN model learns to extract the features of various UI elements in the image during training; Step 1.5: Input the image into the trained CNN model, fuse the feature maps extracted from different layers, and obtain the representation of the visual features of the UI element. Step 1.2.2: For text content, use OCR (optical character recognition) technology to convert the text in the design draft into recognizable strings to provide text features of UI elements for subsequent steps; Step 1.2.3: Combine the visual features of step 1.2.1 and the text features of step 1.2.2 to obtain key features, mark the type, position, and size information of the UI elements, and structure the identified UI elements and their key features into JSON and XML data formats; Step 1.2.3.1, use the size, shape, color features, and text features of UI elements to form key features; Step 1.2.3.2, mark the type, position and size information of each UI element; Step 1.2.3..2, convert the identified UI elements and their key features into JSON and XML data formats; Step 1.2.4: Use support vector machine (SVM) to train a classifier to classify and identify each UI element; Step 1.2.4.

1. Prepare a training dataset, including the features and category labels of UI elements; Step 1.2.4.2, select appropriate kernel function and parameters to configure support vector machine; Step 1.2.4.3: Train the support vector machine model to classify UI elements based on feature vectors. Step 1.2.4..

4. Find the optimal decision boundary to separate elements of different categories through model training. Step 1.2.5: Use the YOLO model to perform object detection and identify the positions and boundaries of various UI elements in the design draft; Step 1.3: Model validation and optimization.

3. The method for automatically generating front-end view component code based on machine learning and image recognition according to claim 1, It is characterized in that Step 2 specifically includes the following steps: Step 2.1: Select support vector machine and generative adversarial network (GAN) as classification model and generation model, and perform model training and optimization; Step 2.1.1: Prepare the dataset required for training GAN, including UI element feature representation and corresponding target generation code; Step 2.1.2: Use the generator network to accept the UI element feature encoding and output the front-end view component code; Step 2.1.3, use CNN as the discriminator network to distinguish the data generated by the generator from the real data; Step 2.1.4: Train the GAN model and optimize the generator and discriminator through adversarial training. During the training process, the generator network tries to generate realistic front-end view component code, while the discriminator network tries to distinguish the code generated by the generator from the real code. The adversarial training method is used to continuously optimize until a dynamic equilibrium state is reached. Step 2.1.5: Use the validation dataset to evaluate the performance of the GAN model and adjust the model parameters. Step 2.2: Deploy the trained model to the generation system to automatically generate the front-end view component code; Step 2.2.1, deploy the trained model to the production system; Step 2.2.2: Input the identified UI element features into the model and generate the front-end code; Step 2.2.3: Output the generated front-end code for developers to use; Step 2.3: Collect feedback data, evaluate the quality of generated code, and perform model iteration and optimization.

4. The method for automatically generating front-end view component code based on machine learning and image recognition according to claim 1, It is characterized in that Step 3 specifically includes the following steps: Step 3.

1. Collect user feedback and requirements on the generated front-end view component code, including satisfaction and suggestions on component style, layout, and functionality, analyze and determine optimization aspects, including style adjustment and layout improvement, and model the feedback and requirements into quantifiable optimization goals and constraints. Step 3.2: Based on the requirements analysis results, design a particle swarm optimization algorithm to automatically adjust the code to meet user feedback and requirements, implement the algorithm and integrate it into the generation system to optimize the front-end view component code; Step 3.3: Evaluate the optimized code, compare the differences and improvements with the original version, use user feedback data to evaluate the practicality and effectiveness of the optimization results, adjust the parameters and strategies of the optimization algorithm based on the evaluation results and user feedback, improve code quality and meet user needs.