Image generation method and device, equipment, storage medium and product

By performing feature extraction and reasoning on non-English text, the image latent space representation is generated, which solves the problem of insufficient support for non-English input in the existing technology, and improves the accuracy of image generation and the support effect for non-English input.

CN118535266AInactive Publication Date: 2024-08-23BEIJING 360 INTELLIGENT TECHNOLOGY CO LTD
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202410620315.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-17
Publication Date
2024-08-23
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

Existing image generation technology has poor support for non-English input, resulting in high generation error rates.

Method used

Through feature extraction of the received forward text, the forward text features are obtained, and the image latent space representation is obtained based on feature reasoning to generate images, which avoids translation ambiguities due to language differences and improves the support effect for non-English input.

Benefits of technology

It effectively avoids image generation errors caused by language differences, improves support for non-English input, and ensures that the generated image matches the text input by the user.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118535266A
    Figure CN118535266A
Patent Text Reader

Abstract

The invention belongs to the technical field of image generation, and discloses an image generation method and device, equipment, a storage medium and a product. The method comprises the following steps: performing feature extraction on a received forward text to obtain forward text features, the forward text being a non-English text input by a user in an image generation interface and being used for representing image features included in a generated image; performing feature reasoning according to the forward text features to obtain image hidden space representation; and generating an image according to the image hidden space representation. According to the method, a translation form is not adopted, the text features are extracted for feature reasoning, the image hidden space representation is generated, and then the image is generated according to the image hidden space representation, so that the problem of image generation errors caused by translation ambiguity of language differences is avoided, and the support effect of image generation on non-English input is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of image generation technology, and in particular to an image generation method, device, equipment, storage medium and product. Background Art

[0002] Image generation is an important area of ​​AIGC, and the image generation interface (Stable Diffusion web UI, WebUI for short) is widely used in scientific research and community applications. The original WebUI only supports English input, not non-English input. If you need to use input in other languages ​​(such as Chinese input), you need to use additional plug-ins to translate Chinese into English before generating images. However, in this case, translation ambiguity may occur. For example, if you translate "crane" into "Crane" and generate an image, a picture of a crane will be generated. Summary of the invention

[0003] The main purpose of the present invention is to provide an image generation method, device, equipment, storage medium and product, aiming to solve the technical problems of poor support for non-English input and high error rate of image generation in the prior art.

[0004] To achieve the above object, the present invention provides an image generation method, which comprises the following steps:

[0005] Performing feature extraction on the received positive text to obtain positive text features, wherein the positive text is a non-English text input by a user in an image generation interface and is used to characterize image features contained in the generated image;

[0006] Perform feature inference based on the positive text features to obtain a latent space representation of the image;

[0007] An image is generated according to the image latent space representation.

[0008] Optionally, before the step of performing feature inference according to the forward text features to obtain the image latent space representation, the step further includes:

[0009] Load the Wensheng graph model through the script loading module of the interface plug-in;

[0010] The step of performing feature reasoning based on the positive text features to obtain the image latent space representation comprises:

[0011] The text-generated graph model is used to perform feature inference based on the positive text features to obtain an image latent space representation.

[0012] Optionally, the Wensheng graph model includes a side branch network and a main network;

[0013] The step of performing feature inference according to the positive text features through the text-generated graph model to obtain the image latent space representation comprises:

[0014] Performing feature inference according to the forward text features through the side branch network to obtain a side branch inference result;

[0015] The backbone network performs secondary reasoning based on the side branch reasoning results to obtain the image latent space representation.

[0016] Optionally, the text graph model further includes a generation network;

[0017] The step of generating an image according to the latent space representation of the image comprises:

[0018] An image is generated according to the image latent space representation by the generative network.

[0019] Optionally, before the step of performing feature inference according to the forward text features to obtain the image latent space representation, the step further includes:

[0020] Performing feature extraction on the received negative text to obtain negative text features, wherein the negative text is non-English text input by the user in the image generation interface and is used to characterize image features that are not included in the generated image;

[0021] The step of performing feature reasoning based on the positive text features to obtain the image latent space representation comprises:

[0022] Feature inference is performed based on the positive text features and the negative text features to obtain a latent space representation of the image.

[0023] Optionally, the step of performing feature inference based on the positive text features and the negative text features to obtain the image latent space representation includes:

[0024] Performing feature comparison on the positive text features and the negative text features to obtain feature similarity;

[0025] If the feature similarity is less than or equal to a preset similarity threshold, feature inference is performed based on the positive text feature and the negative text feature to obtain an image latent space representation.

[0026] Optionally, after the step of generating an image according to the image latent space representation, the method further includes:

[0027] Extracting features of at least one image target in the generated image to obtain image target features corresponding to each image target;

[0028] Matching the image target features with the positive text features to obtain a first feature correlation degree corresponding to each image target;

[0029] If the first feature correlations corresponding to each image target are all less than the first correlation threshold, then the step of performing feature inference based on the positive text features and the negative text features to obtain the image latent space representation is returned.

[0030] Optionally, after the step of matching the image target feature with the positive text feature to obtain the feature correlation, the method further includes:

[0031] If there is at least one image target whose corresponding first feature relevance is greater than or equal to the first relevance threshold, matching the image target feature with the negative text feature to obtain the second feature relevance corresponding to each image target;

[0032] If there is at least one image target whose corresponding second feature relevance is greater than or equal to the second relevance threshold, return to the step of performing feature inference based on the positive text feature and the negative text feature to obtain the image latent space representation.

[0033] Optionally, the step of extracting features from the received positive text to obtain positive text features includes:

[0034] Perform language recognition on the received positive text to obtain the text language;

[0035] Obtaining a feature extraction model corresponding to the text language;

[0036] The feature extraction model is used to extract features from the positive text to obtain positive text features.

[0037] Optionally, the step of obtaining a feature extraction model corresponding to the text language includes:

[0038] Detect whether there is a mapping record corresponding to the text language in the language model mapping table;

[0039] If so, extracting the model identifier from the mapping record corresponding to the text language;

[0040] The feature extraction model corresponding to the language of the text is searched according to the model identifier.

[0041] Optionally, the step of performing feature inference based on the forward text features to obtain the image latent space representation includes:

[0042] Generate noise data by using a preset noise generation algorithm;

[0043] Feature inference is performed based on the positive text features and the noise data to obtain an image latent space representation.

[0044] In addition, to achieve the above object, the present invention further provides an image generating device, the image generating device comprising:

[0045] A receiving module, used to extract features from the received positive text to obtain positive text features, wherein the positive text is a non-English text input by a user in the image generation interface and is used to characterize image features contained in the generated image;

[0046] An inference module, used for performing feature inference based on the positive text features to obtain a latent space representation of the image;

[0047] A generation module is used to generate an image according to the image latent space representation.

[0048] Optionally, the reasoning module is further used to load the text graph model through a script loading module of the interface plug-in;

[0049] The reasoning module is also used to perform feature reasoning based on the positive text features through the text-generated graph model to obtain the image latent space representation.

[0050] Optionally, the Wensheng graph model includes a side branch network and a main network;

[0051] The reasoning module is also used to perform feature reasoning based on the forward text features through the side branch network to obtain a side branch reasoning result; and perform secondary reasoning based on the side branch reasoning result through the backbone network to obtain an image latent space representation.

[0052] Optionally, the text graph model further includes a generation network;

[0053] The generation module is also used to generate an image according to the image latent space representation through the generation network.

[0054] Optionally, the receiving module is further used to perform feature extraction on the received negative text to obtain negative text features, where the negative text is non-English text input by the user in the image generation interface and is used to characterize image features that are not included in the generated image;

[0055] The reasoning module is also used to perform feature reasoning based on the positive text features and the negative text features to obtain the image latent space representation.

[0056] Optionally, the reasoning module is also used to perform feature comparison on the positive text features and the negative text features to obtain feature similarity; if the feature similarity is less than or equal to a preset similarity threshold, feature reasoning is performed based on the positive text features and the negative text features to obtain an image latent space representation.

[0057] In addition, to achieve the above-mentioned purpose, the present invention also proposes an image generating device, which includes: a processor, a memory, and an image generating program stored in the memory and executable on the processor, and the image generating program implements the steps of the image generating method described above when executed by the processor.

[0058] In addition, to achieve the above-mentioned purpose, the present invention further proposes a computer-readable storage medium, on which an image generation program is stored, and when the image generation program is executed, the steps of the image generation method described above are implemented.

[0059] In addition, to achieve the above-mentioned purpose, the present invention also proposes a computer program product, which includes an image generation program, and when the image generation program is executed, the steps of the image generation method described above are implemented.

[0060] The present invention extracts features from the received positive text to obtain positive text features, where the positive text is non-English text input by the user in the image generation interface and is used to characterize the image features contained in the generated image; performs feature reasoning based on the positive text features to obtain the image latent space representation; and generates the image based on the image latent space representation. Since the method does not adopt the form of translation, but extracts text features to perform feature reasoning to generate the image latent space representation, and then generates the image based on the image latent space representation, the problem of image generation errors caused by translation ambiguity due to language differences is avoided, and the image generation support effect for non-English input is improved. BRIEF DESCRIPTION OF THE DRAWINGS

[0061] Figure 1 It is a schematic diagram of the structure of an electronic device in a hardware operating environment involved in an embodiment of the present invention;

[0062] Figure 2 It is a flowchart of a first embodiment of an image generating method of the present invention;

[0063] Figure 3 It is a flowchart of a second embodiment of the image generating method of the present invention;

[0064] Figure 4 It is a flowchart of a second embodiment of the image generating method of the present invention;

[0065] Figure 5 A schematic diagram of model loading according to an embodiment of the present invention;

[0066] Figure 6 It is a structural block diagram of the first embodiment of the image generating device of the present invention.

[0067] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION

[0068] It should be understood that the specific embodiments described herein are only used to explain the present invention, and are not used to limit the present invention.

[0069] Reference Figure 1 , Figure 1 The figure is a schematic diagram of the structure of an image generation device in a hardware operating environment involved in an embodiment of the present invention.

[0070] like Figure 1 As shown, the electronic device may include: a processor 1001, such as a central processing unit (CPU), a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. Among them, the communication bus 1002 is used to realize the connection and communication between these components. The user interface 1003 may include a display screen (Display), an input unit such as a keyboard (Keyboard), and the optional user interface 1003 may also include a standard wired interface and a wireless interface. The network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a wireless fidelity (Wireless-Fidelity, WI-FI) interface). The memory 1005 may be a high-speed random access memory (Random Access Memory, RAM), or a stable non-volatile memory (Non-Volatile Memory, NVM), such as a disk storage. The memory 1005 may also be a storage device independent of the aforementioned processor 1001.

[0071] Those skilled in the art will understand that Figure 1 The structure shown in the figure does not constitute a limitation on the electronic device, and may include more or less components than shown in the figure, or combine certain components, or arrange the components differently.

[0072] like Figure 1 As shown, the memory 1005 as a storage medium may include an operating system, a network communication module, a user interface module, and an image generation program.

[0073] exist Figure 1In the electronic device shown, the network interface 1004 is mainly used for data communication with a network server; the user interface 1003 is mainly used for data interaction with a user; the processor 1001 and the memory 1005 in the electronic device of the present invention can be set in an image generating device, and the electronic device calls the image generating program stored in the memory 1005 through the processor 1001, and executes the image generating method provided by an embodiment of the present invention.

[0074] The embodiment of the present invention provides an image generation method, referring to Figure 2 , Figure 2 FIG. 4 is a flow chart of a first embodiment of an image generating method according to the present invention.

[0075] In this embodiment, the image generation method includes the following steps:

[0076] Step S10: extract features from the received positive text to obtain positive text features.

[0077] It should be noted that the executor of this embodiment can be the image generating device, and the image generating device can be an electronic device such as a personal computer or a server, or other devices that can achieve the same or similar functions. This embodiment does not limit this. In this embodiment and the following embodiments, the image generating method of the present invention is described by taking the image generating device as an example.

[0078] It should be noted that the positive text can be non-English text (such as Chinese text, French text, Japanese text, etc.) entered by the user in the image generation interface, which is used to characterize the image features contained in the generated image. For example, if the positive text is "apple", the final generated image will definitely contain image features such as apple.

[0079] In a specific implementation, feature extraction can be performed on the positive text through a text feature extraction algorithm or a text feature extraction model to obtain positive text features, wherein the text feature extraction algorithm or the text feature extraction model can be pre-set by the administrator of the image generation device, for example: a pre-trained clip model is used as a text feature extraction model.

[0080] In a specific implementation, in order to ensure that text features can be normally extracted for texts in different languages, step S10 in this embodiment may include:

[0081] Perform language recognition on the received positive text to obtain the text language;

[0082] Obtaining a feature extraction model corresponding to the text language;

[0083] The feature extraction model is used to extract features from the positive text to obtain positive text features.

[0084] It should be noted that the feature extraction model corresponding to the text language can be a feature extraction model pre-trained using training data of the text language. For example, if the clip model is used as the feature extraction model for extracting features from the text, if the text language is Chinese, then the clip model trained using Chinese data needs to be used as the feature extraction model corresponding to the text language.

[0085] It is understandable that when a feature extraction model trained with data of a single language is used to extract features from texts in that language, the overall extraction accuracy is higher and the use effect is better.

[0086] In a specific implementation, in order to quickly determine the feature extraction model corresponding to the text language, the step of obtaining the feature extraction model corresponding to the text language in the Shaolin Temple may include:

[0087] Detect whether there is a mapping record corresponding to the text language in the language model mapping table;

[0088] If so, extracting the model identifier from the mapping record corresponding to the text language;

[0089] The feature extraction model corresponding to the language of the text is searched according to the model identifier.

[0090] It should be noted that the language model mapping table may store mapping records between text languages ​​and feature extraction models.

[0091] It is understandable that since it takes a lot of time and equipment resources to train the model of each language, it is impossible to train the corresponding feature extraction model for all languages. In order to ensure that it can quickly determine whether the text of a certain language can be feature extracted, after the feature extraction model is trained, a mapping record can be constructed according to the model identifier and the type of the text language, and stored in the language model mapping table. Among them, the model identifier can be a unique identifier of the feature extraction model.

[0092] It can be understood that if there is a mapping record corresponding to the text language in the language model mapping table, it means that the feature extraction model corresponding to the text language has been trained before. Therefore, the mapping record corresponding to the text language can be extracted from the language model mapping table, and the model identifier can be extracted from the mapping record. Then, based on the model identifier, the feature extraction model corresponding to the text language can be quickly found.

[0093] Step S20: performing feature inference based on the forward text features to obtain image latent space representation.

[0094] It should be noted that the image latent space representation is used to characterize the features of the final generated image in the latent space, that is, the non-intuitive, implicit features and structures.

[0095] In the specific implementation, a pre-trained text-based graph model can be used to perform feature inference based on the positive text features to obtain the image latent space representation.

[0096] Furthermore, in order to avoid the generated images being too consistent due to overfitting of the model, step S20 in this embodiment may include:

[0097] Generate noise data by using a preset noise generation algorithm;

[0098] Feature inference is performed based on the positive text features and the noise data to obtain an image latent space representation.

[0099] It should be noted that the preset noise generation algorithm may be pre-set by the administrator of the image generation device, for example, a Gaussian noise generation algorithm is used as the preset noise generation algorithm to generate random noise as noise data.

[0100] Of course, other types of noise generation algorithms may also be used, and the generated noise may not be random noise but may be related to the positive text feature, which is not limited in this embodiment.

[0101] It is understandable that by introducing noise data together with the positive text features for feature inference, more variables can be introduced so that the data for each inference will not be too consistent.

[0102] Step S30: generating an image according to the image latent space representation.

[0103] In actual use, after determining the latent space representation of the image, image generation can be performed based on the latent space representation of the image, thereby generating an image that matches the positive text input by the user.

[0104] In a specific implementation, an image can be generated according to the image latent space representation through a pre-trained model. The specific model used can be pre-set by the manager of the image generation device. For example, a pre-trained VAE model is used to generate an image according to the image latent space representation.

[0105] This embodiment extracts features from the received positive text to obtain positive text features. The positive text is the non-English text entered by the user in the image generation interface, which is used to characterize the image features contained in the generated image; performs feature reasoning based on the positive text features to obtain the image latent space representation; and generates the image based on the image latent space representation. Since it does not adopt the form of translation, but extracts text features to perform feature reasoning to generate the image latent space representation, and then generates the image based on the image latent space representation, it avoids the problem of image generation errors caused by translation ambiguity due to language differences, and improves the image generation support effect for non-English input.

[0106] refer to Figure 3 , Figure 3 FIG. 4 is a flow chart of a second embodiment of an image generating method according to the present invention.

[0107] Based on the first embodiment, the image generation method of this embodiment further includes, before step S20:

[0108] Step S11: loading the text graph model through the script loading module of the interface plug-in;

[0109] The step S20 comprises:

[0110] Step S20': performing feature inference according to the forward text features through the text-generated graph model to obtain image latent space representation.

[0111] It should be noted that since the image generation interface is an encapsulated interface, it is difficult to directly use other models. In order to ensure that the Wensheng graph model is available, it is necessary to use the script loading module in the interface plug-in supported by the image generation interface to load the Wensheng graph model into the image generation interface.

[0112] Among them, the interface plug-in can be a plug-in customized and developed by the manager of the image generation device for the image generation interface, or it can be an interface plug-in that has been developed. For example, if the ControlNetWebUI plug-in that has been developed is used as the interface plug-in, the Script module in the ControlNet WebUI plug-in can be used to load the Wensheng graph model.

[0113] In actual use, the text graph model may be a BDM (Bridge Diffusion Model) model that supports non-English text features as input for feature reasoning.

[0114] In a specific implementation, the Wensheng graph model may include a side branch network and a main network. Step S20' in this embodiment may include:

[0115] Performing feature inference according to the forward text features through the side branch network to obtain a side branch inference result;

[0116] The backbone network performs secondary reasoning based on the side branch reasoning results to obtain the image latent space representation.

[0117] It should be noted that the backbone network of the text graph model adopts the structure of Stable Diffusion 1.5 and is initialized using its pre-trained parameters, while the side network is composed of learnable copies derived from the backbone network. Compared with the ControlNet model, the structural difference of the BDM model is that there is no conditional image convolution layer in the side branch. This is because in the BDM model, the prompt of non-English text features is processed by the side network rather than the backbone network.

[0118] Therefore, we can first use the side branch network of the text graph model to perform feature inference based on the forward text features to obtain the side branch inference results, and then input the side branch inference results into the backbone network, and perform secondary inference based on the side branch inference results through the backbone network to obtain the image latent space representation.

[0119] In a specific implementation, the text graph model may further include a generation network. In this case, step S30 in this embodiment may include:

[0120] An image is generated according to the image latent space representation by the generative network.

[0121] It should be noted that the generated network can be embedded in the backbone network or independent of the backbone network, and the generated network can be a VAE model.

[0122] Of course, the text graph model may not include a generative network. In this case, an additional generative model may be loaded through the script loading module of the interface plug-in, and the image is generated according to the image latent space representation through the additionally loaded generative model.

[0123] This embodiment loads the text graph model through the script loading module of the interface plug-in supported by the image generation interface, ensuring that the text graph model can be used normally in the image generation interface, and ensuring that feature inference can be performed based on positive text features through the text graph model to obtain image latent space representation.

[0124] refer to Figure 4 , Figure 4 FIG. 4 is a flow chart of a third embodiment of an image generating method according to the present invention.

[0125] Based on the first embodiment, the image generation method of this embodiment further includes, before step S20:

[0126] Step S11 ′: extracting features from the received negative text to obtain negative text features.

[0127] Step S20 includes:

[0128] Step S20": performing feature inference based on the positive text features and the negative text features to obtain image latent space representation.

[0129] It should be noted that negative text can be non-English text entered by the user in the image generation interface, which is used to represent image features that the generated image does not contain. For example, assuming that the positive text is "apple" and the negative text is "pear", the generated image should contain image features related to apples, but not image features related to pears.

[0130] In a specific implementation, after obtaining the positive text features and the negative text features, the positive text features and the negative text features can be used as input together and input into the text graph model. At this time, the text graph model can first perform feature inference based on the positive text features and the negative text features through the side network, and then input the inference results into the backbone network for secondary inference, thereby obtaining the image latent space representation.

[0131] In a specific implementation, in order to avoid meaningless reasoning, step S20' in this embodiment may include:

[0132] Performing feature comparison on the positive text features and the negative text features to obtain feature similarity;

[0133] If the feature similarity is less than or equal to a preset similarity threshold, feature inference is performed based on the positive text feature and the negative text feature to obtain an image latent space representation.

[0134] It should be noted that since both the positive text and the negative text are input by the user, the user may make an error or similar operation, resulting in a high similarity between the input positive text and the negative text. If the positive text and the negative text have a high similarity or are even identical, it will ultimately lead to the inability to generate reasonable image latent space features. In order to avoid this phenomenon and reduce meaningless reasoning, after obtaining the positive text features and the negative text features, the positive text features and the negative text features can be compared to determine the feature similarity between the positive text and the negative text.

[0135] When performing feature comparison, a feature comparison algorithm such as a cosine similarity algorithm, a text classification algorithm, etc. may be used. Of course, a pre-trained text feature comparison model may also be used for feature comparison, which is not limited in this embodiment.

[0136] It is understandable that if the feature similarity is greater than the preset similarity threshold, it means that the positive text and the negative text are extremely similar at this time. At this time, because the image features included in the specified generated image and the image features not included are too similar, it is difficult to make reasonable inferences. Therefore, the subsequent steps may not be performed at this time, but the user is prompted to adjust the positive text or the negative text;

[0137] If the feature similarity is less than or equal to the preset similarity threshold, it means that the similarity between the positive text and the negative text is low, and a reasonable legend can be made. Therefore, feature inference can be performed based on the positive text features and the negative text features to obtain the image latent space representation.

[0138] The preset similarity threshold can be set by the equipment manager according to actual needs and requirements, for example, the preset similarity threshold is set to 80%.

[0139] Furthermore, in order to ensure that the generated image has a high correlation with the text input by the user, after step S30 in this embodiment, the following steps may be further included:

[0140] Extracting features of at least one image target in the generated image to obtain image target features corresponding to each image target;

[0141] Matching the image target features with the positive text features to obtain a first feature correlation degree corresponding to each image target;

[0142] If the first feature correlations corresponding to each image target are all less than the first correlation threshold, then the step of performing feature inference based on the positive text features and the negative text features to obtain the image latent space representation is returned.

[0143] It should be noted that the image target may be an object, person, animal, etc. contained in the image, and the generated image may contain at least one image target, for example, the generated image may contain multiple image targets such as a person, a table, an apple, etc. The image target feature may be feature data used to characterize the characteristics of the image target, and the first feature correlation may be a quantitative score used to characterize the correlation between the image target feature and the positive text feature. The higher the first feature correlation, the higher the correlation between the image target feature and the positive text feature. The first correlation threshold may be pre-set by the administrator of the image generation device, for example, the first correlation threshold is set to 60%.

[0144] Among them, the feature similarity between the image target feature and the positive text feature can be directly used as the first feature association degree. Of course, the feature similarity can also be corrected and used as the first feature association degree. For example: the feature similarity between the image target feature and the positive text feature is multiplied by a preset first correction coefficient, and the product is used as the first feature association degree.

[0145] In actual use, feature extraction can be performed for each image target respectively to obtain the image target features corresponding to each image target, and then the image target features corresponding to each image target are matched with the positive text features respectively to obtain the first feature correlation degree corresponding to each image target.

[0146] It can be understood that if the first feature correlation corresponding to each image target is less than the first correlation threshold, it means that the correlation between the image target contained in the image generated at this time and the positive text feature is not high. The image generated at this time is likely to not meet the user's needs. Therefore, it is possible to return to the step of performing feature inference based on the positive text feature to obtain the image latent space representation and re-perform inference.

[0147] In a specific implementation, if there is at least one image target whose corresponding first feature correlation is greater than or equal to the first correlation threshold, it is necessary to further detect whether the generated image contains image features that the user does not want to exist. At this time, after the step of matching the image target features with the positive text features and obtaining the first feature correlation corresponding to each image target in this embodiment, the following may also be included:

[0148] If there is at least one image target whose corresponding first feature relevance is greater than or equal to the first relevance threshold, matching the image target feature with the negative text feature to obtain the second feature relevance corresponding to each image target;

[0149] If there is at least one image target whose corresponding second feature relevance is greater than or equal to the second relevance threshold, return to the step of performing feature inference based on the positive text feature and the negative text feature to obtain the image latent space representation.

[0150] It should be noted that the second feature correlation degree may be a quantitative score used to characterize the correlation between the image target feature and the positive text feature. The higher the second feature correlation degree is, the higher the correlation between the image target feature and the positive text feature is.

[0151] In actual use, if there is at least one image target whose corresponding first feature correlation is greater than or equal to the first correlation threshold, it means that the image generated at this time already contains image features with a high correlation with the positive text input by the user. At this time, it can be further detected whether it contains image features that the user does not want to include. Therefore, the image target features corresponding to each image target can be matched with the negative text features to obtain the second feature correlation corresponding to each image target.

[0152] The calculation method of the second feature correlation is similar to that of the first feature correlation, but if a coefficient is used in the specific calculation, it may be different from the coefficient used in calculating the first feature correlation.

[0153] It can be understood that if there is at least one image target whose corresponding second feature correlation is greater than or equal to the second correlation threshold, it means that at least one of the image targets contained in the generated image has a high correlation with the negative text. At this time, it can be determined that the generated image contains image features that the user does not want to include. Therefore, the step of performing feature inference based on the positive text feature and the negative text feature to obtain the image latent space representation can be returned to re-inference;

[0154] If the second feature correlation corresponding to each image target is less than the second correlation threshold, it means that the image targets contained in the generated image at this time have a low correlation with the negative text. At this time, the generated image can be displayed or sent according to the user's operation.

[0155] In practical applications, the technical features in the above-mentioned multiple embodiments can be combined in any manner to form a new technical solution, which is not limited in this embodiment. Figure 5 This is for illustration but not for limitation. Figure 5 This is a schematic diagram of model loading in this embodiment.

[0156] like Figure 5 As shown, taking Chinese as an example, in this embodiment, the ControlNetUnit module, Script module (i.e. the above-mentioned script loading module), and UnetHook module in the ControlNet plug-in supported by the image generation interface can be modified so that:

[0157] Two new parameters (cn_prompt and cn_neg_prompt) were added to the ControlNetUnit module to support the interface input of positive / negative Chinese text;

[0158] The Script module was modified to correctly load the BDM model;

[0159] The UnetHook module is modified to support CLIP for Chinese text feature extraction and BDM reasoning.

[0160] On this basis, the execution process of the image generation method of this embodiment can be: the Script module pre-loads the BDM model (i.e., the above-mentioned text-generated image model), and the user inputs Chinese positive / negative text from the image generation interface and passes it to the ControlNetUnit module; the UnetHook module intercepts the Chinese positive / negative text and extracts text features (including positive text features and negative text features); the text features and the generated noise data are submitted together to the BDM model loaded in advance by the Script module for reasoning; the BDM model will first use the side branch network to perform feature reasoning based on the text features and the generated noise data, and input the obtained output (i.e., the side branch reasoning result) into the backbone network for secondary reasoning, thereby obtaining the image latent space representation; then the VAE model (i.e., the generation network) is used to further reason the image latent space representation, thereby obtaining the generated image, and thereafter the image target features of the image target in the generated image can be compared with the positive text features and the negative text features respectively, and when the final comparison is passed, the generated image is displayed to the user, or processed according to the user's operation (such as uploading or storing, etc.).

[0161] This embodiment introduces negative text, extracts features from the negative text, and performs feature inference on the extracted negative text features together with positive text features to generate an image, thereby ensuring that the user can input negative text in the image generation interface according to actual needs to exclude image features that are not desired to appear in the generated image.

[0162] In addition, an embodiment of the present invention further provides a storage medium, on which an image generation program is stored. When the image generation program is executed by a processor, the steps of the image generation method described above are implemented.

[0163] In addition, an embodiment of the present invention further provides a computer program product, which includes an image generation program. When the image generation program is executed by a processor, the steps of the image generation method described above are implemented.

[0164] Reference Figure 6 , Figure 6 It is a structural block diagram of the first embodiment of the image generating device of the present invention.

[0165] like Figure 6 As shown, the image generating device proposed in the embodiment of the present invention includes:

[0166] The receiving module 10 is used to extract features from the received positive text to obtain positive text features, where the positive text is non-English text input by the user in the image generation interface and is used to characterize image features contained in the generated image;

[0167] An inference module 20, configured to perform feature inference based on the forward text features to obtain a latent space representation of the image;

[0168] The generating module 30 is used to generate an image according to the image latent space representation.

[0169] This embodiment extracts features from the received positive text to obtain positive text features. The positive text is the non-English text entered by the user in the image generation interface, which is used to characterize the image features contained in the generated image; performs feature reasoning based on the positive text features to obtain the image latent space representation; and generates the image based on the image latent space representation. Since it does not adopt the form of translation, but extracts text features to perform feature reasoning to generate the image latent space representation, and then generates the image based on the image latent space representation, it avoids the problem of image generation errors caused by translation ambiguity due to language differences, and improves the image generation support effect for non-English input.

[0170] Furthermore, the reasoning module 20 is also used to load the text graph model through the script loading module of the interface plug-in;

[0171] The reasoning module 20 is further used to perform feature reasoning according to the positive text features through the text-generated graph model to obtain image latent space representation.

[0172] Furthermore, the Wensheng graph model includes a branch network and a backbone network;

[0173] The reasoning module 20 is also used to perform feature reasoning based on the forward text features through the side branch network to obtain a side branch reasoning result; and perform secondary reasoning based on the side branch reasoning result through the backbone network to obtain an image latent space representation.

[0174] Furthermore, the text graph model also includes a generation network;

[0175] The generation module 30 is further configured to generate an image according to the image latent space representation through the generation network.

[0176] Furthermore, the receiving module 10 is further used to extract features from the received negative text to obtain negative text features, wherein the negative text is non-English text input by the user in the image generation interface and is used to characterize image features that are not included in the generated image;

[0177] The reasoning module 20 is further used to perform feature reasoning based on the positive text features and the negative text features to obtain image latent space representation.

[0178] Furthermore, the reasoning module 20 is also used to perform feature comparison on the positive text features and the negative text features to obtain feature similarity; if the feature similarity is less than or equal to a preset similarity threshold, feature reasoning is performed based on the positive text features and the negative text features to obtain an image latent space representation.

[0179] Furthermore, the generation module 30 is also used to extract features of at least one image target in the generated image to obtain image target features corresponding to each image target; match the image target features with the positive text features to obtain the first feature correlation degree corresponding to each image target; if the first feature correlation degree corresponding to each image target is less than the first correlation degree threshold, return to the step of performing feature inference based on the positive text features and the negative text features to obtain the image latent space representation.

[0180] Furthermore, the generation module 30 is also used to match the image target features with the negative text features to obtain the second feature associations corresponding to each image target if there is at least one image target whose corresponding first feature association is greater than or equal to the first association threshold; if there is at least one image target whose corresponding second feature association is greater than or equal to the second association threshold, return to the step of performing feature inference based on the positive text features and the negative text features to obtain the image latent space representation.

[0181] Furthermore, the receiving module 10 is also used to perform language recognition on the received positive text to obtain the text language; obtain a feature extraction model corresponding to the text language; and perform feature extraction on the positive text through the feature extraction model to obtain positive text features.

[0182] Furthermore, the receiving module 10 is also used to detect whether there is a mapping record corresponding to the text language in the language model mapping table; if so, extract the model identifier from the mapping record corresponding to the text language; and search for the feature extraction model corresponding to the text language according to the model identifier.

[0183] Furthermore, the inference module 20 is also used to generate noise data through a preset noise generation algorithm; perform feature inference based on the positive text features and the noise data to obtain the image latent space representation.

[0184] It should be understood that the above is only an example and does not constitute any limitation on the technical solution of the present invention. In specific applications, technicians in this field can make settings as needed, and the present invention does not limit this.

[0185] It should be noted that the workflow described above is merely illustrative and does not limit the scope of protection of the present invention. In practical applications, technicians in this field can select part or all of them according to actual needs to achieve the purpose of the present embodiment, and no limitation is made here.

[0186] In addition, for technical details not fully described in this embodiment, reference can be made to the image generating method provided in any embodiment of the present invention, and will not be repeated here.

[0187] In addition, it should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or system including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or system. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or system including the element.

[0188] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.

[0189] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as a read-only memory (ROM) / RAM, a magnetic disk, or an optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present invention.

[0190] The above are only preferred embodiments of the present invention, and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.

[0191] The present application discloses A1, an image generation method, the image generation method comprising the following steps:

[0192] Performing feature extraction on the received positive text to obtain positive text features, wherein the positive text is a non-English text input by a user in an image generation interface and is used to characterize image features contained in the generated image;

[0193] Perform feature inference based on the positive text features to obtain a latent space representation of the image;

[0194] An image is generated according to the image latent space representation.

[0195] A2. The image generation method as described in A1, before the step of performing feature inference based on the positive text features to obtain the image latent space representation, further comprises:

[0196] Load the Wensheng graph model through the script loading module of the interface plug-in;

[0197] The step of performing feature reasoning based on the positive text features to obtain the image latent space representation comprises:

[0198] The text-generated graph model is used to perform feature inference based on the positive text features to obtain an image latent space representation.

[0199] A3. The image generation method as described in A2, wherein the Wensheng graph model includes a side branch network and a main network;

[0200] The step of performing feature inference according to the positive text features through the text-generated graph model to obtain the image latent space representation comprises:

[0201] Performing feature inference according to the forward text features through the side branch network to obtain a side branch inference result;

[0202] The backbone network performs secondary reasoning based on the side branch reasoning results to obtain the image latent space representation.

[0203] A4. The image generation method as described in A3, wherein the text graph model further includes a generation network;

[0204] The step of generating an image according to the latent space representation of the image comprises:

[0205] An image is generated according to the image latent space representation by the generative network.

[0206] A5. The image generation method as described in A1, before the step of performing feature inference based on the positive text features to obtain the image latent space representation, further comprises:

[0207] Performing feature extraction on the received negative text to obtain negative text features, wherein the negative text is non-English text input by the user in the image generation interface and is used to characterize image features that are not included in the generated image;

[0208] The step of performing feature reasoning based on the positive text features to obtain the image latent space representation comprises:

[0209] Feature inference is performed based on the positive text features and the negative text features to obtain a latent space representation of the image.

[0210] A6. In the image generation method described in A5, the step of performing feature inference based on the positive text features and the negative text features to obtain the image latent space representation comprises:

[0211] Performing feature comparison on the positive text features and the negative text features to obtain feature similarity;

[0212] If the feature similarity is less than or equal to a preset similarity threshold, feature inference is performed based on the positive text feature and the negative text feature to obtain an image latent space representation.

[0213] A7. The image generation method as described in A5, after the step of generating an image according to the image latent space representation, further comprising:

[0214] Extracting features of at least one image target in the generated image to obtain image target features corresponding to each image target;

[0215] Matching the image target features with the positive text features to obtain a first feature correlation degree corresponding to each image target;

[0216] If the first feature correlations corresponding to each image target are all less than the first correlation threshold, then the step of performing feature inference based on the positive text features and the negative text features to obtain the image latent space representation is returned.

[0217] A8. The image generation method as described in A7, after the step of matching the image target feature with the positive text feature to obtain the feature association degree, further comprising:

[0218] If there is at least one image target whose corresponding first feature relevance is greater than or equal to the first relevance threshold, matching the image target feature with the negative text feature to obtain the second feature relevance corresponding to each image target;

[0219] If there is at least one image target whose corresponding second feature relevance is greater than or equal to the second relevance threshold, return to the step of performing feature inference based on the positive text feature and the negative text feature to obtain the image latent space representation.

[0220] A9. In the image generation method described in A1, the step of extracting features from the received positive text to obtain positive text features comprises:

[0221] Perform language recognition on the received positive text to obtain the text language;

[0222] Obtaining a feature extraction model corresponding to the text language;

[0223] The feature extraction model is used to extract features from the positive text to obtain positive text features.

[0224] A10. In the image generation method described in A9, the step of obtaining the feature extraction model corresponding to the text language comprises:

[0225] Detect whether there is a mapping record corresponding to the text language in the language model mapping table;

[0226] If so, extracting the model identifier from the mapping record corresponding to the text language;

[0227] The feature extraction model corresponding to the language of the text is searched according to the model identifier.

[0228] A11. In the image generation method according to any one of A1 to A10, the step of performing feature inference based on the positive text features to obtain the image latent space representation comprises:

[0229] Generate noise data by using a preset noise generation algorithm;

[0230] Feature inference is performed based on the positive text features and the noise data to obtain an image latent space representation.

[0231] The present application also discloses B12, an image generating device, the image generating device comprising:

[0232] A receiving module, used to extract features from the received positive text to obtain positive text features, wherein the positive text is a non-English text input by a user in the image generation interface and is used to characterize image features contained in the generated image;

[0233] An inference module, used for performing feature inference based on the positive text features to obtain a latent space representation of the image;

[0234] A generation module is used to generate an image according to the image latent space representation.

[0235] B13, the image generation device as described in B12, wherein the reasoning module is further used to load the text graph model through the script loading module of the interface plug-in;

[0236] The reasoning module is also used to perform feature reasoning based on the positive text features through the text-generated graph model to obtain the image latent space representation.

[0237] B14, the image generation device as described in B13, wherein the Wensheng graph model includes a side branch network and a main network;

[0238] The reasoning module is also used to perform feature reasoning based on the forward text features through the side branch network to obtain a side branch reasoning result; and perform secondary reasoning based on the side branch reasoning result through the backbone network to obtain an image latent space representation.

[0239] B15. The image generation device as described in B14, wherein the cultural graph model further includes a generation network;

[0240] The generation module is also used to generate an image according to the image latent space representation through the generation network.

[0241] B16. The image generating device as described in B12, wherein the receiving module is further used to extract features of the received negative text to obtain negative text features, wherein the negative text is non-English text input by the user in the image generating interface, and is used to represent image features that are not included in the generated image;

[0242] The reasoning module is also used to perform feature reasoning based on the positive text features and the negative text features to obtain the image latent space representation.

[0243] B17. In the image generating device as described in B16, the inference module is further used to perform feature comparison on the positive text features and the negative text features to obtain feature similarity; if the feature similarity is less than or equal to a preset similarity threshold, feature inference is performed based on the positive text features and the negative text features to obtain an image latent space representation.

[0244] The present application also discloses C18, an image generating device, which includes: a processor, a memory, and an image generating program stored in the memory and executable on the processor, wherein the image generating program implements the steps of the image generating method described above when executed by the processor.

[0245] The present application also discloses D19, a computer-readable storage medium, on which an image generation program is stored, and when the image generation program is executed, the steps of the image generation method described above are implemented.

[0246] The present application also discloses E20, a computer program product, which includes an image generation program, and when the image generation program is executed, the steps of the image generation method described above are implemented.

Claims

1. An image generation method, characterized in that: The image generation method comprises the following steps: Performing feature extraction on the received positive text to obtain positive text features, wherein the positive text is a non-English text input by a user in an image generation interface and is used to characterize image features contained in the generated image; Perform feature inference based on the positive text features to obtain a latent space representation of the image; An image is generated according to the image latent space representation.

2. The image generation method according to claim 1, characterized in that: Before the step of performing feature inference according to the positive text features to obtain the image latent space representation, the method further includes: Load the Wensheng graph model through the script loading module of the interface plug-in; The step of performing feature reasoning based on the positive text features to obtain the image latent space representation comprises: The text-generated graph model is used to perform feature inference based on the positive text features to obtain an image latent space representation.

3. The image generation method according to claim 2, characterized in that: The Wensheng graph model includes a side branch network and a main network; The step of performing feature inference according to the positive text features through the text-generated graph model to obtain the image latent space representation comprises: Performing feature inference according to the forward text features through the side branch network to obtain a side branch inference result; The backbone network performs secondary reasoning based on the side branch reasoning results to obtain the image latent space representation.

4. The image generation method according to claim 3, characterized in that: The Wensheng graph model also includes a generation network; The step of generating an image according to the latent space representation of the image comprises: An image is generated according to the image latent space representation by the generative network.

5. The image generation method according to claim 1, characterized in that: Before the step of performing feature inference according to the positive text features to obtain the image latent space representation, the method further includes: Performing feature extraction on the received negative text to obtain negative text features, wherein the negative text is non-English text input by the user in the image generation interface and is used to characterize image features that are not included in the generated image; The step of performing feature reasoning based on the positive text features to obtain the image latent space representation comprises: Feature inference is performed based on the positive text features and the negative text features to obtain a latent space representation of the image.

6. The image generation method according to claim 5, characterized in that: The step of performing feature reasoning based on the positive text features and the negative text features to obtain the image latent space representation includes: Performing feature comparison on the positive text features and the negative text features to obtain feature similarity; If the feature similarity is less than or equal to a preset similarity threshold, feature inference is performed based on the positive text feature and the negative text feature to obtain an image latent space representation.

7. An image generating device, characterized in that: The image generating device comprises: A receiving module, used to extract features from the received positive text to obtain positive text features, wherein the positive text is a non-English text input by a user in the image generation interface and is used to characterize image features contained in the generated image; An inference module, used for performing feature inference based on the positive text features to obtain a latent space representation of the image; A generation module is used to generate an image according to the image latent space representation.

8. An image generating device, characterized in that: The image generating device comprises: a processor, a memory, and an image generating program stored in the memory and executable on the processor, wherein the image generating program implements the steps of the image generating method according to any one of claims 1 to 6 when executed by the processor.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores an image generation program, and when the image generation program is executed, the steps of the image generation method according to any one of claims 1 to 6 are implemented.

10. A computer program product, characterized in that The computer program product comprises an image generation program, and when the image generation program is executed, the steps of the image generation method according to any one of claims 1 to 6 are implemented.

Citation Information

Patent Citations

  • Image generation processing method and device, electronic equipment and storage medium

    CN116012481A

  • Image generation method and device based on interaction, electronic equipment and storage medium

    CN116306588A

  • Training method of image generation model, image generation method, device and equipment

    CN117351115A

  • Image generation method and device, equipment and medium

    CN117475020A

  • Image generation method, device and equipment

    CN117635772A