Image generation method and device, computer equipment and readable storage medium

By obtaining image generation scene information, text description information and reference images, the pre-trained image generation model is used to generate images in stages, which solves the problem of insufficient image generation accuracy in traditional methods, improves the diversity and stability of images, and reduces requirements for training resources.

CN118628604APending Publication Date: 2024-09-10GUANGZHOU QUYAN NETWORK TECH CO LTD
View PDF 0 Cites 4 Cited by

Patent Information

Application Number
CN202410940622.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-15
Publication Date
2024-09-10

AI Technical Summary

Technical Problem

Traditional image generation methods have shortcomings in the accuracy of generated images, especially the poor diversity, stability and content controllability of images, and the generation of target sizes requires additional training resources and time costs.

Method used

By obtaining image generation scene information, text description information and reference images, the pre-trained image generation model is used to generate images in stages. An initial image of a preset size is first generated, and then the image to be generated is generated again according to the target size to ensure that the image features match. Avoid additional training of models.

Benefits of technology

It improves the accuracy and controllability of image generation, reduces the need for additional training resources for target sizes, and improves generation efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118628604A
    Figure CN118628604A
Patent Text Reader

Abstract

The invention relates to an image generation method and device, computer equipment and a readable storage medium. The method comprises the following steps: acquiring image generation scene information, text description information corresponding to the image generation scene information and a reference image; inputting the text description information and the reference image into an image generation model to obtain an initial generation image with a preset size; and inputting the text description information, the reference image and the initial generated image into an image generation model to obtain a to-be-generated image with the target size. By adopting the method, the initial image of the preset size for the image generation scene can be generated by utilizing the image generation model, the to-be-generated image of the target size is generated by utilizing the image generation model on the basis of the initial image, the to-be-generated image of the target size is generated in stages, the image generation model does not need to be additionally trained for the target size, and the image generation efficiency is improved. The problem that the image accuracy is not high when the image of the target size is directly generated is avoided, and the image generation accuracy is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to an image generation method, apparatus, computer equipment, computer-readable storage medium, and computer program product. Background Art

[0002] With the continuous development of computer vision and machine learning technology, image generation algorithms have been greatly promoted and supported. The rise of deep learning, generative adversarial networks (GANs), variational autoencoders (VAEs) and other technologies have provided more powerful tools and methods for image generation tasks, generating images with specific content, form or style through image generation algorithms and models.

[0003] In traditional methods, image generation algorithms based on generative adversarial networks can generate images through techniques such as texture synthesis and style transfer. However, the image generation effect of image generation algorithms based on generative adversarial networks depends to a large extent on the quality and diversity of the training data set. The diversity, stability, and content controllability of the generated images are poor, and the training process is complex and requires more training resources. Traditional methods are based on stable diffusion models and can generate images of specific proportions and contents based on input prompt words. However, the process of using input words to control the content of the picture to generate images is easily affected by the size of the raw image during model training. When the size of the raw image is inconsistent with the target size, the controllability and generation effect of the generated image are reduced. In addition, training a specific model for the target size requires additional training resources and time costs.

[0004] Therefore, the traditional method has the problem of low image accuracy when generating images. Summary of the invention

[0005] Based on this, it is necessary to provide an image generation method, apparatus, computer device, computer-readable storage medium and computer program product that can improve the accuracy of image generation in response to the above technical problems.

[0006] In a first aspect, the present application provides an image generation method, comprising:

[0007] Acquire image generation scene information associated with the image to be generated, and acquire text description information corresponding to the image generation scene information, and a reference image corresponding to the image generation scene information; the text description information is used to describe image features of the image to be generated;

[0008] Input the text description information and the reference image into a pre-trained image generation model to obtain an initial generated image; the size of the initial generated image is a preset size corresponding to the image generation model;

[0009] The text description information, the reference image and the initial generated image are input into the image generation model to obtain the image to be generated; the image features of the image to be generated match the image features of the initial generated image; the size of the image to be generated is the target size; the target size is different from the preset size.

[0010] In one embodiment, the obtaining of text description information corresponding to the image generation scene information includes:

[0011] Acquire a text description template corresponding to the image generation scene information from a preset text description template library;

[0012] Acquire the prompt word corresponding to the text description template from a preset prompt word information library;

[0013] The prompt word is set at a position corresponding to the prompt word in the text description template to generate the text description information.

[0014] In one embodiment, inputting the text description information and the reference image into a pre-trained image generation model to obtain an initial generated image includes:

[0015] Encoding the text description information through the image generation model to obtain text feature information corresponding to the text description information;

[0016] Acquire preset noise through the image generation model, and generate first latent space feature information corresponding to the text feature information according to the preset noise, the text feature information and the reference image;

[0017] The first latent space feature information is decoded by the image generation model to obtain the initial generated image.

[0018] In one embodiment, the step of inputting the text description information, the reference image, and the initial generated image into the image generation model to obtain the image to be generated includes:

[0019] Encoding the text description information through the image generation model to obtain text feature information corresponding to the text description information;

[0020] Generate second latent space feature information corresponding to the text feature information according to the initial generated image, the text feature information and the reference image through the image generation model;

[0021] The target size is acquired through the image generation model, and the second latent space feature information is decoded according to the target size to obtain the image to be generated.

[0022] In one embodiment, the method further comprises:

[0023] Obtaining weight information corresponding to the reference image;

[0024] According to the initially generated image, the text feature information, the reference image and the weight information, second latent space feature information corresponding to the text feature information is generated.

[0025] In one embodiment, the reference image includes a style image and a pose image, and obtaining the reference image corresponding to the image generation scene information includes:

[0026] Acquire a style image corresponding to the image generation scene information from a preset style image library;

[0027] A posture image corresponding to the image generation scene information is obtained from a preset posture image library.

[0028] In a second aspect, the present application further provides an image generating device, comprising:

[0029] An acquisition module, used to acquire image generation scene information associated with the image to be generated, and to acquire text description information corresponding to the image generation scene information, and a reference image corresponding to the image generation scene information; the text description information is used to describe image features of the image to be generated;

[0030] A text image module, used for inputting the text description information and the reference image into a pre-trained image generation model to obtain an initial generated image; the size of the initial generated image is a preset size corresponding to the image generation model;

[0031] The image generation module is used to input the text description information, the reference image and the initial generated image into the image generation model to obtain the image to be generated; the image features of the image to be generated match the image features of the initial generated image; the size of the image to be generated is the target size; the target size is different from the preset size.

[0032] In a third aspect, the present application further provides a computer device, wherein the computer device comprises a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the steps of the above method are implemented.

[0033] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program implements the steps of the above method when executed by a processor.

[0034] In a fifth aspect, the present application further provides a computer program product, wherein the computer program product comprises a computer program, and when the computer program is executed by a processor, the steps of the above method are implemented.

[0035] The above-mentioned image generation method, apparatus, computer device, computer-readable storage medium and computer program product obtain image generation scene information associated with the image to be generated, obtain text description information corresponding to the image generation scene information, and obtain a reference image corresponding to the image generation scene information, thereby accurately obtaining the image generation scene, and obtaining the text description information and reference image corresponding to the image generation scene, thereby providing a data basis for the subsequent generation of images in specific scenes based on the text description information and the reference image; the text description information is used to describe the image features of the image to be generated; the text description information and the reference image are input into a pre-trained image generation model to obtain an initial generated image, thereby using the pre-trained image generation model to generate an initial image for the image generation scene based on the text description information and the reference image, so as to facilitate the subsequent further generation of images based on the initial image; the size of the initial generated image is a preset size corresponding to the image generation model; the text description information and the reference image are input into a pre-trained image generation model to obtain an initial generated image The initial generated image is input into the image generation model to obtain the image to be generated; the image features of the image to be generated match the image features of the initial generated image; the size of the image to be generated is the target size; the target size is different from the preset size, so that based on the image generation model, the image to be generated is generated on the basis of the initial generated image in combination with the text description information and the reference image, and the image generation model can be used to generate an initial image with a preset size for the image generation scene based on the text description information and the reference image corresponding to the image generation scene information, and the image generation model is used again on the basis of the initial image, combined with the text description information and the reference image corresponding to the image generation scene information, to generate the image to be generated with the target size, so that the image to be generated of the target size is generated in stages, and there is no need to additionally train the image generation model for the target size, so as to avoid the problem that the image content does not meet the requirements when the image with the target size is directly generated, thereby resulting in a decrease in image accuracy, thereby improving the accuracy of image generation. BRIEF DESCRIPTION OF THE DRAWINGS

[0036] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the drawings required for use in the embodiments of the present application or related technical descriptions will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0037] Figure 1 A diagram of an application environment of an image generation method in one embodiment;

[0038] Figure 2 is a schematic flow chart of an image generating method in an embodiment;

[0039] Figure 3 A schematic diagram of a process of generating an initial generated image in one embodiment;

[0040] Figure 4 A schematic diagram of a process of generating an image to be generated in one embodiment;

[0041] Figure 5 A schematic diagram of a process of generating an image in one embodiment;

[0042] Figure 6 is a structural block diagram of an image generating device in one embodiment;

[0043] Figure 7 The figure is a diagram of the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION

[0044] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0045] The image generation method provided in the embodiment of the present application can be applied to Figure 1In the application environment shown. Among them, the terminal 102 communicates with the server 104 through the network. The data storage system can store the data that the server 104 needs to process. The data storage system can be integrated on the server 104, or it can be placed on the cloud or other network servers. The server 104 obtains the image generation scene information associated with the image to be generated, and obtains the text description information corresponding to the image generation scene information, and the reference image corresponding to the image generation scene information; the text description information is used to describe the image features of the image to be generated; the server 104 inputs the text description information and the reference image into the pre-trained image generation model to obtain the initial generated image; the size of the initial generated image is the preset size corresponding to the image generation model; the server 104 inputs the text description information, the reference image and the initial generated image into the image generation model to obtain the image to be generated; the image features of the image to be generated match the image features of the initial generated image; the size of the image to be generated is the target size; the target size is different from the preset size. Among them, the terminal 102 can be, but is not limited to, various personal computers, laptops, smart phones, tablets, Internet of Things devices and portable wearable devices, and the Internet of Things devices can be smart TVs, smart car devices, projection devices, etc. The portable wearable device may be a smart watch, a smart bracelet, a head-mounted device, etc. The head-mounted device may be a virtual reality (VR) device, an augmented reality (AR) device, smart glasses, etc. The server 104 may be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server providing cloud computing services.

[0046] In an exemplary embodiment, Figure 2 As shown, an image generation method is provided, and the method is applied to a server as an example for description, including the following steps S202 to S206. Among them:

[0047] Step S202, obtaining image generation scene information associated with the image to be generated, and obtaining text description information corresponding to the image generation scene information, and a reference image corresponding to the image generation scene information; the text description information is used to describe the image features of the image to be generated.

[0048] The image to be generated may refer to an image that needs to be generated. In practical applications, the image to be generated may refer to an image that meets user requirements, wherein the user requirements may include but are not limited to image content, image style, image size, etc.

[0049] Among them, the image generation scene information may refer to information that characterizes the type of image content of the image to be generated. In practical applications, the image generation scene information may include but is not limited to character image generation scenes and landscape image generation scenes, etc. The image generation scene information may be information input / selected by the user and can meet the user's needs.

[0050] The text description information may refer to information describing image features of the image to be generated. In practical applications, the image features of the image to be generated may include image content, and the text description information may consist of a number of prompt words.

[0051] The reference image may refer to an image used as a reference for image generation. In practical applications, the reference image may influence / guide the generation process and image content of the image to be generated.

[0052] As an example, when an image that meets user needs needs to be generated, the server can obtain image generation scene information associated with the image to be generated, and then the server can obtain text description information corresponding to the image generation scene information and a reference image corresponding to the image generation scene information from a pre-created database.

[0053] Step S204, inputting the text description information and the reference image into a pre-trained image generation model to obtain an initial generated image; the size of the initial generated image is a preset size corresponding to the image generation model.

[0054] Among them, the pre-trained image generation model may refer to a pre-trained model for generating images. In practical applications, the image generation model may include a stable diffusion (SD) model. The character image generation scene may correspond to at least one character image generation model (such as character image generation model 1, character image generation model 2, etc.), and the landscape image generation scene may correspond to at least one landscape image generation model (such as landscape image generation model 1, landscape image generation model 2, etc.).

[0055] Among them, the preset size may refer to information that characterizes the image size of the initially generated image. In practical applications, the preset size may include the size of the training samples (such as sample images) input into the image generation model during the training process of the image generation model. In specific implementations, the preset size may include the size of an image whose length / width is less than a preset specific threshold. The preset size can be used as a "regular size (such as a ratio of image length to width of 4:3)".

[0056] As an example, the server inputs text description information and a reference image into a pre-trained image generation model to obtain an initial generated image. The server can display the initial generated image to the user and adjust the initial generated image based on the user's input content to obtain an adjusted initial generated image.

[0057] Step S206, input the text description information, the reference image and the initial generated image into the image generation model to obtain the image to be generated; the image features of the image to be generated match the image features of the initial generated image; the size of the image to be generated is the target size; the target size is different from the preset size.

[0058] The image feature of the image to be generated may refer to information representing the image content of the image to be generated.

[0059] The image feature of the initially generated image may refer to information representing the image content of the initially generated image.

[0060] The target size may refer to information representing the image size of the image to be generated. In practical applications, the target size may include the size of an image whose length / width is greater than or equal to a preset specific threshold. The target size may be used as a "long image size".

[0061] As an example, the server inputs the text description information, the reference image and the initial generated image into the image generation model. The image generation model can generate the image to be generated based on the text description information and the reference image on the basis of the initial generated image. For example, the image generation model can use the text description information and the reference image to "redraw" the initial generated image to obtain the image to be generated.

[0062] In the above-mentioned image generation method, by obtaining image generation scene information associated with the image to be generated, obtaining text description information corresponding to the image generation scene information, and obtaining a reference image corresponding to the image generation scene information, the image generation scene is accurately obtained, and the text description information and reference image corresponding to the image generation scene are obtained, so as to provide a data basis for the subsequent generation of images in specific scenes based on the text description information and the reference image; the text description information is used to describe the image features of the image to be generated; the text description information and the reference image are input into a pre-trained image generation model to obtain an initial generated image, so as to use the pre-trained image generation model to generate an initial image for the image generation scene based on the text description information and the reference image, so as to facilitate the subsequent further generation of images based on the initial image; the size of the initial generated image is the preset size corresponding to the image generation model; the text description information, the reference image and the initial generated image are input into the image generation model A model is formed to obtain an image to be generated; the image features of the image to be generated match the image features of the initially generated image; the size of the image to be generated is the target size; the target size is different from the preset size, so that based on the image generation model, the image to be generated is generated on the basis of the initially generated image in combination with the text description information and the reference image, and the image generation model can be used to generate an initial image with a preset size for the image generation scene based on the text description information and the reference image corresponding to the image generation scene information, and the image generation model is used again on the basis of the initial image, in combination with the text description information and the reference image corresponding to the image generation scene information, to generate an image to be generated with the target size, so that the image to be generated of the target size is generated in stages, and there is no need to additionally train the image generation model for the target size, so as to avoid the problem that the image content does not meet the requirements when the image with the target size is directly generated, thereby reducing the image accuracy, thereby improving the accuracy of image generation.

[0063] In an exemplary embodiment, obtaining text description information corresponding to the image generation scene information includes: obtaining a text description template corresponding to the image generation scene information from a preset text description template library; obtaining a prompt word corresponding to the text description template from a preset prompt word information library; and setting the prompt word at a position corresponding to the prompt word in the text description template to generate text description information.

[0064] Among them, the preset text description template library may refer to a pre-set database containing several text description templates. In actual applications, the image generation scene information may correspond to at least one text description template in the preset text description template library. For example, the character image generation scene may correspond to at least one character image text description template in the preset text description template library, and the landscape image generation scene may correspond to at least one landscape image text description template in the preset text description template library.

[0065] Among them, the text description template may refer to information that describes the content that the text description information needs to include. In actual applications, when the image generation scene information is a character image generation scene, the text description template may include but is not limited to the character's gender, character expression, character posture, character clothing, character background, etc. When the image generation scene information is a landscape image generation scene, the text description template may include but is not limited to landscape elements.

[0066] The preset prompt word information library may refer to a pre-set database containing a number of prompt words. In actual applications, the image generation scene information may correspond to at least one prompt word in the preset prompt word information library.

[0067] Among them, the prompt words may refer to information that constitutes the text description information. In actual applications, the prompt words have corresponding positions in the text description template. When the image generation scene information is a character image generation scene, the prompt words may include texts for the character's gender, character expression, character posture, character clothing, character background, etc. When the image generation scene information is a landscape image generation scene, the prompt words may include texts for landscape elements.

[0068] As an example, the server can obtain a text description template corresponding to the image generation scene information from a preset text description template library, and obtain a prompt word corresponding to the text description template from a preset prompt word information library, and then the server sets the prompt word to the position corresponding to the prompt word in the text description template to generate text description information. The pre-trained image generation model can generate an initial generated image and an image to be generated based on the text description information and the reference image.

[0069] In actual applications, the text description template may also include image generation model information. The server may obtain the image generation model information corresponding to the text description template from a preset image generation model library. The image generation model corresponding to the image generation model information corresponding to the text description template may generate an initial generated image and an image to be generated based on the text description information and a reference image. The image generation scene information may correspond to at least one image generation model in the preset image generation model library. The character image generation scene may correspond to at least one character image generation model in the image generation model library. The landscape image generation scene may correspond to at least one landscape image generation model in the image generation model library. For example: when a preset text description template library, a preset prompt word information library, a preset image generation model library, and a preset reference image library are built offline, when it is necessary to generate an image to be generated for a character image generation scene, the server can randomly select a character image text description template from the preset text description template library as the text description template corresponding to the character image generation scene, and then the server can randomly select several prompt words from the preset prompt word information library as the prompt words corresponding to the text description template. The server can also randomly select a character image generation model information from the preset image generation model library as the image generation model information corresponding to the character image generation scene. The server can set the image generation model information corresponding to the character image generation scene in the text description template at the position corresponding to the image generation model information, and set the prompt word in the text description. The server can input the text description information and a reference image randomly selected from a preset reference image library into a pre-trained image generation model to generate an initial generated image, and input the initial generated image and the image to be generated, the text description information and the reference image into the pre-trained image generation model to generate the image to be generated; the server can also use the image corresponding to the image generation model information in the text description information as a pre-trained image generation model, and then the server can input the text description information and a reference image randomly selected from a preset reference image library into the pre-trained image generation model to generate an initial generated image, and input the initial generated image and the image to be generated, the text description information and the reference image into the pre-trained image generation model to generate the image to be generated.

[0070] In this embodiment, by obtaining a text description template corresponding to the image generation scene information from a preset text description template library; obtaining a prompt word corresponding to the text description template from a preset prompt word information library; and setting the prompt word at the position corresponding to the prompt word in the text description template to generate text description information, it is possible to accurately obtain the corresponding text description template in the preset text description template library based on the image generation scene information, and generate text description information in combination with the prompt word that needs to be filled in the text description template, thereby improving the accuracy of the text description information, providing a data basis for the subsequent generation of the image to be generated, and thus improving the accuracy of image generation.

[0071] In some embodiments, text description information and a reference image are input into a pre-trained image generation model to obtain an initial generated image, including: encoding the text description information through the image generation model to obtain text feature information corresponding to the text description information; obtaining preset noise through the image generation model, and generating first latent space feature information corresponding to the text feature information based on the preset noise, the text feature information and the reference image; decoding the first latent space feature information through the image generation model to obtain the initial generated image.

[0072] The text feature information may refer to information obtained by encoding the text description information. In practical applications, the text feature information may include text feature vectors (text embeddings).

[0073] The preset noise may refer to pre-set noise or data. In practical applications, the preset noise may include initialized Gaussian random noise.

[0074] The first latent space feature information may refer to information obtained by gradually removing corresponding noise from preset noise based on text feature information and a reference image. In practical applications, the latent space feature information may be expressed as latent.

[0075] As an example, Figure 3As shown, a flow chart of generating an initial generated image is provided, the image generation model may include a text encoder (Text Encoder), a deep learning network (such as U-net) and an image decoder, the image generation model may encode the text description information through the text encoder to obtain text feature information corresponding to the text description information, the image generation model may obtain preset noise, and input the preset noise, text feature information and reference image into the deep learning network, the deep learning network may implement a denoising process, generate denoised first latent space feature information corresponding to the text feature information, and then the image generation model decodes the first latent space feature information through the image decoder to obtain the initial generated image, wherein the image generation model may also include a control network, the image generation model may encode the reference image to obtain reference image feature information, the deep learning network may denoise the preset noise based on the text feature information and the reference image feature information to obtain the first latent space feature information, and the image generation model may control or adjust the influence of the reference image feature information / reference image on the initial generated image through the control network.

[0076] In this embodiment, the text description information is encoded through the image generation model to obtain text feature information corresponding to the text description information; the preset noise is obtained through the image generation model, and the first latent space feature information corresponding to the text feature information is generated according to the preset noise, the text feature information and the reference image; the first latent space feature information is decoded through the image generation model to obtain an initial generated image, and the initial generated image that meets the user's needs can be generated based on the image generation model using the text description information and the reference image, thereby improving the accuracy of the initial generated image, providing a data basis for the subsequent generation of the image to be generated based on the initial generated image, thereby improving the accuracy of image generation.

[0077] In some embodiments, text description information, a reference image, and an initially generated image are input into an image generation model to obtain an image to be generated, including: encoding the text description information through the image generation model to obtain text feature information corresponding to the text description information; generating second latent space feature information corresponding to the text feature information according to the initially generated image, the text feature information, and the reference image through the image generation model; obtaining a target size through the image generation model, and decoding the second latent space feature information according to the target size to obtain the image to be generated.

[0078] The second latent space feature information may refer to information obtained by gradually removing corresponding noise from the initial generated image based on the text feature information and the reference image.

[0079] As an example, Figure 4As shown, a flow chart of generating an image to be generated is provided, the image generation model may include a text encoder, an image encoder (VAE Decoder), a deep learning network (such as U-net) and an image decoder, the image generation model may encode the text description information through the text encoder to obtain text feature information corresponding to the text description information, the image generation model may encode the initial generated image through the image encoder to obtain image feature information of the initial generated image, and input the image feature information, text feature information and reference image of the initial generated image into the deep learning network, the deep learning network may implement a denoising process, generate denoised first latent space feature information corresponding to the text feature information, and then the image generation model decodes the second latent space feature information according to the target size through the image decoder to obtain the image to be generated with the target size, wherein the image generation model may also include a control network, the image generation model may encode the reference image to obtain reference image feature information, the deep learning network may denoise the image feature information of the initial generated image based on the text feature information and the reference image feature information to obtain the second latent space feature information, and the image generation model may control or adjust the influence of the reference image feature information / reference image on the initial generated image through the control network.

[0080] In this embodiment, the text description information is encoded through the image generation model to obtain text feature information corresponding to the text description information; the second latent space feature information corresponding to the text feature information is generated through the image generation model according to the initial generated image, the text feature information and the reference image; the target size is obtained through the image generation model, and the second latent space feature information is decoded according to the target size to obtain the image to be generated. Based on the initial generated image, the image generation model, the text description information and the reference image can generate an accurate image to be generated with the target size, thereby improving the accuracy of the image to be generated and thus improving the accuracy of the image generation.

[0081] In some embodiments, the above method also includes: obtaining weight information corresponding to the reference image; generating second latent space feature information corresponding to the text feature information based on the initial generated image, text feature information, the reference image and weight information.

[0082] The weight information may refer to information characterizing the degree of influence of the reference image on the image output by the image generation model. In practical applications, the weight information may be adjusted based on actual needs.

[0083] As an example, in the process of generating an initial generated image, the image generation model can obtain the first weight information of the reference image, and input the preset noise, text feature information, the reference image and the first weight information into the U-net network in the image generation model to generate the first latent space feature information corresponding to the text feature information; similarly, in the process of generating the image to be generated, the image generation model can obtain the second weight information of the reference image, and input the initial generated image, text feature information, the reference image and the second weight information into the U-net network in the image generation model to generate the second latent space feature information corresponding to the text feature information.

[0084] In this embodiment, by obtaining weight information corresponding to the reference image; generating second latent space feature information corresponding to the text feature information according to the initial generated image, text feature information, the reference image and weight information, the influence of the reference image on the generated image can be controlled based on the weight information corresponding to the reference image, thereby ensuring that the reference image can reasonably guide the generation of the image to be generated, obtaining an image that meets the requirements, and improving the accuracy of the image to be generated.

[0085] In some embodiments, the reference image includes a style image and a posture image, and obtaining the reference image corresponding to the image generation scene information includes: obtaining the style image corresponding to the image generation scene information from a preset style image library; obtaining the posture image corresponding to the image generation scene information from a preset posture image library.

[0086] Among them, the style image may refer to a reference image with a characteristic style. In practical applications, the style image may include but is not limited to character style images of various styles, landscape style images of various styles, etc. The image generation scene information may correspond to at least one style image (such as character style image 1, character style image 2 or landscape style image 1, landscape style image 2, etc.).

[0087] Among them, a posture image may refer to a reference image with a characteristic style. In practical applications, style images may include but are not limited to character posture images of various styles, etc. The image generation scene information may correspond to at least one posture image (such as character posture image 1, character posture image 2, etc.).

[0088] The preset style image library may refer to a pre-set database containing a number of character style images of various styles and landscape style images of various styles.

[0089] The preset posture image library may refer to a pre-set database containing a number of human posture images of various styles and the like.

[0090] As an example, when a preset style image library and a preset pose image library are established offline, the server can obtain the style image corresponding to the image generation scene information from the preset style image library and obtain the pose image corresponding to the image generation scene information from the preset pose image library. The style image and the pose image can be used as reference images to "guide" the generation process and image content of the initial generated image and the image to be generated.

[0091] In this embodiment, by obtaining a style image corresponding to the image generation scene information from a preset style image library; obtaining a posture image corresponding to the image generation scene information from a preset posture image library, the style image and posture image corresponding to the image generation scene information can be obtained from the preset graphics library as reference images, ensuring that the reference image matches the image generation scene information, providing a data basis for the subsequent generation of an initial generated image and an image to be generated in combination with the reference image, and improving the accuracy of the image to be generated.

[0092] In some embodiments, when it is necessary to generate an image of a specific size (such as a target size) based on a text description, additional training of an image generation model for the specific size requires more training resources. Generating an image of a specific size directly based on a text description is affected by the size of the training samples (such as raw images) used in the model training phase, and the image controllability and generation effect of the model output result are reduced, and there is a problem of low image accuracy. Therefore, when it is necessary to automatically generate images of diverse and specific sizes (such as long image sizes), such as Figure 5As shown, a schematic diagram of the image generation process is provided, and input parameters can be obtained from a preset text description template library, a preset prompt word information library, a preset image generation model library, and a preset reference image library that are constructed offline and correspond to different image generation scenarios. Specifically, the server obtains image generation scenario information input or selected by the user, and then the server randomly selects a text description template corresponding to the image generation scenario information from the preset text description template library, randomly selects a prompt word corresponding to the text description template from the preset prompt word information library, randomly selects image generation model information corresponding to the image generation scenario information from the preset image generation model library, obtains a style image corresponding to the image generation scenario information from the preset style image library, and obtains a posture image corresponding to the image generation scenario information from the preset posture image library. The style image and the posture image can be used as reference images, and the text description template , prompt words and image generation model can constitute text description information, and then the server can perform the text-to-image task, that is, the server inputs the text description information and the reference image into the pre-trained image generation model. After a certain number of iterations, the image generation model can generate an initial generated image. Specifically, the image generation model can use a text encoder to encode the text description information to obtain a text feature vector, and initialize a preset random noise at the same time. Then, the text feature vector, the reference image and the noise vector corresponding to the preset random noise are input into the U-net network in the image generation model to generate denoised latent space feature information. Then, the image generation model can use an image decoder to reconstruct the denoised latent space feature information into a pixel map to obtain an initial generated image, wherein the image generation model can use a control network to control the degree of influence of the reference image on the initial generated image.

[0093] After obtaining the initial generated image, the server can perform the image-to-image task, that is, the server inputs the initial generated image, text description information and reference image into the image generation model to generate the image to be generated. Specifically, the image generation model can use the text encoder to encode the text description information to obtain the text feature vector, and use the image encoder to encode the initial generated image to obtain the image feature information of the initial generated image. Then, the text feature vector, the reference image and the image feature information of the initial generated image are input into the U-net network in the image generation model to generate denoised latent space feature information. Then, the image generation model can use the image decoder to reconstruct the denoised latent space feature information into a pixel map to obtain the image to be generated. The image to be generated can be used as a prompt of the image generation model based on the text description information to redraw the initial generated image to obtain an image that is more in line with the text description information. Among them, the image generation model can use the control network to control the influence of the reference image on the image to be generated.

[0094] In this embodiment, by introducing a stable diffusion (SD) model, an automation scheme is designed, and a prompt word library, an SD model library, and a reference picture library (style and character posture) corresponding to the target picture are offline constructed. Each time a raw picture is randomly selected as a model raw picture input condition, then the selected prompt word text is input by using the SD model, and the reference picture is used as a control condition to generate a picture with a regular proportion and a good picture effect. Then, the SD picture generation algorithm is used to input the SD generated picture, and the generated long picture ratio is specified for redrawing, so as to realize batch generation of diversified high-quality long pictures. The process of SD text-generated picture + picture-generated picture can be used, combined with conditional control, to synthesize high-quality long pictures with high controllability, which does not rely on the training data set, does not need to train a new model, and can quickly insert and use the existing model. By building a material library, some parameters of the raw picture are randomly generated to obtain pictures with more diverse picture content, thereby generating long pictures with multiple styles, realizing automatic batch generation of high-quality long pictures with diversified styles, and the long picture generation process does not require manual intervention.

[0095] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.

[0096] Based on the same inventive concept, the embodiment of the present application also provides an image generation device for implementing the above-mentioned image generation method. The implementation solution provided by the device to solve the problem is similar to the implementation solution recorded in the above-mentioned method, so the specific limitations in one or more image generation device embodiments provided below can refer to the limitations on the image generation method above, and will not be repeated here.

[0097] In an exemplary embodiment, Figure 6 As shown, an image generation device is provided, including: an acquisition module 602, a text generation image module 604 and a picture generation image module 606, wherein:

[0098] The acquisition module 602 is used to acquire image generation scene information associated with the image to be generated, and acquire text description information corresponding to the image generation scene information, and a reference image corresponding to the image generation scene information; the text description information is used to describe the image features of the image to be generated.

[0099] The text image module 604 is used to input the text description information and the reference image into a pre-trained image generation model to obtain an initial generated image; the size of the initial generated image is a preset size corresponding to the image generation model.

[0100] The image generation module 606 is used to input the text description information, the reference image and the initial generated image into the image generation model to obtain the image to be generated; the image features of the image to be generated match the image features of the initial generated image; the size of the image to be generated is the target size; the target size is different from the preset size.

[0101] In one of the exemplary embodiments, the acquisition module 602 is further specifically used to acquire a text description template corresponding to the image generation scene information from a preset text description template library; acquire a prompt word corresponding to the text description template from a preset prompt word information library; and set the prompt word at a position corresponding to the prompt word in the text description template to generate the text description information.

[0102] In one of the exemplary embodiments, the above-mentioned text image module 604 is also specifically used to encode the text description information through the image generation model to obtain text feature information corresponding to the text description information; obtain preset noise through the image generation model, and generate first latent space feature information corresponding to the text feature information based on the preset noise, the text feature information and the reference image; decode the first latent space feature information through the image generation model to obtain the initial generated image.

[0103] In one of the exemplary embodiments, the above-mentioned image generation module 606 is specifically used to encode the text description information through the image generation model to obtain text feature information corresponding to the text description information; generate second latent space feature information corresponding to the text feature information according to the initial generated image, the text feature information and the reference image through the image generation model; obtain the target size through the image generation model, and decode the second latent space feature information according to the target size to obtain the image to be generated.

[0104] In one of the exemplary embodiments, the above-mentioned image generation module 606 is also specifically used to obtain weight information corresponding to the reference image; and generate second latent space feature information corresponding to the text feature information based on the initial generated image, the text feature information, the reference image and the weight information.

[0105] In one of the exemplary embodiments, the reference image includes a style image and a posture image, and the above-mentioned acquisition module 602 is specifically used to obtain the style image corresponding to the image generation scene information from a preset style image library; and obtain the posture image corresponding to the image generation scene information from a preset posture image library.

[0106] Each module in the above-mentioned image generation device can be implemented in whole or in part by software, hardware or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to each module above.

[0107] In an exemplary embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as shown in FIG. Figure 7 As shown. The computer device includes a processor, a memory, an input / output interface, a communication interface, a display unit and an input device. The processor, the memory and the input / output interface are connected through a system bus, and the communication interface, the display unit and the input device are connected to the system bus through the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be implemented through WIFI, a mobile cellular network, near field communication (NFC) or other technologies. When the computer program is executed by the processor, an image generation method is implemented. The display unit of the computer device is used to form a visually visible picture, which can be a display screen, a projection device or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covering the display screen, or a button, trackball or touchpad set on the computer device shell, or an external keyboard, touchpad or mouse.

[0108] Those skilled in the art will understand that Figure 7The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0109] In one embodiment, a computer device is further provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps in the above method embodiments when executing the computer program.

[0110] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments are implemented.

[0111] In one embodiment, a computer program product is provided, including a computer program, which implements the steps in the above method embodiments when executed by a processor.

[0112] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant regulations.

[0113] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, an artificial intelligence (AI) processor, etc., but are not limited to this.

[0114] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.

[0115] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be construed as limiting the scope of the present application. It should be noted that, for a person of ordinary skill in the art, several modifications and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

Claims

1. An image generation method, characterized in that: The method comprises: Acquire image generation scene information associated with the image to be generated, and acquire text description information corresponding to the image generation scene information, and a reference image corresponding to the image generation scene information; the text description information is used to describe image features of the image to be generated; Input the text description information and the reference image into a pre-trained image generation model to obtain an initial generated image; the size of the initial generated image is a preset size corresponding to the image generation model; The text description information, the reference image and the initial generated image are input into the image generation model to obtain the image to be generated; the image features of the image to be generated match the image features of the initial generated image; the size of the image to be generated is the target size; the target size is different from the preset size.

2. The method according to claim 1, characterized in that The acquiring of text description information corresponding to the image generation scene information includes: Acquire a text description template corresponding to the image generation scene information from a preset text description template library; Acquire the prompt word corresponding to the text description template from a preset prompt word information library; The prompt word is set at a position corresponding to the prompt word in the text description template to generate the text description information.

3. The method according to claim 1, characterized in that The step of inputting the text description information and the reference image into a pre-trained image generation model to obtain an initial generated image includes: Encoding the text description information through the image generation model to obtain text feature information corresponding to the text description information; Acquire preset noise through the image generation model, and generate first latent space feature information corresponding to the text feature information according to the preset noise, the text feature information and the reference image; The first latent space feature information is decoded by the image generation model to obtain the initial generated image.

4. The method according to claim 3, characterized in that The step of inputting the text description information, the reference image, and the initial generated image into the image generation model to obtain the image to be generated includes: Encoding the text description information through the image generation model to obtain text feature information corresponding to the text description information; Generate second latent space feature information corresponding to the text feature information according to the initial generated image, the text feature information and the reference image through the image generation model; The target size is acquired through the image generation model, and the second latent space feature information is decoded according to the target size to obtain the image to be generated.

5. The method according to claim 4, characterized in that The method further comprises: Obtaining weight information corresponding to the reference image; According to the initially generated image, the text feature information, the reference image and the weight information, second latent space feature information corresponding to the text feature information is generated.

6. The method according to claim 1, characterized in that The reference image includes a style image and a pose image, and the step of obtaining the reference image corresponding to the image generation scene information includes: Acquire a style image corresponding to the image generation scene information from a preset style image library; A posture image corresponding to the image generation scene information is obtained from a preset posture image library.

7. An image generating device, characterized in that: The device comprises: An acquisition module, used to acquire image generation scene information associated with the image to be generated, and to acquire text description information corresponding to the image generation scene information, and a reference image corresponding to the image generation scene information; the text description information is used to describe image features of the image to be generated; A text image module, used for inputting the text description information and the reference image into a pre-trained image generation model to obtain an initial generated image; the size of the initial generated image is a preset size corresponding to the image generation model; The image generation module is used to input the text description information, the reference image and the initial generated image into the image generation model to obtain the image to be generated; the image features of the image to be generated match the image features of the initial generated image; the size of the image to be generated is the target size; the target size is different from the preset size.

8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.

10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.

Citation Information

Cited By

  • Urban micro-space optimization method and system using panoramic picture

    CN119358764A

  • Image generation method and device, intelligent agent, intelligent agent system and storage medium

    CN119597948A

  • Video generation method and device, equipment and storage medium

    CN119676472A

  • Cabin wallpaper generation method and device, electronic equipment and storage medium

    CN119741191A