Image generation method, model training method, device, equipment and medium

By assigning preset attributes to the features obtained by random sampling and calling the image generation model, the problem that the image generation model is difficult to control the generated image characteristics is solved, and the controllability of image generation is improved.

CN115035365BActive Publication Date: 2025-02-25BEIJING DAJIA INTERNET INFORMATION TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210658315.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-06-10
Publication Date
2025-02-25
Estimated Expiration
2042-06-10

AI Technical Summary

Technical Problem

In the prior art, the image generation model is difficult to control the characteristics of the generated image, resulting in poor controllability of image generation.

Method used

By randomly sampling in the feature set, at least two features are obtained and preset attributes are assigned to them, the image generation model is called to generate images, so that the features belonging to each preset attribute in the image match the preset attribute.

Benefits of technology

The controllability of image generation is improved so that by changing the characteristics of specific preset attributes, the characteristics of the attribute in the generated image can be adjusted without affecting the characteristics of other attributes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115035365B_ABST
    Figure CN115035365B_ABST
Patent Text Reader

Abstract

The present disclosure relates to an image generation method, a model training method, an apparatus, a device and a medium, and belongs to the field of computer technology. The method includes: performing random sampling in a feature set to obtain at least two first features; assigning a preset attribute to each of the at least two first features; calling an image generation model to generate a first image based on at least two first features and the preset attribute to which each first feature belongs; replacing the first feature belonging to the first preset attribute in at least two first features with the second feature obtained by random sampling; calling an image generation model to generate a second image based on the remaining first features, the second features, the preset attributes to which the remaining first features belong, and the preset attributes to which the second features belong. When generating an image, by changing the features belonging to one of the preset attributes, the features belonging to the preset attribute in the generated image can be adjusted, thereby achieving control of the features of the image.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer technology, and in particular to an image generation method, a model training method, a device, a equipment and a medium. Background Art

[0002] With the development of computer technology, the ways of processing images are becoming more and more diverse. At present, an image generation method is proposed, which can automatically generate images.

[0003] In the related art, any noise is used as an image feature, and the mapping relationship between image features and images is learned by training an image generation model. The image generation model can be called to generate a corresponding image based on the noise used as an image feature. However, since the influence of noise is unknown, it is difficult to control the features of the generated image, so the controllability of image generation is poor. Summary of the invention

[0004] The present disclosure provides an image generation method, a model training method, an apparatus, a device and a medium, which can improve the controllability of image generation.

[0005] According to one aspect of an embodiment of the present disclosure, there is provided an image generating method, the method comprising:

[0006] Performing random sampling in a feature set to obtain at least two first features, wherein the feature set includes a plurality of features for generating an image;

[0007] assigning a preset attribute to each of the at least two first features;

[0008] Invoking an image generation model to generate a first image based on the at least two first features and the preset attributes to which each first feature belongs, so that the image features belonging to each preset attribute in the first image are respectively the same as the first features belonging to each preset attribute;

[0009] Replacing a first feature of the at least two first features that belongs to a first preset attribute with a second feature obtained by random sampling, where the first preset attribute is any one of the at least two preset attributes;

[0010] The image generation model is called to generate a second image based on the remaining first features, the second features, the preset attributes to which the remaining first features belong, and the preset attributes to which the second features belong, so that the image features belonging to each preset attribute in the second image are respectively the same as the remaining first features or the second features belonging to each preset attribute.

[0011] Optionally, before calling the image generation model to generate the first image based on the at least two first features and the preset attribute to which each first feature belongs, the method further includes:

[0012] Based on the arrangement order of the at least two preset attributes and the preset attribute to which each first feature belongs, splicing the at least two first features;

[0013] The calling of the image generation model to generate the first image based on the at least two first features and the preset attribute to which each first feature belongs includes:

[0014] The image generation model is called to generate the first image based on the spliced ​​first feature.

[0015] Optionally, the randomly sampling in the feature set to obtain at least two first features includes:

[0016] Random sampling is performed in at least two feature sets to obtain the at least two first features, wherein different feature sets correspond to different preset attributes;

[0017] The assigning a preset attribute to each of the at least two first features comprises:

[0018] Assign a preset attribute corresponding to the feature set to which each first feature belongs to respectively.

[0019] Optionally, the training process of the image generation model includes:

[0020] Perform random sampling in the feature set to obtain at least two third features;

[0021] assigning a preset attribute to each of the at least two third features;

[0022] Calling the image generation model to generate a first sample image based on the at least two third features and the preset attributes to which each third feature belongs, so that the image features belonging to each preset attribute in the first sample image are respectively the same as the third features belonging to each preset attribute;

[0023] The first sample image is discriminated to obtain a first discrimination result, wherein the first discrimination result indicates a probability that the first sample image is discriminated as a non-synthetic image, and the non-synthetic image is not generated by a model;

[0024] Based on the first discrimination result, the image generation model is trained to increase the probability that an image generated by calling the trained image generation model is discriminated as the non-synthetic image.

[0025] According to another aspect of an embodiment of the present disclosure, a model training method is provided, the method comprising:

[0026] Randomly sample from the feature set to obtain at least two third features;

[0027] assigning a preset attribute to each of the at least two third features;

[0028] Calling an image generation model to generate a first sample image based on the at least two third features and the preset attributes to which each third feature belongs, so that the image features belonging to each preset attribute in the first sample image are respectively the same as the third features belonging to each preset attribute;

[0029] The first sample image is discriminated to obtain a first discrimination result, wherein the first discrimination result indicates a probability that the first sample image is discriminated as a non-synthetic image, and the non-synthetic image is not generated by a model;

[0030] Based on the first discrimination result, the image generation model is trained to increase the probability that an image generated by calling the trained image generation model is discriminated as the non-synthetic image.

[0031] Optionally, the discriminating the first sample image to obtain a first discrimination result includes:

[0032] Calling an image discrimination model to discriminate the first sample image to obtain the first discrimination result;

[0033] The step of training the image generation model based on the first discrimination result includes:

[0034] Based on the first discrimination result, the image generation model and the image discrimination model are trained to increase the probability that the image generated by the trained image generation model is discriminated as the non-synthetic image, and to reduce the probability that the image generated by the image generation model is discriminated as the non-synthetic image by calling the trained image discrimination model.

[0035] Optionally, the method further comprises:

[0036] Acquire a second sample image, where the second sample image is the non-synthetic image;

[0037] calling the image discrimination model to discriminate the second sample image to obtain a second discrimination result, wherein the second discrimination result indicates a probability that the second sample image is discriminated as the non-synthetic image;

[0038] The step of training the image generation model and the image discrimination model based on the first discrimination result includes:

[0039] Based on the first discrimination result, training the image generation model to increase the probability that the image generated by calling the trained image generation model is discriminated as the non-synthetic image;

[0040] Based on the first discrimination result and the second discrimination result, the image discrimination model is trained to reduce the probability of calling the trained image discrimination model to discriminate the image generated by the image generation model as the non-synthetic image, and to increase the probability of calling the trained image discrimination model to discriminate the non-synthetic image as the non-synthetic image.

[0041] Optionally, the method further comprises:

[0042] Perform random sampling in the feature set to obtain a fourth feature;

[0043] Replacing the third feature of the at least two third features that belongs to a second preset attribute with the fourth feature, where the second preset attribute is any one of the at least two preset attributes;

[0044] Calling the image generation model to generate a third sample image based on the remaining third feature, the fourth feature, the preset attribute to which the remaining third feature belongs, and the preset attribute to which the fourth feature belongs, so that the image feature belonging to each preset attribute in the third sample image is respectively the same as the remaining third feature or the fourth feature belonging to each preset attribute;

[0045] The step of discriminating the first sample image to obtain a first discrimination result includes:

[0046] The first sample image and the third sample image are discriminated to obtain the first discrimination result, wherein the first discrimination result indicates the probability that the first sample image and the third sample image meet the first target condition, wherein the first target condition refers to that the first sample image and the third sample image are discriminated as the non-synthetic images, and that the image features of at least one preset attribute in the first sample image and the third sample image are the same and the image features of at least one preset attribute are different.

[0047] Optionally, the discriminating the first sample image and the third sample image to obtain the first discrimination result includes:

[0048] Calling an image discrimination model to discriminate the first sample image and the third sample image to obtain the first discrimination result;

[0049] The step of training the image generation model based on the first discrimination result includes:

[0050] Based on the first discrimination result, the image generation model and the image discrimination model are trained to increase the probability that at least two images generated by the trained image generation model are discriminated as satisfying the first target condition, and to reduce the probability that at least two images generated by the image generation model are discriminated as satisfying the first target condition by calling the trained image discrimination model.

[0051] Optionally, the method further comprises:

[0052] Acquire a fourth sample image and a fifth sample image, wherein the fourth sample image and the fifth sample image satisfy a second target condition, wherein the second target condition is that the fourth sample image and the fifth sample image are the non-synthetic images, and image features of at least one preset attribute are the same and image features of at least one preset attribute are different in the fourth sample image and the fifth sample image;

[0053] calling the image discrimination model to discriminate the fourth sample image and the fifth sample image to obtain a third discrimination result, wherein the third discrimination result indicates a probability that the fourth sample image and the fifth sample image are discriminated as satisfying the second target condition;

[0054] The step of training the image generation model and the image discrimination model based on the first discrimination result includes:

[0055] Based on the first discrimination result, training the image generation model to increase the probability that at least two images generated by calling the trained image generation model are judged to meet the first target condition;

[0056] Based on the first discrimination result and the third discrimination result, the image discrimination model is trained to reduce the probability of calling the trained image discrimination model to discriminate at least two images generated by the image generation model as satisfying the first target condition, and to increase the probability of calling the trained image discrimination model to discriminate an image satisfying the second target condition as satisfying the second target condition.

[0057] According to another aspect of the embodiments of the present disclosure, there is provided an image generating device, the device comprising:

[0058] an acquisition unit, configured to perform random sampling in a feature set to obtain at least two first features, wherein the feature set includes a plurality of features for generating an image;

[0059] an allocating unit, configured to allocate a preset attribute to each of the at least two first features;

[0060] A generating unit is configured to execute calling the image generating model, and generate a first image based on the at least two first features and the preset attributes to which each first feature belongs, so that the image features belonging to each preset attribute in the first image are respectively the same as the first features belonging to each preset attribute;

[0061] The allocation unit is further configured to replace a first feature belonging to a first preset attribute among the at least two first features with a second feature obtained by random sampling, wherein the first preset attribute is any one of the at least two preset attributes;

[0062] The generation unit is further configured to execute the call to the image generation model, and generate a second image based on the remaining first features, the second features, the preset attributes to which the remaining first features belong, and the preset attributes to which the second features belong, so that the image features belonging to each preset attribute in the second image are respectively the same as the remaining first features or the second features belonging to each preset attribute.

[0063] Optionally, the device further comprises:

[0064] A splicing unit, configured to splice the at least two first features based on the arrangement order of the at least two preset attributes and the preset attribute to which each first feature belongs;

[0065] The generating unit is configured to execute calling the image generating model and generate the first image based on the spliced ​​first feature.

[0066] Optionally, the acquisition unit is configured to perform random sampling in at least two feature sets to obtain the at least two first features, wherein different feature sets correspond to different preset attributes;

[0067] The allocation unit is configured to allocate preset attributes corresponding to the feature set to which each first feature belongs.

[0068] Optionally, the device further comprises:

[0069] The acquisition unit is further configured to perform random sampling in the feature set to obtain at least two third features;

[0070] The allocating unit is further configured to allocate a preset attribute to each of the at least two third features;

[0071] The generating unit is further configured to execute calling the image generating model, and generate a first sample image based on the at least two third features and the preset attributes to which each third feature belongs, so that the image features belonging to each preset attribute in the first sample image are respectively the same as the third features belonging to each preset attribute;

[0072] a discrimination unit configured to discriminate the first sample image to obtain a first discrimination result, wherein the first discrimination result indicates a probability that the first sample image is discriminated as a non-synthetic image, and the non-synthetic image is not generated by a model;

[0073] The training unit is configured to train the image generation model based on the first discrimination result, so as to increase the probability that the image generated by calling the trained image generation model is discriminated as the non-synthetic image.

[0074] According to another aspect of the embodiments of the present disclosure, a model training device is provided, the device comprising:

[0075] A first acquisition unit is configured to perform random sampling in the feature set to obtain at least two third features;

[0076] an allocating unit, configured to allocate a preset attribute to each of the at least two third features;

[0077] A generating unit is configured to execute calling the image generating model, and generate a first sample image based on the at least two third features and the preset attributes to which each third feature belongs, so that the image features belonging to each preset attribute in the first sample image are respectively the same as the third features belonging to each preset attribute;

[0078] a discrimination unit configured to discriminate the first sample image to obtain a first discrimination result, wherein the first discrimination result indicates a probability that the first sample image is discriminated as a non-synthetic image, and the non-synthetic image is not generated by a model;

[0079] The training unit is configured to train the image generation model based on the first discrimination result, so as to increase the probability that the image generated by calling the trained image generation model is discriminated as the non-synthetic image.

[0080] Optionally, the discrimination unit is configured to execute calling an image discrimination model to discriminate the first sample image to obtain the first discrimination result;

[0081] The training unit is configured to execute training of the image generation model and the image discrimination model based on the first discrimination result, so as to increase the probability that the image generated by the trained image generation model is discriminated as the non-synthetic image, and reduce the probability that the image generated by the image generation model is discriminated as the non-synthetic image by calling the trained image discrimination model.

[0082] Optionally, the device further comprises:

[0083] A second acquisition unit is configured to acquire a second sample image, where the second sample image is the non-synthetic image;

[0084] The discrimination unit is further configured to execute calling the image discrimination model, discriminate the second sample image, and obtain a second discrimination result, wherein the second discrimination result indicates a probability that the second sample image is discriminated as the non-synthetic image;

[0085] The training unit comprises:

[0086] A first training subunit is configured to train the image generation model based on the first discrimination result, so as to increase the probability that the image generated by the trained image generation model is discriminated as the non-synthetic image;

[0087] The second training subunit is configured to train the image discrimination model based on the first discrimination result and the second discrimination result, so as to reduce the probability of calling the trained image discrimination model to discriminate the image generated by the image generation model as the non-synthetic image, and increase the probability of calling the trained image discrimination model to discriminate the non-synthetic image as the non-synthetic image.

[0088] Optionally, the device further comprises:

[0089] The first acquisition unit is further configured to perform random sampling in the feature set to obtain a fourth feature;

[0090] The allocation unit is further configured to replace the third feature of the at least two third features that belongs to a second preset attribute with the fourth feature, where the second preset attribute is any one of the at least two preset attributes;

[0091] The generating unit is further configured to execute calling the image generating model, and generate a third sample image based on the remaining third feature, the fourth feature, the preset attribute to which the remaining third feature belongs, and the preset attribute to which the fourth feature belongs, so that the image feature belonging to each preset attribute in the third sample image is respectively the same as the remaining third feature or the fourth feature belonging to each preset attribute;

[0092] The discrimination unit is configured to perform discrimination on the first sample image and the third sample image to obtain the first discrimination result, wherein the first discrimination result indicates the probability that the first sample image and the third sample image meet a first target condition, wherein the first target condition refers to that the first sample image and the third sample image are discriminated as the non-synthetic images, and that the image features of at least one preset attribute in the first sample image and the third sample image are the same and the image features of at least one preset attribute are different.

[0093] Optionally, the discrimination unit is configured to execute calling an image discrimination model to discriminate the first sample image and the third sample image to obtain the first discrimination result;

[0094] The training unit is configured to execute training of the image generation model and the image discrimination model based on the first discrimination result, so as to increase the probability that at least two images generated by the trained image generation model are discriminated as satisfying the first target condition, and reduce the probability that at least two images generated by the image generation model are discriminated as satisfying the first target condition by calling the trained image discrimination model.

[0095] Optionally, the device further comprises:

[0096] a second acquisition unit, configured to acquire a fourth sample image and a fifth sample image, wherein the fourth sample image and the fifth sample image satisfy a second target condition, wherein the second target condition refers to that the fourth sample image and the fifth sample image are the non-synthetic images, and the fourth sample image and the fifth sample image have the same image feature of at least one preset attribute and different image features of at least one preset attribute;

[0097] The discrimination unit is further configured to execute calling the image discrimination model, discriminate the fourth sample image and the fifth sample image, and obtain a third discrimination result, wherein the third discrimination result indicates a probability that the fourth sample image and the fifth sample image are judged to satisfy the second target condition;

[0098] The training unit comprises:

[0099] A first training subunit is configured to train the image generation model based on the first discrimination result, so as to increase the probability that at least two images generated by calling the trained image generation model are judged to meet the first target condition;

[0100] The second training subunit is configured to train the image discrimination model based on the first discrimination result and the third discrimination result, so as to reduce the probability of calling the trained image discrimination model to discriminate at least two images generated by the image generation model as satisfying the first target condition, and increase the probability of calling the trained image discrimination model to discriminate an image satisfying the second target condition as satisfying the second target condition.

[0101] According to another aspect of the embodiments of the present disclosure, an electronic device is provided, the electronic device comprising:

[0102] processor;

[0103] a memory for storing instructions executable by the processor;

[0104] Among them, the processor is configured to execute the instructions to implement the image generation method as described in the above aspects, or to implement the model training method as described in the above aspects.

[0105] According to another aspect of an embodiment of the present disclosure, a computer-readable storage medium is provided. When instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device can execute the image generation method described in the above aspects, or implement the model training method described in the above aspects.

[0106] According to another aspect of an embodiment of the present disclosure, a computer program product is provided, including a computer program, which, when executed by a processor, implements the image generation method as described in the above aspects, or implements the model training method as described in the above aspects.

[0107] The method provided by the embodiment of the present disclosure assigns at least two preset attributes to at least two features obtained by random sampling, and then calls the image generation model to perform processing based on at least two features and the preset attributes to which each feature belongs, thereby generating an image having these two image features. By assigning specific preset attributes to the features obtained by random sampling, it is possible to control the features belonging to different preset attributes in the generated image. Therefore, by changing the features belonging to one of the preset attributes, the features belonging to the preset attribute in the generated image can be adjusted, while the features belonging to other preset attributes can be guaranteed to remain unchanged, thereby improving the controllability of image generation.

[0108] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0109] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.

[0110] Figure 1 It is a schematic diagram of an implementation environment according to an exemplary embodiment.

[0111] Figure 2 The figure is a flowchart of an image generating method according to an exemplary embodiment.

[0112] Figure 3 is a flowchart of another image generating method according to an exemplary embodiment.

[0113] Figure 4 The figure is a flowchart of a method for training an image generation model according to an exemplary embodiment.

[0114] Figure 5 The figure is a flowchart of another method for training an image generation model according to an exemplary embodiment.

[0115] Figure 6 The figure is a flowchart of another method for training an image generation model according to an exemplary embodiment.

[0116] Figure 7 It is a block diagram of an image generating method according to an exemplary embodiment.

[0117] Figure 8 is a block diagram of another image generating method according to an exemplary embodiment.

[0118] Fig. 9 It is a block diagram of an image recognition method according to an exemplary embodiment.

[0119] Fig.10 The figure is a block diagram of an image generating device according to an exemplary embodiment.

[0120] Fig.11 is a block diagram of another image generating device according to an exemplary embodiment.

[0121] Fig.12 It is a block diagram of a model training device according to an exemplary embodiment.

[0122] Fig.13 It is a block diagram of another model training device according to an exemplary embodiment.

[0123] Fig.14 It is a block diagram of a terminal according to an exemplary embodiment.

[0124] Fig.15 It is a block diagram of a server according to an exemplary embodiment. DETAILED DESCRIPTION

[0125] In order to enable ordinary persons in the art to better understand the technical solutions of the present disclosure, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the accompanying drawings.

[0126] It should be noted that the terms "first", "second", etc. in the specification and claims of the present disclosure and the above-mentioned figure descriptions are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.

[0127] It should be noted that the user information (including but not limited to user device information, user personal information, etc.), data (including but not limited to data used for analysis, stored data, displayed data, etc.) and signals involved in this disclosure are all authorized by the user or fully authorized by all parties. The collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of relevant countries and regions. For example, the images involved in this disclosure were obtained with full authorization.

[0128] The embodiment of the present disclosure provides an image generation method, and the execution subject is an electronic device. Exemplarily, the electronic device is a terminal, and the terminal is a computer, a mobile phone, a tablet computer or other terminals. Exemplarily, the electronic device is a server, and the server is a background server or a cloud server that provides cloud computing and cloud storage services. Among them, the electronic device assigns a preset attribute to each of the at least two features obtained by random sampling, and then calls the image generation model to generate an image based on the at least two features and the preset attributes to which each feature belongs, so that the image features belonging to each preset attribute in the image are respectively the same as the features belonging to each preset attribute. Subsequently, by changing the features belonging to one of the preset attributes, the features belonging to the preset attribute in the generated image are adjusted, and at the same time, the features belonging to other preset attributes can be guaranteed to remain unchanged. Therefore, the embodiment of the present disclosure achieves the control of the features belonging to different preset attributes in the generated image by assigning specific preset attributes to the randomly generated features, thereby improving the controllability of image generation.

[0129] Figure 1 is a schematic diagram of an implementation environment according to an exemplary embodiment. Figure 1 , the implementation environment includes a terminal 101 and a server 102. The terminal 101 and the server 102 are connected via a wireless or wired network.

[0130] Exemplarily, the terminal 101 is installed with a target application provided by the server 102, and the terminal 101 can realize functions such as image generation through the target application. Of course, the target application can also have other functions, such as network social functions, video sharing functions, or chat functions. Exemplarily, the target application is a target application in the operating system of the terminal 101, or a target application provided by a third party. Exemplarily, the target application is a short video application, a game application, a social application, or other applications, which is not limited in the embodiments of the present disclosure.

[0131] In the disclosed embodiment, the server 102 provides an image generation model to the terminal 101. After the terminal 101 randomly samples at least two features, it assigns a preset attribute to each feature, calls the image generation model, and generates an image based on the at least two features and the preset attributes to which each feature belongs.

[0132] The image generation method provided by the embodiments of the present disclosure can be applied to any scenario where image generation is required.

[0133] For example, it is applied in the scenario of making game videos. The electronic device predetermines two preset attributes, one of which is the appearance attribute and the other is the action attribute. Among them, the features belonging to the appearance attribute are used to control the appearance of the virtual object in the image, and the features belonging to the action attribute are used to control the action of the virtual object in the image.

[0134] The electronic device assigns an appearance attribute to a randomly generated feature to obtain a feature belonging to the appearance attribute, and assigns action attributes to the randomly generated multiple features respectively to obtain multiple different features belonging to the action attribute. Then the electronic device uses the method provided by the embodiment of the present disclosure to call the image generation model, and generates each image based on the feature belonging to the appearance attribute and each feature belonging to the action attribute. Among them, since the same feature belonging to the appearance attribute is used, the appearance of the virtual objects in the generated multiple images is the same, and since different features belonging to the action attribute are used, the actions of the virtual objects in the multiple images are different. Finally, the electronic device synthesizes these multiple images into a video, which includes the same virtual object performing different actions, and this video can be used as a game video for plot guidance in electronic games.

[0135] In addition, the image generation method provided in the embodiments of the present disclosure can also be applied to other scenarios. For example, the method provided in the embodiments of the present disclosure can be used to generate multiple images including the same virtual object and having different image styles. For another example, multiple images including different virtual objects and the same actions performed by the virtual objects can be generated, etc. The embodiments of the present disclosure are not limited to this.

[0136] Figure 2 is a flowchart of an image generation method according to an exemplary embodiment. Figure 2 The method is performed by an electronic device and comprises the following steps:

[0137] In step 201, the electronic device randomly samples from a feature set to obtain at least two first features.

[0138] In an embodiment of the present disclosure, a feature set includes multiple features for generating an image. The features in the feature set may be features in any form, for example, the features in the feature set are all features in the form of vectors. Optionally, multiple features in the feature set conform to a target distribution, for example, the target distribution is a Gaussian distribution, etc., which is not limited in the embodiment of the present disclosure. The electronic device performs random sampling in the feature set to obtain at least two first features, and since the at least two first features are obtained by random sampling, they can be called random noise.

[0139] In step 202, the electronic device assigns a preset attribute to each of the at least two first features.

[0140] The electronic device pre-sets at least two preset attributes, and the preset attributes refer to the attributes of the image, for example, the preset attributes are the style attributes of the image, the color attributes of the image, the appearance attributes of the virtual object in the image, the action attributes of the virtual object in the image, or the gender attributes of the virtual object in the image, etc. For example, the virtual object in the character image refers to the virtual character, and the virtual object in the animal image refers to the virtual animal, etc. After the electronic device obtains at least two first features, one of the at least two preset attributes is assigned to each first feature, and each first feature is assigned to a different preset attribute, thereby obtaining a first feature belonging to at least two preset attributes, so that the at least two first features have specific physical meanings.

[0141] In step 203, the electronic device calls the image generation model to generate a first image based on at least two first features and the preset attributes to which each first feature belongs, so that the image features belonging to each preset attribute in the first image are respectively the same as the first features belonging to each preset attribute.

[0142] The image generation model is used to generate an image based on the features belonging to the at least two preset attributes. The training process of the image generation model is as follows: Figure 4 After the electronic device assigns preset attributes to at least two first features, the electronic device calls the image generation model, processes the at least two first features according to the preset attributes to which the at least two first features belong, maps the first features from the feature space to the image space, thereby obtaining a first image, and outputs the first image. The image features belonging to each preset attribute in the first image are respectively the same as the first features belonging to each preset attribute.

[0143] For example, the at least two first features include a first feature A belonging to an appearance attribute and a first feature B belonging to an action attribute. The electronic device calls an image generation model to generate a first image including a virtual object based on the two first features and the preset attributes to which each first feature belongs. The virtual object in the first image has the appearance indicated by the first feature A and the action indicated by the first feature B.

[0144] In step 204, the electronic device replaces the first feature of at least two first features that belongs to a first preset attribute with the second feature obtained by random sampling, where the first preset attribute is any one of the at least two preset attributes.

[0145] The electronic device continues to randomly sample the feature set to obtain a second feature. The second feature is similar to the first feature, and both the second feature and the first feature are features obtained by random sampling, for example, both the second feature and the first feature are features in the form of vectors.

[0146] The electronic device determines a first preset attribute among the at least two preset attributes, where the first preset attribute is any one of the at least two preset attributes. The electronic device determines a first feature belonging to the first preset attribute among the at least two first features, and replaces the first feature belonging to the first preset attribute with a second feature obtained by random sampling, where the second feature is different from the first feature belonging to the first preset attribute. Among the at least two features obtained after the replacement, the feature belonging to the first preset attribute has changed, while the features belonging to attributes other than the first preset attribute have not changed.

[0147] In step 205, the electronic device calls the image generation model to generate a second image based on the remaining first features, the second features, and the preset attributes to which the remaining first features belong and the preset attributes to which the second features belong, so that the image features belonging to each preset attribute in the second image are respectively the same as the remaining first features or second features belonging to each preset attribute.

[0148] The process of calling the image generation model to generate the second image in step 205 is the same as the process of calling the image generation model to generate the first image in step 203 above, and will not be described in detail here.

[0149] For ease of explanation, the other attributes of the at least two preset attributes except the first preset attribute are referred to as third preset attributes, and image features belonging to the first preset attribute in the first image are different from image features belonging to the first preset attribute in the second image, and image features belonging to the third preset attribute in the first image are the same as image features belonging to the third preset attribute in the second image.

[0150] For example, the first preset attribute is an action attribute, which indicates the action of a virtual object in an image, and the third preset attribute is an appearance attribute, which indicates the appearance of the virtual object in the image. Since the features of the first preset attribute used to generate the first image and the second image are different, the action of the virtual object in the first image is different from the action of the virtual object in the second image. Since the features of the third preset attribute used to generate the first image and the second image are the same, the appearance of the virtual object in the first image is the same as the appearance of the virtual object in the second image.

[0151] The method provided by the embodiment of the present disclosure assigns at least two preset attributes to at least two features obtained by random sampling, and then calls the image generation model to perform processing based on at least two features and the preset attributes to which each feature belongs, thereby generating an image having these two image features. By assigning specific preset attributes to the features obtained by random sampling, it is possible to control the features belonging to different preset attributes in the generated image. Therefore, by changing the features belonging to one of the preset attributes, the features belonging to the preset attribute in the generated image can be adjusted, while the features belonging to other preset attributes can be guaranteed to remain unchanged, thereby improving the controllability of image generation.

[0152] Figure 3 is a flowchart of another image generating method according to an exemplary embodiment, the method is executed by an electronic device, with the above Figure 2 Based on the embodiment of the present disclosure, the embodiment of the present disclosure specifically describes the process of randomly sampling to obtain the first feature and the second feature and to generate the first image and the second image. Figure 3 , the method comprises the following steps:

[0153] In step 301, the electronic device randomly samples at least two feature sets to obtain at least two first features.

[0154] In the disclosed embodiment, the electronic device pre-sets at least two preset attributes, which are attributes of the image. The electronic device creates a feature set for each preset attribute, thereby obtaining at least two feature sets, each of which includes at least one randomly generated feature, and different feature sets correspond to different preset attributes.

[0155] Optionally, the dimensions of features in different feature sets are different, for example, the dimension of features in the feature set corresponding to the first preset attribute is 5, and the dimension of features in the feature set corresponding to the second preset attribute is 10, etc. Among them, the features in the feature set can be features in any form, for example, the features in the at least two feature sets are all features in the form of vectors. Optionally, multiple features in each feature set conform to the target distribution, for example, the target distribution is a Gaussian distribution, etc., which is not limited in the embodiments of the present disclosure.

[0156] The electronic device randomly samples the at least two feature sets respectively, so as to obtain a first feature by sampling in each feature set. For example, the at least two feature sets include feature set A and feature set B, and the electronic device randomly samples in feature set A to obtain a first feature x, and randomly samples in feature set B to obtain a first feature y.

[0157] In step 302, the electronic device assigns a preset attribute corresponding to the feature set to which each first feature belongs.

[0158] After the electronic device acquires at least two first features, for each first feature, the preset attribute corresponding to the feature set to which the first feature belongs is determined, and the preset attribute is assigned to the first feature, thereby determining the first feature as an image feature belonging to the preset attribute, and finally obtaining a first feature belonging to at least two preset attributes. That is, by assigning the preset attribute to the first feature, the first feature without physical meaning is converted into a feature with specific physical meaning.

[0159] In the disclosed embodiment, the electronic device creates different feature sets for different preset attributes, then randomly samples from different feature sets to obtain a first feature, and assigns different preset attributes to the first features sampled from different feature sets, thereby increasing the difference between features belonging to different preset attributes, making it easier to separately control features belonging to different preset attributes in a generated image, thereby improving the controllability of image generation.

[0160] For example, the at least two preset attributes include an appearance attribute and an action attribute, the appearance attribute is used to represent the appearance of the virtual object in the image, and the action attribute is used to represent the action of the virtual object in the image. After the electronic device obtains the first feature x and the first feature y, it determines the first feature x as an image feature belonging to the appearance attribute, and determines the first feature y as an image feature belonging to the action attribute.

[0161] In step 303, the electronic device splices at least two first features based on the arrangement order of the at least two preset attributes and the preset attribute to which each first feature belongs.

[0162] For example, the at least two preset attributes are appearance attributes and action attributes, the first feature A belongs to the appearance attribute, and the first feature B belongs to the action attribute. The arrangement order of the at least two preset attributes is "appearance attribute, action attribute". The electronic device splices the two first features according to the arrangement order of "first feature A, first feature B", that is, the first feature A is in front and the first feature B is in the back.

[0163] In step 304, the electronic device calls the image generation model to generate a first image based on the spliced ​​first features.

[0164] The image features belonging to each preset attribute in the first image are respectively the same as the first features belonging to each preset attribute. In the disclosed embodiment, since the at least two first features are spliced ​​according to the arrangement order of the at least two preset attributes, after the spliced ​​first features are input into the image generation model, the image generation model can determine which part of the spliced ​​features belongs to which preset attribute according to the arrangement order of the at least two preset attributes, thereby performing targeted processing on each part of the spliced ​​features to generate a corresponding image.

[0165] In step 305, the electronic device replaces the first feature of the at least two first features that belongs to the first preset attribute with the second feature obtained by random sampling.

[0166] The process of replacing the first feature with the second feature in step 305 is the same as the process of replacing the first feature with the second feature in step 204, and will not be described in detail here.

[0167] In step 306, the electronic device combines the remaining first features and the second features based on the arrangement order of the at least two preset attributes and the preset attributes to which the remaining first features belong and the preset attributes to which the second features belong.

[0168] In step 307, the electronic device calls the image generation model to generate a second image based on the spliced ​​first feature and the second feature.

[0169] The image features of each preset attribute in the second image are respectively the same as the remaining first features or second features of each preset attribute. The process of generating the second image in step 306-step 307 is the same as the process of generating the first image in step 303-step 304, and will not be described in detail here.

[0170] In the disclosed embodiments, different preset attributes are divided to control the features of different preset attributes in the image. When generating an image, the features of one of the preset attributes can be adjusted in the generated image by changing the features of the preset attribute. At the same time, the features of other preset attributes can be kept unchanged, thereby achieving control over the features of the image.

[0171] The method provided by the embodiment of the present disclosure assigns at least two preset attributes to at least two features obtained by random sampling, and then calls the image generation model to perform processing based on at least two features and the preset attributes to which each feature belongs, thereby generating an image having these two image features. By assigning specific preset attributes to the features obtained by random sampling, it is possible to control the features belonging to different preset attributes in the generated image. Therefore, by changing the features belonging to one of the preset attributes, the features belonging to the preset attribute in the generated image can be adjusted, while the features belonging to other preset attributes can be guaranteed to remain unchanged, thereby improving the controllability of image generation.

[0172] Furthermore, different feature sets are created for different preset attributes, and then random sampling is performed in different feature sets to obtain the first feature, and different preset attributes are assigned to the first features sampled in different feature sets, thereby increasing the difference between image features belonging to different preset attributes, making it easier to control the features belonging to different preset attributes in the generated image separately, thereby improving the controllability of image generation.

[0173] Moreover, the at least two first features can be spliced ​​according to the arrangement order of at least two preset attributes. Therefore, after the spliced ​​first features are input into the image generation model, the image generation model can determine which part of the spliced ​​features belongs to which preset attribute according to the arrangement order of the at least two preset attributes, thereby performing targeted processing on each part of the spliced ​​features to generate a corresponding image.

[0174] Figure 4 is a flowchart of a method for training an image generation model according to an exemplary embodiment, the method being executed by an electronic device, see Figure 4 , the method comprises the following steps:

[0175] In step 401, the electronic device performs random sampling in a feature set to obtain at least two third features.

[0176] In step 402, the electronic device assigns a preset attribute to each of the at least two third features.

[0177] In some embodiments, the electronic device randomly samples at least two feature sets to obtain at least two third features, each feature set includes at least one randomly generated feature, and different feature sets correspond to different preset attributes. The electronic device assigns a preset attribute corresponding to the feature set to which it belongs to each third feature, respectively, to obtain third features belonging to at least two preset attributes.

[0178] In step 403, the electronic device calls the image generation model to generate a first sample image based on at least two third features and the preset attributes to which each third feature belongs, so that the image features belonging to each preset attribute in the first sample image are respectively the same as the third features belonging to each preset attribute.

[0179] In some embodiments, the electronic device splices at least two third features based on the arrangement order of the at least two preset attributes and the preset attribute to which each third feature belongs. The electronic device calls the image generation model to generate a first sample image based on the spliced ​​third features.

[0180] The process of generating the first sample image in step 401 to step 403 is the same as the process of generating the first image in step 201 to step 203 or step 301 to step 304, and will not be described in detail here.

[0181] In step 404, the electronic device identifies the first sample image to obtain a first identification result.

[0182] After obtaining the first sample image, the electronic device discriminates the first sample image to obtain a first discrimination result, which indicates the probability that the first sample image is discriminated as a non-synthetic image, which is not generated by the model.

[0183] In the disclosed embodiment, the first sample image is generated by the image generation model. The greater the probability that the first sample image is judged as a non-synthetic image, the more realistic the first sample image is, indicating that the effect of the image generated by the image generation model is better, that is, the image generation model has a stronger ability to generate images. The smaller the probability that the first sample image is judged as a non-synthetic image, the less realistic the first sample image is, indicating that the effect of the image generated by the image generation model is worse, that is, the image generation model has a weaker ability to generate images.

[0184] In step 405, the electronic device trains the image generation model based on the first discrimination result, so as to increase the probability that an image generated by calling the trained image generation model is discriminated as a non-synthetic image.

[0185] Since the greater the probability that an image generated by the image generation model is judged as a non-synthetic image, the better the effect of the image generated by the image generation model, and the smaller the probability that an image generated by the image generation model is judged as a non-synthetic image, the worse the effect of the image generated by the image generation model, the electronic device trains the image generation model with increasing the probability that the first sample image is judged as a non-synthetic image as a training goal, so as to increase the probability that the image generated by the trained image generation model is judged as a non-synthetic image.

[0186] Among them, increasing the probability of an image generated by calling the trained image generation model to be judged as a non-synthetic image means that when the input of the image generation model is the same, the probability of an image generated by calling the trained image generation model to be judged as a non-synthetic image is greater than the probability of an image generated by calling the image generation model before training to be judged as a non-synthetic image.

[0187] The method provided by the embodiment of the present disclosure assigns at least two preset attributes to at least two randomly generated features, obtains features belonging to the at least two preset attributes, and then calls an image generation model to process the features belonging to the at least two preset attributes to generate a sample image, and then trains the image generation model based on the discrimination result of the sample image to increase the probability that the image generated by the image generation model is discriminated as a non-synthetic image, thereby enabling the image synthesis model to learn how to generate an image based on the features of at least two preset attributes, thereby being able to control the properties of the synthesized image and improving the controllability of image synthesis.

[0188] Figure 5 is a flowchart of another method for training an image generation model according to an exemplary embodiment, the method is executed by an electronic device, with the above Figure 4 Based on the embodiment of the present disclosure, the embodiment of the present disclosure specifically describes the process of training the image generation model and the image discrimination model. Figure 5 , the method comprises the following steps:

[0189] In step 501, the electronic device performs random sampling in a feature set to obtain at least two third features.

[0190] In step 502, the electronic device assigns a preset attribute to each of the at least two third features.

[0191] In step 503, the electronic device calls the image generation model to generate a first sample image based on at least two third features and the preset attributes to which each third feature belongs, so that the image features belonging to each preset attribute in the first sample image are respectively the same as the third features belonging to each preset attribute.

[0192] The process of generating the first sample image in step 501 to step 503 is the same as the process of generating the first sample image in step 401 to step 403, and will not be described in detail here.

[0193] In step 504, the electronic device calls the image discrimination model to discriminate the first sample image and obtain a first discrimination result.

[0194] The image discrimination model is used to discriminate the probability that any image is a non-synthetic image. After the electronic device obtains the first sample image, the first sample image is input into the image discrimination model, and the image discrimination model discriminates the first sample image and outputs the first discrimination result.

[0195] In the embodiment of the present disclosure, the first sample image is generated by the image generation model, and the greater the probability that the first sample image is discriminated as a non-synthetic image by the image discrimination model, the lower the accuracy of the image discrimination model. The smaller the probability that the first sample image is discriminated as a non-synthetic image by the image discrimination model, the higher the accuracy of the image discrimination model.

[0196] In step 505, the electronic device trains the image generation model and the image discrimination model based on the first discrimination result, so as to increase the probability that an image generated by the trained image generation model is discriminated as a non-synthetic image, and reduce the probability that an image generated by the image generation model is discriminated as a non-synthetic image by calling the trained image discrimination model.

[0197] Since the greater the probability that an image generated by the image generation model is judged as a non-synthetic image, the better the effect of the image generated by the image generation model, and the smaller the probability that an image generated by the image generation model is judged as a non-synthetic image, the worse the effect of the image generated by the image generation model, the electronic device trains the image generation model with increasing the probability that the first sample image is judged as a non-synthetic image as a training goal, so as to increase the probability that the image generated by the trained image generation model is judged as a non-synthetic image.

[0198] Since the greater the probability that the first sample image is judged as a non-synthetic image by the image discrimination model, the lower the accuracy of the image discrimination model. The smaller the probability that the first sample image is judged as a non-synthetic image by the image discrimination model, the higher the accuracy of the image discrimination model. Therefore, the electronic device trains the image discrimination model with the training goal of reducing the probability that the image discrimination model judges the first sample image as a non-synthetic image, so as to reduce the probability that the trained image discrimination model is called to judge the image generated by the image generation model as a non-synthetic image.

[0199] Among them, reducing the probability of calling the trained image discrimination model to discriminate the image generated by the image generation model as a non-synthetic image means that when the image generated by the input image generation model is the same, the probability of calling the trained image discrimination model to discriminate the image as a non-synthetic image is lower than the probability of calling the pre-trained image discrimination model to discriminate the image as a non-synthetic image.

[0200] In the disclosed embodiment, the idea of ​​adversarial training is used to train the image generation model and the image discrimination model. By training the image generation model, the image discrimination model is difficult to distinguish the images generated by the image generation model, thereby improving the accuracy of the image generation model. By training the image discrimination model, the image discrimination model is able to distinguish the images generated by the image generation model, thereby improving the accuracy of the image discrimination model. By conducting adversarial training on the image generation model and the image discrimination model, the effect of image generation can be improved.

[0201] In some embodiments, the above step 505 is replaced by the following steps 511-513:

[0202] 511. The electronic device obtains a second sample image, calls an image discrimination model, discriminates the second sample image, and obtains a second discrimination result.

[0203] The second sample image is a non-synthetic image, for example, the second sample image is an image captured by the electronic device from a video, or the second sample image is an image photographed by the electronic device, etc. The second discrimination result indicates the probability that the second sample image is discriminated as a non-synthetic image.

[0204] In the disclosed embodiment, the second sample image is a non-synthetic image. The greater the probability that the second sample image is discriminated as a non-synthetic image by the image discrimination model, the higher the accuracy of the image discrimination model. The smaller the probability that the second sample image is discriminated as a non-synthetic image by the image discrimination model, the lower the accuracy of the image discrimination model.

[0205] 512. The electronic device trains an image generation model based on the first discrimination result to increase the probability that an image generated by the trained image generation model is discriminated as a non-synthetic image.

[0206] 513. The electronic device trains an image discrimination model based on the first discrimination result and the second discrimination result, so as to reduce the probability of calling the trained image discrimination model to discriminate an image generated by the image generation model as a non-synthetic image, and to increase the probability of calling the trained image discrimination model to discriminate a non-synthetic image as a non-synthetic image.

[0207] Since the greater the probability that the first sample image is discriminated as a non-synthetic image by the image discrimination model, the lower the accuracy of the image discrimination model. The smaller the probability that the first sample image is discriminated as a non-synthetic image by the image discrimination model, the higher the accuracy of the image discrimination model. Therefore, the electronic device trains the image discrimination model with the training goal of reducing the probability that the image discrimination model discriminates the first sample image as a non-synthetic image, so as to reduce the probability that the trained image discrimination model is called to discriminate the image generated by the image generation model as a non-synthetic image.

[0208] Since the greater the probability that the second sample image is discriminated as a non-synthetic image by the image discrimination model, the higher the accuracy of the image discrimination model. The smaller the probability that the second sample image is discriminated as a non-synthetic image by the image discrimination model, the lower the accuracy of the image discrimination model. Therefore, the electronic device trains the image discrimination model with the training goal of increasing the probability that the image discrimination model discriminates the second sample image as a non-synthetic image, so as to increase the probability of calling the trained image discrimination model to discriminate a non-synthetic image as a non-synthetic image.

[0209] In the disclosed embodiment, the first sample image generated by the image generation model is used as a negative sample, and the second sample image belonging to the non-synthetic image is used as a positive sample. The positive and negative samples are used to jointly train the image discrimination model. This enables the image discrimination model to learn how to discriminate non-synthetic images from both the positive and negative sample perspectives, which is conducive to further improving the discrimination ability and accuracy of the image discrimination model.

[0210] The method provided by the embodiment of the present disclosure assigns at least two preset attributes to at least two randomly generated features, obtains features belonging to the at least two preset attributes, and then calls an image generation model to process the features belonging to the at least two preset attributes to generate a sample image, and then trains the image generation model based on the discrimination result of the sample image to increase the probability that the image generated by the image generation model is discriminated as a non-synthetic image, thereby enabling the image synthesis model to learn how to generate an image based on the features of at least two preset attributes, thereby being able to control the properties of the synthesized image and improving the controllability of image synthesis.

[0211] In addition, the image generation model and the image discrimination model are trained using the idea of ​​adversarial training. By training the image generation model, the image discrimination model is difficult to distinguish the images generated by the image generation model, thereby improving the accuracy of the image generation model. By training the image discrimination model, the image discrimination model can distinguish the images generated by the image generation model, thereby improving the accuracy of the image discrimination model. By conducting adversarial training on the image generation model and the image discrimination model, the effect of image generation can be improved.

[0212] In addition, the first sample image generated by the image generation model is used as a negative sample, and the second sample image belonging to a non-synthetic image is used as a positive sample. The positive and negative samples are used to jointly train the image discrimination model. This enables the image discrimination model to learn how to discriminate non-synthetic images from both the positive and negative sample perspectives, which is conducive to further improving the discrimination ability and accuracy of the image discrimination model.

[0213] Figure 6 is a flowchart of another method for training an image generation model according to an exemplary embodiment, the method is executed by an electronic device, with the above Figure 4 Based on the embodiment of the present disclosure, the embodiment of the present disclosure specifically describes the process of training the image generation model and the image discrimination model. Figure 6 , the method comprises the following steps:

[0214] In step 601, the electronic device performs random sampling in a feature set to obtain at least two third features.

[0215] In step 602, the electronic device assigns a preset attribute to each of the at least two third features.

[0216] In step 603, the electronic device calls the image generation model to generate a first sample image based on at least two third features and the preset attributes to which each third feature belongs, so that the image features belonging to each preset attribute in the first sample image are respectively the same as the third features belonging to each preset attribute.

[0217] The process of generating the first sample image in step 601 to step 603 is the same as the process of generating the first sample image in step 401 to step 403, and will not be described in detail here.

[0218] In step 604, the electronic device performs random sampling in the feature set to obtain a fourth feature, and replaces the third feature of at least two third features that belongs to the second preset attribute with the fourth feature.

[0219] The electronic device continues to randomly sample from the feature set to obtain a fourth feature. The electronic device determines a second preset attribute from the at least two preset attributes, the second preset attribute is any one of the at least two preset attributes, the electronic device determines a third feature belonging to the second preset attribute from the at least two third features, and replaces the third feature belonging to the second preset attribute with a fourth feature obtained by random sampling, the fourth feature is different from the third feature belonging to the second preset attribute, then among the at least two features obtained after the replacement, the feature belonging to the second preset attribute has changed, and the features belonging to attributes other than the second preset attribute have not changed.

[0220] In step 605, the electronic device calls the image generation model to generate a third sample image based on the remaining third feature, the fourth feature, and the preset attributes to which the remaining third feature belongs and the preset attributes to which the fourth feature belongs, so that the image features belonging to each preset attribute in the third sample image are respectively the same as the remaining third features or fourth features belonging to each preset attribute.

[0221] The process of calling the image generation model to generate the third sample image in step 605 is the same as the process of calling the image generation model to generate the first sample image in step 503, and will not be described in detail here.

[0222] For the sake of convenience, the other attributes of the at least two preset attributes except the second preset attribute are called the fourth preset attribute. The image features belonging to the second preset attribute in the first sample image are different from the image features belonging to the second preset attribute in the third sample image, and the image features belonging to the fourth preset attribute in the first sample image are the same as the image features belonging to the fourth preset attribute in the third sample image.

[0223] In step 606, the electronic device calls the image discrimination model to discriminate the first sample image and the third sample image to obtain a first discrimination result.

[0224] In the disclosed embodiment, the image discrimination model is used to discriminate whether any two images satisfy the first target condition, and the first discrimination result indicates the probability that the first sample image and the third sample image satisfy the first target condition. The first target condition refers to that the first sample image and the third sample image are discriminated as non-synthetic images, and the image features of at least one preset attribute in the first sample image and the third sample image are the same and the image features of at least one preset attribute are different.

[0225] The greater the probability that the first sample image and the third sample image are judged to satisfy the first target condition, the more realistic the image generated by the image generation model is, and the stronger the ability of the image generation model to distinguish image features of different attributes is, that is, the higher the accuracy of the image generation model is. The smaller the probability that the first sample image and the third sample image are judged to satisfy the first target condition, the less realistic the first sample image is, and the weaker the ability of the image generation model to distinguish image features of different attributes is, that is, the lower the accuracy of the image generation model is.

[0226] In addition, during the training process, it can be considered that the accuracy of the image generation model is not high enough, and it can be considered that the first sample image and the third sample image do not meet the first target condition. Therefore, the greater the probability that the first sample image and the third sample image are judged by the image discrimination model as meeting the first target condition, the lower the accuracy of the image discrimination model. The smaller the probability that the first sample image and the third sample image are judged by the image discrimination model as meeting the first target condition, the higher the accuracy of the image discrimination model.

[0227] In step 607, the electronic device trains the image generation model and the image discrimination model based on the first discrimination result, so as to increase the probability that at least two images generated by the trained image generation model are discriminated as satisfying the first target condition, and reduce the probability that at least two images generated by the image generation model are discriminated as satisfying the first target condition by calling the trained image discrimination model.

[0228] Since the greater the probability that the first sample image and the third sample image are judged to satisfy the first target condition, the higher the accuracy of the image generation model. The smaller the probability that the first sample image and the third sample image are judged to satisfy the first target condition, the lower the accuracy of the image generation model. Therefore, the electronic device trains the image generation model with the training goal of increasing the probability that the first sample image and the third sample image are judged to satisfy the first target condition, so as to increase the probability that at least two images generated by calling the trained image generation model are judged to satisfy the first target condition.

[0229] Optionally, increasing the probability that at least two images generated by calling the trained image generation model are judged as satisfying the first target condition means that when the input of the image generation model is the same, using a method similar to the above steps 601 to 606, the probability that the two images generated by calling the trained image generation model are judged as satisfying the first target condition is greater than the probability that the two images generated by calling the pre-trained image generation model are judged as satisfying the first target condition.

[0230] In the disclosed embodiments, different preset attributes are divided to control the features in the image belonging to different preset attributes. In the process of training the image generation model, the features belonging to one of the preset attributes are changed to adjust the features in the generated image belonging to the preset attribute, while ensuring that the features belonging to other preset attributes remain unchanged, so that the image generation model learns how to distinguish the features belonging to different preset attributes, thereby improving the image generation model's ability to control the image generation process.

[0231] In addition, the greater the probability that the first sample image and the third sample image are judged by the image discrimination model as satisfying the first target condition, the lower the accuracy of the image discrimination model. The smaller the probability that the first sample image and the third sample image are judged by the image discrimination model as satisfying the first target condition, the higher the accuracy of the image discrimination model. Therefore, the electronic device trains the image discrimination model with the training goal of reducing the probability that the image discrimination model judges the first sample image and the third sample image as satisfying the first target condition, so as to reduce the probability that the trained image discrimination model is called to judge at least two images generated by the image generation model as satisfying the first target condition.

[0232] Optionally, reducing the probability that the trained image discrimination model is called to discriminate at least two images generated by the image generation model as satisfying the first target condition means that when the two input images are the same, the probability that the trained image discrimination model is called to discriminate the two images as satisfying the first target condition is less than the probability that the pre-trained image discrimination model is called to discriminate the two images as satisfying the first target condition. Furthermore, the two input images are generated by calling the image generation model using the same method as steps 601 to 606 above.

[0233] In the disclosed embodiment, the idea of ​​adversarial training is used to train the image generation model and the image discrimination model. By training the image generation model, the image discrimination model is difficult to accurately discriminate the two images generated by the image generation model, thereby improving the accuracy of the image generation model. By training the image discrimination model, the image discrimination model is able to accurately discriminate the two images generated by the image generation model, thereby improving the accuracy of the image discrimination model. By performing adversarial training on the image generation model and the image discrimination model, the effect of image generation can be improved.

[0234] It should be noted that the embodiments of the present disclosure are only described by calling the image discrimination model to discriminate the first sample image and the third sample image. In other embodiments, the electronic device may also use other methods to discriminate the first sample image and the third sample image to obtain a first discrimination result, and train the image generation model based on the first discrimination result to increase the probability that at least two images generated by calling the trained image generation model are discriminated as meeting the first target condition.

[0235] In some embodiments, the above step 607 is replaced by the following steps 611-614:

[0236] 611. The electronic device obtains a fourth sample image and a fifth sample image.

[0237] Among them, the fourth sample image and the fifth sample image meet the second target condition, and the second target condition means that the fourth sample image and the fifth sample image are non-synthetic images, and the image features of at least one preset attribute in the fourth sample image and the fifth sample image are the same and the image features of at least one preset attribute are different.

[0238] For example, the fourth sample image and the fifth sample image are two different images captured by the electronic device from the same video, and the two images have similarities and differences, for example, the two images include the same object but the actions performed by the object are different. Alternatively, the fourth sample image and the fifth sample image are two different images obtained by the electronic device shooting the same object, etc.

[0239] 612. The electronic device calls the image discrimination model to discriminate the fourth sample image and the fifth sample image to obtain a third discrimination result.

[0240] The third discrimination result indicates the probability that the fourth sample image and the fifth sample image are judged to satisfy the second target condition. In the embodiment of the present disclosure, since the fourth sample image and the fifth sample image satisfy the second target condition, the greater the probability that the fourth sample image and the fifth sample image are judged to satisfy the second target condition by the image discrimination model, the higher the accuracy of the image discrimination model. The smaller the probability that the fourth sample image and the fifth sample image are judged to satisfy the second target condition by the image discrimination model, the lower the accuracy of the image discrimination model.

[0241] 613. The electronic device trains an image generation model based on the first discrimination result to increase the probability that at least two images generated by the trained image generation model are discriminated as satisfying the first target condition.

[0242] 614. The electronic device trains an image discrimination model based on the first discrimination result and the third discrimination result, so as to reduce the probability of calling the trained image discrimination model to discriminate at least two images generated by the image generation model as satisfying the first target condition, and to increase the probability of calling the trained image discrimination model to discriminate an image satisfying the second target condition as satisfying the second target condition.

[0243] Since the greater the probability that the first sample image and the third sample image are judged by the image discrimination model as satisfying the first target condition, the lower the accuracy of the image discrimination model. The smaller the probability that the first sample image and the third sample image are judged by the image discrimination model as satisfying the first target condition, the higher the accuracy of the image discrimination model. Therefore, the electronic device trains the image discrimination model with the training goal of reducing the probability that the image discrimination model judges the first sample image and the third sample image as satisfying the first target condition, so as to reduce the probability that the trained image discrimination model is called to judge at least two images generated by the image generation model as satisfying the first target condition.

[0244] Since the probability that the fourth sample image and the fifth sample image are judged by the image discrimination model as satisfying the second target condition is greater, the accuracy of the image discrimination model is higher. The probability that the fourth sample image and the fifth sample image are judged by the image discrimination model as satisfying the second target condition is smaller, the accuracy of the image discrimination model is lower. Therefore, the electronic device trains the image discrimination model with the training goal of increasing the probability that the image discrimination model judges the fourth sample image and the fifth sample image as satisfying the second target condition, so as to increase the probability that the trained image discrimination model is called to judge the image satisfying the second target condition as satisfying the second target condition.

[0245] In the disclosed embodiment, the first sample image and the third sample image generated by the image generation model are used as negative samples, and the fourth sample image and the fifth sample image that meet the second target condition are used as positive samples. The positive samples and the negative samples are used to jointly train the image discrimination model. This enables the image discrimination model to learn how to discriminate images from both the positive and negative sample perspectives, which is conducive to further improving the discrimination ability and accuracy of the image discrimination model.

[0246] In the related art, by training an image generation model, the mapping relationship between random noise and image is learned, and the image generation model can be called to generate an image based on random noise. Figure 7 As shown, random noise is input into the image generation model, and then the generated image is output. However, in this method, it is unknown which features of the image are controlled by each dimension in the random noise, and one dimension in the random noise may affect multiple features of the image. Therefore, it is difficult to control the features of the generated image through random noise.

[0247] The disclosed embodiment provides a controllable image synthesis method. In the process of training an image generation model, by assigning specific preset attributes to randomly generated features, different types of features in the image are distinguished, so that the image generation model can control the features of different preset attributes in the generated image. Taking at least two preset attributes including a first preset attribute and a second preset attribute as an example, the training process of the image generation model is as follows.

[0248] (1) Acquire features belonging to the first preset attribute and features belonging to the second preset attribute.

[0249] The electronic device obtains the standard Gaussian distribution p(z id ) and the standard Gaussian distribution p(z corresponding to the second preset attribute s ), from the standard Gaussian distribution p(z id ) as the first feature z belonging to the first preset attribute id , from the standard Gaussian distribution p(z s ) and sample two features as the second feature z belonging to the second preset feature. s1 and the third feature z s2 .

[0250] (ii) Generate a first image and a second image.

[0251] like Figure 8 As shown, the electronic device converts the first feature z id and the second feature z s1 Input into the image generation model to generate images The first feature z id and the third feature z s2 Input into the image generation model to generate images

[0252]

[0253] Where G(·) represents the image generation model.

[0254] (III) Image and images Make a judgment.

[0255] Electronic devices convert images and images Input into the image discrimination model to obtain the discrimination result D1, which represents the image and images The probability of meeting the condition, where the condition refers to the image and images It is judged as a non-synthetic image, and the image and images The image features of one preset attribute are the same and the image features of another preset attribute are different.

[0256] (iv) Distinguish image I1 and image I2.

[0257] The electronic device captures images I1 and I2 from the video q(x), such as Fig. 9 As shown, the electronic device inputs the image I1 and the image I2 into the image discrimination model to obtain a discrimination result D2, which represents the probability that the image I1 and the image I2 meet the condition, wherein the condition is that the image I1 and the image I2 are discriminated as non-synthetic images, and the image features of one preset attribute in the image I1 and the image I2 are the same and the image features of one preset attribute are different.

[0258] (V) Train image synthesis model and image discrimination model.

[0259] The electronic device determines first target information, and trains the image synthesis model by minimizing the first target information. The formula of the first target information is as follows:

[0260]

[0261] Wherein, X represents the first target information, represents the discrimination result D1, D(·) represents the image discrimination model, represents the standard Gaussian distribution p(z id ) and the standard Gaussian distribution p(z s ) is the mathematical expectation of .

[0262] The electronic device determines the second target information, and trains the image discrimination model by maximizing the second target information. The formula of the second target information is as follows:

[0263]

[0264] Wherein, Y represents the second target information, represents the discrimination result D1, D(I1,I2) represents the discrimination result D2, D(·) represents the image discrimination model, represents the standard Gaussian distribution p(z id ) and the standard Gaussian distribution p(z s ) is the mathematical expectation of . Represents the mathematical expectation of the video q(x).

[0265] Fig.10 is a block diagram of an image generating device according to an exemplary embodiment. Fig.10The device includes an acquisition unit 1001, an allocation unit 1002 and a generation unit 1003.

[0266] An acquisition unit 1001 is configured to perform random sampling in a feature set to obtain at least two first features, where the feature set includes a plurality of features used to generate an image;

[0267] An allocating unit 1002 is configured to allocate a preset attribute to each of the at least two first features;

[0268] The generating unit 1003 is configured to execute calling the image generating model, and generate the first image based on at least two first features and the preset attribute to which each first feature belongs, so that the image feature belonging to each preset attribute in the first image is respectively the same as the first feature belonging to each preset attribute;

[0269] The allocation unit 1002 is further configured to replace a first feature belonging to a first preset attribute among at least two first features with a second feature obtained by random sampling, where the first preset attribute is any one of the at least two preset attributes;

[0270] The generation unit 1003 is also configured to execute the call of the image generation model to generate a second image based on the remaining first features, the second features, and the preset attributes to which the remaining first features belong and the preset attributes to which the second features belong, so that the image features belonging to each preset attribute in the second image are respectively the same as the remaining first features or the second features belonging to each preset attribute.

[0271] The device provided by the embodiment of the present disclosure assigns at least two preset attributes to at least two features obtained by random sampling, and then calls the image generation model to perform processing based on at least two features and the preset attributes to which each feature belongs, thereby generating an image having these two image features. By assigning specific preset attributes to the features obtained by random sampling, it is possible to control the features belonging to different preset attributes in the generated image. Therefore, by changing the features belonging to one of the preset attributes, the features belonging to the preset attribute in the generated image can be adjusted, while the features belonging to other preset attributes can be guaranteed to remain unchanged, thereby improving the controllability of image generation.

[0272] In one possible implementation, see Fig.11 , the device further comprises:

[0273] The splicing unit 1004 is configured to execute splicing of at least two first features based on the arrangement order of at least two preset attributes and the preset attribute to which each first feature belongs;

[0274] The generating unit 1003 is configured to execute calling the image generating model and generate a first image based on the spliced ​​first feature.

[0275] In one possible implementation, see Fig.11 , the acquisition unit 1001 is configured to perform random sampling in at least two feature sets to obtain at least two first features, wherein different feature sets correspond to different preset attributes;

[0276] The allocating unit 1002 is configured to allocate a preset attribute corresponding to the feature set to each first feature.

[0277] In one possible implementation, see Fig.11 , the device further comprises:

[0278] The acquisition unit 1001 is further configured to perform random sampling in the feature set to obtain at least two third features;

[0279] The allocating unit 1002 is further configured to allocate a preset attribute to each of the at least two third features;

[0280] The generating unit 1003 is further configured to execute calling the image generating model, and generate a first sample image based on at least two third features and the preset attribute to which each third feature belongs, so that the image feature belonging to each preset attribute in the first sample image is respectively the same as the third feature belonging to each preset attribute;

[0281] The discrimination unit 1005 is configured to discriminate the first sample image to obtain a first discrimination result, wherein the first discrimination result indicates a probability that the first sample image is discriminated as a non-synthetic image, and the non-synthetic image is not generated by the model;

[0282] The training unit 1006 is configured to train the image generation model based on the first discrimination result, so as to increase the probability that an image generated by the trained image generation model is discriminated as a non-synthetic image.

[0283] Regarding the device in the above embodiment, the specific manner in which each unit performs the operation has been described in detail in the embodiment of the method, and will not be elaborated here.

[0284] Fig.12 is a block diagram of a model training device according to an exemplary embodiment. Fig.12 The device includes a first acquisition unit 1201, an allocation unit 1202, a generation unit 1203, a discrimination unit 1204 and a training unit 1205.

[0285] The first acquisition unit 1201 is configured to perform random sampling in the feature set to obtain at least two third features;

[0286] An allocating unit 1202 is configured to allocate a preset attribute to each of the at least two third features;

[0287] The generating unit 1203 is configured to execute calling the image generating model, and generate a first sample image based on at least two third features and the preset attribute to which each third feature belongs, so that the image feature belonging to each preset attribute in the first sample image is respectively the same as the third feature belonging to each preset attribute;

[0288] The discrimination unit 1204 is configured to discriminate the first sample image to obtain a first discrimination result, wherein the first discrimination result indicates a probability that the first sample image is discriminated as a non-synthetic image, and the non-synthetic image is not generated by the model;

[0289] The training unit 1205 is configured to train the image generation model based on the first discrimination result, so as to increase the probability that an image generated by the trained image generation model is discriminated as a non-synthetic image.

[0290] The device provided by the embodiment of the present disclosure assigns at least two preset attributes to at least two randomly generated features, obtains image features belonging to the at least two preset attributes, and then calls an image generation model to process the image features belonging to the at least two preset attributes to generate a sample image, and then trains the image generation model based on the discrimination result of the sample image to increase the probability that the image generated by the image generation model is discriminated as a non-synthetic image, thereby enabling the image synthesis model to learn how to generate an image based on the features of at least two preset attributes, thereby being able to control the properties of the synthesized image and improving the controllability of image synthesis.

[0291] In one possible implementation, see Fig.13 The discrimination unit 1204 is configured to execute the calling of the image discrimination model, discriminate the first sample image, and obtain the first discrimination result;

[0292] The training unit 1205 is configured to execute training of the image generation model and the image discrimination model based on the first discrimination result, so as to increase the probability of calling the trained image generated by the image generation model to be discriminated as the non-synthetic image, and reduce the probability of calling the trained image discrimination model to discriminate the image generated by the image generation model as the non-synthetic image.

[0293] In one possible implementation, see Fig.13 , the device further comprises:

[0294] A second acquiring unit 1206 is configured to acquire a second sample image, where the second sample image is the non-synthesized image;

[0295] The discrimination unit 1204 is further configured to execute calling the image discrimination model, discriminate the second sample image, and obtain a second discrimination result, wherein the second discrimination result indicates a probability that the second sample image is discriminated as the non-synthetic image;

[0296] The training unit 1205 comprises:

[0297] The first training subunit 1215 is configured to train the image generation model based on the first discrimination result, so as to increase the probability that the image generated by the trained image generation model is discriminated as the non-synthetic image;

[0298] The second training subunit 1225 is configured to perform training on the image discrimination model based on the first discrimination result and the second discrimination result, so as to reduce the probability of calling the trained image discrimination model to discriminate the image generated by the image generation model as the non-synthetic image, and increase the probability of calling the trained image discrimination model to discriminate the non-synthetic image as the non-synthetic image.

[0299] In one possible implementation, see Fig.13 , the device further comprises:

[0300] The first acquisition unit 1201 is further configured to perform random sampling in the feature set to obtain a fourth feature;

[0301] The allocating unit 1202 is further configured to replace the third features of at least two third features that belong to a second preset attribute with the fourth feature, where the second preset attribute is any one of the at least two preset attributes;

[0302] The generating unit 1203 is further configured to execute calling the image generating model, and generate a third sample image based on the remaining third feature, the fourth feature, the preset attribute to which the remaining third feature belongs, and the preset attribute to which the fourth feature belongs, so that the image feature belonging to each preset attribute in the third sample image is respectively the same as the remaining third feature or the fourth feature belonging to each preset attribute;

[0303] The discrimination unit 1204 is configured to perform discrimination on the first sample image and the third sample image to obtain the first discrimination result, wherein the first discrimination result indicates the probability that the first sample image and the third sample image meet the first target condition, wherein the first target condition refers to that the first sample image and the third sample image are discriminated as the non-synthetic images, and that the image features of at least one preset attribute in the first sample image and the third sample image are the same and the image features of at least one preset attribute are different.

[0304] In one possible implementation, see Fig.13 The discrimination unit 1204 is configured to execute the calling image discrimination model, discriminate the first sample image and the third sample image, and obtain the first discrimination result;

[0305] The training unit 1205 is configured to execute training of the image generation model and the image discrimination model based on the first discrimination result, so as to increase the probability that the image generated by the trained image generation model is discriminated as satisfying the first target condition, and reduce the probability that the image generated by the image generation model is discriminated as satisfying the first target condition by calling the trained image discrimination model.

[0306] In one possible implementation, see Fig.13 , the device further comprises:

[0307] The second acquisition unit 1206 is configured to acquire a fourth sample image and a fifth sample image, wherein the fourth sample image and the fifth sample image meet a second target condition, wherein the second target condition refers to that the fourth sample image and the fifth sample image are the non-synthesized images, and the fourth sample image and the fifth sample image have the same image feature of at least one preset attribute and different image features of at least one preset attribute;

[0308] The discrimination unit 1204 is further configured to execute calling the image discrimination model, discriminate the fourth sample image and the fifth sample image, and obtain a third discrimination result, wherein the third discrimination result indicates a probability that the fourth sample image and the fifth sample image are judged to satisfy the second target condition;

[0309] The training unit 1205 comprises:

[0310] The first training subunit 1215 is configured to train the image generation model based on the first discrimination result, so as to increase the probability that the image generated by the trained image generation model is discriminated as meeting the first target condition;

[0311] The second training subunit 1225 is configured to execute training of the image discrimination model based on the first discrimination result and the third discrimination result, so as to reduce the probability of calling the trained image discrimination model to discriminate the image generated by the image generation model as satisfying the first target condition, and increase the probability of calling the trained image discrimination model to discriminate the image satisfying the second target condition as satisfying the second target condition.

[0312] Regarding the device in the above embodiment, the specific manner in which each unit performs the operation has been described in detail in the embodiment of the method, and will not be elaborated here.

[0313] The embodiment of the present disclosure provides an electronic device, which includes: a processor and a memory for storing instructions executable by the processor, wherein the processor is configured to execute the instructions to implement the above-mentioned image generation method.

[0314] In some embodiments, the electronic device includes a terminal. Fig.14 1 is a block diagram of a terminal 1400 according to an exemplary embodiment. The terminal 1400 may be a portable mobile terminal, such as a smart phone, a tablet computer, an MP3 player (Moving Picture Experts Group Audio Layer III), an MP4 player (Moving Picture Experts Group Audio Layer IV), a laptop computer or a desktop computer. The terminal 1400 may also be referred to as a user device, a portable terminal, a laptop terminal, a desktop terminal or other names.

[0315] The terminal 1400 includes a processor 1401 and a memory 1402 .

[0316] The processor 1401 may include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor 1401 may be implemented in at least one hardware form of DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), and PLA (Programmable Logic Array). The processor 1401 may also include a main processor and a coprocessor, the main processor is a processor for processing data in the awake state, also known as a CPU (Central Processing Unit); the coprocessor is a low-power processor for processing data in the standby state. The memory 1402 may include one or more computer-readable storage media, which may be non-transitory. The memory 1402 may also include a high-speed random access memory, and a non-volatile memory, such as one or more disk storage devices, flash memory storage devices. In some embodiments, the non-transitory computer-readable storage medium in the memory 1402 is used to store at least one program code, which is used to be executed by the processor 1401 to implement the image generation method provided in the method embodiment of the present disclosure.

[0317] In some embodiments, the terminal 1400 may further optionally include: a peripheral device interface 1403 and at least one peripheral device. The processor 1401, the memory 1402 and the peripheral device interface 1403 may be connected via a bus or a signal line. Each peripheral device may be connected to the peripheral device interface 1403 via a bus, a signal line or a circuit board. Specifically, the peripheral device includes: a radio frequency circuit 1404, a display screen 1405, a camera assembly 1406 and a power supply 1407.

[0318] The peripheral device interface 1403 may be used to connect at least one peripheral device related to I / O (Input / Output) to the processor 1401 and the memory 1402. In some embodiments, the processor 1401, the memory 1402, and the peripheral device interface 1403 are integrated on the same chip or circuit board; in some other embodiments, any one or two of the processor 1401, the memory 1402, and the peripheral device interface 1403 may be implemented on a separate chip or circuit board, which is not limited in this embodiment.

[0319] The radio frequency circuit 1404 is used to receive and transmit RF (Radio Frequency) signals, also known as electromagnetic signals. The radio frequency circuit 1404 communicates with the communication network and other communication devices through electromagnetic signals. The radio frequency circuit 1404 converts the electrical signal into an electromagnetic signal for transmission, or converts the received electromagnetic signal into an electrical signal. Optionally, the radio frequency circuit 1404 includes: an antenna system, an RF transceiver, one or more amplifiers, a tuner, an oscillator, a digital signal processor, a codec chipset, a user identity module card, and the like. The radio frequency circuit 1404 can communicate with other terminals through at least one wireless communication protocol. The wireless communication protocol includes, but is not limited to: the World Wide Web, a metropolitan area network, an intranet, various generations of mobile communication networks (2G, 3G, 4G and 5G), a wireless local area network and / or a WiFi (Wireless Fidelity) network. In some embodiments, the radio frequency circuit 1404 may also include circuits related to NFC (Near Field Communication), which is not limited in the present disclosure.

[0320] The display screen 1405 is used to display a UI (User Interface). The UI may include graphics, text, icons, videos, and any combination thereof. When the display screen 1405 is a touch display screen, the display screen 1405 also has the ability to collect touch signals on the surface or above the surface of the display screen 1405. The touch signal can be input to the processor 1401 as a control signal for processing. At this time, the display screen 1405 can also be used to provide virtual buttons and / or virtual keyboards, also known as soft buttons and / or soft keyboards. In some embodiments, the display screen 1405 can be one, arranged on the front panel of the electronic device 1400; in other embodiments, the display screen 1405 can be at least two, respectively arranged on different surfaces of the electronic device 1400 or in a folding design; in other embodiments, the display screen 1405 can be a flexible display screen, arranged on a curved surface or a folding surface of the electronic device 1400. Even, the display screen 1405 can also be arranged as a non-rectangular irregular figure, that is, a special-shaped screen. The display screen 1405 can be made of materials such as LCD (Liquid Crystal Display) and OLED (Organic Light-Emitting Diode).

[0321] The camera assembly 1406 is used to capture images or videos. Optionally, the camera assembly 1406 includes a front camera and a rear camera. The front camera is arranged on the front panel of the electronic device, and the rear camera is arranged on the back of the electronic device. In some embodiments, there are at least two rear cameras, which are any one of a main camera, a depth of field camera, a wide-angle camera, and a telephoto camera, so as to realize the fusion of the main camera and the depth of field camera to realize the background blur function, the fusion of the main camera and the wide-angle camera to realize panoramic shooting and VR (Virtual Reality) shooting function or other fusion shooting functions. In some embodiments, the camera assembly 1406 may also include a flash. The flash can be a monochrome temperature flash or a dual-color temperature flash. A dual-color temperature flash refers to a combination of a warm light flash and a cold light flash, which can be used for light compensation at different color temperatures.

[0322] The power supply 1407 is used to power various components in the electronic device 1400. The power supply 1407 can be an alternating current, a direct current, a disposable battery, or a rechargeable battery. When the power supply 1407 includes a rechargeable battery, the rechargeable battery can be a wired rechargeable battery or a wireless rechargeable battery. A wired rechargeable battery is a battery that is charged through a wired line, and a wireless rechargeable battery is a battery that is charged through a wireless coil. The rechargeable battery can also be used to support fast charging technology.

[0323] Those skilled in the art will understand that Fig.14 The structure shown in the figure does not constitute a limitation on the terminal 1400, and the terminal 1400 may include more or less components than those shown in the figure, or combine some components, or adopt a different component arrangement.

[0324] In some embodiments, the electronic device includes a server. Fig.15 This is a schematic diagram of the structure of a server according to an exemplary embodiment. The server 1500 may have relatively large differences due to different configurations or performances, and may include one or more processors (Central Processing Units, CPU) 1501 and one or more memories 1502, wherein the memory 1502 stores at least one computer program, and the at least one computer program is loaded and executed by the processor 1501 to implement the methods provided by the above-mentioned various method embodiments. Of course, the server may also have components such as a wired or wireless network interface, a keyboard, and an input and output interface for input and output, and the server may also include other components for implementing device functions, which will not be described in detail here.

[0325] In an exemplary embodiment, a computer-readable storage medium is also provided, and when the instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device can perform the steps in the above-mentioned image generation method. For example, the computer-readable storage medium can be a ROM (Read Only Memory), a RAM (Random Access Memory), a CD-ROM (Compact Disc Read-Only Memory), a magnetic tape, a floppy disk, an optical data storage device, etc.

[0326] In an exemplary embodiment, a computer program product is also provided, including a computer program, and when the computer program is executed by a processor of an electronic device, the steps in the above-mentioned image generating method are implemented.

[0327] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the disclosure herein. The present disclosure is intended to cover any variations, uses or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The description and examples are to be considered exemplary only, and the true scope and spirit of the present disclosure are indicated by the following claims.

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

Claims

1. An image generation method, characterized in that: The method comprises: Random sampling is performed in the feature set to obtain at least two third features, and a preset attribute is assigned to each of the at least two third features; an image generation model is called to generate a first sample image based on the at least two third features and the preset attribute to which each third feature belongs, so that the image features belonging to each preset attribute in the first sample image are respectively the same as the third features belonging to each preset attribute; Random sampling is performed in the feature set to obtain a fourth feature, and the fourth feature is used to replace the third feature of the at least two third features that belongs to a second preset attribute, where the second preset attribute is any one of the at least two preset attributes; the image generation model is called to generate a third sample image based on the remaining third features, the fourth feature, the preset attribute to which the remaining third features belong, and the preset attribute to which the fourth feature belongs, so that the image features belonging to each preset attribute in the third sample image are respectively the same as the remaining third features or the fourth features belonging to each preset attribute; The first sample image and the third sample image are discriminated to obtain a first discrimination result, wherein the first discrimination result indicates a probability that the first sample image and the third sample image meet a first target condition, wherein the first target condition refers to that the first sample image and the third sample image are discriminated as non-synthetic images, and the first sample image and the third sample image have the same image feature of at least one preset attribute and different image features of at least one preset attribute; Based on the first discrimination result, training the image generation model to increase the probability that the image generated by calling the trained image generation model is discriminated as the non-synthetic image; Performing random sampling in the feature set to obtain at least two first features, the feature set including a plurality of features for generating an image; assigning a preset attribute to each of the at least two first features; Calling the image generation model to generate a first image based on the at least two first features and the preset attributes to which each first feature belongs, so that the image features belonging to each preset attribute in the first image are respectively the same as the first features belonging to each preset attribute; Replacing a first feature of the at least two first features that belongs to a first preset attribute with a second feature obtained by random sampling, where the first preset attribute is any one of the at least two preset attributes; The image generation model is called to generate a second image based on the remaining first features, the second features, the preset attributes to which the remaining first features belong, and the preset attributes to which the second features belong, so that the image features belonging to each preset attribute in the second image are respectively the same as the remaining first features or the second features belonging to each preset attribute.

2. The image generation method according to claim 1, characterized in that: Before calling the image generation model to generate the first image based on the at least two first features and the preset attributes to which each first feature belongs, the method further includes: Based on the arrangement order of the at least two preset attributes and the preset attribute to which each first feature belongs, splicing the at least two first features; The calling the image generation model to generate a first image based on the at least two first features and a preset attribute to which each first feature belongs includes: The image generation model is called to generate the first image based on the spliced ​​first feature.

3. The image generation method according to claim 1, characterized in that: The random sampling in the feature set to obtain at least two first features includes: Random sampling is performed in at least two of the feature sets to obtain the at least two first features, wherein different feature sets correspond to different preset attributes; The assigning a preset attribute to each of the at least two first features comprises: Assign a preset attribute corresponding to the feature set to which each first feature belongs to respectively.

4. A model training method, characterized in that: The method comprises: Randomly sample from the feature set to obtain at least two third features; assigning a preset attribute to each of the at least two third features; Calling an image generation model to generate a first sample image based on the at least two third features and the preset attributes to which each third feature belongs, so that the image features belonging to each preset attribute in the first sample image are respectively the same as the third features belonging to each preset attribute; The first sample image is discriminated to obtain a first discrimination result, wherein the first discrimination result indicates a probability that the first sample image is discriminated as a non-synthetic image, and the non-synthetic image is not generated by a model; Based on the first discrimination result, training the image generation model to increase the probability that the image generated by calling the trained image generation model is discriminated as the non-synthetic image; Wherein, the image generation model is used to implement the image generation method as described in any one of claims 1 to 3.

5. The model training method according to claim 4, characterized in that: The step of discriminating the first sample image to obtain a first discrimination result includes: Calling an image discrimination model to discriminate the first sample image to obtain the first discrimination result; The step of training the image generation model based on the first discrimination result includes: Based on the first discrimination result, the image generation model and the image discrimination model are trained to increase the probability that the image generated by the trained image generation model is discriminated as the non-synthetic image, and to reduce the probability that the image generated by the image generation model is discriminated as the non-synthetic image by calling the trained image discrimination model.

6. The model training method according to claim 5, characterized in that: The method further comprises: Acquire a second sample image, where the second sample image is the non-synthetic image; calling the image discrimination model to discriminate the second sample image to obtain a second discrimination result, wherein the second discrimination result indicates a probability that the second sample image is discriminated as the non-synthetic image; The step of training the image generation model and the image discrimination model based on the first discrimination result includes: Based on the first discrimination result, training the image generation model to increase the probability that the image generated by calling the trained image generation model is discriminated as the non-synthetic image; Based on the first discrimination result and the second discrimination result, the image discrimination model is trained to reduce the probability of calling the trained image discrimination model to discriminate the image generated by the image generation model as the non-synthetic image, and to increase the probability of calling the trained image discrimination model to discriminate the non-synthetic image as the non-synthetic image.

7. The model training method according to claim 4, characterized in that: The method further comprises: Perform random sampling in the feature set to obtain a fourth feature; Replacing the third feature of the at least two third features that belongs to a second preset attribute with the fourth feature, where the second preset attribute is any one of the at least two preset attributes; Calling the image generation model to generate a third sample image based on the remaining third feature, the fourth feature, the preset attribute to which the remaining third feature belongs, and the preset attribute to which the fourth feature belongs, so that the image feature belonging to each preset attribute in the third sample image is respectively the same as the remaining third feature or the fourth feature belonging to each preset attribute; The step of discriminating the first sample image to obtain a first discrimination result includes: The first sample image and the third sample image are discriminated to obtain the first discrimination result, wherein the first discrimination result indicates the probability that the first sample image and the third sample image meet the first target condition, wherein the first target condition refers to that the first sample image and the third sample image are discriminated as the non-synthetic images, and that the image features of at least one preset attribute in the first sample image and the third sample image are the same and the image features of at least one preset attribute are different.

8. The model training method according to claim 7, characterized in that: The step of discriminating the first sample image and the third sample image to obtain the first discrimination result includes: Calling an image discrimination model to discriminate the first sample image and the third sample image to obtain the first discrimination result; The step of training the image generation model based on the first discrimination result includes: Based on the first discrimination result, the image generation model and the image discrimination model are trained to increase the probability that at least two images generated by the trained image generation model are discriminated as satisfying the first target condition, and to reduce the probability that at least two images generated by the image generation model are discriminated as satisfying the first target condition by calling the trained image discrimination model.

9. The model training method according to claim 8, characterized in that: The method further comprises: Acquire a fourth sample image and a fifth sample image, wherein the fourth sample image and the fifth sample image satisfy a second target condition, wherein the second target condition is that the fourth sample image and the fifth sample image are the non-synthetic images, and image features of at least one preset attribute are the same and image features of at least one preset attribute are different in the fourth sample image and the fifth sample image; calling the image discrimination model to discriminate the fourth sample image and the fifth sample image to obtain a third discrimination result, wherein the third discrimination result indicates a probability that the fourth sample image and the fifth sample image are discriminated as satisfying the second target condition; The step of training the image generation model and the image discrimination model based on the first discrimination result includes: Based on the first discrimination result, training the image generation model to increase the probability that at least two images generated by calling the trained image generation model are judged to meet the first target condition; Based on the first discrimination result and the third discrimination result, the image discrimination model is trained to reduce the probability of calling the trained image discrimination model to discriminate at least two images generated by the image generation model as satisfying the first target condition, and to increase the probability of calling the trained image discrimination model to discriminate an image satisfying the second target condition as satisfying the second target condition.

10. An image generating device, characterized in that: The device comprises: An acquisition unit is configured to perform random sampling in the feature set to obtain at least two third features; an allocating unit, configured to allocate a preset attribute to each of the at least two third features; A generating unit is configured to execute calling the image generating model, and generate a first sample image based on the at least two third features and the preset attributes to which each third feature belongs, so that the image features belonging to each preset attribute in the first sample image are respectively the same as the third features belonging to each preset attribute; The acquisition unit is further configured to perform random sampling in the feature set to obtain a fourth feature; The allocation unit is further configured to replace the third feature of the at least two third features that belongs to a second preset attribute with the fourth feature, where the second preset attribute is any one of the at least two preset attributes; The generating unit is further configured to execute calling the image generating model, and generate a third sample image based on the remaining third feature, the fourth feature, the preset attribute to which the remaining third feature belongs, and the preset attribute to which the fourth feature belongs, so that the image feature belonging to each preset attribute in the third sample image is respectively the same as the remaining third feature or the fourth feature belonging to each preset attribute; a discrimination unit configured to discriminate the first sample image and the third sample image to obtain a first discrimination result, wherein the first discrimination result indicates a probability that the first sample image and the third sample image meet a first target condition, wherein the first target condition refers to that the first sample image and the third sample image are discriminated as non-synthetic images, and the first sample image and the third sample image have the same image feature of at least one preset attribute and different image features of at least one preset attribute; A training unit configured to train the image generation model based on the first discrimination result, so as to increase the probability that the image generated by the trained image generation model is discriminated as the non-synthetic image; The acquisition unit is further configured to perform random sampling in a feature set to obtain at least two first features, wherein the feature set includes a plurality of features for generating an image; The allocating unit is further configured to allocate a preset attribute to each of the at least two first features; The generating unit is further configured to execute calling the image generating model, and generate a first image based on the at least two first features and the preset attributes to which each first feature belongs, so that the image features belonging to each preset attribute in the first image are respectively the same as the first features belonging to each preset attribute; The allocation unit is further configured to replace a first feature belonging to a first preset attribute among the at least two first features with a second feature obtained by random sampling, where the first preset attribute is any one of the at least two preset attributes; The generation unit is further configured to execute the call to the image generation model, and generate a second image based on the remaining first features, the second features, the preset attributes to which the remaining first features belong, and the preset attributes to which the second features belong, so that the image features belonging to each preset attribute in the second image are respectively the same as the remaining first features or the second features belonging to each preset attribute.

11. A model training device, characterized in that: The device comprises: A first acquisition unit is configured to perform random sampling in the feature set to obtain at least two third features; an allocating unit, configured to allocate a preset attribute to each of the at least two third features; A generating unit is configured to execute calling the image generating model, and generate a first sample image based on the at least two third features and the preset attributes to which each third feature belongs, so that the image features belonging to each preset attribute in the first sample image are respectively the same as the third features belonging to each preset attribute; a discrimination unit configured to discriminate the first sample image to obtain a first discrimination result, wherein the first discrimination result indicates a probability that the first sample image is discriminated as a non-synthetic image, and the non-synthetic image is not generated by a model; A training unit configured to train the image generation model based on the first discrimination result, so as to increase the probability that the image generated by the trained image generation model is discriminated as the non-synthetic image; Wherein, the image generation model is used to implement the image generation method as described in any one of claims 1 to 3.

12. An electronic device, characterized in that: The electronic device comprises: processor; a memory for storing instructions executable by the processor; The processor is configured to execute the instructions to implement the image generation method as described in any one of claims 1 to 3, or to implement the model training method as described in any one of claims 4 to 9.

13. A computer-readable storage medium, characterized in that: When the instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the image generation method as described in any one of claims 1 to 3, or implement the model training method as described in any one of claims 4 to 9.

14. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, it implements the image generation method described in any one of claims 1 to 3, or implements the model training method described in any one of claims 4 to 9.

Citation Information

Patent Citations

  • Controllable figure image generation method based on generative adversarial network

    CN113538608A

  • Attribute conditioned image generation

    US20220028139A1