Pet image generation method and device

By combining image generation models and plug-ins, and using Stable Diffusion and LoRa models, the problem of poor AI technology in pet image generation is solved, and efficient, high-quality pet image generation is achieved to meet user needs.

CN118587322APending Publication Date: 2024-09-03BEIJING ZITIAO NETWORK TECH CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202410650399.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-23
Publication Date
2024-09-03

AI Technical Summary

Technical Problem

The current AI technology used to generate pet images is not effective and difficult to meet user needs. In particular, the facial information of pets is different from that of human faces and has many types, resulting in low quality of generated images.

Method used

The pre-trained image generation model is combined with the plug-in to generate the target pet image through the text and image features input by the user. The Stable Diffusion model and the LoRa model are used for fine-tuning to generate pet images that meet the user's needs.

Benefits of technology

The efficiency and quality of pet image generation are improved. Users can input images with looser conditions. The generated images are more suitable for the characteristics and species of the target pet. The operation is convenient and the generation time is reduced.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118587322A
    Figure CN118587322A
Patent Text Reader

Abstract

The invention discloses a pet image generation method, and the method comprises the steps: obtaining a first text inputted by a user and a to-be-processed pet image, the first text indicating the requirements that a generated target pet image needs to meet, and the to-be-processed pet image comprises a target pet used for generating the target pet image; the first text is input into an image generation model, the image generation model comprises a pre-trained first plug-in, image features of the to-be-processed pet image are input into the first plug-in, and the first plug-in can process the image features. The image generation model may process the input text, and in addition, the image generation model may interact with the first plug-in to generate a target pet image. The image generation model has the image generation capability, and the first plug-in can process the image features to guide the image generation model to generate the target pet image matched with the target pet, so that the target pet image meeting the user demand can be generated for the user by using the scheme.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of image processing, and in particular to a method and device for generating pet images. Background Art

[0002] With the development of artificial intelligence (AI) technology, AI technology can be used to generate images, for example, to generate artistic images for people.

[0003] In some scenarios, users want to generate images for pets, such as generating artistic images for pets. However, the current AI technology is not very effective in generating images for pets. Therefore, a solution is urgently needed to solve the above problem. Summary of the invention

[0004] In order to solve or at least partially solve the above technical problems, an embodiment of the present application provides a pet image generation method and device.

[0005] In a first aspect, an embodiment of the present application provides a method for generating a pet image, the method comprising:

[0006] Acquire a first text input by a user and a pet image to be processed, wherein the first text indicates requirements to be met by a generated target pet image, and the pet image to be processed includes a target pet used to generate the target pet image;

[0007] Inputting the first text into an image generation model, and inputting the image features of the to-be-processed pet image into a first plug-in of the image generation model that is pre-trained, wherein the first plug-in is used to process the image features, and the image generation model is used to interact with the first plug-in and process the text input into the image generation model to generate the target pet image;

[0008] Acquire and output the target pet image output by the image generation model.

[0009] Optionally, the first plug-in includes:

[0010] A pet head portrait plug-in, and / or a pet full-body portrait plug-in, wherein the image features of the pet image to be processed include head portrait features and / or full-body portrait features;

[0011] The pet avatar plug-in is used to process the avatar features of the target pet;

[0012] The pet full-body image plug-in is used to process the full-body image features of the target pet.

[0013] Optionally, the pet avatar plug-in is trained in the following way:

[0014] The pet avatar plug-in is trained using a first training image, a description text of the first training image, and a first sub-image of the first training image, wherein the first training image serves as a training label, and the first sub-image includes: a head image of the first training image, or a head segmentation of the first training image, and the first training image is an image including a pet.

[0015] Optionally, the pet full-body image plug-in is trained in the following manner:

[0016] The pet full-body image plug-in is trained using a second training image, a description text of the second training image, and a second sub-image of the second training image, wherein the second training image serves as a training label, and the second sub-image includes: a full-body image of the second training image, or a full-body segmentation of the second training image, and the second training image is an image including a pet.

[0017] Optionally, the pet head portrait plug-in and the pet full body portrait plug-in are trained in the following manner:

[0018] The pet avatar plug-in and the pet full-body avatar plug-in are trained using a third training image, a description text of the third training image, and a third sub-image of the third training image, wherein the third training image serves as a training label, and the third sub-image includes: a full-body image of the third training image, or a full-body segmentation of the third training image, or a head image of the third training image, or a head segmentation of the third training image, and the third training image is an image including a pet.

[0019] Optionally, the method further includes:

[0020] Identify the pet image to be processed and determine the breed of the target pet;

[0021] Supplementing the first text based on the breed of the target pet to obtain a second text;

[0022] The step of inputting the first text into an image generation model comprises:

[0023] The second text obtained by supplementing the first text is input into the image generation model.

[0024] Optionally, the method further includes:

[0025] Acquire an image style selected by a user, and determine a second plug-in corresponding to the image style, where the second plug-in is used to control the style of the target pet image;

[0026] When generating the target pet image, the image generation model is also used to interact with the second plug-in to generate the target pet image.

[0027] Optionally, before inputting the first text into the image generation model and inputting the image features of the to-be-processed pet image into the first plug-in of the image generation model, the method further includes:

[0028] It is determined that the pet image to be processed does not include a human face.

[0029] Optionally, the pet image to be processed is a single pet image.

[0030] In a second aspect, an embodiment of the present application provides a pet image generation device, the device comprising:

[0031] A first acquisition unit is used to acquire a first text input by a user and a pet image to be processed, wherein the first text indicates requirements to be met by the generated target pet image, and the pet image to be processed includes a target pet used to generate the target pet image;

[0032] An input unit, used for inputting the first text into an image generation model, and inputting the image features of the to-be-processed pet image into a first plug-in of the image generation model that is pre-trained, the first plug-in being used for processing the image features, the image generation model being used for interacting with the first plug-in and processing the text input into the image generation model to generate the target pet image;

[0033] An output unit is used to obtain and output the target pet image output by the image generation model.

[0034] Optionally, the first plug-in includes:

[0035] A pet head portrait plug-in, and / or a pet full-body portrait plug-in, wherein the image features of the pet image to be processed include head portrait features and / or full-body portrait features;

[0036] The pet avatar plug-in is used to process the avatar features of the target pet;

[0037] The pet full-body image plug-in is used to process the full-body image features of the target pet.

[0038] Optionally, the pet avatar plug-in is trained in the following way:

[0039] The pet avatar plug-in is trained using a first training image, a description text of the first training image, and a first sub-image of the first training image, wherein the first training image serves as a training label, and the first sub-image includes: a head image of the first training image, or a head segmentation of the first training image, and the first training image is an image including a pet.

[0040] Optionally, the pet full-body image plug-in is trained in the following manner:

[0041] The pet full-body image plug-in is trained using a second training image, a description text of the second training image, and a second sub-image of the second training image, wherein the second training image serves as a training label, and the second sub-image includes: a full-body image of the second training image, or a full-body segmentation of the second training image, and the second training image is an image including a pet.

[0042] Optionally, the pet head portrait plug-in and the pet full body portrait plug-in are trained in the following manner:

[0043] The pet avatar plug-in and the pet full-body avatar plug-in are trained using a third training image, a description text of the third training image, and a third sub-image of the third training image, wherein the third training image serves as a training label, and the third sub-image includes: a full-body image of the third training image, or a full-body segmentation of the third training image, or a head image of the third training image, or a head segmentation of the third training image, and the third training image is an image including a pet.

[0044] Optionally, the device further comprises:

[0045] A first determination unit, configured to identify the pet image to be processed and determine the breed of the target pet;

[0046] A supplementing unit, configured to supplement the first text based on the breed of the target pet to obtain a second text;

[0047] The input unit is used to:

[0048] The second text obtained by supplementing the first text is input into the image generation model.

[0049] Optionally, the device further comprises:

[0050] A second acquisition unit, configured to acquire an image style selected by a user, and determine a second plug-in corresponding to the image style, wherein the second plug-in is configured to control the style of the target pet image;

[0051] When generating the target pet image, the image generation model is also used to interact with the second plug-in to generate the target pet image.

[0052] Optionally, the device further comprises:

[0053] The second determining unit is used to determine that the pet image to be processed does not include a human face before inputting the first text into the image generation model and inputting the image features of the pet image to be processed into the first plug-in of the image generation model.

[0054] Optionally, the pet image to be processed is a single pet image.

[0055] In a third aspect, an embodiment of the present application provides an electronic device, the device comprising a processor and a memory;

[0056] The processor is configured to execute instructions stored in the memory, so that the device performs the method as described in any one of the first aspects above.

[0057] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, comprising instructions, wherein the instructions instruct a device to execute a method as described in any one of the above first aspects.

[0058] In a fifth aspect, an embodiment of the present application provides a computer program product, which, when executed on a computer, enables the computer to execute any of the methods described in the first aspect above.

[0059] Compared with the prior art, the embodiments of the present application have the following advantages:

[0060] The embodiment of the present application provides a pet image generation method, the method comprising: obtaining a first text input by a user and a pet image to be processed, the first text indicating the requirements to be met by the generated target pet image, the pet image to be processed including a target pet used to generate the target pet image. Furthermore, the first text is input into an image generation model, the image generation model comprises a pre-trained first plug-in, the image features of the pet image to be processed can be input into the first plug-in, and the first plug-in can process the image features. The image generation model can process the input text, and in addition, the image generation model can interact with the first plug-in to generate the target pet image. Since the image generation model has image generation capabilities, and the first plug-in can process image features to guide the image generation model to generate a target pet image that matches the target pet, it can be seen that the solution of the embodiment of the present application can generate a target pet image that meets the user's needs for the user. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0062] Figure 1 A schematic diagram of a process for generating a pet image provided in an embodiment of the present application;

[0063] Figure 2 A schematic diagram of a process for generating a pet image provided in an embodiment of the present application;

[0064] Figure 3 A flowchart of a method for training a pet avatar plug-in provided in an embodiment of the present application;

[0065] Figure 4 A flowchart of a method for training a pet full-body image plug-in provided in an embodiment of the present application;

[0066] Figure 5 A flowchart of a plug-in training method provided in an embodiment of the present application;

[0067] Figure 6a A flowchart of a plug-in training method provided in an embodiment of the present application;

[0068] Figure 6b A flowchart of another plug-in training method provided in an embodiment of the present application;

[0069] Figure 7 A flowchart of another pet image generation method provided in an embodiment of the present application;

[0070] Figure 8 A schematic diagram of the structure of a pet image generating device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0071] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0072] The inventor of the present application has found through research that with the development of AI technology, AI technology can generate human images better. For example, AI technology can generate portrait images for people by "changing faces". Influenced by the use of AI technology to generate portraits of people, there is a demand to generate images (such as portraits) for pets.

[0073] The current face-changing scheme for generating portraits of people cannot be directly applied to generating images for pets. This is because the facial information of pets is different from that of human faces. In addition to the facial features, pet facial information also includes information such as fur color and hair. Moreover, the appearance of pets of different types and / or breeds varies greatly. Specifically, pets of different types and / or breeds may have large differences in fur color, eyes, ears, body shape, bones, etc. Among them, the type of pet is used to distinguish different pet species. For example, cats and dogs are two different types of pets. Pets of the same type can include multiple breeds. For example, for dogs, they can include Scottish shepherds, Tibetan mastiffs, Samoyeds, golden retrievers and other breeds.

[0074] The inventor of the present application has found that currently, a Stable Diffusion model and a Low-Rank Adaptation of Large Language Models (LoRa) model can be used to generate pet images. Among them:

[0075] The Stable Diffusion model is a generative model commonly used in AI drawing. It can generate corresponding description-based or image-based new images through descriptive text or image input.

[0076] In order to more effectively control the image content generated by the Stable Diffusion model, some fine-tuning technologies based on large models have emerged, such as the aforementioned LoRa model, which only requires a small number of samples to complete training. The LoRa model can be used in conjunction with the Stable Diffusion model to adjust the images generated by the Stable Diffusion model, making the images generated by the Stable Diffusion model more in line with user needs.

[0077] As a specific example, the process of generating pet images using the Stable Diffusion model and the LoRa model can be referred to Figure 1 To understand, Figure 1 A flowchart of a pet image generation method provided in an embodiment of the present application.

[0078] like Figure 1As shown, the user can input multiple high-quality pet images, and use the multiple pet images to quickly train a LoRa model. In addition, the user can input prompt words for generating pet pictures into the Stable Diffusion model. The prompt words can be understood as the requirements that the generated pet images need to meet. For example, the prompt words can be: "A cat wearing a green sweater and a Santa hat, surrounded by Christmas trees and gifts." In one example, negative prompt words (such as negative prompt words preset by the client) can also be input. The negative prompt words can be used to indicate content that cannot appear in the generated pet image. In another example, the user can also adjust the parameters of the aforementioned Stable Diffusion model as needed, which is not described in detail here.

[0079] The quickly trained LoRa model can guide the Stable Diffusion model to generate a pet image based on the prompt word input by the user to be more consistent with the multiple pet images input by the user. In this way, a pet image that meets the user's needs can be generated.

[0080] This method has strict requirements on the quantity and quality of pet images input by users. It requires users to input multiple pet images, and the quality of these multiple pet images is relatively high. Users generally need to take clear photos of pets from multiple angles to obtain the aforementioned "multiple high-quality pet images". For users, the operation is difficult. On the other hand, the aforementioned "quick training of a LoRa model" (corresponding to Figure 1 The time-consuming process of generating the pet image is long, generally taking several minutes, which results in a long time-consuming process of generating the pet image.

[0081] In view of this, an embodiment of the present application provides a pet image generation method, which, on the one hand, has more relaxed requirements on the pet image input by the user, and on the other hand, is more efficient in generating pet images.

[0082] Various non-limiting implementations of the present application are described in detail below in conjunction with the accompanying drawings.

[0083] Exemplary Methods

[0084] See also Figure 2 , which is a flow chart of a pet image generation method provided in an embodiment of the present application. The solution provided in the embodiment of the present application can be applied to a client or a server, and the embodiment of the present application does not make specific limitations. In the following description of the embodiment of the present application, the application of the solution to the client is used as an example for explanation.

[0085] In this embodiment, the method may include, for example, the following steps: S101 - S103 .

[0086] S101: Acquire a first text input by a user and a pet image to be processed, wherein the first text indicates requirements to be met by a generated target pet image, and the pet image to be processed includes a target pet used to generate the target pet image.

[0087] In one example, the client may provide the user with an image upload portal, and the user may trigger the pet image upload operation through the image upload portal and upload the pet image to be processed. In an embodiment of the present application, the user may upload one or more pet images as the pet image to be processed. In other words, in an embodiment of the present application, there is no strict requirement on the number of pet images uploaded by the user, and the user may choose to upload only one pet image. In the case where the user only uploads one pet image, the solution provided in the embodiment of the present application may also generate a target pet image that meets the user's needs. In the case where the user only uploads one image, the aforementioned pet image to be processed is a single pet image. Of course, the user may also choose to upload multiple pet images, which is not specifically limited in the embodiment of the present application.

[0088] In one example, the image to be processed includes a target pet. The embodiment of the present application does not specifically limit the type and breed of the target pet. The target pet can be a pet of any type and breed.

[0089] In one example, the client may provide the user with an input area for inputting pet image generation requirements. The user may input the aforementioned first text in the input area according to his or her own requirements. The first text may indicate the user's pet image generation requirements. The so-called pet image generation requirements may be understood as the requirements that the generated target pet image needs to meet. In other words, the first text may be used to indicate the requirements that the generated target pet image needs to meet. The embodiment of the present application does not specifically limit the first text. The first text may be determined according to actual conditions. For example, the first text may be: "A cat wearing a green sweater and a Santa hat, surrounded by Christmas trees and gifts."

[0090] S102: Input the first text into an image generation model, and input the image features of the pet image to be processed into a first plug-in of the image generation model that is pre-trained, wherein the first plug-in is used to process the image features, and the image generation model is used to interact with the first plug-in and process the text input into the image generation model to generate the target pet image.

[0091] After obtaining the first text, the first text can be input into an image generation model. The image generation model mentioned here can be a model capable of generating a new image based on the input text and / or image. As a specific example, the image generation model can be a Stable Diffusion model.

[0092] In order to make the target pet image generated by the image generation model more in line with user needs. A first plug-in that cooperates with the image generation model can be pre-trained. Since the first plug-in is used in cooperation with the image generation model, the first plug-in can also be considered as a plug-in of the image generation model. The first plug-in can process image features. The client can input the image features of the pet image to be processed into the first plug-in so that the first plug-in can process the image features.

[0093] The image generation model can process input text, such as the first text, so as to generate a target pet image that conforms to the first text. In an embodiment of the present application, the target pet image not only needs to conform to the first text, but also needs to fit the target pet in the pet image to be processed. To achieve this goal, the image generation model can interact with the aforementioned first plug-in. As a specific example, the image generation model can obtain the processing result of the first plug-in processing the aforementioned image features, so as to generate the target pet image in combination with the processing result. Since the aforementioned processing result is obtained based on the image features of the pet image to be processed, therefore, generating the target pet image in combination with the result to be processed can make the generated pet image more fit the target pet.

[0094] The embodiment of the present application does not specifically limit the first plug-in, and the first plug-in can be any plug-in with image feature processing function. As an example, the first plug-in can be, for example, an IP-Adapter, wherein the IP-Adapter is an effective and lightweight adapter that can process the image or image features input by the user and diffuse the processing results into the image generation model to guide the image generation model to better generate a new image close to the user input image.

[0095] In a specific example, in order to enable the image generation model to better capture the characteristics of the target pet, the first plug-in may include a pet head portrait plug-in and / or a pet full-body portrait plug-in.

[0096] The pet avatar plug-in is used to process the avatar features of the target pet. In the case where the first plug-in includes a pet avatar plug-in, the image features of the aforementioned pet image to be processed include the avatar features of the target pet. Accordingly, in this scenario, the image generation model can better capture the avatar features of the target pet, so as to combine the avatar features of the target pet to generate a target pet image that fits the target pet. In one example, the pet avatar plug-in can also be an IP-Adapter.

[0097] The pet full-body image plug-in is used to process the full-body image features of the target pet. In the case where the first plug-in includes a pet full-body image plug-in, the image features of the aforementioned pet image to be processed include the full-body image features of the target pet. Accordingly, in this scenario, the image generation model can better capture the full-body image features of the target pet, so as to combine the full-body image features of the target pet to generate a target pet image that fits the target pet. In one example, the pet full-body image plug-in can also be an IP-Adapter.

[0098] In one example, in order to make the generated target pet image more suitable for the target pet, the pet image to be processed can also be identified to determine the breed of the target pet. As an example, the pet image to be processed can be identified using traditional image recognition technology to determine the breed of the target pet. As another example, a model capable of identifying pet breeds can also be trained, and the pet image to be processed can be input into the model to obtain the breed of the target pet.

[0099] After determining the breed of the target pet, the first text can be supplemented based on the breed of the target pet to obtain a second text. The supplemented second text includes the breed of the target pet in addition to the original semantics of the first text. For example:

[0100] The pet image to be processed input by the user is an image of a calico cat, that is, the breed of the target pet is a calico cat. The first text is: "A cat wearing a green sweater and a Santa hat, surrounded by Christmas trees and gifts". The second text after supplementation can be "A calico cat wearing a green sweater and a Santa hat, surrounded by Christmas trees and gifts". Accordingly, in the scenario where the first text is supplemented to obtain the second text, the second text can be input into the image generation model, so that the image generation model interacts with the first plug-in and processes the second text to generate the target pet image.

[0101] In one example, the client may also provide the user with an image style selection portal. For example, the client may display multiple image styles to be selected, and the user may select one of the image styles from the multiple image styles to be selected. For the convenience of description, the image style selected by the user is referred to as the "target image style". When the client generates a target pet image, it may generate a pet image that conforms to the target image style.

[0102] In an embodiment of the present application, plug-ins corresponding to respective image styles to be selected may be pre-trained, and the plug-in corresponding to each image style to be selected may be used to interact with the image generation model to guide the image generation model to generate an image based on the corresponding image style to be selected.

[0103] Therefore, when generating a pet image that conforms to the target image style, the second plug-in of the image generation model can be used in a specific implementation. The second plug-in can be a plug-in corresponding to the aforementioned target image style. After the user selects the target image style, the client can obtain the plug-in corresponding to the target image style as the second plug-in. As can be seen from the description of the plug-in corresponding to the selected image style, the second plug-in can be used to control the style of the target pet image. Specifically, the second plug-in can interact with the image generation model to guide the image generation model to generate the target pet image based on the target image style.

[0104] The embodiment of the present application does not specifically limit the image style to be selected, and the image style to be selected can be determined according to actual conditions. The embodiment of the present application does not specifically limit the second plug-in either. In a specific example, the second plug-in can be, for example, a LoRa style control model.

[0105] In one example, in order to prevent users from maliciously using facial images to generate pet images, the client may also perform facial recognition on the pet image to be processed before executing S102, and continue to execute S102 and subsequent steps if it is determined that the pet image to be processed does not include a human face. Correspondingly, if it is determined that the pet image to be processed includes a human face, the client may no longer execute S102 and subsequent steps. Optionally, if the pet image to be processed includes a human face, the client may output a prompt message, which is used to prompt the user to re-upload the pet image.

[0106] S103: Acquire and output the target pet image output by the image generation model.

[0107] After the image generation model generates the target pet image, the client may obtain the target pet image and further output the target pet image, wherein outputting the target pet image may, for example, display the target pet image in a page provided by the client.

[0108] In some embodiments, the target pet image displayed by the client may also support functions such as downloading (or saving) and forwarding, which will not be described in detail here.

[0109] From the above description, it can be seen that by using the solution of the embodiment of the present application, on the one hand, the user does not need to input multiple pet images, and the user only needs to input one pet image as the pet image to be processed, which is convenient for the user to operate. In addition, in the embodiment of the present application, the aforementioned first plug-in is pre-trained, and there is no need to "temporarily" train an auxiliary model (such as a LoRa model) based on the pet image to be processed input by the user. Therefore, this solution can efficiently generate the target pet image.

[0110] As mentioned above, the first plug-in is pre-trained, and the first plug-in may include a pet head portrait plug-in and / or a pet full-body portrait plug-in.

[0111] Next, the training methods of the pet portrait plug-in and the pet full-body portrait plug-in are introduced respectively.

[0112] See also Figure 3 , which is a flow chart of a pet avatar plug-in training method provided in an embodiment of the present application. Figure 3 The method shown may include the following S201-S202.

[0113] In the embodiment of the present application, multiple sets of training samples can be used to train the pet avatar plug-in. When training the pet avatar plug-in, the processing method for each set of training samples is similar. Next, taking one set of training samples as an example, the training process of the pet avatar plug-in is described.

[0114] S201: Acquire a first training image, a description text of the first training image, and a first sub-image of the first training image, wherein the first sub-image includes: a head image of the first training image, or a head segmentation of the first training image, and the first training image is an image including a pet.

[0115] In an embodiment of the present application, the aforementioned first training image, the description text of the first training image, and the first sub-image of the first training image can be used as a set of training samples. In one example, the first training image is an image including a pet, and the first training image can be, for example, an image obtained by photographing the pet at any angle. The description text of the first training image can include multiple texts for describing the first training image, for example, it can include a description of factors such as the clothing, demeanor, and environment of the pet in the first training image.

[0116] In an embodiment of the present application, the head image of the first training image may be an image including a pet's head captured from the first training image, wherein the head image of the first training image may include some other image background in addition to the pet's head. The head segmentation of the first training image may also be obtained by processing the first training image, wherein the head segmentation does not include the image background in the first training image in addition to the pet's head.

[0117] S202: Train the pet avatar plug-in using the first training image, the description text of the first training image, and the first sub-image, wherein the first training image serves as a training label.

[0118] After acquiring the first training image, the description text of the first training image, and the first sub-image of the first training image, the pet avatar plug-in may be trained based on the first training image, the description text of the first training image, and the first sub-image. When training the pet avatar plug-in, the first training image may be used as a training label.

[0119] In the process of training the pet avatar plug-in, the pet avatar plug-in can generate a first predicted image based on its own parameters, the description text of the first training image, and the first sub-image. Furthermore, the parameters of the pet avatar plug-in are updated based on the first predicted image and the first training image as a training label, so that the pet avatar plug-in has a stronger image generation capability. For example, if the first predicted image is regenerated using the pet avatar plug-in after the parameter update, the regenerated first predicted image can be closer to the first training image.

[0120] As an example, a loss function may be calculated based on the first predicted image and the first training image, and further based on the loss function, the parameters of the pet avatar plug-in may be updated.

[0121] When the number of parameter updates experienced by the pet avatar plug-in is greater than a certain threshold, or when the loss function during training based on a certain set of training samples meets certain conditions (for example, close to 0), the training of the pet avatar plug-in is completed.

[0122] See also Figure 4 , which is a flow chart of a method for training a pet full-body image plug-in provided in an embodiment of the present application. Figure 4 The method shown may include the following S301-S302.

[0123] In the embodiment of the present application, multiple sets of training samples can be used to train the pet full-body image plug-in. When training the pet full-body image plug-in, the processing method for each set of training samples is similar. Next, taking one set of training samples as an example, the training process of the pet full-body image plug-in is described.

[0124] S301: Acquire a second training image, a description text of the second training image, and a second sub-image of the second training image, wherein the second sub-image includes: a full-body image of the second training image, or a full-body segmentation of the second training image, and the second training image is an image including a pet.

[0125] In an embodiment of the present application, the second sub-image of the second training image may be a full-body image of the second training image, or a full-body segmentation of the second training image. The full-body image of the second training image may be an image of the pet's whole body captured from the second training image, wherein the full-body image of the second training image may include some other image background in addition to the pet's whole body. The full-body segmentation of the second training image may also be obtained by processing the second training image, wherein the full-body segmentation does not include the image background in the second training image in addition to the pet's whole body.

[0126] S302: Train the pet full-body image plug-in by using the second training image, the description text of the second training image, and the second sub-image of the second training image, wherein the second training image serves as a training label.

[0127] After acquiring the second training image, the description text of the second training image, and the second sub-image, the pet full-body image plug-in can be trained based on the second training image, the description text of the second training image, and the second sub-image. When training the pet full-body image plug-in, the second training image can be used as a training label.

[0128] In the process of training the pet full-body portrait plug-in, the pet full-body portrait plug-in can generate a second predicted image based on its own parameters, the description text of the second training image, and the second sub-image. Further, according to the second predicted image and the second training image as the training label, the parameters of the pet full-body portrait plug-in are updated so that the pet full-body portrait plug-in has a stronger image generation capability. For example, if the second predicted image is regenerated using the pet full-body portrait plug-in after the parameter update, the regenerated second predicted image can be closer to the second training image.

[0129] As an example, a loss function may be calculated based on the second predicted image and the second training image, and further based on the loss function, the parameters of the pet full-body image plug-in may be updated.

[0130] When the number of parameter updates experienced by the pet full-body image plug-in is greater than a certain threshold, or when the loss function during training based on a certain set of training samples meets certain conditions (eg, close to 0), the training of the pet full-body image plug-in is completed.

[0131] In one example, the aforementioned pet avatar plug-in and the pet full-body avatar plug-in can be trained in the same way. In this scenario, the pet avatar plug-in and the pet full-body avatar plug-in can be trained in the same way. Figure 5 The general plugin trained using the method shown. Figure 5 A flowchart of a plug-in training method provided in an embodiment of the present application. Figure 5 The method shown may include the following S401-S402.

[0132] S401: Acquire a third training image, a description text of the third training image, and a third sub-image of the third training image, wherein the third sub-image includes: a full-body image of the third training image, or a full-body segmentation of the third training image, or a head image of the third training image, or a head segmentation of the third training image, and the third training image is an image including a pet.

[0133] Regarding the full body image of the third training image and the full body segmentation of the third training image, reference may be made to the description of the full body image of the second training image and the full body segmentation of the second training image in the foregoing text, and no repeated description will be made here.

[0134] Regarding the head image of the third training image and the head segmentation of the third training image, reference may be made to the foregoing description of the head image of the first training image and the head segmentation of the first training image, which will not be repeated here.

[0135] S402: Using the third training image, the description text of the third training image, and the third sub-image, the pet head portrait plug-in and the pet full-body portrait plug-in are trained, wherein the third training image is used as a training label.

[0136] After obtaining the third training image, the description text of the third training image, and the third sub-image, a universal plug-in can be trained based on the third training image, the description text of the third training image, and the third sub-image. The universal plug-in can be used as the aforementioned pet head portrait plug-in or pet full-body portrait plug-in. When training the universal plug-in, the third training image can be used as a training label.

[0137] In the process of training the general plug-in, the general plug-in can generate a third predicted image based on its own parameters, the description text of the third training image, and the third sub-image. Further, the parameters of the general plug-in are updated according to the third predicted image and the third training image as the training label, so that the general plug-in has a stronger image generation capability. For example, if the third predicted image is regenerated using the general plug-in after the parameter update, the regenerated third predicted image can be closer to the third training image.

[0138] As an example, a loss function may be calculated based on the third predicted image and the third training image, and further based on the loss function, the parameters of the general plug-in may be updated.

[0139] When the number of parameter updates experienced by the general plug-in is greater than a certain threshold, or when the loss function during training based on a certain set of training samples meets a certain condition (for example, close to 0), the training of the general plug-in is completed.

[0140] In some scenarios, considering that for some pets, there may be a set of images, for example, multiple video frames are extracted from a video of the pet, each of which includes a certain pet. In this scenario, the set of images can be used as training images to train the pet head portrait plug-in and the pet full-body portrait plug-in.

[0141] In one example, the group of images includes a fourth training image and the aforementioned first training image, then: the pet avatar plug-in can also be trained using the first training image, the description text of the first training image, and the fourth sub-image of the fourth training image, wherein the first training image is used as a training label. The fourth sub-image includes: a head image of the fourth training image, or a head segmentation of the fourth training image.

[0142] Regarding the fourth sub-image, you can refer to the description of the first sub-image in the previous article, which will not be repeated here. Correspondingly, the method of training the pet avatar plug-in based on the first training image, the description text of the first training image, and the fourth sub-image can also refer to the relevant description in the previous article, which will not be repeated here.

[0143] In another example, the group of images includes a fifth training image and the aforementioned second training image, then: the pet full-body image plug-in can also be trained using the second training image, the description text of the second training image, and the fifth sub-image of the fifth training image, wherein the second training image is used as a training label, and the fifth sub-image includes: a full-body image of the fifth training image, or a full-body segmentation of the fifth training image.

[0144] Regarding the fifth sub-image, you can refer to the description of the second sub-image in the previous text, which will not be repeated here. Correspondingly, the method of training the pet full-body image plug-in based on the second training image, the description text of the second training image, and the fifth sub-image can also refer to the relevant description in the previous text, which will not be repeated here.

[0145] In another example, the group of images includes a sixth training image and the aforementioned third training image, then: the aforementioned universal plug-in can also be trained using the third training image, the description text of the third training image, and the sixth sub-image of the sixth training image, wherein the third training image is used as a training label, and the sixth sub-image includes: a full-body image of the sixth training image, or a full-body segmentation of the sixth training image, or a head image of the sixth training image, or a head segmentation of the sixth training image.

[0146] Regarding the sixth sub-image, you can refer to the description of the first sub-image and the second sub-image in the previous text, and will not repeat the description here. Correspondingly, the method of training the universal plug-in based on the third training image, the description text of the third training image, and the sixth sub-image can also refer to the relevant description in the previous text, and will not be repeated here.

[0147] Next, the training method of the aforementioned pet head portrait plug-in and pet full body portrait plug-in is described in conjunction with the accompanying drawings.

[0148] like Figure 6a As shown, Figure 6a A flowchart of a plug-in training method provided in an embodiment of the present application.

[0149] like Figure 6a As shown, for a pet with only one pet image that can be used for training, the pet image can be processed to obtain a pet head portrait, a pet full-body portrait, a pet head segmentation, and a pet full-body segmentation. Among them:

[0150] The pet avatar may be an image including the pet's head captured from the pet image. In addition to the pet's head, the pet avatar may also include some other image backgrounds.

[0151] The full-body image of the pet may be an image including the full body of the pet captured from the pet image. In addition to the full body of the pet, the full-body image of the pet may also include some other image backgrounds.

[0152] The pet head segmentation includes the pet's head but not other image background.

[0153] Pet full body segmentation includes the whole body of the pet, excluding other image background.

[0154] You can select any one image from the pet portrait, pet full-body portrait, pet head segmentation and pet full-body segmentation, among which the selected pet portrait can be used as a training head image, the selected pet portrait segmentation can be used as a training head image, the selected pet full-body portrait can be used as a training full-body image, and the selected pet full-body segmentation can be used as a training full-body image.

[0155] In addition, the pet image can be used as the first training image.

[0156] Furthermore, the IP--Adapter is trained based on an image selected by the user, the pet image and a description text of the pet image.

[0157] like Figure 6b As shown, Figure 6b A flowchart of another plug-in training method provided in an embodiment of the present application.

[0158] like Figure 6b As shown, for a pet having multiple pet images that can be used for training, the multiple pet images can constitute a pet image group. Correspondingly, the description texts corresponding to the multiple pet images can constitute a description text group.

[0159] For each pet image in the pet image group, the pet image can be processed to obtain a pet head portrait, a pet full-body portrait, a pet head segmentation, and a pet full-body segmentation. Further, a pet head portrait set including multiple pet head portraits, a pet full-body image set including multiple pet full-body portraits, a pet head segmentation set including multiple pet head segmentations, and a pet full-body segmentation set including multiple pet full-body segmentations are obtained.

[0160] You can select any image from a pet portrait set, a pet full-body portrait set, a pet head segmentation set, and a pet full-body segmentation set, wherein the pet portrait selected from the pet portrait set can be used as a training head image, the pet portrait segmentation selected from the pet portrait segmentation set can be used as a training head image, the pet full-body portrait selected from the pet full-body portrait set can be used as a training full-body image, and the pet full-body segmentation selected from the pet full-body segmentation set can be used as a training full-body image.

[0161] In addition, a pet image is selected from the pet image group as the first training image, and a description text corresponding to the selected pet image is determined from the description text group.

[0162] Furthermore, the IP-Adapter is trained based on an image selected by the user, the first training image and the description text corresponding to the selected pet image.

[0163] It should be noted that Figure 6a and Figure 6b The training process can be combined. For example, when training IP-–Adapter, in one round of training, you can use Figure 6a The process shown in the figure can be used in another round of training. Figure 6b The process shown.

[0164] The IP--Adapter trained by the above process can be equivalent to the general plug-in mentioned above. In other words, the IP--Adapter trained by the above process can be used as a pet head portrait plug-in or a pet full-body portrait plug-in. In a specific example, two IP--Adapters can be trained by the above process, one of which is used as a pet head portrait plug-in and the other as a pet full-body portrait plug-in.

[0165] Next, combine Figure 7 , the pet image generation method provided in the embodiment of the present application is introduced. Figure 7 A flowchart of another pet image generation method provided in an embodiment of the present application is shown below. Figure 7 As shown:

[0166] The user may input a prompt word for generating picture content, and the prompt word for generating picture content may be equivalent to the first text mentioned in the above embodiment.

[0167] In addition, the user may also input a pet picture, which may be equivalent to the pet image to be processed mentioned in the above embodiment.

[0168] The client can first detect whether the pet picture input by the user includes a human face. If it is detected that the pet picture includes a human face, the processing flow ends. In the case that it is detected that the pet picture does not include a human face, the following flow is executed:

[0169] The client determines the breed of the pet included in the pet picture based on the pet picture input by the user. And further based on the obtained breed, the generated picture content prompt word input by the user is optimized to obtain the optimized content prompt word. In one example, preset negative prompt words can also be added to the optimized content prompt words. Further, the text features of the optimized content prompt words and negative prompt words are extracted, and the text features are input into the Stable Diffusion model. The Stable Diffusion model mentioned here can correspond to the image generation model mentioned in the above embodiment.

[0170] In one example, the user can adjust the parameters of the Stable Diffusion model as needed.

[0171] In addition, a pet detector is used to extract a pet head portrait and a pet full-body portrait from a pet picture. Further, an image feature extraction technique is used to extract features of the pet head portrait to obtain head image features, and the head image features are input into the pet head portrait plug-in. Also, an image feature extraction technique is used to extract features of the pet full-body portrait to obtain full-body image features, and the full-body image features are input into the pet full-body portrait plug-in.

[0172] In addition, the LoRa style control model is used as the second plug-in of the Stable Diffusion model. The Stable Diffusion model processes the input text features and interacts with the pet head portrait plug-in, the pet full-body portrait plug-in and the LoRa style control model to output the generated target pet image.

[0173] Exemplary Devices

[0174] Based on the method provided in the above embodiment, the embodiment of the present application further provides a device, which is described below in conjunction with the accompanying drawings.

[0175] See also Figure 8 , Figure 8 The structure diagram of a pet image generation device provided in an embodiment of the present application is shown in FIG. 800 . The device 800 may specifically include: a first acquisition unit 801 , an input unit 802 , and an output unit 803 .

[0176] A first acquisition unit 801 is used to acquire a first text input by a user and a pet image to be processed, wherein the first text indicates requirements to be met by a generated target pet image, and the pet image to be processed includes a target pet used to generate the target pet image;

[0177] An input unit 802 is used to input the first text into an image generation model, and input the image features of the to-be-processed pet image into a pre-trained first plug-in of the image generation model, wherein the first plug-in is used to process the image features, and the image generation model is used to interact with the first plug-in and process the text input into the image generation model to generate the target pet image;

[0178] The output unit 803 is used to obtain and output the target pet image output by the image generation model.

[0179] Optionally, the first plug-in includes:

[0180] A pet head portrait plug-in, and / or a pet full-body portrait plug-in, wherein the image features of the pet image to be processed include head portrait features and / or full-body portrait features;

[0181] The pet avatar plug-in is used to process the avatar features of the target pet;

[0182] The pet full-body image plug-in is used to process the full-body image features of the target pet.

[0183] Optionally, the pet avatar plug-in is trained in the following way:

[0184] The pet avatar plug-in is trained using a first training image, a description text of the first training image, and a first sub-image of the first training image, wherein the first training image serves as a training label, and the first sub-image includes: a head image of the first training image, or a head segmentation of the first training image, and the first training image is an image including a pet.

[0185] Optionally, the pet full-body image plug-in is trained in the following manner:

[0186] The pet full-body image plug-in is trained using a second training image, a description text of the second training image, and a second sub-image of the second training image, wherein the second training image serves as a training label, and the second sub-image includes: a full-body image of the second training image, or a full-body segmentation of the second training image, and the second training image is an image including a pet.

[0187] Optionally, the pet head portrait plug-in and the pet full body portrait plug-in are trained in the following manner:

[0188] The pet avatar plug-in and the pet full-body avatar plug-in are trained using a third training image, a description text of the third training image, and a third sub-image of the third training image, wherein the third training image serves as a training label, and the third sub-image includes: a full-body image of the third training image, or a full-body segmentation of the third training image, or a head image of the third training image, or a head segmentation of the third training image, and the third training image is an image including a pet.

[0189] Optionally, the device further comprises:

[0190] A first determination unit, configured to identify the pet image to be processed and determine the breed of the target pet;

[0191] A supplementing unit, configured to supplement the first text based on the breed of the target pet to obtain a second text;

[0192] The input unit 802 is used to:

[0193] The second text obtained by supplementing the first text is input into the image generation model.

[0194] Optionally, the device further comprises:

[0195] A second acquisition unit, configured to acquire an image style selected by a user, and determine a second plug-in corresponding to the image style, wherein the second plug-in is configured to control the style of the target pet image;

[0196] When generating the target pet image, the image generation model is also used to interact with the second plug-in to generate the target pet image.

[0197] Optionally, the device further comprises:

[0198] The second determining unit is used to determine that the pet image to be processed does not include a human face before inputting the first text into the image generation model and inputting the image features of the pet image to be processed into the first plug-in of the image generation model.

[0199] Optionally, the pet image to be processed is a single pet image.

[0200] Since the device 800 is a device corresponding to the pet image generation method provided by the above method embodiment, the specific implementation of each unit of the device 800 is the same concept as the above method embodiment. Therefore, regarding the specific implementation of each unit of the device 800, please refer to the relevant description part of the above method embodiment, which will not be repeated here.

[0201] The embodiment of the present application also provides an electronic device, the electronic device comprising a processor and a memory;

[0202] The processor is used to execute the instructions stored in the memory, so that the device executes the pet image generation method provided by the above method embodiment.

[0203] An embodiment of the present application provides a computer-readable storage medium, including instructions, wherein the instructions instruct a device to execute the pet image generation method provided in the above method embodiment.

[0204] The embodiment of the present application also provides a computer program product. When the computer program product is run on a computer, the computer executes the pet image generation method provided by the above method embodiment.

[0205] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the invention disclosed herein. The present application is intended to cover any modification, use or adaptation of the present application, which follows the general principles of the present application and includes common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present application are indicated by the following claims.

[0206] It should be understood that the present application is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.

[0207] The above description is only a preferred embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application should be included in the protection scope of the present application.

Claims

1. A method for generating a pet image, characterized in that: The method comprises: Acquire a first text input by a user and a pet image to be processed, wherein the first text indicates requirements to be met by a generated target pet image, and the pet image to be processed includes a target pet used to generate the target pet image; Inputting the first text into an image generation model, and inputting the image features of the to-be-processed pet image into a first plug-in of the image generation model that is pre-trained, wherein the first plug-in is used to process the image features, and the image generation model is used to interact with the first plug-in and process the text input into the image generation model to generate the target pet image; Acquire and output the target pet image output by the image generation model.

2. The method according to claim 1, characterized in that The first plug-in includes: A pet head portrait plug-in, and / or a pet full-body portrait plug-in, wherein the image features of the pet image to be processed include head portrait features and / or full-body portrait features; The pet avatar plug-in is used to process the avatar features of the target pet; The pet full-body image plug-in is used to process the full-body image features of the target pet.

3. The method according to claim 2, characterized in that The pet avatar plug-in is trained in the following way: The pet avatar plug-in is trained using a first training image, a description text of the first training image, and a first sub-image of the first training image, wherein the first training image serves as a training label, and the first sub-image includes: a head image of the first training image, or a head segmentation of the first training image, and the first training image is an image including a pet.

4. The method according to claim 2, characterized in that: The pet full-body image plug-in is trained in the following way: The pet full-body image plug-in is trained using a second training image, a description text of the second training image, and a second sub-image of the second training image, wherein the second training image serves as a training label, and the second sub-image includes: a full-body image of the second training image, or a full-body segmentation of the second training image, and the second training image is an image including a pet.

5. The method according to claim 2, characterized in that: The pet head portrait plug-in and the pet full body portrait plug-in are trained in the following way: The pet avatar plug-in and the pet full-body avatar plug-in are trained using a third training image, a description text of the third training image, and a third sub-image of the third training image, wherein the third training image serves as a training label, and the third sub-image includes: a full-body image of the third training image, or a full-body segmentation of the third training image, or a head image of the third training image, or a head segmentation of the third training image, and the third training image is an image including a pet.

6. The method according to claim 1, characterized in that The method further comprises: Identify the pet image to be processed and determine the breed of the target pet; Supplementing the first text based on the breed of the target pet to obtain a second text; The step of inputting the first text into an image generation model comprises: The second text obtained by supplementing the first text is input into the image generation model.

7. The method according to claim 1, characterized in that The method further comprises: Acquire an image style selected by a user, and determine a second plug-in corresponding to the image style, where the second plug-in is used to control the style of the target pet image; When generating the target pet image, the image generation model is also used to interact with the second plug-in to generate the target pet image.

8. The method according to claim 1, characterized in that Before inputting the first text into the image generation model and inputting the image features of the to-be-processed pet image into the first plug-in of the image generation model, the method further includes: It is determined that the pet image to be processed does not include a human face.

9. The method according to claim 1, characterized in that: The pet image to be processed is a single pet image.

10. A pet image generating device, characterized in that: The device comprises: A first acquisition unit is used to acquire a first text input by a user and a pet image to be processed, wherein the first text indicates requirements to be met by the generated target pet image, and the pet image to be processed includes a target pet used to generate the target pet image; An input unit, used for inputting the first text into an image generation model, and inputting the image features of the to-be-processed pet image into a first plug-in of the image generation model that is pre-trained, the first plug-in being used for processing the image features, the image generation model being used for interacting with the first plug-in and processing the text input into the image generation model to generate the target pet image; An output unit is used to obtain and output the target pet image output by the image generation model.

11. An electronic device, characterized in that: The device comprises a processor and a memory; The processor is configured to execute instructions stored in the memory so that the device executes the method according to any one of claims 1 to 9.

12. A computer-readable storage medium, characterized in that: The method comprises instructions, wherein the instructions instruct the device to execute the method according to any one of claims 1 to 9.

Citation Information

Cited By

  • Data processing method and device

    CN119888281A