Image generation method, device, and computer equipment
By obtaining and adjusting the target object attributes and identity feature information in the image description information, the problem of object identity feature information mismatch in image generation is solved, and the accuracy of the generated image is improved.
Patent Information
- Application Number
- CN202410573487.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-10
- Publication Date
- 2024-09-20
- Estimated Expiration
- 2044-05-10
AI Technical Summary
Existing image generation methods are difficult to accurately maintain the identity information of objects in the image, resulting in object distortion, image mismatch, and inaccuracy in the generated image.
By obtaining image description information, find and adjust the attribute information and identity feature information of the target object, thereby generating a more accurate target image.
The accuracy of generated images is improved, mismatching of object identity information is reduced, and more accurate image generation is achieved.
Smart Images

Figure CN118152609B
Abstract
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, storage medium and computer program product. Background Art
[0002] With the development of computer technology and Internet technology, the stable diffusion model has emerged, and significant progress has been made in the field of image generation. Among them, the stable diffusion model is a large generative model in the field of computer vision, which can be used in a variety of scenarios such as text-generated images and image-generated images. Among them, fine-tuning specific concepts (such as a user's avatar or a pet dog) into the generative model and providing a customized generator is an application scenario that has received widespread attention.
[0003] However, the current image generation method mainly uses image data with text descriptions to train the generation model. For example, the text description information during fine-tuning is: "a spotted dog with a black circle around its eye", but the dog's eyes do not have black circles when applied to generation. This is because it is difficult to accurately maintain the identity feature information of the object in the image that is mainly marked by appearance features in the traditional image generation method. Therefore, the predicted image output by this generation model may have object distortion, image mismatch, etc., which may lead to very inaccurate generated objects. Therefore, how to effectively improve the accuracy of the generated image to avoid information mismatch has become a problem that needs to be solved urgently. Summary of the invention
[0004] Based on this, it is necessary to provide an image generation method, apparatus, computer device, computer-readable storage medium and computer program product to address the above-mentioned technical problems, which can effectively improve the accuracy of generated images and also effectively reduce the occurrence of identity information mismatch of objects in generated images.
[0005] In a first aspect, the present application provides an image generation method. The method comprises: in response to an image generation request, obtaining image description information; based on the object identifier of the target object carried in the image description information, searching for the attribute information and identity feature information of the target object from a database; adjusting the identity feature information based on the attribute information to obtain target identity feature information; and generating a target image based on the image description information and the target identity feature information.
[0006] In a second aspect, the present application also provides an image generation device. The device includes: an acquisition module, which is used to obtain image description information in response to an image generation request; a search module, which is used to search for attribute information and identity feature information of the target object from a database based on the object identifier of the target object carried in the image description information; an adjustment module, which is used to adjust the identity feature information based on the attribute information to obtain target identity feature information; and a generation module, which is used to generate a target image based on the image description information and the target identity feature information.
[0007] 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 processor executes the computer program, the steps of the method in each embodiment of the present application are implemented.
[0008] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the steps of the method in each embodiment of the present application are implemented.
[0009] In a fifth aspect, the present application further provides a computer program product, which includes a computer program, and when the computer program is executed by a processor, the steps of the method in each embodiment of the present application are implemented.
[0010] The above-mentioned image generation method, device, computer equipment, storage medium and computer program product obtain image description information by responding to an image generation request; search for attribute information and identity feature information of the target object from a database based on the object identification of the target object carried in the image description information; adjust the identity feature information based on the attribute information to obtain the target identity feature information, and generate a target image based on the image description information and the target identity feature information. Since the attribute information and identity feature information of each target object to be fine-tuned are pre-recorded in the database, the terminal can directly search for the attribute information and identity feature information of the target object from the database based on the object identification of the target object carried in the image description information, and adjust the identity feature information based on the attribute information, so that more accurate target identity feature information can be quickly obtained, and then the target image generated based on the image description information and the target identity feature information is also more accurate, achieving the technical effect of effectively improving the accuracy of the generated image while effectively reducing the occurrence of identity information mismatch of the object in the generated image. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] FIG1 is a diagram showing an application environment of an image generation method according to an embodiment;
[0012] FIG2 is a schematic diagram of a flow chart of an image generating method in one embodiment;
[0013] FIG3 is a schematic diagram of a display interface on a product side in one embodiment;
[0014] FIG4 is a schematic diagram of a process of an image generation model performing reasoning and generating a target image in one embodiment;
[0015] FIG5 is a schematic diagram of a process for training an image generation model in one embodiment;
[0016] FIG6 is a flow chart showing the steps of determining a control signal based on image description information including object identification and category attributes and an identity feature map in one embodiment;
[0017] FIG7 is a schematic diagram of a process of deploying a trained image generation model to a business to generate a target image in one embodiment;
[0018] FIG8 is a schematic diagram of a process of model training and application in one embodiment;
[0019] FIG9 is a structural block diagram of an image generating device in one embodiment;
[0020] FIG. 10 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0021] 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.
[0022] Cloud technology refers to a hosting technology that unifies hardware, software, network and other resources within a wide area network or local area network to achieve data computing, storage, processing and sharing.
[0023] Cloud technology is a general term for network technology, information technology, integration technology, management platform technology, application technology, etc. based on the cloud computing business model. It can form a resource pool, which is used on demand and flexible and convenient. Cloud computing technology will become an important support. The services of technical network systems require a large amount of computing and storage resources, such as video websites, picture websites and more portal websites. With the rapid development and application of the Internet industry, in the future, each item may have its own identification mark, which needs to be transmitted to the system for logical processing. Data of different levels will be processed separately. All kinds of industry data need strong system backing support, which can only be achieved through cloud computing.
[0024] Cloud storage is a new concept that extends and develops from the concept of cloud computing. A distributed cloud storage system (hereinafter referred to as storage system) refers to a storage system that uses cluster applications, grid technology, and distributed storage file systems to bring together a large number of different types of storage devices (storage devices are also called storage nodes) in the network through application software or application interfaces to work together and provide external data storage and business access functions.
[0025] 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. In other words, artificial intelligence is a comprehensive technology in computer science that attempts to understand the essence of intelligence and produce a new intelligent machine that can respond in a similar way to human intelligence. Artificial intelligence is to study the design principles and implementation methods of various intelligent machines so that machines have the functions of perception, reasoning and decision-making.
[0026] Artificial intelligence technology is a comprehensive discipline that covers a wide range of fields, including both hardware-level and software-level technologies. Basic artificial intelligence technologies generally include sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing technology, pre-trained model technology, operation / interaction systems, mechatronics, etc. Among them, pre-trained models are also called large models and basic models. After fine-tuning, they can be widely used in downstream tasks in various major directions of artificial intelligence. Artificial intelligence software technology mainly includes computer vision technology, speech processing technology, natural language processing technology, and machine learning / deep learning.
[0027] With the research and advancement of artificial intelligence technology, artificial intelligence technology has been studied and applied in many fields, such as common smart homes, smart wearable devices, virtual assistants, smart speakers, smart marketing, unmanned driving, automatic driving, drones, robots, smart medical care, smart customer service, Internet of Vehicles, automatic driving, smart transportation, etc. I believe that with the development of technology, artificial intelligence technology will be applied in more fields and play an increasingly important role.
[0028] Computer Vision (CV) is a science that studies how to make machines "see". To put it more specifically, it refers to using cameras and computers to replace human eyes to identify and measure targets, and further perform image processing to make computer processing into images that are more suitable for human eye observation or transmission to instruments for detection. As a scientific discipline, computer vision studies related theories and technologies, and attempts to establish an artificial intelligence system that can obtain information from images or multidimensional data. Large model technology has brought important changes to the development of computer vision technology. Pre-trained models in the visual field such as swin-transformer, ViT, V-MOE, and MAE can be quickly and widely applied to downstream specific tasks after fine tuning. Computer vision technology usually includes image processing, image recognition, image semantic understanding, image retrieval, OCR, video processing, video semantic understanding, video content / behavior recognition, three-dimensional object reconstruction, 3D technology, virtual reality, augmented reality, simultaneous positioning and map construction, and other technologies, as well as common biometric recognition technologies such as face recognition and fingerprint recognition.
[0029] Pre-training model, also known as cornerstone model or big model, refers to a deep neural network (DNN) with large parameters. It is trained on massive unlabeled data, and uses the function approximation ability of large-parameter DNN to enable PTM to extract common features from the data. After fine tuning, parameter efficient fine tuning (PEFT), prompt-tuning and other technologies, it is suitable for downstream tasks. Therefore, the pre-training model can achieve ideal results in few-shot or zero-shot scenarios. PTM can be divided into language models (ELMO, BERT, GPT), visual models (swin-transformer, ViT, V-MOE), speech models (VALL-E), multimodal models (ViBERT, CLIP, Flamingo, Gato), etc. according to the data modality processed. Among them, the multimodal model refers to a model that establishes two or more data modality feature representations. The pre-training model is an important tool for outputting artificial intelligence generated content (AIGC), and can also be used as a general interface to connect multiple specific task models.
[0030] Model parallel computing: refers to assigning the model's computing tasks to multiple computing devices (such as CPU, GPU, TPU, etc.) to perform computing simultaneously, thereby accelerating the training and reasoning of the model. Model parallel computing can effectively utilize computing resources and improve the computing efficiency and training speed of the model.
[0031] It should be noted that in the following description, the terms "first, second and third" involved are merely used to distinguish similar objects and do not represent a specific ordering of the objects. It can be understood that "first, second and third" can be interchanged in a specific order or sequence where permitted, so that the embodiments of the present application described here can be implemented in an order other than that illustrated or described here.
[0032] The image generation method provided in the embodiment of the present application can be applied to the application environment shown in Figure 1. 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 set up separately, can be integrated on the server 104, or can be placed on the cloud or other network servers. That is, the terminal 102 can interact with the image generation platform, that is, the server 104. The terminal 102 responds to the image generation request triggered by different objects, obtains the image description information, and based on the object identification of the target object carried in the image description information, searches for the attribute information and identity feature information of the target object from the local database or from the server 104; further, the terminal 102 can adjust the identity feature information based on the found attribute information to obtain the target identity feature information, and generate the target image based on the image description information and the target identity feature information.
[0033] The terminal 102 may be a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart speaker, a smart TV, a smart watch, an IoT device, and a portable wearable device. The IoT device may be a smart vehicle device, etc. The portable wearable device may be a smart watch, a smart bracelet, a head-mounted device, etc.
[0034] The server 104 may be an independent physical server or a service node in a blockchain system. A peer-to-peer network is formed between the service nodes in the blockchain system. The peer-to-peer protocol is an application layer protocol running on the transmission control protocol (TCP).
[0035] In addition, server 104 can also be a server cluster composed of multiple physical servers, and can be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDN, Content Delivery NetworkCDN), as well as big data and artificial intelligence platforms.
[0036] The terminal 102 and the server 104 may be connected via Bluetooth, USB (Universal Serial Bus) or a network or other communication connection method, and this application does not impose any limitation thereto.
[0037] In one embodiment, as shown in FIG2 , an image generation method is provided. The method may be executed by a server or a terminal alone, or may be executed by the server and the terminal together. The method is described by taking the terminal in FIG1 as an example, and includes the following steps:
[0038] Step 202: In response to the image generation request, obtain image description information.
[0039] Among them, the image generation request refers to a request for generating a specific image triggered by different objects. The image generation request in the present application may carry image description information and an original image. For example, object A triggers an image generation request A for generating a specific image of "a cat with a black circle around its eye (including the cat's name)". The image generation request A may carry the image description information "a cat with a black circle around its eye (including the cat's name)" and an original image (the original image may include a cat without a black circle around its eye).
[0040] Image description information refers to information used to describe the features of an object contained in an image to be generated (i.e., a target image). For example, the image description information in this application may be a piece of image description text input in text form. It is understood that the image description information in this application includes but is not limited to image description information in text form, and may also be in other forms, which are not specifically limited here.
[0041] Specifically, the image generation method provided by the present application can be widely applied to various personalized creation fields such as social networking, games, and film and television drama production scenarios. For example, the following is an example description of a specific application scenario:
[0042] 1. Image generation: Given a descriptive text, the image generation method provided in this application can generate an image that is consistent with the text content contained in the text, which has a wide range of applications in the fields of artistic creation, entertainment, advertising design, and film and television production scenes.
[0043] 2. Image editing: Given a descriptive text and an image, the image generation method provided by this application can edit the image according to the text content contained in the text. For example, a user (i.e., different objects) can change the color, shape, or position of an object contained in a specific image by inputting descriptive text.
[0044] 3. Smart Album: It can automatically generate description text for photos entered by users (i.e. different objects), or generate corresponding photos based on the description text entered by users.
[0045] 4. Game development: Developers can generate specific game scenes or characters through descriptive text, or generate corresponding text descriptions by designing game scenes or characters.
[0046] That is, the devices used by different users (operating objects) can interact with the multimedia information platform (or application). When the user (operating object) wants to generate an image containing a specific object, the user can open the multimedia application (Application, APP) on the terminal through a trigger operation, and enter the main page of the multimedia application through a selection operation, that is, the user can log in to the multimedia application (such as an image editing application) through a trigger operation. Further, the user can initiate an image generation request through a trigger operation in the main page displayed by the multimedia application. For example, in the main page of a game application displayed by the terminal, each object using the game application (such as a developer) can view the specific content and related functional information in the main page of the game, and each object using the game application can also trigger an image generation request for a specific type. The terminal responds to the image generation request triggered by the object using the game application in the main page of the game application, and obtains the image description information. When the terminal obtains the image description information input in real time by the object using the game application in the main page of the game application, the terminal can display the specific content corresponding to the image description information in the page.
[0047] For example, let's take the scenario of image generation in game development as an example. Assume that the multimedia application is a game application. As shown in Figure 3, it is a schematic diagram of the display interface of the image generation method provided by this application on the product side. That is, when user A (operating object) wants to generate an image containing a specific object (such as a cat named Xiaobai), user A can open game application A on the terminal through a trigger operation, and enter the main page of game application A as shown in Figure 3 through a selection operation, that is, user A can log in to game application A through a trigger operation. Further, user A can initiate an image generation request through a trigger operation in the main page of game application A as shown in Figure 3. For example, in the main page of the game application shown in Figure 3 displayed on the terminal, user A (such as a developer) can view the specific content and related functional information in the game main page. User A can click the "Generate Input" icon in the main page of the game application as shown in Figure 3 to make the terminal respond to the above-mentioned click operation of user A and display an input box or input page. After user A completes the input operation, user A can further trigger a specific type of image generation request by clicking the "Generate Start" icon in the main page of the game application as shown in Figure 3. The terminal responds to the "Generate Start" operation triggered by user A in the main page of the game application (i.e., the image generation request) to obtain the image description text A (i.e., image description information) input by user A. When the terminal obtains the image description text A input by user A in real time on the main page of the game application, the terminal can display the specific text content of the image description text A on the page.
[0048] Step 204: Based on the object identifier of the target object carried in the image description information, the attribute information and identity feature information of the target object are searched from the database.
[0049] The target object refers to a specific object contained in the image description information. For example, assuming that the image description information input by the user is: "My husky Xiaobai (object name) has a black circle on one eye", the target object is: My husky Xiaobai (object name).
[0050] The object identifier of the target object refers to an identifier used to uniquely identify the target object. The object identifier in this application can be an object name. For example, the object name corresponding to the target object "My Husky Xiaobai" can be set to: "a [V] dog", that is, a unique identifier "a [V] dog" is set in advance for the object name (embedded concept) of the target object.
[0051] Attribute information refers to the category attribute information to which the target object belongs, that is, the attribute information in this application may include category attributes (information), for example, the category attribute to which the target object "my husky Xiaobai" belongs is: dog.
[0052] Identity feature information refers to the identity feature information of a specific object (target object). The identity feature information in this application may include an identity feature map. For example, in the technical solution provided in this application, the identity feature map of the target object can be used as the identity feature information, or feature information can be first extracted from the identity feature map and then the extracted feature information can be used as the identity feature information.
[0053] Specifically, when the terminal responds to the image generation request and obtains the image description information, the terminal can search the target object's attribute information and identity feature information from the database based on the object identifier of the target object carried in the image description information. For example, the terminal can first search the training data to see whether the object identifier (object name) is included in the training data based on the object identifier (object name) of the target object carried in the image description information. After determining that the training data contains the object identifier (object name), the terminal then searches the database for the object attribute information and identity feature information corresponding to the object identifier (object name). Among them, the database in the embodiment of the present application will record the object name, attribute and identity feature information of the fine-tuned object each time the model is trained, i.e., the ID (identity) map.
[0054] It can be understood that the database in this application will record the object name, attributes and identity feature information of each fine-tuning, namely, the ID (identity) map, that is, the terminal can respond to the training start operation triggered by the user in the model training page as shown in Figure 3, and input multiple training samples of the target object to be fine-tuned into the initial model for training to obtain the trained image generation model. Furthermore, after the terminal obtains the trained image generation model, the terminal can save the object identification, category attributes and identity feature map corresponding to the target object to be fine-tuned during this training into the database.
[0055] For example, let's take the scenario of image generation in game development as an example. Suppose the multimedia application is a game application. When user A (operating object) wants to generate an image containing a specific object (such as a cat named Xiaobai), user A can open the game application A on the terminal through a trigger operation, and enter the main page of the game application A as shown in Figure 3 through a selection operation. The terminal responds to the "Generate Start" operation triggered by user A in the main page of the game application (that is, the image generation request), and obtains the image description text A (that is, the image description information) input by user A. Assuming that the specific text content contained in the image description text A is: "The husky Xiaobai (object name) in the first frame of the game screen has an eye with a black circle", the terminal can Based on the object identifier "Xiaobai (object name)" of the target object (the Husky Xiaobai in the first frame of the game screen) contained in the image description text A, first search the training data to see whether the object identifier (object name), i.e., "Xiaobai", is included to determine whether the attribute information and identity feature information corresponding to the object, i.e., "Xiaobai", have been stored in the database; further, after the terminal finds the object identifier "Xiaobai" contained in the training data, the terminal can further find the attribute information corresponding to the object identifier (object name), i.e., "Xiaobai", from the database as: dog, and the identity feature information as: an ID picture containing Xiaobai's appearance features.
[0056] Step 206: adjust the identity feature information based on the attribute information to obtain the target identity feature information.
[0057] Among them, the target identity feature information refers to the more accurate identity feature information of the target object obtained after adjusting the identity feature information found in the database. For example, assuming that the terminal finds the attribute information of the target object "Husky Xiaobai" from the database based on the object name corresponding to the target object: dog, and the identity feature information is: an ID image (ref-image) of the target object, assuming that the ID image is an image containing a full-body image of "Husky Xiaobai", and the ID image is a picture used to uniquely determine the target object, then the terminal can adjust the identity feature information, i.e., the image containing the full-body image of "Husky Xiaobai", based on the attribute information of the target object: dog, and obtain more accurate identity feature information of the target object: the enlarged feature extracted from the image containing the full-body image of "Husky Xiaobai" is: one eye of "Husky Xiaobai" has a black circle, and the enlarged feature "one eye of "Husky Xiaobai" has a black circle" is the final more accurate identity feature information of the target object, which can be used as the target identity feature information.
[0058] Step 208: Generate a target image based on the image description information and the target identity feature information.
[0059] The target image refers to an image that meets the image description information. For example, assuming that the image description information input by the user is: "One of the eyes of my husky Xiaobai has a black circle", the target image finally generated contains a husky Xiaobai (object name), and one of the eyes of the husky Xiaobai (target object) has a black circle.
[0060] Specifically, after the terminal finds the attribute information and identity feature information of the target object from the database based on the object identifier of the target object carried in the image description information, the terminal can adjust the identity feature information based on the attribute information to obtain the target identity feature information. For example, the terminal can perform inner product processing on the found attribute information and identity feature information to obtain the identity feature information after the inner product processing, and use the identity feature information after the inner product processing as the target identity feature information; further, the terminal can perform image generation processing on the image description information and the target identity feature information through an image generation model to obtain the target image. It can be understood that the method of obtaining the target identity feature information in this application includes but is not limited to the above method, and the attribute information and identity feature information can also be processed (such as splicing processing) through an image generation model to obtain the target identity feature information.
[0061] For example, let's take the scenario of image generation in game development as an example. Assume that the multimedia application is a game application. When user A (operating object) wants to generate an image containing a specific object (such as a dog named Xiaobai), user A can open the game application A on the terminal through a trigger operation, and enter the main page of the game application A as shown in Figure 3 through a selection operation. The terminal responds to the "Generate Start" operation triggered by user A in the main page of the game application (i.e., image generation request), and obtains the image description text A (i.e., image description information) input by user A. The terminal searches the database for the object identifier "Xiaobai (object name)" of the target object (i.e., Husky Xiaobai) contained in the image description text A (one of the eyes of Husky Xiaobai in the first frame of the game screen has a black circle) based on the object identifier "Xiaobai (object name)". (object name), that is, the attribute information corresponding to "Xiaobai" is: dog, and the identity feature information is: an ID picture containing Xiaobai's appearance features. After that, the terminal can obtain the template image (also called the image to be adjusted) based on the image description information, and call the pre-trained image generation model to perform inner product processing on the attribute information (dog) and the identity feature information (ID picture) to obtain the target identity feature information S; further, the terminal can continue to perform image generation processing on the template image, image description information and target identity feature information S through the image generation model to obtain the target image, that is, the obtained target image contains: a Husky Xiaobai (object name), and one of the eyes of the Husky Xiaobai (target object) has a black circle.
[0062] In this embodiment, the image description information is obtained by responding to the image generation request; based on the object identification of the target object carried in the image description information, the attribute information and identity feature information of the target object are searched from the database; the identity feature information is adjusted based on the attribute information to obtain the target identity feature information, and the target image is generated based on the image description information and the target identity feature information. Since the attribute information and identity feature information of each target object to be fine-tuned are pre-recorded in the database, the terminal can directly search the attribute information and identity feature information of the target object from the database based on the object identification of the target object carried in the image description information, and adjust the identity feature information based on the attribute information, so that more accurate target identity feature information can be quickly obtained, and then the target image generated based on the image description information and the target identity feature information is also more accurate, achieving the technical effect of effectively improving the accuracy of the generated image while effectively reducing the occurrence of identity information mismatch of the object in the generated image.
[0063] In one embodiment, the method further comprises:
[0064] Obtaining an original image corresponding to the image description information;
[0065] The generating a target image based on the image description information and the target identity feature information includes:
[0066] The original image is adjusted based on the image description information and the target identity feature information to obtain a target image that meets the image description information.
[0067] The original image refers to the image to be adjusted. For example, assuming that the image description information input by the user is: "One of the eyes of my husky Xiaobai has a black circle", the original image input by the user contains: a husky Xiaobai (object name), but the eyes of the husky Xiaobai (target object) do not have black circles.
[0068] Specifically, the scenario of image generation in game development is taken as an example for explanation. Assume that the multimedia application is a game application. When user A (operating object) wants to generate an image containing a specific object, user A can open the game application A on the terminal through a trigger operation, and enter the main page of the game application A as shown in Figure 3 through a selection operation. The terminal responds to the "Generate Start" operation (i.e., image generation request) triggered by user A in the main page of the game application, and obtains the image description text A (i.e., image description information) input by user A. The terminal can further obtain the original image S corresponding to the image description text A input by user A; the terminal is based on the object identifier "Xiaobai (object name)" of the target object (i.e., Husky Xiaobai) contained in the image description text A (one of the eyes of Husky Xiaobai in the first frame of the game screen has a black circle), and obtains the original image S from the data After finding the attribute information corresponding to the object identifier (object name), i.e., "Xiaobai", in the database as: dog, and the identity feature information as: an ID image containing Xiaobai's appearance features, the terminal can input the above-obtained attribute information, identity feature information, and image description information, i.e., image description text A, as input parameters into a pre-trained image generation model, so that the image generation model performs inner product processing on the attribute information and identity feature information to obtain target identity feature information, and adjusts the original image S based on the image description text A and the target identity feature information, and finally obtains a target image that conforms to the image description text A, i.e., the obtained target image contains: a husky Xiaobai (object name), and one of the eyes of the husky Xiaobai (target object) has a black circle. As a result, by adjusting the identity feature information using the attribute information of the object, more accurate target identity feature information of the object can be obtained quickly and accurately, and then the target image generated based on the image description information and the target identity feature information is also more accurate, achieving the technical effect of effectively improving the accuracy of the generated image while effectively reducing the occurrence of identity information mismatch of the object in the generated image.
[0069] In one embodiment, the step of adjusting the identity feature information based on the attribute information to obtain the target identity feature information includes:
[0070] Perform inner product processing on the attribute information and the identity feature information to obtain the identity feature information after the inner product processing, and use the identity feature information after the inner product processing as the target identity feature information;
[0071] The generating a target image based on the image description information and the target identity feature information includes:
[0072] The image generation model is used to perform image generation processing on the image description information and the target identity feature information to obtain the target image.
[0073] Specifically, the scenario of image generation in game development is taken as an example for explanation. Assume that the multimedia application is a game application. As shown in Figure 4, it is a flow chart of the image generation model inference and generation of the target image. When user A (operating object) wants to generate an image containing a specific object, the terminal responds to the "Generate Start" operation (i.e., image generation request) triggered by user A in the main page of the game application, and obtains the image description text A (i.e., image description information) input by user A. The terminal can further obtain the original image S corresponding to the image description text A from the database; based on the object identifier "Xiaobai (object name)" of the target object (i.e., Husky Xiaobai) contained in the image description text A (one of the eyes of Husky Xiaobai in the first frame of the game screen has a black circle), the terminal finds the attribute information corresponding to the object identifier (object name), i.e., "Xiaobai" from the database: dog, and the identity feature information is: an ID picture containing Xiaobai's appearance features. After that, the terminal can obtain the above-mentioned attribute information, identity information, and identity information from the database. The image description information and the image description text A are input as input parameters into the pre-trained image generation model shown in FIG4, so that the image generation model first extracts the features of the attribute information and the identity feature information, and then performs inner product processing on the attribute information (feature 1) and the identity feature information (feature 2) to obtain the target identity feature information (feature 3); further, the terminal can extract the text feature (feature 4) of the image description information, i.e., the image description text A, through the image generation model, and concatenate the text feature (feature 4) and the target identity feature information (feature 3) ("C" operation), so as to obtain the control signal L (also referred to as control information) after the "C" operation as shown in FIG4, and process the original image S based on the control signal L, and output the predicted image, i.e., the target image. Thus, by adjusting the identity feature information using the attribute information of the object, more accurate target identity feature information of the object can be obtained quickly and accurately, and then the target image generated based on the image description information and the target identity feature information is also more accurate, achieving the technical effect of effectively improving the accuracy of the generated image while effectively reducing the occurrence of identity information mismatch of the object in the generated image.
[0074] In one embodiment, the step of generating a target image based on the image description information and the target identity feature information by using an image generation model includes:
[0075] Based on the image description information, a template image is obtained;
[0076] Convert the template image from pixel space to latent space image;
[0077] Add noise to the latent space image to obtain a noisy image;
[0078] Based on the image description information and the target identity feature information, the noisy image is denoised to obtain the latent space target image;
[0079] Convert the latent space target image to a pixel space image and use the pixel space image as the target image.
[0080] Among them, the template image refers to the original image corresponding to the image description information. For example, the template image in this application can be an image historically input by the user, that is, the template image in this application can be a historical image and stored in the database.
[0081] Specifically, as shown in Figure 4, it is a flowchart of the image generation model inference and generation of the target image. When user A (operating object) wants to generate an image containing a specific object, the terminal responds to the "Generate Start" operation (i.e., image generation request) triggered by user A in the main page of the game application, and obtains the image description text A (i.e., image description information) input by user A. Based on the object identifier "Xiaobai (object name)" of the target object (i.e., Husky Xiaobai) contained in the image description text A (one of the eyes of Husky Xiaobai in the first frame of the game screen has a black circle), the terminal searches the database for the attribute information corresponding to the object identifier (object name), i.e., "Xiaobai": dog, and The identity feature information is: After an ID image containing Xiaobai's appearance features, the terminal can input the above-obtained attribute information, identity feature information and image description information, i.e., image description text A, as input parameters into the pre-trained image generation model as shown in FIG4, so that the image generation model obtains a template image based on the image description text A (one of the eyes of the husky Xiaobai in the first frame of the game screen has a black circle), and converts the template image from the pixel space to the latent space image Z; further, the image generation model can add noise to the latent space image Z, and obtain the noisy image Z as shown in FIG4 T , and based on the image description information, i.e., the image description text A and the target identity feature information, the noisy image Z T De-noising is performed to obtain a latent space target image D, and the latent space target image D is converted into a pixel space image Y, and finally the pixel space image Y is output as the target image i. Thus, the technical effect of effectively improving the accuracy of the generated image and effectively reducing the occurrence of identity information mismatch of the object in the generated image is achieved.
[0082] In one embodiment, the method further comprises:
[0083] In response to a model training request triggered in the main page, displaying a model training page;
[0084] In response to a parameter input operation triggered in a model training page, a plurality of training samples of a target object to be fine-tuned are obtained;
[0085] In response to a training start operation triggered in the model training page, a plurality of training samples of the target object to be fine-tuned are input into the initial model for training to obtain a trained image generation model.
[0086] Specifically, as shown in Figure 3, it is a schematic diagram of the display interface of the image generation method provided by the present application on the product side. That is, when user A (developer) wants to train the image generation model, user A can open application A on the terminal through a trigger operation, and enter the main page of application A as shown in Figure 3 through a selection operation. Furthermore, user A can initiate a model training request through a trigger operation in the main page of application A as shown in Figure 3. For example, in the main page of application A as shown in Figure 3 displayed on the terminal, user A (developer) can view the specific content and related functional information in the main page, and user A can click the "training" icon in the main page of application A as shown in Figure 3, so that the terminal responds to the above-mentioned click operation of user A (i.e., model training request) and displays the model training page as shown on the right side of Figure 3.
[0087] Further, user A can click the "training input" icon in the model training page shown on the right side of FIG. 3 so that the terminal responds to the above parameter input operation triggered by user A in the model training page and obtains multiple training samples of the target object to be fine-tuned (such as Xiaobai); after user A completes the input operation of the training parameters, user A can further click the "start" icon (i.e., training start operation) in the model training page shown on the right side of FIG. 3 so that the terminal responds to the "start" operation (i.e., training start operation) triggered by user A in the model training page, inputs multiple training samples of the target object to be fine-tuned (such as Xiaobai) into the initial model for training, so as to obtain the trained image generation model, and displays the output information containing the training results in the model training page shown on the right side of FIG. 3. As a result, through the visual interface interactive operation, it is possible to quickly and efficiently fine-tune a specific concept (such as a user's avatar or a pet dog) into the generation model, provide a customized image generation model, simplify the tedious operation of model training, and effectively improve the accuracy of the generated image while effectively improving the efficiency of the training of the generated image model.
[0088] In one embodiment, each training sample includes at least a sample image of the target object to be fine-tuned, an identity feature map, and image description information including object identification and category attributes; after inputting multiple training samples of the target object to be fine-tuned into the initial model for training to obtain a trained image generation model, the method further includes:
[0089] The object identification, category attributes and identity feature map corresponding to the target object to be fine-tuned are saved in a database; wherein the attribute information includes the category attributes; and the identity feature information includes the identity feature map.
[0090] Specifically, after user A completes the input operation of training parameters in the model training page shown on the right side of FIG. 3, user A can further click the "start" icon (i.e., training start operation) in the model training page shown on the right side of FIG. 3, so that the terminal responds to the "start" operation (i.e., training start operation) triggered by user A in the model training page, and inputs multiple training samples of the target object to be fine-tuned (such as Xiaobai) into the initial model for training. After obtaining the trained image generation model, the terminal can save the object identification, category attributes, and identity feature map corresponding to the target object to be fine-tuned (Xiaobai) into the database, so that when the trained image generation model is subsequently called to generate the target image, the object identification, category attributes, and identity feature map corresponding to each fine-tuning target object (such as Xiaobai) can be quickly found from the database for processing. As a result, the technical effect of effectively improving the accuracy of the generated image and effectively reducing the occurrence of identity information mismatch of the object in the generated image is achieved.
[0091] In one embodiment, each training sample includes at least a sample image of the target object to be fine-tuned, an identity feature map, and image description information including object identification and category attributes; the step of inputting multiple training samples of the target object to be fine-tuned into the initial model for training to obtain the trained image generation model includes:
[0092] Converting sample images in a plurality of training samples of a target object to be fine-tuned into a latent space image;
[0093] determining a control signal based on the image description information and the identity feature map including the object identification and category attributes;
[0094] The latent space image and the control signal are input into the initial model for training to obtain a trained image generation model.
[0095] Specifically, as shown in FIG5 , it is a schematic diagram of the process of training the image generation model. That is, when the terminal inputs multiple training samples of the target object to be fine-tuned into the initial model for training, the terminal can convert the sample images in the multiple training samples of the target object to be fine-tuned into latent space images through the image encoder in the initial model, and determine the control signal based on the image description information and identity feature map containing the object identification and category attributes, and finally input the latent space image (noise-added) and the control signal into the Denoising U-Net (denoising network) in the initial model as shown in FIG5 for training, and the trained image generation model can be obtained. Therefore, through the interactive operation of the visual interface, it is possible to quickly and efficiently fine-tune specific concepts (such as a user's avatar or a pet dog) into the generation model, provide a customized image generation model, simplify the tedious operation of model training, and effectively improve the accuracy of the generated image while effectively improving the efficiency of the training of the generated image model.
[0096] In one embodiment, as shown in FIG6 , the step of determining the control signal based on the image description information including the object identification and the category attribute and the identity feature map includes:
[0097] Step 602, extracting the identity image representation of the identity feature map through an image encoder;
[0098] Step 604, extracting attribute information from the image description information including the object identifier and the category attribute through a text encoder;
[0099] Step 606, performing inner product processing on the identity image representation and the attribute information to obtain the identity image representation after the inner product processing, and using the identity image representation after the inner product processing as the target identity feature information;
[0100] Step 608, extracting description features from the image description information including the object identifier and the category attribute through a text encoder;
[0101] Step 610, concatenate the attribute information, target identity feature information and description features to obtain a control signal.
[0102] Specifically, as shown in FIG5 , it is a schematic diagram of the process of training the image generation model. That is, when the terminal inputs multiple training samples of the target object to be fine-tuned into the initial model for training, the terminal can extract the identity image representation of the identity feature map, that is, the ID map, through the image encoder in the initial model as shown in FIG5 , and extract the attribute information from the image description information containing the object identification and category attributes through the text encoder in the initial model; further, the terminal can perform inner product processing (point multiplication operation) on the identity image representation and the attribute information through the initial model as shown in FIG5 , obtain the identity image representation after the inner product processing, and use the identity image representation after the inner product processing as the target identity feature information; at the same time, the terminal can also extract the text description feature from the image description information containing the object identification and category attributes through the text encoder (Conditioning) in the initial model as shown in FIG5 , and splice the attribute information, the target identity feature information and the text description feature through the "C" operation as shown in FIG5 , so as to obtain the control signal. As a result, by splicing attribute information, more accurate target identity feature information and text description features, more accurate control information can be obtained quickly and accurately, and the target image generated based on the control information is also more accurate, achieving the technical effect of effectively improving the accuracy of the generated image while effectively reducing the occurrence of identity information mismatch of the object in the generated image.
[0103] In one embodiment, the step of inputting the latent space image and the control signal into the initial model for training to obtain the trained image generation model includes:
[0104] Add noise to the latent space image to obtain a noisy image;
[0105] The control signal and the noisy image are input into the initial model for noise detection to obtain the predicted noise, and the training is stopped until the loss value determined based on the predicted noise meets the preset loss condition to obtain the trained image generation model.
[0106] Specifically, as shown in FIG5 , it is a schematic diagram of the process of training the image generation model. That is, when the terminal inputs multiple training samples of the target object to be fine-tuned into the initial model for training, the terminal converts the sample images in the multiple training samples of the target object to be fine-tuned into the latent space image Z through the image encoder in the initial model, and after determining the control signal based on the image description information including the object identification and category attributes and the identity feature map, the terminal can add noise to the latent space image Z through the initial model to obtain the noisy image Z T , and the control signal and the noise image Z TNoise detection is performed on the input initial model, and the predicted noise can be output. The training is stopped when the loss value determined based on the predicted noise and the minimized true value noise meets the preset loss condition, and the trained image generation model can be obtained. As a result, by splicing the attribute information, more accurate target identity feature information and text description features, more accurate control information can be obtained quickly and accurately, and the target image generated based on the control information is also more accurate, achieving the technical effect of effectively improving the accuracy of the generated image while effectively reducing the occurrence of identity information mismatch of the object in the generated image.
[0107] In one embodiment, the image generation request includes a game screen generation request; the target object includes a target game character;
[0108] In response to the image generation request, the step of obtaining image description information includes:
[0109] In the process of interacting with the game application, in response to a game screen generation request triggered in the main page of the game application, obtaining image description information corresponding to the game screen generation request;
[0110] The step of searching the database for the attribute information and identity feature information of the target object based on the object identifier of the target object carried in the image description information includes:
[0111] In response to an image generation operation triggered in the main page of the game application, based on the object identifier of the target game character carried in the image description information, the attribute information and identity feature information of the target game character are searched from the database.
[0112] Specifically, the scene of image generation in game development is used as an example for explanation. As shown in FIG3 , it is a schematic diagram of the display interface of the image generation method provided by the present application on the product side. That is, when user A (developer) wants to generate a game image containing a specific object (such as a cat named Xiaobai), user A can open game application A on the terminal through a trigger operation, and enter the main page of game application A as shown in Figure 3 through a selection operation. Further, in the process of user A interacting with the game application, user A can initiate a game screen generation request by clicking the "Generate Input" icon in the main page shown in Figure 3 displayed by game application A, and the terminal responds to the game screen generation request triggered by user A in the main page of game application A, and obtains the image description information input by user A corresponding to the game screen generation request; further, user A can trigger the image generation operation in the main page shown in Figure 3 displayed by game application A, for example, user A can click the "Generate Start" icon to make the terminal respond to the above-mentioned image generation operation triggered by user A in the main page of game application A, execute a series of steps based on the object identification of the target game character carried in the image description information, and search the attribute information and identity feature information of the target game character from the database, and finally generate a target image containing the target game character. Therefore, by using the object's attribute information to adjust the identity feature information, more accurate target identity feature information of the object can be obtained quickly and accurately, and then the target image generated based on the image description information and the target identity feature information is also more accurate, achieving the technical effect of effectively improving the accuracy of the generated image while effectively reducing the occurrence of identity information mismatch of the object in the generated image.
[0113] In one embodiment, the step of adjusting the identity feature information based on the attribute information to obtain the target identity feature information includes:
[0114] Performing inner product processing on the attribute information and the identity feature information through an image generation model to obtain the target identity feature information;
[0115] The generating a target image based on the image description information and the target identity feature information includes:
[0116] Based on the image description information, obtaining a template image;
[0117] The template image, the image description information and the target identity feature information are processed by an image generation model to obtain a target image.
[0118] Specifically, as shown in FIG7 , it is a flow chart of deploying the trained image generation model to generate the target image in the business. As shown in FIG7 , the terminal responds to the image generation request, obtains the image description information, i.e., the text description (carrying the object name), and finds the attribute information (i.e., attribute category) and identity feature information (i.e., ID map) of the target object from the database based on the object name of the target object carried in the text description (carrying the object name). The terminal can perform reasoning by calling the model shown in FIG7 , and return the reasoning result to the front-end page for display, i.e., the terminal can obtain the target identity feature information by calling the trained image generation model, and perform inner product processing on the attribute information and identity feature information through the image generation model; further, the terminal can obtain the template image based on the image description information, and perform image generation processing on the template image, image description information and target identity feature information through the image generation model, so as to obtain the target image. That is, the user inputs a description sentence with the object name, and the terminal calls the service to find the attributes and ID map of the object according to the object word in the description sentence, and inputs the found attributes, ID map and description sentence into the trained model for reasoning to generate the result image. As a result, by adjusting the identity feature information using the object's attribute information, more accurate target identity feature information of the object can be obtained quickly and accurately, and the target image generated based on the image description information and the target identity feature information is also more accurate, achieving the technical effect of effectively improving the accuracy of the generated image while effectively reducing the occurrence of identity information mismatch of the object in the generated image.
[0119] The present application also provides an application scenario, and the application scenario applies the above-mentioned image generation method. Specifically, the application of the image generation method in the application scenario is as follows:
[0120] In the process of user interaction with multimedia information (or image editing) platform, the above-mentioned image generation method can be used. When the user (operation object) wants to generate an image containing a specific object, the user can open the multimedia application on the terminal through a trigger operation, and enter the main page of the multimedia application through a selection operation, that is, the user can log in to the multimedia application (such as image editing application) through a trigger operation. Further, the user can initiate an image generation request through a trigger operation in the main page displayed by the multimedia application, and the terminal responds to the image generation request triggered by the user, obtains the image description information, and based on the object identification of the target object carried in the image description information, searches for the attribute information and identity feature information of the target object from the database; further, the terminal can adjust the identity feature information based on the attribute information to obtain the target identity feature information, and generate the target image based on the image description information and the target identity feature information. As a result, when different users interact with the multimedia information platform, the image generation method provided in this application guides the model to learn the consistency information of each training object by forming the consistency control information with the object ID and the object attribute (concept category), and recording the consistency control information with a specific model structure. At the same time, by constraining identity feature information through object attributes, more accurate identity feature information of the object can be generated, which can effectively improve the accuracy of the generated image. It can also effectively reduce the occurrence of identity information mismatch of objects in the generated image, and also support consistent information learning of objects in multiple environments.
[0121] The method provided in the embodiment of the present application can be applied to various image generation scenarios. The following takes the scenario of user interaction with a multimedia information platform as an example to illustrate the image generation method provided in the embodiment of the present application.
[0122] Among them, the diffusion model text graph: a generative model based on the diffusion process, inputs the target text text, the model performs a series of operations on a random noise graph x, and generates a predicted image Y related to the text under the cross-attention of the target text.
[0123] Training instance: A single image for training. The main object in the image is the target. The purpose of diffusion model training is to train the main object in the image into the model.
[0124] Concept category: The category to which the training sample belongs. For example, if the training sample is “Husky”, one of its concept categories is “dog”.
[0125] Generation consistency: For generative models, consistency means that for a certain instance, after being processed by the model (such as training the instance), when the model generates an image of the instance, the target in the resulting image remains consistent with the performance of the instance (such as the generated husky has the same appearance features as the trained husky).
[0126] Training object: refers to the target to be fine-tuned in the training instance (e.g., the image-text pair for the SD or stable diffusion model), such as a picture and "a girl", then the training object is the girl in the image.
[0127] Object ID: refers to the identity of a specific object. ID stands for identity, which refers to the identity information of an object with its appearance as the main feature. For example, my Husky is a specific object, and its ID can distinguish it from any other dog in the world.
[0128] With the emergence of stable diffusion, the field of image generation has made significant progress. Fine-tuning specific concepts (such as a user's avatar or a pet dog) into the generative model and providing a customized generator is a widely used application scenario. However, the traditional model of using image data with text descriptions to train the generative model is naturally not conducive to maintaining the object ID information in the image. For example, when fine-tuning, it is a spotted dog with a black circle on one eye, while when generating the dog, the dog's eye does not have a black circle.
[0129] Solution 1 in traditional technology: Dreambooth. The input of Dreambooth is several training object images provided by the user, the corresponding object description, and multiple regularized images of the object category. Dreambooth is fine-tuned on the stable-diffusion open source model. The fine-tuning process is as follows: First, the terminal sets a unique identifier for the embedded concept, such as [V]. The text description of the concept contains the identifier, such as: "a [V] dog" for the training image of a dog. During the training process, Dreambooth uses a priori protection loss to alleviate the overfitting problem, that is, it optimizes the generation loss of training samples and regularized images at the same time.
[0130] Solution 2 in traditional technology: Textual Inversion training process.
[0131] First, define a keyword that has not appeared in the existing model. This new keyword will be encoded by the terminal through the generated compiler, i.e. Tokenizer (with different numerical representations), just like other keywords. Then, the terminal converts it into an embedding vector. That is, the terminal will find the best embedding vector representation for the new keyword through the text converter. This does not require modifying the model, and can be regarded as finding a new representation inside the model to express this new keyword.
[0132] Problems with traditional technical solutions:
[0133] 1) Consistency cannot be guaranteed: Consistency cannot be guaranteed after training, and object distortion and image mismatch may occur;
[0134] 2) Inaccurate generation: For example, after fine-tuning an object image with a background, the resulting image is likely to also carry the background, resulting in a very inaccurate generated object.
[0135] The technical solution provided in this application can solve these problems at the same time through the design of an innovative complete process:
[0136] 1) This application proposes consistency information consisting of object ID and object attributes (concept categories), and uses a specific model structure to record this information, guiding the model to learn the consistency information of each training object.
[0137] 2) Generate more accurate object ID information by constraining identity feature information through object attributes to avoid information mismatch; at the same time, support consistent information learning of objects in multiple environments.
[0138] That is, the solution provided in the embodiment of the present application aims to solve the problem of inconsistent concepts when fine-tuning the generation model. It proposes a generation model training method that uses object adaptive enhanced control combined with ID control information. In the conventional generation model, consistency information of ID attributes and ID features is designed to control the generation process. At the same time, the conventional image-text training mode is abandoned during training, and training is carried out in the form of object ID sample set data, so as to fine-tune new concepts under the open source SD architecture and maintain the consistency of ID generated by the new concepts.
[0139] The key technologies in the technical solution of this application are as follows:
[0140] 1) Innovatively propose consistency information with ID attributes and ID features as the main content and add it to the traditional SD model structure;
[0141] 2) A model training method that maintains object ID consistency by embedding the object's attributes and features into the model so that it can record the object's consistency information, and by controlling multiple conditions for consistency generation through data processes during training to achieve consistency generation;
[0142] 3) Generate more accurate object ID information by constraining the target object ID through object attributes to avoid information mismatch; at the same time, support consistent information learning of objects in multiple environments.
[0143] On the product side, the technical solution provided by this application, which has the object consistency of cultural image creation, can be widely used in various personalized creation fields such as social, game, film and television production scenes, etc. The following is a description of the specific application scenarios on the product side:
[0144] 1. Image generation: Given a descriptive text, the model can generate an image that is consistent with the text content, which has a wide range of applications in art creation, entertainment, advertising design, and film and television production scenes.
[0145] 2. Image Editing: Given a descriptive text and an image, the model can edit the image based on the text content. For example, users can change the color, shape, or position of an object in the image through descriptive text.
[0146] 3. Smart Album: It can automatically generate descriptions for users’ photos, or generate corresponding photos based on users’ descriptions.
[0147] 4. Game development: Developers can generate game scenes or characters through descriptive text, or generate corresponding text by designing game scenes or characters.
[0148] As shown in FIG3 , the product style of the technical solution provided by the present application can be as shown in FIG3 . The left side of FIG3 is the main interface, including the generation interface and the training trigger button. Input the generation text and click the generation start button to generate the output image. Click the training button to trigger the training interface on the right, input the corresponding information, click the start button, and generate the training output information (including whether the training is successful, etc.).
[0149] On the technical side, as shown in Figure 5, it is a block diagram of the fine-tuning training process. The concept category of the object generates attribute information, the ref-image of the object generates ID initial information, and the ID initial information and attribute information are cross-linked to obtain accurate ID information; the attribute information and ID information are spliced with the description text content generated in the native SD to generate a new control signal to control the transformer generation in the U-Net. The attribute information and ID information control the consistency of the generated objects.
[0150] As shown in Figure 4, it is an inference generation flowchart of the image generation method provided in the present application. During inference, the terminal treats the generated text as text, searches the training data for the object name contained therein, searches the database (recording the object name, attributes, and ID map for each fine-tuning) to obtain the object attributes and ID map, and then the terminal generates an output image by reasoning according to the process shown in Figure 4.
[0151] 1.1 Principle Overview
[0152] The model is based on the processing flow shown in Figure 5. The category of the object generates attribute information, the ref-image of the object generates ID initial information, and the ID initial information and attribute information are cross-linked to obtain accurate ID information; the attribute information and ID information are spliced with the description text content generated in the native SD to generate a new control signal to control the transformer in the U-Net. The attribute information and ID information control the consistency of the generated object.
[0153] As shown in Figure 5, during training, the input is organized by object, and there is more than one training sample for each object. Each sample contains: a single sample image, image description text, concept category, and ref-image. The object to be trained is bound to a unique identifier (such as the [V] in a [V] dog in the traditional method dreambooth, that is, in the text shown in Figure 5, there is a [V] mark, and this mark needs to be fine-tuned during fine-tuning). The object consistency of the technical solution provided in this application is achieved by splicing consistent control information. The consistency information (provided by category and object image) is spliced with the text generation control information through the C operation (concat) as the control information of the cross attention of U-net. The fine-tuning parameters are the crossattention of U-Net (using LoRA module) and the unique identifier in the text embedding.
[0154] In the reasoning process, the unique identifier and the trained LoRA module are used in combination with other text concept expressions to generate diverse images, as shown in Figure 4.
[0155] 1.2 Data Input
[0156] For each object to be fine-tuned, there is object training data. The object training data contains multiple samples, each of which contains the following items:
[0157] 1. Image: Provide a sample image of the object to be embedded, such as the training image in Figure 5;
[0158] 2. Text of the image: The user specifies a unique identifier tied to the object and enters the concept category;
[0159] 3. Object attributes: Here, it refers to category attributes, such as text words such as dog and person;
[0160] 4. Object ID image (ref-image): This refers to an image that can uniquely identify the object, such as a headshot of a human, a full-body image of a dog, etc. The ref-image can come from any image with the object in the object training sample, or it can be an object image specified by the user.
[0161] 1.3 Model Generation and Fine-tuning
[0162] The principle of the stable-diffusion generative model is as follows: First, the initial image is compressed by the image encoder VAE and converted from pixel space to latent space to capture the essential information of the image. A diffusion process is applied to the image in the latent space, that is, noise is added. Then, the CLIP text encoder Text Encoder is used to convert the input description into the conditions of the denoising process.
[0163] The image is denoised based on some conditions to obtain a latent representation of the generated image. The denoising process can be flexibly adjusted based on text, image, or other forms of conditions (e.g. text2img for text conditions, img2img for images conditions). Finally, the image is converted back from the latent space to the pixel space through the image decoder to generate the final image.
[0164] LoRA fine-tuning: Generally, the CLIP model of Stable-diffusion and the linear layer of CrossAttention of Unet are fine-tuned.
[0165] 1.4 Object consistency maintenance
[0166] As shown in Figure 5, object consistency is maintained, including:
[0167] 1) First, extract the image representation of the ref-image - extract the image embedding1 of the image through the image encoder Image Encoder of CLIP;
[0168] 2) Then, the text encoder of CLIP is used to extract the Text Embedding1 of the concept attribute category word (such as dog) as attribute information;
[0169] 3) By performing an inner product between the Image Embedding 1 of the ref-image and the Text Embedding 1 of the attribute, we obtain the Image Embedding 2 that amplifies the information about the object in the ref-image (e.g., amplifies the representation bits related to dog in the Image Embedding) as the ID information.
[0170] 4) Extract the text embedding2 of the text to be generated (with the text unique identifier [V] of the fine-tuning object) through the text encoder of CLIP;
[0171] 5) Attribute and ID information, generated text (Image Embedding2, Text Embedding1, TextEmbedding2) are concatenated as consistent control signals;
[0172] 6) The control signal comes into play when it is generated.
[0173] 1.5 The process of minimizing the loss is as follows: The loss function of Stable-diffusion is:
[0174]
[0175] Among them, x is the training RGB image, and the image is converted to the latent space feature through the variational autoencoder VAE In the latent space, c is the Text Embedding (in this solution, c is the control signal with consistency mentioned above), represents Gaussian distributed noise, is the noise predicted by the model, It is the result of adding noise to the latent space feature z at time step t.
[0176] 1.6 Training Process
[0177] As shown in Figure 5, the training process for each round is:
[0178] 1) Parameter initialization before the first round of training: Use VAE, Text Encoder, and UNet of the open source trained model (stable-diffusion v1-5), and Text Embedding based on the initialization concept unique identifier of the training instance.
[0179] 2) Construct the current training image-text pair: construct multiple samples for each object, each sample consists of 4 items.
[0180] 3) As shown in Figure 5, the terminal sends the above sample pairs to the model for training. The image is converted into latent space features and noise is used as the image modality input of the model through VAE, and the added noise is used as the true value noise. The text to be generated is passed through the text encoder Text Encoder to obtain the Text Embedding; according to the above generated consistency control information as the cross attention control input, the two inputs are predicted by UNnet, and the LoRA module of the CrossAttention linear layer added to the Text Encoder and UNet is trained by minimizing the l2 loss of the true value noise and the predicted noise.
[0181] The training step is 1000 times and the learning rate is set to 1e-4.
[0182] The model in the technical solution of this application can be used for AIGC image creation and generation, including input object training process and model reasoning.
[0183] As shown in Figure 8, it is a schematic diagram of the model training and application process. The user enters the object name, attribute category, one or more training images of the target to be fine-tuned, and a reference image with id information (recorded as ID image, reference image can be omitted, and if not, a random image is selected from the training image as the id image). The model is fine-tuned according to the method of this solution to obtain a new model, which is deployed to the business. At the same time, the attributes and ID images corresponding to the object name are saved in the database.
[0184] The test process as shown in Figure 7 is as follows: the user inputs a description sentence with an object name, and the service searches for the object's attributes and ID map based on the object word in the description sentence, and inputs the attributes, ID map, and description sentence into the model for inference to generate a result graph.
[0185] In addition, in the technical solution provided by the present application, the order of the three splicing information used for consistency control can be changed, the training steps, the learning rate, etc. can be adjusted; the open source solution used in the embodiment of the present application can be replaced by other open source solutions with the same function, such as LoRA fine-tuning, which can be changed to dreambooth fine-tuning; in order to improve the stable and high consistency effect and increase diversity, the ref-image of the consistency control in training can be randomly selected for ID image (the selected image data comes from the picture-text pair); the basic generation model uses Stable diffusion v1.5, and SDXL can also be used, which is an upgraded version of stable diffusion.
[0186] The beneficial effects of the technical solution of this application include:
[0187] 1) Object consistency control: Consistency information is formed through object attributes in text mode and object ID features in image mode, which expands the control information in the original SD generation and allows information related to object consistency to be input into the model in advance.
[0188] 2) Accurate object ID information: In the consistency information, since the image modality generally includes a lot of other additional information in addition to the object (such as background, passers-by, etc.), in order to improve the accuracy of object ID, the ID features of the simple image modality object information are further amplified with the help of text attributes.
[0189] 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.
[0190] 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.
[0191] In one embodiment, as shown in FIG. 9 , an image generation device is provided, including: an acquisition module 902 , a search module 904 , an adjustment module 906 , and a generation module 908 , wherein:
[0192] The acquisition module 902 is used to acquire image description information in response to an image generation request.
[0193] The search module 904 is used to search the attribute information and identity feature information of the target object from the database based on the object identifier of the target object carried in the image description information.
[0194] The adjustment module 906 is used to adjust the identity feature information based on the attribute information to obtain target identity feature information.
[0195] The generating module 908 is used to generate a target image based on the image description information and the target identity feature information.
[0196] In one embodiment, the acquisition module is also used to acquire an original image corresponding to the image description information; the device also includes: an adjustment module, used to adjust the original image based on the image description information and the target identity feature information to obtain a target image that conforms to the image description information.
[0197] In one embodiment, the device also includes: a processing module, used to perform inner product processing on the attribute information and the identity feature information to obtain the identity feature information after the inner product processing, and use the identity feature information after the inner product processing as the target identity feature information; perform image generation processing on the image description information and the target identity feature information through an image generation model to obtain a target image.
[0198] In one embodiment, the acquisition module is also used to acquire a template image based on the image description information; the device also includes: a conversion module, used to convert the template image from pixel space to latent space image; an adding module, used to add noise to the latent space image to obtain a noisy image; the processing module is also used to denoise the noisy image based on the image description information and the target identity feature information to obtain a latent space target image; the conversion module is also used to convert the latent space target image into a pixel space image, and use the pixel space image as the target image.
[0199] In one embodiment, the device also includes: a display module, which is used to display a model training page in response to a model training request triggered in the main page; the acquisition module is also used to obtain multiple training samples of the target object to be fine-tuned in response to a parameter input operation triggered in the model training page; the device also includes: a training module, which is used to input the multiple training samples of the target object to be fine-tuned into the initial model for training in response to a training start operation triggered in the model training page, so as to obtain the trained image generation model.
[0200] In one embodiment, each of the training samples includes at least a sample image of the target object to be fine-tuned, an identity feature map, and image description information including object identification and category attributes; the device also includes: a saving module, used to save the object identification, category attributes and identity feature map corresponding to the target object to be fine-tuned into the database; wherein the attribute information includes category attributes; and the identity feature information includes an identity feature map.
[0201] In one embodiment, each of the training samples includes at least a sample image of the target object to be fine-tuned, an identity feature map, and image description information containing object identification and category attributes; the device also includes: a conversion module, used to convert the sample images in the multiple training samples of the target object to be fine-tuned into latent space images; a determination module, used to determine a control signal based on the image description information containing object identification and category attributes and the identity feature map; the training module is also used to input the latent space image and the control signal into the initial model for training to obtain the trained image generation model.
[0202] In one embodiment, the device also includes: an extraction module, which is used to extract the identity image representation of the identity feature map through an image encoder; extract attribute information from the image description information containing object identification and category attributes through a text encoder; a processing module, which is used to perform inner product processing on the identity image representation and the attribute information to obtain the identity image representation after the inner product processing, and use the identity image representation after the inner product processing as the target identity feature information; the extraction module is also used to extract description features from the image description information containing object identification and category attributes through the text encoder; a splicing module is used to splice the attribute information, the target identity feature information and the description features to obtain the control signal.
[0203] In one embodiment, the device also includes: an adding module, used to add noise to the latent space image to obtain a noisy image; a training module, used to input the control signal and the noisy image into the initial model for noise detection to obtain predicted noise, and stop training when the loss value determined based on the predicted noise meets a preset loss condition to obtain the trained image generation model.
[0204] In one embodiment, the image generation request includes a game screen generation request; the target object includes a target game character; the acquisition module is also used to, in the process of interacting with the game application, respond to the game screen generation request triggered in the main page of the game application, and obtain image description information corresponding to the game screen generation request; the search module is also used to respond to the image generation operation triggered in the main page of the game application, and based on the object identifier of the target game character carried in the image description information, search for attribute information and identity feature information of the target game character from a database.
[0205] In one embodiment, the device also includes: a processing module, which is used to perform inner product processing on the attribute information and the identity feature information through an image generation model to obtain the target identity feature information; the acquisition module is also used to obtain a template image based on the image description information; and the template image, the image description information and the target identity feature information are subjected to image generation processing through an image generation model to obtain a target image.
[0206] 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.
[0207] In one embodiment, a computer device is provided, which may be a terminal or a server. In this embodiment, the computer device is described as a terminal, and its internal structure diagram may be shown in FIG10. 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 via a system bus, and the communication interface, the display unit, and the input device are connected to the system bus via 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 may be implemented through WIFI, a mobile cellular network, NFC (near field communication) 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 image, and 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. The input device of the computer device can be a touch layer covered on the display screen, or a button, trackball or touchpad set on the computer device casing, or an external keyboard, touchpad or mouse, etc.
[0208] Those skilled in the art will understand that the structure shown in FIG. 10 is merely a block diagram of a partial 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 shown in the figure, or combine certain components, or have a different arrangement of components.
[0209] In one embodiment, a computer device is 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-mentioned method embodiments when executing the computer program.
[0210] 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.
[0211] 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.
[0212] 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 laws, regulations and standards of relevant countries and regions.
[0213] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods 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 this application can include at least one of non-volatile 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), magnetoresistive 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, etc., but are not limited to this.
[0214] 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 specification.
[0215] 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 understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations 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: Input multiple training samples of the target object to be fine-tuned into the initial model for training to obtain a trained image generation model, and save the object identification, category attributes and identity feature map corresponding to the target object to be fine-tuned into a database; In response to the image generation request, obtaining image description information; Based on the object identifier of the target object carried in the image description information, searching the database for attribute information and identity feature information of the target object; wherein the attribute information includes category attributes; and the identity feature information includes an identity feature map; Adjusting the identity feature information based on the attribute information to obtain target identity feature information includes: performing inner product processing on the attribute information and the identity feature information to obtain the identity feature information after the inner product processing, and using the identity feature information after the inner product processing as the target identity feature information; The text features of the image description information and the target identity feature information are spliced together through the image generation model to obtain a control signal, and a target image is generated based on the control signal.
2. The method according to claim 1, characterized in that The method further comprises: Acquire an original image corresponding to the image description information; The generating a target image based on the control signal comprises: The original image is adjusted based on the control signal to obtain a target image that conforms to the image description information.
3. The method according to claim 1, characterized in that The generating a target image based on the control signal comprises: Based on the image description information, obtaining a template image; Converting the template image from pixel space to latent space image; Adding noise to the latent space image to obtain a noisy image; Based on the control signal, denoising the noisy image to obtain a latent space target image; The latent space target image is converted into a pixel space image, and the pixel space image is used as the target image.
4. The method according to claim 1, characterized in that: The method further comprises: In response to a model training request triggered in the main page, displaying a model training page; In response to a parameter input operation triggered in the model training page, a plurality of training samples of the target object to be fine-tuned are obtained; In response to a training start operation triggered in the model training page, a plurality of the training samples of the target object to be fine-tuned are input into the initial model for training to obtain the trained image generation model.
5. The method according to claim 4, characterized in that Each of the training samples at least includes a sample image of the target object to be fine-tuned, an identity feature map, and image description information including object identification and category attributes.
6. The method according to claim 4, characterized in that Each of the training samples at least includes a sample image of the target object to be fine-tuned, an identity feature map, and image description information including object identification and category attributes; the inputting of the plurality of training samples of the target object to be fine-tuned into the initial model for training to obtain the trained image generation model includes: Converting the sample images in the plurality of training samples of the target object to be fine-tuned into latent space images; Determining a control signal based on the image description information including the object identification and category attributes and the identity feature map; The latent space image and the control signal are input into the initial model for training to obtain the trained image generation model.
7. The method according to claim 6, characterized in that The determining of the control signal based on the image description information including the object identification and the category attribute and the identity feature map comprises: Extracting an identity image representation of the identity feature map through an image encoder; Extracting attribute information from the image description information including the object identifier and the category attribute by a text encoder; Performing inner product processing on the identity image representation and the attribute information to obtain the identity image representation after the inner product processing, and using the identity image representation after the inner product processing as target identity feature information; Extracting description features from the image description information including the object identifier and the category attribute by the text encoder; The attribute information, the target identity feature information and the description feature are concatenated to obtain the control signal.
8. The method according to claim 6, characterized in that The step of inputting the latent space image and the control signal into the initial model for training to obtain the trained image generation model comprises: Adding noise to the latent space image to obtain a noisy image; The control signal and the noisy image are input into the initial model for noise detection to obtain predicted noise, and the training is stopped until the loss value determined based on the predicted noise meets a preset loss condition to obtain the trained image generation model.
9. The method according to claim 1, characterized in that: The image generation request includes a game screen generation request; The target object includes a target game character; The step of obtaining image description information in response to the image generation request includes: In the process of interacting with the game application, in response to the game screen generation request triggered in the main page of the game application, obtaining image description information corresponding to the game screen generation request; The step of searching the database for the attribute information and identity feature information of the target object based on the object identifier of the target object carried in the image description information includes: In response to an image generation operation triggered in the main page of the game application, based on the object identifier of the target game character carried in the image description information, the attribute information and identity feature information of the target game character are searched from a database.
10. The method according to claim 1, characterized in that The adjusting the identity feature information based on the attribute information to obtain target identity feature information includes: Performing inner product processing on the attribute information and the identity feature information through an image generation model to obtain the target identity feature information; The generating a target image based on the control signal comprises: Based on the image description information, obtaining a template image; The image generation model is used to perform image generation processing on the template image based on the control signal to obtain a target image.
11. An image generating device, characterized in that: The device comprises: A training module, used for inputting a plurality of training samples of the target object to be fine-tuned into the initial model for training, so as to obtain a trained image generation model; A saving module, used to save the object identification, category attributes and identity feature map corresponding to the target object to be fine-tuned into a database; An acquisition module, used for acquiring image description information in response to an image generation request; A search module, configured to search the database for attribute information and identity feature information of the target object based on the object identifier of the target object carried in the image description information; wherein the attribute information includes category attributes; and the identity feature information includes an identity feature map; an adjustment module, configured to adjust the identity feature information based on the attribute information to obtain target identity feature information, including: performing inner product processing on the attribute information and the identity feature information to obtain the identity feature information after the inner product processing, and using the identity feature information after the inner product processing as the target identity feature information; A generation module is used to obtain a control signal by splicing the text features of the image description information and the target identity feature information through the image generation model, and generate a target image based on the control signal.
12. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 10 are implemented.
13. 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 10 are implemented.
14. 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 10 are implemented.
