Image generation method and device based on artificial intelligence, computer equipment and medium
By combining pixel convolutional neural network and long and short-term memory network in the image generation model, using receptive field and time series information and performing image optimization processing, the problem of low image quality generated by the autoencoder is solved, and high-quality images are achieved generate.
Patent Information
- Application Number
- CN202411311066.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-19
- Publication Date
- 2024-12-13
AI Technical Summary
The existing self-encoder-based image generation method is low in image quality when processing high-pixel-value images and cannot meet the financial industry's requirements for high-quality images.
Using an image generation model based on pixel convolution neural network and long and short-term memory network, combining receptive field information and time series dimension information, smoothing, color adjustment and contrast adjustment of the generated image through preset image optimization strategies to improve the naturalness of the image degree and quality.
It significantly improves the naturalness and quality of generated images and meets the financial industry's requirements for high-quality images.
Smart Images

Figure CN119131329A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence development technology and the field of financial technology, and in particular to an image generation method, apparatus, computer equipment and storage medium based on artificial intelligence. Background Art
[0002] In the financial industry, with the advancement of technology and the advent of the big data era, image generation technology has gradually become an important tool and is widely used in many fields such as image marketing and market forecasting. However, in image generation tasks, especially when processing images with high pixel values, the complexity and performance of the model have become key technical challenges.
[0003] As a neural network structure for unsupervised learning, the autoencoder model has been initially applied in image generation tasks in the financial industry due to its relatively simple structure. The autoencoder maps the input data to a low-dimensional latent space through the encoder, and attempts to reconstruct the original input data from the low-dimensional representation through the decoder. This structure enables the autoencoder to learn a compact representation of the data and to achieve dimensionality reduction and feature extraction of the data to a certain extent.
[0004] However, despite the relatively simple structure of the autoencoder model, its performance in the image generation process is limited by its limited learning ability. This is mainly due to the large number of pixel values in the image, while the simple structure of the autoencoder model has relatively few parameters and cannot fully capture the complex features and high-order statistical information in the image. Therefore, in the image generation process, the autoencoder often has difficulty in generating high-quality, detailed images, resulting in low quality of the generated images, which cannot meet the high requirements of the financial industry for image generation quality. Summary of the invention
[0005] The purpose of the embodiments of the present application is to propose an image generation method, apparatus, computer equipment and storage medium based on artificial intelligence to solve the technical problem that the existing image generation method based on autoencoder has low quality of generated images.
[0006] In order to solve the above technical problems, the embodiment of the present application provides an image generation method based on artificial intelligence, which adopts the following technical solutions:
[0007] Get the initial image input by the user;
[0008] Traversing all pixel positions in the initial image, for each pixel position, collecting a target pixel value corresponding to the pixel position;
[0009] Calling a pre-built image generation model; wherein the image generation model is a model generated by training a preset pixel convolutional neural network and a long short-term memory network based on pre-built image sample data;
[0010] Performing image generation processing on the target pixel value based on the image generation model to obtain a corresponding first image;
[0011] Optimizing the first image based on a preset image optimization strategy to obtain a corresponding target image;
[0012] The target image is returned to the user.
[0013] Furthermore, for each pixel position, the step of collecting the target pixel value corresponding to the pixel position specifically includes:
[0014] Obtain a specified pixel position, and determine whether the specified pixel position is the top position on the left side of the image; wherein the specified pixel position is any one of all the pixel positions;
[0015] If the designated pixel position is the top position on the left side of the image, a preset pixel value generation strategy is obtained;
[0016] Collecting target pixel values corresponding to the designated pixel positions based on the pixel value generation strategy;
[0017] If the designated pixel position is not the top position on the left side of the image, then obtaining the upper pixel value and the left pixel value matching the designated pixel position;
[0018] A target pixel value corresponding to the designated pixel position is generated based on the upper pixel value and the left pixel value.
[0019] Furthermore, the step of performing image generation processing on the target pixel value based on the image generation model to obtain the corresponding first image specifically includes:
[0020] Performing pixel value input processing on the target pixel value to input the target pixel value into the image generation model;
[0021] Performing forward calculation processing on the target pixel value through the image generation model to obtain corresponding distribution parameters;
[0022] Performing sampling pixel value processing on the distribution parameter to obtain a corresponding designated pixel value;
[0023] Performing pixel value placement processing on the designated pixel value to place the designated pixel value in the initial image;
[0024] Repeating the pixel value input process, the forward calculation process, the sampling pixel value process, and the pixel value placement process until the processing of all the target pixel values is completed and a generated image with all pixel values generated is obtained;
[0025] The generated image is used as the first image.
[0026] Furthermore, the step of optimizing the first image based on a preset image optimization strategy to obtain a corresponding target image specifically includes:
[0027] Performing smoothing on the first image to obtain a corresponding second image;
[0028] Performing color adjustment processing on the second image to obtain a corresponding third image;
[0029] Performing contrast adjustment processing on the third image to obtain a corresponding fourth image;
[0030] The fourth image is used as the target image.
[0031] Furthermore, before the step of calling the pre-built image generation model, the method further includes:
[0032] Obtaining a pre-collected image dataset;
[0033] Preprocessing the image data set to obtain corresponding image sample data;
[0034] Dividing the image sample data into a training data set and a test data set;
[0035] Building an initial model based on the pixel convolutional neural network and the long short-term memory network;
[0036] Determine the target loss function corresponding to the initial model and obtain a preset target optimization algorithm;
[0037] Based on the target loss function and the target optimization algorithm, the initial model is trained using the training data set to obtain a corresponding first model;
[0038] Testing the first model based on the test data set;
[0039] If the first model passes the test, the first model is used as the image generation model.
[0040] Furthermore, the step of constructing an initial model based on the pixel convolutional neural network and the long short-term memory network specifically includes:
[0041] Construct an initial pixel convolutional neural network based on the preset convolutional layer;
[0042] Performing mask setting processing on the initial pixel convolutional neural network to obtain the pixel convolutional neural network;
[0043] Obtaining the long short-term memory network;
[0044] Performing parallel integration processing on the long short-term memory network in the residual module of the pixel convolutional neural network to obtain a corresponding processing network;
[0045] The processing network is used as the initial model.
[0046] Further, after the step of testing the first model based on the test data set, the method further includes:
[0047] If the first model fails the test, obtaining a preset model adjustment strategy;
[0048] Adjust the first model based on the model adjustment strategy until a second model that meets the construction expectations is obtained;
[0049] The second model is used as the image generation model.
[0050] In order to solve the above technical problems, the embodiment of the present application further provides an image generation device based on artificial intelligence, which adopts the following technical solution:
[0051] A first acquisition module, used to acquire an initial image input by a user;
[0052] A collection module, configured to traverse all pixel positions in the initial image, and for each pixel position, collect a target pixel value corresponding to the pixel position;
[0053] A calling module, used to call a pre-built image generation model; wherein the image generation model is a model generated by training a preset pixel convolutional neural network and a long short-term memory network based on pre-built image sample data;
[0054] A generation module, configured to perform image generation processing on the target pixel value based on the image generation model to obtain a corresponding first image;
[0055] An optimization module, used to optimize the first image based on a preset image optimization strategy to obtain a corresponding target image;
[0056] A returning module is used to return the target image to the user.
[0057] In order to solve the above technical problems, the embodiment of the present application further provides a computer device, which adopts the following technical solution:
[0058] Get the initial image input by the user;
[0059] Traversing all pixel positions in the initial image, for each pixel position, collecting a target pixel value corresponding to the pixel position;
[0060] Calling a pre-built image generation model; wherein the image generation model is a model generated by training a preset pixel convolutional neural network and a long short-term memory network based on pre-built image sample data;
[0061] Performing image generation processing on the target pixel value based on the image generation model to obtain a corresponding first image;
[0062] Optimizing the first image based on a preset image optimization strategy to obtain a corresponding target image;
[0063] The target image is returned to the user.
[0064] In order to solve the above technical problems, the embodiment of the present application further provides a computer-readable storage medium, which adopts the following technical solution:
[0065] Get the initial image input by the user;
[0066] Traversing all pixel positions in the initial image, for each pixel position, collecting a target pixel value corresponding to the pixel position;
[0067] Calling a pre-built image generation model; wherein the image generation model is a model generated by training a preset pixel convolutional neural network and a long short-term memory network based on pre-built image sample data;
[0068] Performing image generation processing on the target pixel value based on the image generation model to obtain a corresponding first image;
[0069] Optimizing the first image based on a preset image optimization strategy to obtain a corresponding target image;
[0070] The target image is returned to the user.
[0071] Compared with the prior art, the embodiments of the present application have the following beneficial effects:
[0072] The present application first obtains the initial image input by the user; then traverses all pixel positions in the initial image, and for each pixel position, collects the target pixel value corresponding to the pixel position; then calls a pre-constructed image generation model; wherein the image generation model is a model generated by training a preset pixel convolutional neural network and a long short-term memory network based on pre-constructed image sample data; subsequently, the target pixel value is processed for image generation based on the image generation model to obtain the corresponding first image; the first image is further optimized based on a preset image optimization strategy to obtain the corresponding target image; and finally, the target image is returned to the user. The present application pre-constructs an image generation model that combines a pixel convolutional neural network and a long short-term memory network, and then uses the image generation model to refer to the receptive field information and the dimensional information on the time series when processing the initial image input by the user, thereby effectively improving the naturalness and generation quality of the generated image. In addition, the image is intelligently optimized based on the use of image optimization strategies, further improving the image quality. BRIEF DESCRIPTION OF THE DRAWINGS
[0073] In order to more clearly illustrate the scheme in the present application, a brief introduction is given below to the drawings required for use in the description of the embodiments of the present application. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0074] Figure 1 is an exemplary system architecture diagram to which the present application may be applied;
[0075] Figure 2 A flowchart of an embodiment of an artificial intelligence-based image generation method according to the present application;
[0076] Figure 3 is a structural schematic diagram of an embodiment of an artificial intelligence-based image generation device according to the present application;
[0077] Figure 4 It is a structural diagram of an embodiment of a computer device according to the present application. DETAILED DESCRIPTION
[0078] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by technicians in the technical field of the present application; the terms used in the specification of the application herein are only for the purpose of describing specific embodiments and are not intended to limit the present application; the terms "including" and "having" and any variations thereof in the specification and claims of the present application and the above-mentioned drawings are intended to cover non-exclusive inclusions. The terms "first", "second", etc. in the specification and claims of the present application or the above-mentioned drawings are used to distinguish different objects, not to describe a specific order.
[0079] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0080] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the accompanying drawings.
[0081] like Figure 1 As shown, the system architecture 100 may include a terminal device 101, a network 102 and a server 103. The terminal device 101 may be a laptop 1011, a tablet computer 1012 or a mobile phone 1013. The network 102 is used to provide a medium for a communication link between the terminal device 101 and the server 103. The network 102 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.
[0082] The user can use the terminal device 101 to interact with the server 103 through the network 102 to receive or send messages, etc. Various communication client applications can be installed on the terminal device 101, such as web browser applications, shopping applications, search applications, instant messaging tools, email clients, social platform software, etc.
[0083] The terminal device 101 can be any electronic device with a display screen and supporting web browsing. In addition to the laptop computer 1011, tablet computer 1012 or mobile phone 1013, the terminal device 101 can also be an e-book reader, an MP3 player (Moving Picture Experts Group Audio Layer III), an MP4 (Moving Picture Experts Group Audio Layer IV), a laptop computer, a desktop computer, etc.
[0084] The server 103 may be a server that provides various services, such as a background server that provides support for a web page displayed on the terminal device 101 .
[0085] It should be noted that the artificial intelligence-based image generation method provided in the embodiment of the present application is generally executed by a server / terminal device, and accordingly, the artificial intelligence-based image generation device is generally set in the server / terminal device.
[0086] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
[0087] Continue to refer Figure 2 , showing a flow chart of an embodiment of an artificial intelligence-based image generation method according to the present application. According to different requirements, the order of the steps in the flow chart can be changed, and some steps can be omitted. The artificial intelligence-based image generation method provided in the embodiment of the present application can be applied to any scenario where image generation is required, and the artificial intelligence-based image generation method can be applied to products in these scenarios, for example, image generation in the financial insurance field. The artificial intelligence-based image generation method comprises the following steps:
[0088] Step S201, obtaining an initial image input by a user.
[0089] In this embodiment, the electronic device (e.g. Figure 1The server / terminal device shown in the figure) can obtain the initial image input by the user through a wired connection or a wireless connection. It should be noted that the above-mentioned wireless connection method may include but is not limited to 3G / 4G / 5G connection, WiFi connection, Bluetooth connection, WiMAX connection, Zigbee connection, UWB (ultra wideband) connection, and other wireless connection methods currently known or to be developed in the future. The execution subject of the present application is specifically an image generation system, or simply referred to as a system. The present application can be applied to the image marketing needs of insurance companies, by using image generation models to generate different pictures to meet different scene requirements, thereby speeding up the design output of picture elements in the marketing process and improving the work efficiency of financial business personnel. Specifically, the above-mentioned initial image can be a predefined image input by the user according to marketing needs, or an all-zero image. The all-zero image is an all-zero image with the same size and number of color channels as the final target image (marketing image). Each pixel value in this all-zero image is initialized to zero, which means that there is no color information or brightness information in the image, and it looks completely black (in the RGB color space, black is represented by R=0, G=0, B=0). The above predefined images are constructed by users according to actual marketing needs and have similar sizes and color channel numbers to the final generated images. For example, you can start with a predefined image with a specific texture or color gradient to guide the initial direction of the image generation process.
[0090] Step S202, traverse all pixel positions in the initial image, and for each pixel position, collect the target pixel value corresponding to the pixel position.
[0091] In this embodiment, the specific implementation process of collecting the target pixel value corresponding to each pixel position will be further described in detail in subsequent specific embodiments of the present application and will not be elaborated on here.
[0092] Step S203, calling a pre-built image generation model.
[0093] In this embodiment, the above-mentioned image generation model is a model generated by training a preset pixel convolutional neural network and a long short-term memory network based on pre-constructed image sample data. The specific construction process of the above-mentioned image generation model will be further described in detail in the subsequent specific embodiments of this application, and will not be elaborated on here.
[0094] Step S204: performing image generation processing on the target pixel value based on the image generation model to obtain a corresponding first image.
[0095] In this embodiment, the above-mentioned specific implementation process of performing image generation processing on the target pixel value based on the image generation model to obtain the corresponding first image will be further described in detail in subsequent specific embodiments of the present application and will not be elaborated in detail here.
[0096] Step S205: optimizing the first image based on a preset image optimization strategy to obtain a corresponding target image.
[0097] In this embodiment, the above-mentioned specific implementation process of optimizing the first image based on the preset image optimization strategy to obtain the corresponding target image will be further described in detail in the subsequent specific embodiments of this application and will not be elaborated in detail here.
[0098] Step S206: returning the target image to the user.
[0099] In this embodiment, after obtaining the target image, the target image is further saved as a file, for example, using a common image format such as PNG or JPEG, and then the final image after format processing is returned to the user to complete the image generation feedback processing for the user.
[0100] The present application first obtains the initial image input by the user; then traverses all pixel positions in the initial image, and for each pixel position, collects the target pixel value corresponding to the pixel position; then calls a pre-constructed image generation model; wherein the image generation model is a model generated by training a preset pixel convolutional neural network and a long short-term memory network based on pre-constructed image sample data; subsequently, the target pixel value is processed for image generation based on the image generation model to obtain the corresponding first image; the first image is further optimized based on a preset image optimization strategy to obtain the corresponding target image; and finally, the target image is returned to the user. The present application pre-constructs an image generation model that combines a pixel convolutional neural network and a long short-term memory network, and then uses the image generation model to refer to the receptive field information and the dimensional information on the time series when processing the initial image input by the user, thereby effectively improving the naturalness and generation quality of the generated image. In addition, the image is intelligently optimized based on the use of image optimization strategies, further improving the image quality.
[0101] In some optional implementations, step S202 includes the following steps:
[0102] Obtain a designated pixel position, and determine whether the designated pixel position is the top position on the left side of the image; wherein the designated pixel position is any one of all the pixel positions.
[0103] In this embodiment, the top position on the left side of the image refers to the upper left corner (coordinate (0, 0)) of the initial image, and there is no pixel value above or to the left of the designated pixel position.
[0104] If the designated pixel position is the top position on the left side of the image, a preset pixel value generation strategy is obtained.
[0105] In this embodiment, the strategy content of the above pixel value generation strategy includes: the value of the pixel position at the top position on the left side of the image is modeled as independent of all other pixels, and its distribution is obtained by executing the forward calculation flow, that is, the mean and variance values of the distribution are predicted by the model, and the first pixel value is obtained by sampling. Alternatively, a fixed boundary value (such as zero or a predefined pixel value) is used as the pixel value at the top position on the left side of the image.
[0106] Target pixel values corresponding to the designated pixel positions are collected based on the pixel value generation strategy.
[0107] In this embodiment, corresponding processing may be performed according to the policy content of the above-mentioned pixel value generation policy to collect the target pixel value corresponding to the designated pixel position.
[0108] If the designated pixel position is not the top position on the left side of the image, the upper pixel value and the left pixel value matching the designated pixel position are obtained.
[0109] In this embodiment, for a pixel position that is not the top position on the left side of the image, pixel values that have been generated above and to the left of the pixel position are collected as input.
[0110] A target pixel value corresponding to the designated pixel position is generated based on the upper pixel value and the left pixel value.
[0111] In this embodiment, the upper pixel value and the left pixel value that match the specified pixel position can be obtained by checking the initial image (at the beginning of generation) or the pixel values generated in the previous step, and used as the target pixel value corresponding to the specified pixel position.
[0112] The present application obtains the designated pixel position and determines whether the designated pixel position is the top position on the left side of the image; if the designated pixel position is the top position on the left side of the image, a preset pixel value generation strategy is obtained; then the target pixel value corresponding to the designated pixel position is collected based on the pixel value generation strategy; and if the designated pixel position is not the top position on the left side of the image, the upper pixel value and the left pixel value that match the designated pixel position are obtained; and the target pixel value corresponding to the designated pixel position is subsequently generated based on the upper pixel value and the left pixel value. After obtaining the designated pixel position, the present application will intelligently generate the target pixel value corresponding to the pixel position based on the position information of the designated pixel position and adopt a processing strategy corresponding to the position information, thereby improving the intelligence of the generation of the target pixel value and ensuring the data accuracy of the target pixel value corresponding to the pixel position.
[0113] In some optional implementations of this embodiment, step S204 includes the following steps:
[0114] The target pixel value is subjected to pixel value input processing to input the target pixel value into the image generation model.
[0115] In this embodiment, the above-mentioned pixel value input processing includes: passing the collected target pixel values as input to the image generation model.
[0116] The target pixel value is forward calculated and processed by the image generation model to obtain corresponding distribution parameters.
[0117] In this embodiment, the forward calculation processing includes: the image generation model performs forward calculation on the input target pixel value, through its convolution layer, LSTM layer, residual connection and activation function, and finally outputs the distribution parameters of the current pixel, namely the mean and variance.
[0118] The distribution parameters are sampled and pixel values are processed to obtain corresponding designated pixel values.
[0119] In this embodiment, the above-mentioned sampled pixel value processing includes: sampling a pixel value from the distribution parameter output by the image generation model to obtain the above-mentioned designated pixel value. It is specifically completed through some form of random process, such as multi-classification sampling according to softmax output, or Gaussian sampling according to mean and variance, etc.
[0120] A pixel value placement process is performed on the designated pixel value to place the designated pixel value in the initial image.
[0121] In this embodiment, the above pixel value placement processing refers to placing the sampled designated pixel value at the corresponding position in the initial image.
[0122] The pixel value input processing, the forward calculation processing, the sampling pixel value processing and the pixel value placement processing are repeatedly performed until the processing of all the target pixel values is completed and a generated image with all pixel values generated is obtained.
[0123] In this embodiment, the above-mentioned pixel value input processing, forward calculation processing, sampling pixel value processing and pixel value placement processing are repeatedly performed until a complete image containing all pixels is obtained, that is, the above-mentioned generated image.
[0124] The generated image is used as the first image.
[0125] In this embodiment, by combining a pixel convolutional neural network with a long short-term memory network as an image generation model, the image generation model refers to the receptive field information and the dimensional information on the time series when generating the value of the current pixel, thereby effectively improving the naturalness and generation quality of the generated image.
[0126] After the target pixel value is input into the image generation model, the present application repeatedly performs corresponding forward calculation processing, sampling pixel value processing, and pixel value placement processing on the target pixel value based on the use of the image generation model until the processing of all the target pixel values is completed, thereby completing the image generation processing for all target pixel values and obtaining the corresponding first image, effectively improving the naturalness and generation quality of the generated first image.
[0127] In some optional implementations, step S205 includes the following steps:
[0128] The first image is smoothed to obtain a corresponding second image.
[0129] In this embodiment, the first image may be smoothed by using image processing technology. The smoothing process includes Gaussian blur and median filtering. Specifically, the implementation process of Gaussian blur includes: selecting a suitable kernel size (usually an odd number, such as 3x3, 5x5) and standard deviation (sigma), applying a Gaussian blur algorithm to the image to replace each pixel with a weighted average of its surrounding pixels, where the weight is given by a Gaussian function, thereby reducing noise and details in the image and making the image look smoother.
[0130] The implementation process of median filtering includes: selecting a window size (such as 3x3, 5x5), and replacing each pixel in the image with the median of all pixel values in the window, thereby removing salt and pepper noise in the image while keeping the edges clear.
[0131] Performing color adjustment processing on the second image to obtain a corresponding third image.
[0132] In this embodiment, the color adjustment process includes: using color space conversion, then adjusting parameters such as saturation and hue, and finally converting back to RGB space, thereby changing the overall hue or color balance of the image.
[0133] Perform contrast adjustment processing on the third image to obtain a corresponding fourth image.
[0134] In this embodiment, the contrast adjustment process includes: adjusting the histogram of the image, specifically using histogram equalization or histogram regulation, or applying a linear transformation to the pixel values of the image, adjusting the contrast by changing the slope and intercept of the transformation, thereby enhancing or weakening the difference between different gray levels in the image.
[0135] The fourth image is used as the target image.
[0136] The present application performs smoothing processing on the first image to obtain the corresponding second image; then performs color adjustment processing on the second image to obtain the corresponding third image; then performs contrast adjustment processing on the third image to obtain the corresponding fourth image; and subsequently uses the fourth image as the target image. The present application performs smoothing processing, color adjustment processing, and contrast adjustment processing on the first image to complete the optimization processing of the first image, effectively improving the naturalness and image quality of the generated target image.
[0137] In some optional implementations, before step S203, the electronic device may further perform the following steps:
[0138] Get a pre-acquired image dataset.
[0139] In this embodiment, a large amount of natural image data is collected in advance and used as an image data set for subsequent model training.
[0140] The image data set is preprocessed to obtain corresponding image sample data.
[0141] In this embodiment, the above preprocessing may include processing such as resizing the image and normalizing pixel values.
[0142] The image sample data is divided into a training data set and a test data set.
[0143] In this embodiment, the image sample data may be divided into a training data set and a test data set according to a preset division ratio, wherein the selection of the division ratio is not specifically limited, for example, 7:3 may be used.
[0144] An initial model is constructed based on the pixel convolutional neural network and the long short-term memory network.
[0145] In this embodiment, a custom pixel convolutional neural network (PixelCNN) + long short-term memory network (LSTM) initial model is pre-built, and it is ensured that the initial model can be forward propagated in pixel order. In the forward propagation process, mask convolution is used to maintain causality, ensuring that the prediction of a pixel depends only on the pixels above and to the left. And it is ensured that the initial model generates images step by step in pixel order, and the prediction of each pixel is based on the generated pixels above and to the left.
[0146] Specifically, the input space of the initial model needs to determine the order of its features. For each input image, the order is defined by the spatial position of the pixels, the left pixel before the right pixel, the top pixel before the bottom pixel, etc. That is, a two-dimensional image is represented by a one-dimensional vector. The picture is composed of pixels one by one. When generating a picture, the neural network model generates one pixel at a time and uses the previously trained pixels to generate the next pixel. Based on the information of a sequence vector, the value of the next pixel is predicted.
[0147] In addition, the specific implementation process of constructing the initial model based on the pixel convolutional neural network and the long short-term memory network will be further described in detail in subsequent specific embodiments of the present application, and will not be elaborated in detail here.
[0148] Determine the target loss function corresponding to the initial model and obtain a preset target optimization algorithm.
[0149] In this embodiment, the target loss function may specifically adopt a cross entropy loss function. The target optimization algorithm may specifically adopt a stochastic gradient descent algorithm, such as SGD, Adam and other optimization algorithms.
[0150] Based on the objective loss function and the objective optimization algorithm, the initial model is trained using the training data set to obtain a corresponding first model.
[0151] In this embodiment, the training process of the initial model includes: forward propagation: forward propagation is performed in pixel order (from left to right, from top to bottom), and the prediction of each pixel is based on the pixels above and to the left and the historical information accumulated by LSTM. Loss calculation: the cross entropy loss between the predicted value and the true value is calculated using the target loss function (cross entropy loss function). Backward propagation: the cross entropy losses of all pixels are added to obtain the total loss. According to the total loss, the automatic differentiation function of the deep learning framework (such as TensorFlow or PyTorch) is used for back propagation, and the model parameters (including the parameters of PixelCNN and LSTM) are updated to minimize the total loss, and all parameters of PixelCNN and LSTM are updated using the target optimization algorithm to obtain the corresponding first model.
[0152] The first model is tested based on the test data set.
[0153] In this embodiment, the performance of the first model on the test data set can be evaluated, and specifically, the accuracy can be used for testing. If the accuracy of the first model on the test data set is greater than the corresponding accuracy threshold, the first model is determined to have passed the test. If the accuracy of the first model on the test data set is less than the corresponding accuracy threshold, the first model is determined to have failed the test. The value of the accuracy threshold is not specifically limited and can be set according to actual business usage requirements.
[0154] If the first model passes the test, the first model is used as the image generation model.
[0155] The present application constructs image sample data for a pre-collected image data set, and constructs an initial model based on the pixel convolutional neural network and the long short-term memory network, thereby determining a target loss function corresponding to the initial model, and obtaining a preset target optimization algorithm. Subsequently, based on the target loss function and the target optimization algorithm, the initial model is trained and tested using the image sample data, thereby obtaining an image generation model that meets expectations, effectively improving the efficiency of building the image generation model, and the obtained image generation model can utilize the spatial feature extraction capability of the pixel convolutional neural network and the temporal modeling capability of the long short-term memory network to generate high-quality images, thereby effectively ensuring the model effect of the image generation model that combines the pixel convolutional neural network and the long short-term memory network.
[0156] In some optional implementations of this embodiment, the constructing an initial model based on the pixel convolutional neural network and the long short-term memory network includes the following steps:
[0157] Construct an initial pixel convolutional neural network based on the preset convolutional layer.
[0158] In this embodiment, the initial pixel convolutional neural network, i.e., the PixelCNN model, is constructed by using standard convolutional layers. Each convolutional layer is implemented by masked convolution to ensure that the current pixel can only see the pixels above and to the left of it. Among them, masked convolution ensures causality, that is, the prediction of a pixel does not depend on the pixels to its right and below. In addition, the PixelCNN model is used as the basis of the image generation model, in which the prediction of each pixel depends on the pixels above and to the left of it (or a wider receptive field).
[0159] Specifically, the construction of the PixelCNN model includes: the first layer is a masked convolution (type A) with a 3x3 filter. Then, 15 residual blocks are used. Each block processes the data using a combination of a 3x3 convolution layer of mask type B and a standard 1x1 convolution layer. Between each convolution layer, there is a nonlinear ReLU, and finally, the residual block also includes a residual connection. Among them, the internal structure of the residual block (residual) includes a standard 1x1 convolution layer, a masked convolution (type B) with a 3x3 filter, and a standard 1x1 convolution layer. On the right side of each convolution, activation calculation is performed before convolution calculation. The last convolution module is a Leaky Relu-CONV-Leaky Relu-CONV layer after the sequence block, where CONV uses a standard convolution with a 1x1 filter. Then, the output layer is a softmax layer that predicts all possible values of the pixel. The output of the model has the same format as the input image size (because the output value of each pixel is required) multiplied by the number of possible values (classified according to the intensity level, such as 256 intensity levels). And the PixelCNN model can learn its parameters by maximizing the likelihood estimate of the training data.
[0160] In addition, PixelCNN is an autoregressive model. During the training process, the PixelCNN model uses multiple mask convolutions to scan each area one by one, predicts a result of the same size as the input image, and then calculates the pixel error between the output image and the input image. That is, the probability distribution of the pixel value of each pixel is predicted one by one, and then the difference between the predicted result and the true value is calculated, which is the loss function (using the cross entropy loss function). Then, the gradient back propagation of the loss function is used to update the parameters of the model, so that the probability distribution of each pixel predicted by the model can be closer to the true pixel value. That is, when training an image, there will be an error for each pixel at each step (cross entropy loss between the predicted value and the true value), and the model is trained through the error of each pixel.
[0161] The initial pixel convolutional neural network is subjected to mask setting processing to obtain the pixel convolutional neural network.
[0162] In this embodiment, the mask setting process specifically includes: applying a mask to the convolution kernel so that the convolution operation is performed only in the valid area above and to the left of the kernel. Specifically, the first layer of convolution usually uses a Class A mask, and the middle value is shielded (the middle value is a mask) because it has not been predicted. To ensure that the center pixel cannot see the information of its own position. Subsequent layers use Class B masks to allow the center pixel to see the predicted value of its own position. Among them, the subsequent layers refer to all layer convolutions except the first layer. Except for the first layer, the values of each subsequent layer are predicted.
[0163] Obtain the long short-term memory network.
[0164] In this embodiment, the long short-term memory network is specifically an LSTM layer. The LSTM layer can capture the long-term dependencies between the generated sequences of pixels, which helps to improve the prediction ability of the model.
[0165] Specifically, this embodiment adds a gating mechanism to control the degree of correlation between the previously accumulated pixel information and the currently predicted pixel information. Because there are many segmentation points or progressive points in an image, these special points are affected by the previous pixels, and the closer to the current point, the greater the influence should be. This embodiment designs an LSTM module (Long Short-Term Memory Network) in parallel when calculating the residual module.
[0166] This embodiment is an LSTM calculation process added to the residual module, that is, the input of the residual module (residual) will be calculated twice, once for the convolution of pure PixelCNN (left figure), and once for the recursion of LSTM (right figure). The gating mechanism of LSTM will store the information of the previous pixel and use its contribution value as the current predicted pixel. The calculation flow is a traditional LSTM unit. Here, there is no need to calculate the residual 15 times like convolution, but only once. Finally, the vector calculation results (output of the residual module) on the left and right of the figure are added and divided by 2, and used as the input in the main process.
[0167] The long short-term memory network is processed in parallel integration in the residual module of the pixel convolutional neural network to obtain a corresponding processing network.
[0168] In this embodiment, the residual module of the PixelCNN model is used to extract spatial features through convolution operations. The residual module is used to implement a standard residual block, which contains a convolution layer, an activation function (such as ReLU) and a possible batch normalization layer, and ensures that the residual connection does not destroy the causality of PixelCNN, that is, the residual connection cannot introduce information about future pixels.
[0169] On the basis of the residual module, the LSTM layer is placed in parallel with the residual module. The input of the LSTM layer is the input of the current residual module, and the flow and accumulation of information are controlled by the LSTM gating mechanism (forget gate, input gate, output gate). The output of the LSTM layer is expanded in time to match the order of image generation. Subsequently, the output of the residual module and the output of the LSTM layer are added or concatenated, and an activation function (such as ReLU) is applied to increase nonlinear capabilities, and the combined output is used as the input of the next layer or the final output layer.
[0170] The processing network is used as the initial model.
[0171] The present application constructs an initial pixel convolutional neural network based on a preset convolutional layer; then performs mask setting processing on the initial pixel convolutional neural network to obtain the pixel convolutional neural network; then obtains the long short-term memory network; subsequently, the long short-term memory network is parallel integrated in the residual module of the pixel convolutional neural network to obtain the corresponding processing network, and the processing network is used as the initial model. The present application constructs an initial pixel convolutional neural network based on a preset convolutional layer, and performs mask setting processing on the initial pixel convolutional neural network to obtain the pixel convolutional neural network, and then performs parallel integration processing on the preset long short-term memory network in the residual module of the pixel convolutional neural network, so that the construction of the initial model can be completed quickly and accurately, and the construction efficiency of the initial model is improved. In addition, the constructed initial model combines the spatial feature extraction capability of the pixel convolutional neural network and the temporal modeling capability of the long short-term memory network, which effectively improves the model processing effect of the initial model.
[0172] In some optional implementations of this embodiment, after the step of testing the first model based on the test data set, the electronic device may further perform the following steps:
[0173] If the first model fails the test, a preset model adjustment strategy is obtained.
[0174] In this embodiment, if the accuracy of the first model on the test data set is less than the corresponding accuracy threshold, it is determined that the first model has failed the test. The policy content of the above-mentioned model adjustment strategy includes learning rate adjustment, layer adjustment and batch size adjustment. Specifically, the learning rate adjustment includes: monitoring the accuracy on the validation set, and if the performance begins to decline (i.e., signs of overfitting appear), then reducing the learning rate. Specifically, a fixed decay rate (such as decaying once every N epochs) can be used, or a more complex strategy such as a learning rate scheduler can be used to adjust the learning rate. Layer adjustment includes: finding the optimal model depth by increasing or decreasing the number of layers of the model. Among them, deeper models may have stronger feature extraction capabilities, but may also be more prone to overfitting and require longer training time. Batch size adjustment includes: trying different batch sizes and observing their effects on model training and verification performance. Among them, a larger batch size can stabilize the training process, but may increase memory consumption and computing time; a smaller batch size may cause fluctuations during the training process, but may help the model jump out of the local optimal solution.
[0175] The first model is adjusted based on the model adjustment strategy until a second model that meets the construction expectations is obtained.
[0176] In this embodiment, the first model can be adjusted according to the strategy content corresponding to the above-mentioned model adjustment strategy (learning rate adjustment, number of layers adjustment and batch size adjustment), and the model accuracy during the adjustment process can be detected in real time. If it is detected that the model accuracy is stably greater than the above-mentioned accuracy threshold, it is determined that the current model meets the construction expectations and is used as the above-mentioned second model.
[0177] The second model is used as the image generation model.
[0178] In this embodiment, regularization technology can be further used to prevent the model from overfitting. Specifically, a part of the neurons in the network are randomly discarded (i.e., set to zero) during the training process to reduce the co-adaptability between neurons, thereby preventing overfitting. Wherein, the above-mentioned neurons refer to the output of the convolutional layer or the fully connected layer. Alternatively, a regularization term is added to the loss function, which is the weighted sum of the absolute value (L1) or square (L2) of the model weight coefficient. This helps to make the weight value smaller, thereby reducing the complexity of the model and preventing overfitting. Wherein, the weight of the regularization term (i.e., the regularization coefficient) is a hyperparameter that needs to be adjusted according to the performance of the validation set.
[0179] If the present application detects that the first model has not passed the test, a preset model adjustment strategy is obtained; then the first model is adjusted based on the model adjustment strategy until a second model that meets the construction expectations is obtained; and the second model is subsequently used as the image generation model. If the present application detects that the first model has not passed the test, the first model is intelligently adjusted based on the use of the model adjustment strategy until an image generation model that meets the construction expectations is obtained, thereby helping to improve the model performance and generation effect of the obtained image generation model.
[0180] In some optional implementations, the user information obtained is subject to the user's consent and complies with relevant laws and policies.
[0181] In addition, the non-Company software tools or components that appear in the embodiments of the present application are merely examples and do not represent actual use.
[0182] It should be understood that the order of execution of the steps in the above embodiment does not necessarily mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present invention.
[0183] It should be emphasized that in order to further ensure the privacy and security of the above-mentioned target image, the above-mentioned target image can also be stored in a node of a blockchain.
[0184] The blockchain referred to in this application is a new application model of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, encryption algorithm, etc. Blockchain is essentially a decentralized database, a string of data blocks generated by cryptographic methods. Each data block contains a batch of network transaction information, which is used to verify the validity of its information (anti-counterfeiting) and generate the next block. Blockchain can include the underlying blockchain platform, platform product service layer, and application service layer.
[0185] The embodiments of the present application can acquire and process relevant data based on artificial intelligence technology. Among them, artificial intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.
[0186] AI basic technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing technology, operation / interaction systems, mechatronics, etc. AI software technologies mainly include computer vision technology, robotics technology, biometrics technology, speech processing technology, natural language processing technology, and machine learning / deep learning.
[0187] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through computer-readable instructions, and the computer-readable instructions can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, the aforementioned storage medium can be a non-volatile storage medium such as a disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM).
[0188] It should be understood that, although the steps in the flowchart of the accompanying drawings are displayed in sequence as indicated by the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least a part of the steps in the flowchart of the accompanying drawings may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be executed in turn or alternately with other steps or at least a part of the sub-steps or stages of other steps.
[0189] Further references Figure 3 , as a response to the above Figure 2 The present application provides an embodiment of an image generation device based on artificial intelligence, and the device embodiment is similar to Figure 2 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.
[0190] like Figure 3 As shown, the artificial intelligence-based image generation device 300 described in this embodiment includes: a first acquisition module 301, a collection module 302, a call module 303, a generation module 304, an optimization module 305 and a return module 306. Among them:
[0191] A first acquisition module 301 is used to acquire an initial image input by a user;
[0192] A collection module 302 is used to traverse all pixel positions in the initial image, and for each pixel position, collect a target pixel value corresponding to the pixel position;
[0193] The calling module 303 is used to call a pre-built image generation model; wherein the image generation model is a model generated by training a preset pixel convolutional neural network and a long short-term memory network based on pre-built image sample data;
[0194] A generating module 304 is used to perform image generation processing on the target pixel value based on the image generation model to obtain a corresponding first image;
[0195] An optimization module 305 is used to optimize the first image based on a preset image optimization strategy to obtain a corresponding target image;
[0196] The returning module 306 is used to return the target image to the user.
[0197] In some optional implementations of this embodiment, the collection module 302 includes:
[0198] A first acquisition submodule is used to acquire a designated pixel position and determine whether the designated pixel position is the top position on the left side of the image; wherein the designated pixel position is any one of all the pixel positions;
[0199] A second acquisition submodule, configured to acquire a preset pixel value generation strategy if the designated pixel position is the top position on the left side of the image;
[0200] A first generating submodule, configured to collect a target pixel value corresponding to the specified pixel position based on the pixel value generating strategy;
[0201] A third acquisition submodule is used for acquiring an upper pixel value and a left pixel value matching the designated pixel position if the designated pixel position is not the top position on the left side of the image;
[0202] The second generating submodule is used to generate a target pixel value corresponding to the designated pixel position based on the upper pixel value and the left pixel value.
[0203] In some optional implementations of this embodiment, the generating module 304 includes:
[0204] A first processing submodule, configured to perform pixel value input processing on the target pixel value so as to input the target pixel value into the image generation model;
[0205] A second processing submodule is used to perform forward calculation processing on the target pixel value through the image generation model to obtain corresponding distribution parameters;
[0206] A third processing submodule is used to perform sampling pixel value processing on the distribution parameter to obtain a corresponding designated pixel value;
[0207] a fourth processing submodule, configured to perform pixel value placement processing on the designated pixel value, so as to place the designated pixel value in the initial image;
[0208] A repeating submodule, used for repeatedly performing pixel value input processing, forward calculation processing, sampling pixel value processing and pixel value placement processing, until the processing of all the target pixel values is completed and a generated image with all pixel values generated is obtained;
[0209] The first determining submodule is configured to use the generated image as the first image.
[0210] In some optional implementations of this embodiment, the optimization module 305 includes:
[0211] A smoothing submodule, used for smoothing the first image to obtain a corresponding second image;
[0212] A first adjustment submodule, configured to perform color adjustment processing on the second image to obtain a corresponding third image;
[0213] A second adjustment submodule, configured to perform contrast adjustment processing on the third image to obtain a corresponding fourth image;
[0214] The second determining submodule is configured to use the fourth image as the target image.
[0215] In some optional implementations of this embodiment, the image generation device based on artificial intelligence further includes:
[0216] A second acquisition module is used to acquire a pre-collected image data set;
[0217] A preprocessing module, used to preprocess the image data set to obtain corresponding image sample data;
[0218] A division module, used for dividing the image sample data into a training data set and a test data set;
[0219] A construction module, used to construct an initial model based on the pixel convolutional neural network and the long short-term memory network;
[0220] A third acquisition module is used to determine the target loss function corresponding to the initial model and obtain a preset target optimization algorithm;
[0221] A training module, configured to train the initial model using the training data set based on the target loss function and the target optimization algorithm to obtain a corresponding first model;
[0222] A testing module, used for testing the first model based on the test data set;
[0223] The first determination module is used to use the first model as the image generation model if the first model passes the test.
[0224] In some optional implementations of this embodiment, the building blocks include:
[0225] A construction submodule for constructing an initial pixel convolutional neural network based on a preset convolutional layer;
[0226] A setting submodule is used to perform mask setting processing on the initial pixel convolutional neural network to obtain the pixel convolutional neural network;
[0227] A third acquisition submodule is used to acquire the long short-term memory network;
[0228] An integration submodule, used for performing parallel integration processing on the long short-term memory network in the residual module of the pixel convolutional neural network to obtain a corresponding processing network;
[0229] The third determining submodule is used to use the processing network as the initial model.
[0230] In some optional implementations of this embodiment, the image generation device based on artificial intelligence further includes:
[0231] A fourth acquisition module, configured to acquire a preset model adjustment strategy if the first model fails the test;
[0232] An adjustment module, used for adjusting the first model based on the model adjustment strategy until a second model that meets the construction expectation is obtained;
[0233] The second determining module is used to use the second model as the image generation model.
[0234] To solve the above technical problems, the present application also provides a computer device. Figure 4 , Figure 4 This is a basic structural block diagram of the computer device in this embodiment.
[0235] The computer device 4 includes a memory 41, a processor 42, and a network interface 43 that are interconnected through a system bus. It should be noted that the figure only shows a computer device 4 with components 41-43, but it should be understood that it is not required to implement all the components shown, and more or fewer components can be implemented instead. Among them, those skilled in the art can understand that the computer device here is a device that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes but is not limited to microprocessors, application specific integrated circuits (Application Specific Integrated Circuit, ASIC), programmable gate arrays (Field-Programmable Gate Array, FPGA), digital processors (Digital Signal Processor, DSP), embedded devices, etc.
[0236] The computer device may be a computing device such as a desktop computer, a notebook, a PDA, a cloud server, etc. The computer device may interact with a user through a keyboard, a mouse, a remote controller, a touch pad, or a voice control device.
[0237] The memory 41 includes at least one type of readable storage medium, and the readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (for example, SD or DX memory, etc.), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, disk, optical disk, etc. In some embodiments, the memory 41 can be an internal storage unit of the computer device 4, such as a hard disk or memory of the computer device 4. In other embodiments, the memory 41 can also be an external storage device of the computer device 4, such as a plug-in hard disk equipped on the computer device 4, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (FlashCard), etc. Of course, the memory 41 can also include both the internal storage unit of the computer device 4 and its external storage device. In this embodiment, the memory 41 is generally used to store the operating system and various application software installed on the computer device 4, such as computer-readable instructions of an image generation method based on artificial intelligence, etc. In addition, the memory 41 can also be used to temporarily store various types of data that have been output or are to be output.
[0238] The processor 42 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chips in some embodiments. The processor 42 is generally used to control the overall operation of the computer device 4. In this embodiment, the processor 42 is used to run computer-readable instructions stored in the memory 41 or process data, such as computer-readable instructions for running the artificial intelligence-based image generation method.
[0239] The network interface 43 may include a wireless network interface or a wired network interface. The network interface 43 is generally used to establish a communication connection between the computer device 4 and other electronic devices.
[0240] The present application also provides another embodiment, namely, providing a computer-readable storage medium, which stores computer-readable instructions, and the computer-readable instructions can be executed by at least one processor to enable the at least one processor to perform the steps of the above-mentioned artificial intelligence-based image generation method.
[0241] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in each embodiment of the present application.
[0242] Obviously, the embodiments described above are only some embodiments of the present application, rather than all embodiments. The preferred embodiments of the present application are given in the accompanying drawings, but they do not limit the patent scope of the present application. The present application can be implemented in many different forms. On the contrary, the purpose of providing these embodiments is to make the understanding of the disclosure of the present application more thorough and comprehensive. Although the present application is described in detail with reference to the aforementioned embodiments, for those skilled in the art, it is still possible to modify the technical solutions recorded in the aforementioned specific implementation methods, or to perform equivalent replacement of some of the technical features therein. Any equivalent structure made using the contents of the specification and drawings of this application, directly or indirectly used in other related technical fields, is similarly within the scope of patent protection of this application.
Claims
1. An image generation method based on artificial intelligence, characterized in that: The steps include: Get the initial image input by the user; Traversing all pixel positions in the initial image, for each pixel position, collecting a target pixel value corresponding to the pixel position; Calling a pre-built image generation model; wherein the image generation model is a model generated by training a preset pixel convolutional neural network and a long short-term memory network based on pre-built image sample data; Performing image generation processing on the target pixel value based on the image generation model to obtain a corresponding first image; Optimizing the first image based on a preset image optimization strategy to obtain a corresponding target image; The target image is returned to the user.
2. The method for generating an image based on artificial intelligence according to claim 1, characterized in that: The step of collecting the target pixel value corresponding to each pixel position specifically includes: Obtain a specified pixel position, and determine whether the specified pixel position is the top position on the left side of the image; wherein the specified pixel position is any one of all the pixel positions; If the designated pixel position is the top position on the left side of the image, a preset pixel value generation strategy is obtained; Collecting target pixel values corresponding to the designated pixel positions based on the pixel value generation strategy; If the designated pixel position is not the top position on the left side of the image, then obtaining the upper pixel value and the left pixel value matching the designated pixel position; A target pixel value corresponding to the designated pixel position is generated based on the upper pixel value and the left pixel value.
3. The method for generating an image based on artificial intelligence according to claim 1, characterized in that: The step of performing image generation processing on the target pixel value based on the image generation model to obtain the corresponding first image specifically includes: Performing pixel value input processing on the target pixel value to input the target pixel value into the image generation model; Performing forward calculation processing on the target pixel value through the image generation model to obtain corresponding distribution parameters; Performing sampling pixel value processing on the distribution parameter to obtain a corresponding designated pixel value; Performing pixel value placement processing on the designated pixel value to place the designated pixel value in the initial image; Repeating the pixel value input process, the forward calculation process, the sampling pixel value process, and the pixel value placement process until the processing of all the target pixel values is completed and a generated image with all pixel values generated is obtained; The generated image is used as the first image.
4. The method for generating an image based on artificial intelligence according to claim 1, characterized in that: The step of optimizing the first image based on a preset image optimization strategy to obtain a corresponding target image specifically includes: Performing smoothing on the first image to obtain a corresponding second image; Performing color adjustment processing on the second image to obtain a corresponding third image; Performing contrast adjustment processing on the third image to obtain a corresponding fourth image; The fourth image is used as the target image.
5. The method for generating an image based on artificial intelligence according to claim 1, characterized in that: Before the step of calling the pre-built image generation model, the method further includes: Obtaining a pre-collected image dataset; Preprocessing the image data set to obtain corresponding image sample data; Dividing the image sample data into a training data set and a test data set; Building an initial model based on the pixel convolutional neural network and the long short-term memory network; Determine the target loss function corresponding to the initial model and obtain a preset target optimization algorithm; Based on the target loss function and the target optimization algorithm, the initial model is trained using the training data set to obtain a corresponding first model; Testing the first model based on the test data set; If the first model passes the test, the first model is used as the image generation model.
6. The method for generating an image based on artificial intelligence according to claim 5, characterized in that: The step of constructing an initial model based on the pixel convolutional neural network and the long short-term memory network specifically includes: Construct an initial pixel convolutional neural network based on the preset convolutional layer; Performing mask setting processing on the initial pixel convolutional neural network to obtain the pixel convolutional neural network; Obtaining the long short-term memory network; Performing parallel integration processing on the long short-term memory network in the residual module of the pixel convolutional neural network to obtain a corresponding processing network; The processing network is used as the initial model.
7. The method for generating an image based on artificial intelligence according to claim 5, characterized in that: After the step of testing the first model based on the test data set, the method further includes: If the first model fails the test, obtaining a preset model adjustment strategy; Adjust the first model based on the model adjustment strategy until a second model that meets the construction expectations is obtained; The second model is used as the image generation model.
8. An image generation device based on artificial intelligence, characterized in that: include: A first acquisition module, used to acquire an initial image input by a user; A collection module, configured to traverse all pixel positions in the initial image, and for each pixel position, collect a target pixel value corresponding to the pixel position; A calling module, used to call a pre-built image generation model; wherein the image generation model is a model generated by training a preset pixel convolutional neural network and a long short-term memory network based on pre-built image sample data; A generation module, configured to perform image generation processing on the target pixel value based on the image generation model to obtain a corresponding first image; An optimization module, used to optimize the first image based on a preset image optimization strategy to obtain a corresponding target image; A returning module is used to return the target image to the user.
9. A computer device, characterized in that: It comprises a memory and a processor, wherein the memory stores computer-readable instructions, and when the processor executes the computer-readable instructions, the steps of the artificial intelligence-based image generation method as described in any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-readable instructions, which, when executed by a processor, implement the steps of the artificial intelligence-based image generation method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Image-based cartoon animation generation method and device, equipment and storage medium
CN114782592A
