Image generation method and device, electronic equipment and storage medium
By segmenting the original image with object and background and using the target prompt word to guide the image generation model to generate target objects and background images, the problem of object features errors in the graph generation operation is solved, and the accuracy and effect of the generated image are improved.
Patent Information
- Application Number
- CN202411703192.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-26
- Publication Date
- 2025-03-18
AI Technical Summary
In the graph-general application of generative artificial intelligence, when the target image achieved by prompt words corresponding to user needs contains objects in the original image, object features errors are prone to occur, resulting in low accuracy and poor effect of generated images.
By segmenting the original image with the object and the background, the first object image and the first background image are obtained, the target object in the first object image is characterized, the target prompt word is constructed, and the first object image is inputted to the image generation model to perform the graph generation operation to obtain the second object image; at the same time, the original prompt word and the first background image are input to the image generation model to generate the second background image, and the target image is finally synthesized based on the second object image and the second background image.
In this way, it is ensured that the features of the target object remain accurate in the generated image, thereby improving the accuracy and effect of the target image.
Smart Images

Figure CN119648855A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence technology, and specifically to an image generation method, device, electronic device and storage medium. Background Art
[0002] In the image-generating application of generative artificial intelligence, users need to upload an original image, and then use the generative model to generate a target image that matches the content of the original image and meets user needs, such as generating a target image of a specific style, or generating a high-resolution target image.
[0003] However, under the current technical solution, the target image generated by the generative model is realized by prompts corresponding to user needs. However, when the original image is converted into the target image by prompts, in the case of scenes containing objects in the original image, the features of the object may be wrong, resulting in low precision and poor effect of the generated image. Summary of the invention
[0004] The embodiments of the present application provide an image generation method, device, electronic device and storage medium, which can avoid the erroneous generation of object features in image-to-image operations and improve the effect and accuracy of the generated image.
[0005] In a first aspect, an embodiment of the present application provides an image generation method, comprising:
[0006] Segmenting the original image into an object and a background to obtain a first object image and a first background image;
[0007] Performing feature detection on a target object in the first object image to obtain a target feature of the target object;
[0008] Based on the target feature and the original prompt word, construct a target prompt word, wherein the target prompt word includes text for describing the target feature;
[0009] Inputting the target prompt word and the first object image into an image generation model to perform an image-to-image operation on the first object image to obtain a second object image;
[0010] Inputting the original prompt word and the first background image into the image generation model to perform an image-to-image operation on the first background image to obtain a second background image;
[0011] A target image is obtained based on the second object image and the second background image.
[0012] In a second aspect, an embodiment of the present application provides an image generating device, including: an acquisition unit and a processing unit;
[0013] The acquisition unit is used to acquire the original image;
[0014] The processing unit is used to segment the object and background of the original image to obtain a first object image and a first background image; perform feature detection on the target object in the first object image to obtain the target feature of the target object; construct a target prompt word based on the target feature and the original prompt word, wherein the target prompt word includes a text for describing the target feature; input the target prompt word and the first object image into an image generation model to perform an image-to-image operation on the first object image to obtain a second object image; input the original prompt word and the first background image into the image generation model to perform an image-to-image operation on the first background image to obtain a second background image; and obtain a target image based on the second object image and the second background image.
[0015] In a third aspect, an embodiment of the present application provides an electronic device, comprising: a processor and a memory, wherein the processor is connected to the memory, the memory is used to store a computer program, and the processor is used to execute the computer program stored in the memory, so that the electronic device performs the method described in the first aspect.
[0016] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and the computer program enables a computer to execute the method described in the first aspect.
[0017] In a fifth aspect, an embodiment of the present application provides a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program, and the computer is operable to cause the computer to execute the method described in the first aspect.
[0018] Implementing the embodiments of the present application has the following beneficial effects:
[0019] It can be seen that in the embodiment of the present application, when performing the image-to-image operation on the original image, the original image is first segmented into an object and a background to obtain a first object image and a first background image, and then the target object in the first object image is detected to obtain the target feature of the target object. Then, based on the target feature, a target prompt word corresponding to the target feature is constructed, and the image-to-image operation is performed on the first object image alone using the target prompt word to obtain the second object image. Since the target prompt word containing the target feature is used as a guide, the image-to-image operation is performed on the first target object image alone, and the target feature of the target object in the generated second object image will not be wrong; and the image-to-image operation is performed on the first background image alone to obtain the second background image. Finally, based on the second object image and the second background image, the target image is obtained. Since the second object image and the second background image are both generated through image-to-image operations, the target image is also obtained through image-to-image operations. Since the features of the target object in the second object image are the same as those in the first target object image and no errors will occur, the features of the target object in the target image will also not be wrong. This ensures the accuracy of the features of the target object when the original image is subjected to image-to-image operations to generate the target image, thereby improving the accuracy and effect of the target image. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0021] Figure 1 A schematic diagram of an image generation system provided in an embodiment of the present application;
[0022] Figure 2 A schematic diagram of a scene for image generation provided in an embodiment of the present application;
[0023] Figure 3 A schematic diagram of another scene of image generation provided in an embodiment of the present application;
[0024] Figure 4 A schematic diagram of a stylized model provided in an embodiment of the present application;
[0025] Figure 5 A schematic diagram of a flow chart of an image generation method provided in an embodiment of the present application;
[0026] Figure 6 A schematic diagram of segmenting a human body and a background provided in an embodiment of the present application;
[0027] Figure 7 A schematic diagram of stylizing a first human image and a first background image provided in an embodiment of the present application;
[0028] Figure 8 A schematic diagram of an image generation model provided in an embodiment of the present application;
[0029] Fig. 9 A schematic diagram of fusing a second human image and a second background image provided in an embodiment of the present application;
[0030] Fig.10 A schematic diagram of stylizing an intermediate image provided in an embodiment of the present application;
[0031] Fig.11 A schematic diagram of an image generating device provided in an embodiment of the present application;
[0032] Fig.12 A schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0033] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are 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.
[0034] The terms "first", "second", "third" and "fourth" etc. in the specification and claims of the present application and the drawings are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but optionally includes steps or units that are not listed, or optionally includes other steps or units inherent to these processes, methods, products or devices.
[0035] Reference to "embodiments" herein means that a particular feature, result, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0036] First, the target object mentioned in this application can be any type of object, for example, the target object can be a person (mainly a physical person or a natural person or a real person), a digital person, a robot, an animal, etc. Secondly, the target feature of the target object involved in this application can be any feature of the target object, such as the gender feature, facial features, skin color feature and body shape feature of the target object, etc., wherein the facial features include but are not limited to: nose feature, left eye feature, right eye feature and mouth feature. For the sake of ease of description, this application mainly takes the target object as a person as an example, and the target feature is the gender of the person as an example for illustration. Therefore, the target objects involved in the following can all be understood as people, and the target features can all be understood as gender, but the target objects and target features are not limited. Correspondingly, the object images involved in the following can be understood as human images, and the two are similar in nature and can be distinguished.
[0037] It should be noted that the image-generating operation involved in this application can be any one of a variety of image-generating operations, wherein the various image-generating operations include but are not limited to: stylization operation, super-resolution operation, image restoration operation, image beautification operation, and the like. The stylization operation is to convert the style of the original image into a target style, and the target style can be set by the user or automatically determined based on the original image, and this application does not limit this. Furthermore, the target style can be any one of various styles such as anime style, Korean style, futuristic style, minimalist style, etc. The super-resolution operation is to convert the resolution of the original image into a super-resolution, that is, the resolution of the converted target image is greater than the resolution threshold; the image restoration operation is to repair defects in the original image, such as repairing blinking or closing eyes, and the like. The image beautification operation is to beautify the original image, such as removing interference factors such as raindrops and fog in the original image, and the like. It can be understood that each image-generating operation is implemented by a model corresponding to the image-generating operation, and for the sake of distinction, the model corresponding to the stylized operation can be called a stylized model, the model corresponding to the super-resolution operation can be called a super-resolution model, the model corresponding to the image restoration operation can be called an image restoration model, and so on. Finally, for the sake of ease of understanding, this application mainly takes the image-generating operation as a stylized operation, and accordingly, the model corresponding to the image-generating operation is explained using the stylized model as an example. Therefore, the subsequent mention of performing image-generating operations on images can be understood as stylizing the image. However, this application does not limit image-generating operations.
[0038] See also Figure 1 , Figure 1 Schematic diagram of an image generation system provided in an embodiment of the present application. Figure 1 As shown, the image generation system includes a client 10 and an image generation device 20 .
[0039] like Figure 1 As shown, the client 10 obtains the original image. For example, the user can upload the original image to the client 10 by clicking the upload button "+". Then, the client 10 uploads the original image to the image generation device 20, and requests the image generation device 20 to perform an image-to-image operation on the original image. Accordingly, after receiving the original image, the image generation device 20 will segment the original image into an object and a background to obtain a first object image and a first background image; perform feature detection on the target object in the first object image to obtain a target feature of the target object; construct a target prompt word based on the target feature and the original prompt word, wherein the target prompt word includes a text for describing the target feature. Then, the target prompt word and the first object image are input into the image generation model to perform an image-to-image operation on the first object image to obtain a second object image; the original prompt word and the first background image are input into the image generation model to perform an image-to-image operation on the first background image to obtain a second background image; and the target image is obtained based on the second object image and the second background image. Finally, the image generating device 20 returns the target image to the client 10, so that the client 10 can display the target image on the display interface.
[0040] See also Figure 2 , Figure 2 A schematic diagram of a scene for image generation provided in an embodiment of the present application.
[0041] like Figure 2 As shown, the user uploads the original image on the client, and then the client displays a variety of image generation operations, such as: Figure 2 Stylization, super-resolution, and so on are shown. This application is mainly explained by taking stylization operation as an example. Accordingly, in order to support a variety of image-generating operations, a model library is maintained on the image generation device side, in which models corresponding to each image-generating operation are deployed, such as a stylization model corresponding to a stylization operation and a super-resolution model corresponding to a super-resolution operation. Then, the user can select the corresponding image-generating operation on the client. After selecting the corresponding image-generating operation, the original image will be sent to the image generation device, and the image generation device will be requested to perform the image-generating operation selected by the user on the original image.
[0042] Furthermore, if the image generation operation selected by the user is a stylized operation, a variety of style selection boxes will pop up on the client, such as Figure 2The style shown in the stylized model is anime style, Korean style, futuristic style, simple style, etc. Then, the user can select a target style to convert the style of the original image to the target style selected by the user. Then, the client can send the original image and the target style selected by the user to the image generation device. Correspondingly, the image generation device determines the original prompt word based on the target style, and finally inputs the original prompt word and the original image into the stylized model, and converts the style of the original image into the target style through the stylized model to obtain the target image.
[0043] Going a step further, Figure 3 As shown, the above-mentioned multiple graph-to-graph operations can be implemented through multiple servers, wherein each server is used to implement a graph-to-graph operation. Exemplarily, the models corresponding to the graph-to-graph operations are deployed to multiple servers respectively, such as Figure 3 As shown, a stylization model and a super-resolution model are deployed on server 1 and server 2, respectively, so server 1 and server 2 can implement stylization and super-resolution, respectively. Therefore, when the user chooses to perform a stylization operation on the original image on the client, the image generation device can send a stylization request to server 1, wherein the stylization request includes the original image and the original prompt words corresponding to the target style, and the stylization request is used to request server 1 to convert the style of the original image into the target style. Accordingly, after receiving the stylization request, server 1 can call the stylization model to stylize the original image, so as to convert the style of the original image into the target style and obtain the target image.
[0044] Combine the following Figure 4 , introducing the process of stylizing the original image through a stylized model in this application.
[0045] like Figure 4 As shown, the stylization model includes an object segmentation model, a feature detection model and an image generation model.
[0046] Exemplarily, the original image is first input into an object segmentation model to segment the original image into an object and a background, thereby obtaining a first object image and a first background image; then, the first object image is input into a feature detection model to perform feature detection on a target object in the first object image, thereby obtaining a target feature of the target object. Furthermore, based on the target feature and the original prompt word, a target prompt word is constructed, wherein the target prompt word includes text for describing the target feature. Then, the first object image and the target prompt word are input into an image generation model, an image generation operation is performed on the first object image to perform stylization, thereby obtaining a second object image; and the first background image and the original prompt word are input into the image generation model to perform stylization on the first background image, thereby obtaining a second background image.
[0047] Finally, a target image is obtained based on the second object image and the second background image.
[0048] See also Figure 5 , Figure 5 A flowchart of an image generation method provided in an embodiment of the present application is provided. The method is applied to the above-mentioned image generation device. The method includes but is not limited to the following steps:
[0049] 501: Segment the original image into an object and a background to obtain a first object image and a first background image.
[0050] Exemplarily, first, the image generating device obtains an original image from a client, and then performs object segmentation on the original image.
[0051] Specifically, the image generating device segments the object and the background of the original image to obtain a mask corresponding to the target object and a mask corresponding to the background. Then, based on the mask of the target object, the original image is segmented to obtain a first object image, that is, the mask of the target object is multiplied with the original image to obtain the first object image; based on the mask of the background, the original image is segmented to obtain a first background image, that is, the original image and the mask of the background are multiplied to obtain the first background image.
[0052] It can be understood that if there are multiple target objects in the original image, a first object image can be segmented separately for each target object, and then feature detection and image-to-image operation are performed separately for each first object image. The entire processing process is similar to the processing process of the first object image in this application and will not be described again. This application is mainly explained by taking the example of an original image with one target object.
[0053] The following takes the target object being a person as an example to illustrate the process of segmenting the original image.
[0054] like Figure 6 As shown, the original image is segmented to obtain a mask image of human body 1, a mask image of human body 2, and a mask image of the background. Then, the mask image of human body 1, the mask image of human body 2, and the mask image of the background are multiplied with the original image respectively to obtain a first human body image (i.e., a first object image) of human body 1, a first human body image (i.e., a first object image) of human body 2, and a first background image.
[0055] 502: Perform feature detection on a target object in the first object image to obtain target features of the target object.
[0056] Exemplarily, feature extraction is performed on the first object image to obtain a first feature map; feature detection is performed based on the first feature map to obtain target features of the target object. For example, the first object image can be input into a feature detection model for feature detection to obtain target features of the target object.
[0057] 503: construct a target prompt word based on the target feature and the original prompt word, wherein the target prompt word includes text for describing the target feature.
[0058] The original prompt word is used to indicate that the style of the image is converted to the target style. Optionally, the original prompt word is a prompt word input by the user. For example, when performing style conversion on the original image, the user can input a prompt word to convert the style of the original image to the target style; or, optionally, the original prompt word is pre-configured, for example, a corresponding prompt word is pre-configured for each image-to-image operation, and different prompt words are configured for different target styles. For example, if the target style is anime style, the original prompt word is "Convert the style of this image to anime style"; for futuristic style, the original prompt word can be "Convert the style of this image to a futuristic style"; for minimalist style, the preset prompt can be "Convert the style of this image to minimalist style". In this way, when the user selects an image-to-image operation, the prompt word corresponding to the image-to-image operation can be obtained, and the prompt word is used as the original prompt word.
[0059] Further, after obtaining the target feature, a feature prompt word corresponding to the target feature can be obtained, wherein the feature prompt word includes a text for describing the target feature, for example, the text for describing the target feature is obtained, and the text is used as the feature prompt word. For example, if the target feature is a gender feature, if the gender of the target object is male, the feature prompt word can be a man, and if the target feature is female, the feature prompt word can be a girl. Then, the feature prompt word is spliced with the original prompt word to obtain the target prompt word.
[0060] For example, if the target feature is a male and the original prompt word is "Convert the style of this image to anime style", then the target prompt word is: "Convert the style of this image to anime style; a man". Then, when the image-to-image operation is performed on the first object image, the style of the first object image is converted to anime style through the target prompt word, and the gender of the target object in the first object image is prompted to be male.
[0061] It should be noted that when the target feature includes two or more features, feature prompt words corresponding to each feature can be constructed respectively, and then the feature prompt words corresponding to each feature are concatenated with the original prompt words to obtain the target prompt words. For example, when the target feature includes gender features and facial features, feature prompt words corresponding to gender and feature prompt words corresponding to facial features are constructed respectively, and then the feature prompt words corresponding to gender and feature prompt words corresponding to facial features are concatenated with the original prompt words to obtain the target prompt words.
[0062] In one embodiment of the present application, before the feature prompt word corresponding to the target feature is concatenated with the original prompt word, it is first determined whether the original prompt word contains text related to the target feature.
[0063] Optionally, if it is included, the text is directly deleted, and the original prompt word after deleting the text is concatenated with the feature prompt word to obtain the target prompt word. For example, if the target feature is a gender feature, and the original prompt word contains text for describing gender, the text for describing gender in the original prompt word is directly deleted, and the prompt word after deleting the text for describing gender is concatenated with the feature prompt word to obtain the target prompt word, thereby avoiding the interference and influence of the text in the original prompt word on the image generation process, and ensuring that the target prompt word can guide the model not to generate incorrect target features; if it is not included, the original prompt word is directly concatenated with the feature prompt word to obtain the target prompt word.
[0064] Optionally, if included, first determine whether the feature described by the text is the same as the target feature. If they are the same, the original prompt word and the feature prompt word can be spliced to obtain the target prompt word. In this way, the target prompt word has two parts of text used to describe the target feature, thereby highlighting the importance of the target feature, allowing the model to pay more attention to the target feature, and further avoiding target feature errors; if they are not the same, delete the original prompt word and the text related to the target feature, and splice the original prompt word after deleting the text with the feature prompt word to obtain the target prompt word, thereby avoiding the interference and influence of the text in the original prompt word on the image generation process, and ensuring that the target prompt word can guide the model not to generate incorrect target features. For example, when the target feature is male, if the gender-related text in the original prompt word is female, the text is deleted, and the target feature is indicated as male through the feature prompt word, avoiding the incorrect guidance of the gender-related text in the original prompt word; if the gender-related text in the original prompt word is male, it means that the gender indicated in the original prompt word is consistent with the gender indicated by the feature prompt word, then the feature prompt word can be directly spliced with the original prompt word to emphasize that the gender of the target object is male, so that the features after style conversion are also in line with male characteristics, avoiding errors in the target features.
[0065] 504: Input the target prompt word and the first object image into an image generation model to perform an image-to-image operation on the first object image to obtain a second object image.
[0066] Exemplarily, based on the target prompt word, an image-to-image operation is performed on the first object image to obtain the second object image.
[0067] Exemplarily, the target prompt word and the first object image may be input into an image generation model to perform an image-to-image operation on the first object image to obtain a second target object image.
[0068] For example, if Figure 7 As shown, the target prompt word of human body 1 and the first human body image of human body 1 can be input into the image generation model to obtain the second human body image of human body 1, and the target prompt word of human body 2 and the first human body image of human body 2 can be input into the image generation model to obtain the second human body image of human body 2.
[0069] Optionally, in one embodiment of the present application, the denoising step number of the first object image in the image generation model is controlled to be the second target denoising step number. Specifically, when the first object image is input into the image generation model, noise is first added to the first object image to obtain a second noise image. Exemplarily, a second target denoising step number S2 corresponding to the original image is obtained, and based on the second target denoising step number and the target prompt word, an image-to-image operation is performed on the second noise image to obtain the second object image. Specifically, the second target denoising step number can be understood as the number of steps for adding noise to the first object image, so the number of steps for adding noise to the first object image can be controlled to be the second target denoising step number S2 to obtain a second noise image. In addition, in order to denoise the first person image in a high-dimensional space and reduce the dimension of the feature, the present application adds noise to the first object image, which essentially can first perform feature extraction on the first object image to obtain a first feature map, and then add noise of step S2 to the first feature map to obtain a second noise image. Finally, based on the second target denoising step number and the target prompt word, an image-to-image operation is performed on the second noise image, that is, the second noise image is denoised in step S2 to obtain a second object image, that is, the second noise image and the target prompt word are used as input data of the image generation model, and the second noise image is denoised in step S2 to obtain a second object image.
[0070] Optionally, the image generation model may be a diffusion model.
[0071] In one embodiment of the present application, since the facial features include not only some surface features, such as the size of the nose, the color of the eyes, etc., but also include the structural features between the facial features, such as the relative position and distance between the facial features, these features are difficult to describe through feature prompt words. Therefore, in order to ensure the refinement of the facial features, facial feature images can also be segmented, and the facial feature images can be used to perform fine control over the image generation operation process.
[0072] Exemplarily, before denoising the second noise image, the first object image may be segmented into facial features to obtain a facial feature image, wherein the facial feature image may be multiple images of multiple facial features, and this application mainly takes a facial feature image as an example. For example, a facial feature mask image is obtained, and the facial features of the first object image are segmented based on the facial feature mask image to obtain a facial feature image.
[0073] Then, feature extraction is performed on the facial features image to obtain target facial features corresponding to the facial features image. Exemplarily, feature extraction is performed on the facial features image to obtain initial facial features; the position information of the facial features in the facial features image in the target object image is obtained, wherein the position information is the relative position information of the facial features in the target object. For example, the first object image is gridded to obtain multiple gridded areas, then the gridded areas where the facial features are located are obtained, and the position coordinates of the gridded areas are used as the position information of the facial features in the target object image. The position information is encoded to obtain position features, wherein the position features are position vectors, and the position vectors are used to indicate the positions of the facial features in the target object image; the initial facial features and the position features are fused to obtain the target facial features, that is, the position features are superimposed on the initial facial features to obtain the target facial features, for example, the position features are copied, and the multiple copied position features are respectively superimposed on each column of the initial facial features to obtain the target facial features.
[0074] It can be seen that in the embodiment of the present application, when constructing the facial features, the position information of the facial features in the target object is also integrated. In this way, when the facial features are used to stylize the target object, the model can be instructed to denoise the features of the area indicated by the position information into features corresponding to the initial facial features, thereby ensuring the consistency of the facial features during the stylization process, avoiding errors in the facial features, and further improving the accuracy and effect of stylizing the image.
[0075] Then, the target facial features, the target prompt word and the first object image are input into the image generation model to perform an image-to-image operation on the first object image to obtain a second object image. Specifically, similarly, firstly, S2 step noise is added to the first object image to obtain a second noise image. Then, based on the second target denoising step number, the target facial features and the target prompt word, an image-to-image operation is performed on the second noise image to obtain the second object image, that is, based on the target facial features and the target prompt word, S2 step denoising is performed on the second noise image to obtain the second object image.
[0076] The following describes the process of performing an image-to-image operation on a first object image using a facial feature image in conjunction with the model structure of the image generation model.
[0077] like Figure 8 As shown, the image generation model includes a diffusion model, a style control module and a feature control module. The diffusion model includes a coding layer, a feature extraction layer and a decoding layer. It should be noted that different style control modules can be used for different styles, that is, each style can correspond to a style control module. Figure 8The style control module shown is a style control module corresponding to the target style. Of course, all styles can also use the same style control module, and this application does not limit the type of style control module. Therefore, the image generation device can denoise the second noise image through the diffusion model and the style control module, and control the denoising step number to S2 to obtain the second object image.
[0078] Specifically, the target prompt word is first encoded to obtain the first text feature; then, in the i-th denoising process, the noise image i-1 is encoded to obtain the first image feature i, that is, the noise image is encoded through the encoding layer to obtain the first image feature i, wherein the noise image is the noise image obtained after the i-1th denoising, and when i=1, the noise image i-1 is the second noise image; the first image feature i and the first text feature are fused to obtain the first intermediate feature i, that is, the first image feature i and the first text feature are cross-attention fused to obtain the first intermediate feature i. More specifically, the weight matrix during the cross-attention fusion is adjusted through the style control module to obtain the target weight matrix, and the first image feature i and the first text feature are cross-attention fused through the target weight matrix to obtain the first intermediate feature i.
[0079] Then, feature extraction is performed on the first intermediate feature i to obtain the second intermediate feature i, that is, feature extraction is performed on the first intermediate feature i through the feature extraction layer to obtain the second intermediate feature i.
[0080] Then, the second intermediate feature i, the first text feature and the facial features are fused to obtain a third intermediate feature i. Exemplarily, the third intermediate feature i is obtained by first cross-attention fusion of the second intermediate feature i and the first text feature, and then the result of the cross-attention fusion is fused with the facial features through a feature control module, wherein the cross-attention fusion of the second intermediate feature i and the first text feature is similar to the process of cross-attention fusion of the first image feature i and the first text feature, which will not be described again.
[0081] Furthermore, the third intermediate feature i is decoded to obtain a fourth intermediate feature i; the fourth intermediate feature i, the first text feature and the facial features are fused to obtain a noise image i corresponding to the i-th denoising. For example, the fourth intermediate feature i and the first text feature are cross-attention fused, and then the result of the cross-attention fusion is fused with the facial features through a feature control module to obtain a noise image i, wherein the cross-attention fusion of the fourth intermediate feature i and the first text feature is similar to the above-mentioned process of cross-attention fusion of the first image feature i and the first text feature, and will not be described again.
[0082] Finally, the i+1th denoising is performed based on the noise image i until the denoising step number reaches the second target denoising step number, then the denoising of the second noise is stopped to obtain the second object image, that is, when the denoising step number reaches the second target denoising step number, the denoised image at this time is decoded to obtain the second object image.
[0083] 505: Input the original prompt word and the first background image into the image generation model to perform an image-to-image operation on the first background image to obtain a second background image.
[0084] Likewise, if Figure 7 As shown, the original prompt word and the first background image are input into the image generation model, and an image-to-image operation is performed on the first background image, that is, the first background image is stylized to obtain a second background image.
[0085] Specifically, based on the second target denoising step number, noise is added to the first background image to obtain a third noisy image. Similarly, the second target denoising step number is used as the denoising step number to add noise to the first background image to obtain a third noisy image. Then, based on the original prompt word and the second target denoising step number, an image-to-image operation is performed on the third noisy image to obtain the second background image, that is, based on the original prompt word, the third noisy image is denoised (i.e., stylized), and the denoising step number is controlled to be the second target denoising step number to obtain the second background image.
[0086] 506: Obtain a target image based on the second object image and the second background image.
[0087] Exemplarily, the second object image and the second background image are fused to obtain a target image.
[0088] Exemplarily, the second object image is segmented based on the mask image of the target object to obtain the third object image, that is, the mask image of the target object is multiplied with the second object image to obtain the third object image. The second background image is segmented based on the mask image of the background to obtain the third background image, that is, the mask image of the background is multiplied with the third background image to obtain the third background image. Finally, the target image is obtained based on the third object image and the third background image.
[0089] Optionally, the third object image and the third background image are fused to obtain a target image, that is, the third object image and the third background image are directly fused to obtain the target image.
[0090] It should be noted that since the second object image and the second background image are generated twice independently, although the styles of the second object image and the second background image are both the target style, the second object image and the second background image are not coordinated in color and tone. Therefore, directly hard fusion of the third object image and the third background image will result in an image that is not coordinated in color and tone. Therefore, it is necessary to perform the image-to-image operation again to obtain a target image with coordinated color and tone. Optionally, the third object image and the third background image are fused to obtain an intermediate image; the image-to-image operation is performed on the intermediate image to obtain the target image, that is, the intermediate image and the initial prompt word are input into the image generation model to perform the image-to-image operation on the intermediate image to obtain the target image.
[0091] Exemplarily, the denoising step number of the intermediate image in the image generation model is controlled to be a first target denoising step number, wherein the first target denoising step number is less than the second target denoising step number, and the sum of the first target denoising step number and the second target denoising step number is the standard denoising step number of the image generation model. It should be noted that the denoising step number of the intermediate image in the image generation model is controlled to be the first target denoising step number, that is, the denoising step number in the re-denoising process is controlled to be relatively small, thereby reducing the randomness in the re-denoising process and preventing the randomness of the re-generation process from causing the problem of target feature generation errors. Among them, the sum of the first target denoising step number and the second target denoising step number is the standard denoising step number for the image generation model of this application to perform image-to-image operations, which can also be understood as the total denoising step number for stylizing the image. That is, the present application splits the image stylization process into two implementations. The first stylization process mainly allows the image generation model to convert the style of the image into the target style. Therefore, the second target denoising step number is designed to be relatively large, giving the image generation model more denoising opportunities, so that the image style can be successfully converted into the target style. However, the second stylization process is mainly to fine-tune the color and tone of the intermediate image, which does not require too many denoising times, so the first target denoising step number is designed to be relatively small.
[0092] Therefore, based on the first target denoising step number, noise is added to the intermediate image to obtain a first noisy image, that is, the first target denoising step number is used as the denoising step number, noise is added to the intermediate image to obtain a first noisy image; then, based on the first target denoising step number and the original prompt word, an image-to-image operation is performed on the first noisy image to obtain the target image. Based on the original prompt word, the first noisy image is denoised, and the denoising step number is controlled to be the first target denoising step number to obtain the target image.
[0093] For example, if Fig. 9 As shown, the mask image of human body 1 is multiplied by the second human body image of human body 1 to segment the second human body image of human body 1 and obtain the third human body image of human body 1. Similarly, the mask image of human body 2 is multiplied by the second human body image of human body 2 to segment the second human body image of human body 2 and obtain the third human body image of human body 2; and the mask image of the background is multiplied by the second background image to obtain the third background image. Finally, the third human body image of human body 1, the third human body image of human body 2 and the third background image are fused to obtain an intermediate image. Then, as Fig.10 As shown, the intermediate image and the original prompt word are input into the image generation model, and an image-to-image operation is performed on the intermediate image, that is, a stylized image is performed to obtain the target image.
[0094] It can be seen that in the embodiment of the present application, when performing the image-to-image operation on the original image, the original image is first segmented into an object and a background to obtain a first object image and a first background image, and then the target object in the first object image is detected to obtain the target feature of the target object. Then, based on the target feature, a target prompt word corresponding to the target feature is constructed, and the image-to-image operation is performed on the first object image alone using the target prompt word to obtain the second object image. Since the target prompt word containing the target feature is used as a guide, the image-to-image operation is performed on the first target object image alone, and the target feature of the target object in the generated second object image will not be wrong; and the image-to-image operation is performed on the first background image alone to obtain the second background image. Finally, based on the second object image and the second background image, the target image is obtained. Since the second object image and the second background image are both generated through image-to-image operations, the target image is also obtained through image-to-image operations. Since the features of the target object in the second object image are the same as those in the first target object image and no errors will occur, the features of the target object in the target image will also not be wrong. This ensures the accuracy of the features of the target object when the original image is subjected to image-to-image operations to generate the target image, thereby improving the accuracy and effect of the target image.
[0095] In one embodiment of the present application, the first target denoising step number and the second target denoising step number can be set according to the complexity of the original image. Exemplarily, the complexity of the original image is determined based on the first object image and the first background image; the first target denoising step number and the second target denoising step number are determined based on the complexity, wherein the greater the complexity, the higher the second target denoising step number. For example, the mapping relationship between complexity and denoising step number is configured in advance, and then the second target denoising step number can be determined based on the complexity of the original image and the mapping relationship, and then the first target denoising step number can be determined based on the total denoising step number and the second target denoising step number. Wherein, when the first target denoising step number is used to stylize the intermediate image, at least the style of the target image is made to be the target style, when the second target denoising step number is used to stylize the first object image, at least the style of the second object image is made to be the target style, and when the second target denoising step number is used to stylize the first background image, at least the style of the second background image is made to be the target style.
[0096] It should be noted that the mapping relationship is different for complexities with different meanings. For example, if the complexity is content complexity, the mapping relationship is a mapping relationship corresponding to content complexity; if the complexity is color complexity, the mapping relationship is a mapping relationship corresponding to color complexity.
[0097] In one embodiment of the present application, the first content complexity of the first object image is determined based on the gray value of each pixel in the first object image. The second content complexity of the first background image is determined based on the gray value of each pixel in the first background image; the complexity of the original image can be determined based on the first content complexity and the second content complexity. For example, the maximum value of the first content complexity and the second content complexity can be used as the complexity of the original image; or the average value of the first content complexity and the second content complexity can be used as the complexity of the original image.
[0098] It can be understood that the higher the content complexity, the more features and image details there are in the original image. In the stylization process, it is more difficult to convert the image style into the target style, and more denoising is required to complete the stylization. Therefore, based on the content complexity of the image, the complexity of the original image is set. In this way, for the original image with higher content complexity, a larger second target denoising step number can be configured, thereby ensuring that the style of the original image can be successfully converted into the target style in the first stylization process, thereby ensuring the stylization of the original image.
[0099] In one embodiment of the present application, if the image-to-image operation is to convert the style of the original image into a target style, that is, to stylize the original image, then the first color complexity of the first object image can be determined based on the color value of each pixel of the first object image; and the second color complexity of the first background image can be determined based on the color value of each pixel of the first background image. The complexity of the original image is determined based on the first color complexity and the second color complexity. For example, the maximum value of the first color complexity and the second color complexity can be used as the complexity of the original image; or the average value of the first color complexity and the second color complexity can be used as the complexity of the original image.
[0100] It can be understood that the higher the color complexity, the greater the difference between the style of the original image and the target style, and the more difficult it is to convert the style of the image into the target style. More denoising steps are required to complete the stylization. Therefore, based on the color complexity, the complexity of the original image is set. In this way, for the original image with higher color complexity, a larger second target denoising step number can be configured, thereby ensuring that the style of the original image can be successfully converted into the target style in the first stylization process, thereby ensuring the stylization of the original image.
[0101] In one embodiment of the present application, if the image-to-image operation is to convert the style of the original image into a target style, the complexity of the original image can be comprehensively determined by combining the content complexity and the color complexity. Exemplarily, based on the gray value of each pixel of the first object image, the first content complexity of the first object image is determined; based on the gray value of each pixel of the first background image, the second content complexity of the first background image is determined; based on the color value of each pixel of the first object image, the first color complexity of the first object image is determined; based on the color value of each pixel of the first background image, the second color complexity of the first background image is determined; based on the first content complexity and the first color complexity, the first target complexity is determined. For example, the first content complexity and the first color complexity can be multiplied to obtain the first target complexity. Based on the second content complexity and the second color complexity, the second target complexity is determined. For example, the second content complexity and the second color complexity are multiplied to obtain the second target complexity. Finally, based on the first target complexity and the second target complexity, the complexity of the original image is determined. For example, the maximum value of the first target complexity and the second target complexity is taken as the complexity of the original image; or, the average value of the first target complexity and the second target complexity is taken as the complexity of the original image.
[0102] It can be seen that in the embodiment of the present application, the complexity of the original image can be based on the color complexity and content complexity. In this way, the complexity of the original image is more accurate, and the second target denoising step number set will be more accurate, which can meet the needs of color difference and content. It can better ensure that the style of the image can be successfully converted into the target style in the first stylization process, thereby ensuring the stylization of the original image.
[0103] The following describes how to determine the first content complexity and the first color complexity.
[0104] Exemplarily, based on each pixel of the first object image, the average grayscale value within a preset neighborhood of each pixel of the first object image is determined, wherein the preset neighborhood may be a 3*3 neighborhood, a 4*4 neighborhood, etc., so the grayscale value of any pixel other than the pixel in the preset neighborhood may be obtained, and then the grayscale values of the pixels other than the pixel in the preset neighborhood may be averaged to obtain the average grayscale value. The grayscale value of each pixel of the first object image and the average grayscale value corresponding to each pixel of the first object image are combined into a first two-dimensional group to obtain a plurality of first two-dimensional groups; for example, if the grayscale value of each pixel is i and the average grayscale value is j, then the two-dimensional group is (i, j). Based on the number of pixels of the first object image, the occurrence frequency of each first two-dimensional group is determined. Exemplarily, based on the two dimensions corresponding to each pixel, (i, j), the number of occurrences of each two-dimensional group (i, j) is counted, and the occurrence frequency of each two-dimensional group is determined based on the number of pixels of the first object image.
[0105] Exemplarily, the occurrence frequency of each two-dimensional group can be expressed by formula (1):
[0106]
[0107] Among them, P ij is the occurrence frequency of the two-dimensional group (i, j), f(i, j) is the number of occurrences of the two-dimensional group (i, j), and N is the number of pixels.
[0108] Then, based on the occurrence frequency of each two-dimensional group, the first content complexity of the first object image is determined. Exemplarily, the first content complexity of the first object image can be expressed by formula (2):
[0109]
[0110] Wherein, H is the first content complexity of the first object image.
[0111] It should be noted that the method for determining the second content complexity is similar to the method for determining the first content complexity and will not be described again.
[0112] Exemplarily, the color value of each pixel of the first object image is obtained, wherein the color value is the RGB pixel value of each pixel, and the RGB pixel value of each pixel is converted into the HSV color space to obtain the HSV value of each pixel in the HSV color space, wherein H represents hue, H represents saturation, and V represents value. Then, for the HSV value of each pixel in the HSV color space, the color distribution histogram of the first object image in the HSV dimension is determined respectively; the color distribution histogram in each dimension is normalized respectively to obtain the normalized color distribution histogram of the first object image in the HSV dimension; the normalized color distribution histogram of the target style in the HSV dimension is obtained; based on the normalized color distribution histogram of the first object image in the HSV dimension and the normalized color distribution histogram of the target style in the HSV dimension, the color similarity in the HSV dimension is determined respectively. For example, based on the normalized color distribution histogram of the first object image in H dimensions and the normalized color distribution histogram of the target style in H dimensions, the similarity of each bin in the normalized color distribution histogram of the target style is determined. For example, the distance between the two normalized color distribution histograms is used as the similarity. Specifically, the values of each bin in the normalized color distribution histogram of the first object image in H dimensions can be composed into a first vector, the values of each bin in the normalized color distribution histogram of the target style in H dimensions can be composed into a second vector, and the distance between the first vector and the second vector can be used as the distance between the two normalized color distribution histograms.
[0113] It should be noted that the method for determining the second color complexity is similar to the method for determining the first color complexity and will not be described again.
[0114] See also Fig.11 , Fig.11 A schematic diagram of an image generation device provided in an embodiment of the present application. The image generation device 1100 includes: an acquisition unit 1101 and a processing unit 1102, wherein:
[0115] An acquisition unit 1101 is used to acquire an original image;
[0116] The processing unit 1102 is used to segment the object and background of the original image to obtain a first object image and a first background image; perform feature detection on the target object in the first object image to obtain the target feature of the target object; construct a target prompt word based on the target feature and the original prompt word, wherein the target prompt word includes a text for describing the target feature; input the target prompt word and the first object image into an image generation model to perform an image-to-image operation on the first object image to obtain a second object image; input the original prompt word and the first background image into the image generation model to perform an image-to-image operation on the first background image to obtain a second background image; and obtain a target image based on the second object image and the second background image.
[0117] In one embodiment of the present application, in terms of obtaining a target image based on the second object image and the second background image, the processing unit 1102 is specifically configured to:
[0118] Segmenting the second object image based on the mask image of the target object to obtain a third object image;
[0119] Segmenting the second background image based on the background mask image to obtain a third background image;
[0120] The target image is obtained based on the third object image and the third background image.
[0121] In one embodiment of the present application, in fusing the third object image and the third background image to obtain the target image, the processing unit 1102 is specifically configured to:
[0122] fusing the third object image and the third background image to obtain an intermediate image;
[0123] The intermediate image and the initial prompt word are input into the image generation model to perform an image-to-image operation on the intermediate image to obtain the target image.
[0124] In one embodiment of the present application, the denoising step number of the intermediate image in the image generation model is a first target denoising step number; the denoising step number of the first object image in the image generation model is a second target denoising step number; wherein the first target denoising step number is less than the second target denoising step number, and the sum of the first target denoising step number and the second target denoising step number is a standard denoising step number for the image generation model to perform image-to-image operations.
[0125] In one embodiment of the present application, the processing unit 1102 is further configured to:
[0126] Determining the complexity of the original image based on the first object image and the first background image;
[0127] Based on the complexity, the first target denoising step number and the second target denoising step number are determined.
[0128] In one embodiment of the present application, in determining the complexity of the original image based on the first object image and the first background image, the processing unit 1102 is specifically configured to:
[0129] determining a first content complexity of the first object image based on a grayscale value of each pixel of the first object image;
[0130] determining a second content complexity of the first background image based on a grayscale value of each pixel of the first background image;
[0131] determining a first color complexity of the first object image based on a color value of each pixel of the first object image;
[0132] determining a second color complexity of the first background image based on a color value of each pixel of the first background image;
[0133] Determining a first target complexity based on the first content complexity and the first color complexity;
[0134] Determining a second target complexity based on the second content complexity and the second color complexity;
[0135] Based on the first target complexity and the second target complexity, the complexity of the original image is determined.
[0136] In one embodiment of the present application, in terms of constructing a target prompt word based on the target feature and the original prompt word, the processing unit 1102 is specifically configured to:
[0137] Acquire a feature prompt word corresponding to the target feature, wherein the feature prompt word includes text for describing the target feature;
[0138] The characteristic prompt word and the original prompt word are concatenated to obtain the target prompt word.
[0139] In one embodiment of the present application, the target feature includes at least one of the following: gender features, facial features, skin color features, and body shape features of the target feature.
[0140] See also Fig.12 , Fig.12 A schematic diagram of an electronic device provided in an embodiment of the present application. Fig.12As shown, the electronic device 1200 includes a transceiver 1201, a processor 1202, and a memory 1203. They are connected via a bus 1204. The memory 1203 is used to store computer programs and data, and can transmit the data stored in the memory 1203 to the processor 1202.
[0141] The processor 1202 is used to read the computer program in the memory 1203 and perform the following operations:
[0142] The object and background of the original image are segmented to obtain a first object image and a first background image; feature detection is performed on a target object in the first object image to obtain a target feature of the target object; a target prompt word is constructed based on the target feature and the original prompt word, wherein the target prompt word includes a text for describing the target feature; the target prompt word and the first object image are input into an image generation model to perform an image-to-image operation on the first object image to obtain a second object image; the original prompt word and the first background image are input into the image generation model to perform an image-to-image operation on the first background image to obtain a second background image; and a target image is obtained based on the second object image and the second background image.
[0143] Specifically, the transceiver 1201 may be Fig.11 The acquisition unit 1101 of the image generating device 1100 of the embodiment described above, the processor 1202 may be Fig.11 The processing unit 1102 of the image generating device 1100 of the described embodiment.
[0144] It should be understood that the electronic devices in this application may include smart phones (such as Android phones, iOS phones, Windows Phone phones, etc.), tablet computers, PDAs, laptops, mobile Internet devices MID (Mobile Internet Devices, referred to as: MID) or wearable devices, etc. The above electronic devices are only examples, not exhaustive, and include but are not limited to the above electronic devices. In practical applications, the above electronic devices may also include: smart vehicle terminals, computer equipment, etc.
[0145] The image generation device of the present application may be a server or other computing devices, wherein the server of the present application may be a cloud computing server, a content delivery network (Content Delivery Network, CDN) server, a network time protocol (Network Time Protocol, NTP), a domain name resolution system (Domain Name System, DNS) server, and other various types of servers. The above servers are only examples, not exhaustive, and include but are not limited to the above servers.
[0146] An embodiment of the present application also provides a computer-readable storage medium, which stores a computer program. The computer program is executed by a processor to implement part or all of the steps of any image generation method recorded in the above method embodiments.
[0147] An embodiment of the present application also provides a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program, and the computer program is operable to cause a computer to execute part or all of the steps of any image generation method recorded in the above method embodiments.
[0148] It should be noted that, for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described order of actions, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily required by the present application.
[0149] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0150] In the several embodiments provided in the present application, it should be understood that the disclosed device can be implemented in other ways. For example, the device embodiments described above are only schematic, such as the division of the units, which is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, and the indirect coupling or communication connection of the device or unit can be electrical or other forms.
[0151] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0152] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above integrated unit may be implemented in the form of hardware or in the form of a software program module.
[0153] If the integrated unit is implemented in the form of a software program module and sold or used as an independent product, it can be stored in a computer-readable memory. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a memory, including a number of instructions to enable a computer device (which can be a personal computer, server or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned memory includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, disk or CD-ROM and other media that can store program codes.
[0154] A person skilled in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructing related hardware through a program, and the program can be stored in a computer-readable memory, and the memory can include: a flash drive, a read-only memory (English: Read-Only Memory, abbreviated as: ROM), a random access memory (English: Random Access Memory, abbreviated as: RAM), a magnetic disk or an optical disk, etc.
[0155] The embodiments of the present application are introduced in detail above. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method and core idea of the present application. At the same time, for general technical personnel in this field, according to the idea of the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. An image generation method, characterized in that: include: Segmenting the original image into an object and a background to obtain a first object image and a first background image; Performing feature detection on a target object in the first object image to obtain a target feature of the target object; Based on the target feature and the original prompt word, construct a target prompt word, wherein the target prompt word includes text for describing the target feature; Inputting the target prompt word and the first object image into an image generation model to perform an image-to-image operation on the first object image to obtain a second object image; Inputting the original prompt word and the first background image into the image generation model to perform an image-to-image operation on the first background image to obtain a second background image; A target image is obtained based on the second object image and the second background image.
2. The method according to claim 1, characterized in that: The step of obtaining a target image based on the second object image and the second background image includes: Segmenting the second object image based on the mask image of the target object to obtain a third object image; Segmenting the second background image based on the background mask image to obtain a third background image; The target image is obtained based on the third object image and the third background image.
3. The method according to claim 2, characterized in that The fusing the third object image and the third background image to obtain the target image includes: fusing the third object image and the third background image to obtain an intermediate image; The intermediate image and the initial prompt word are input into the image generation model to perform an image-to-image operation on the intermediate image to obtain the target image.
4. The method according to claim 3, characterized in that The number of denoising steps of the intermediate image in the image generation model is a first target denoising step number; The number of denoising steps of the first object image in the image generation model is a second target denoising step number; The first target denoising step number is smaller than the second target denoising step number, and the sum of the first target denoising step number and the second target denoising step number is a standard denoising step number for the image generation model to perform an image-to-image operation.
5. The method according to claim 4, characterized in that The method further comprises: Determining the complexity of the original image based on the first object image and the first background image; Based on the complexity, the first target denoising step number and the second target denoising step number are determined.
6. The method according to claim 5, characterized in that The determining the complexity of the original image based on the first object image and the first background image includes: determining a first content complexity of the first object image based on a grayscale value of each pixel of the first object image; determining a second content complexity of the first background image based on a grayscale value of each pixel of the first background image; determining a first color complexity of the first object image based on a color value of each pixel of the first object image; determining a second color complexity of the first background image based on a color value of each pixel of the first background image; Determining a first target complexity based on the first content complexity and the first color complexity; Determining a second target complexity based on the second content complexity and the second color complexity; Based on the first target complexity and the second target complexity, the complexity of the original image is determined.
7. The method according to any one of claims 1 to 6, characterized in that: The step of constructing a target prompt word based on the target feature and the original prompt word includes: Acquire a feature prompt word corresponding to the target feature, wherein the feature prompt word includes text for describing the target feature; The characteristic prompt word and the original prompt word are concatenated to obtain the target prompt word.
8. The method according to any one of claims 1 to 7, characterized in that: The target feature includes at least one of the following: gender feature, facial feature, skin color feature and body shape feature of the target feature.
9. An image generating device, characterized in that: include: Acquisition unit and processing unit; The acquisition unit is used to acquire the original image; The processing unit is used to segment the original image into an object and a background to obtain a first object image and a first background image; Performing feature detection on a target object in the first object image to obtain a target feature of the target object; Based on the target feature and the original prompt word, a target prompt word is constructed, wherein the target prompt word includes text for describing the target feature; the target prompt word and the first object image are input into an image generation model to perform an image-to-image operation on the first object image to obtain a second object image; the original prompt word and the first background image are input into the image generation model to perform an image-to-image operation on the first background image to obtain a second background image; based on the second object image and the second background image, a target image is obtained.
10. An electronic device, characterized in that: include: A processor and a memory, wherein the processor is connected to the memory, the memory is used to store a computer program, and the processor is used to execute the computer program stored in the memory, so that the electronic device executes the method according to any one of claims 1 to 8.
11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and the computer program is executed by a processor to implement the method according to any one of claims 1 to 8.