Model construction method and device, image generation method and device, equipment and medium

By constructing real images and stylized image generation models, and using color difference representation data to update the stylized image generation model, the problem of difficulty in achieving color consistency of the same part in cross-domain images is solved, and the usability and quality of images are improved.

CN118537206APending Publication Date: 2024-08-23BEIJING ZITIAO NETWORK TECH CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202310159459.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-02-20
Publication Date
2024-08-23

Smart Images

  • Figure CN118537206A
    Figure CN118537206A
Patent Text Reader

Abstract

The invention discloses a model construction method and device, an image generation method and device, equipment and a medium. The model construction method comprises the steps that a pre-constructed real image generation model is utilized, and a stylized image generation model is initialized; and updating the stylized image generation model according to color difference representation data between image generation results determined by the two models aiming at the same implicit code, so that the updated stylized image generation model aims at color use conditions of different parts in image data generated by one implicit code. The color using condition is as close as possible to the color using condition of the corresponding part in the image data generated by the real image generation model aiming at the implicit code, so that the same color used by the same part in the two images generated by the two models aiming at the same implicit code can be ensured; therefore, the adverse effect caused by the fact that the same part in the two images uses different colors can be effectively overcome.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing technology, and in particular to a model building method, image generation method, device, equipment, and medium. Background Art

[0002] A stylized image refers to image data obtained by regenerating a real image (for example, image data obtained by photographing an object existing in the real world) in a certain style, so that the stylized image can be used in some application fields (for example, entertainment, publicity, virtual image processing, etc.).

[0003] In addition, since real images and stylized images belong to different image domains, there are certain differences between the two images (for example, different textures, etc.), which makes it very challenging to generate paired cross-domain images such as (real images, stylized images). Summary of the invention

[0004] The present application provides a model construction method, an image generation method, an apparatus, a device, and a medium, which can automatically generate paired cross-domain images.

[0005] In order to achieve the above objectives, the technical solutions provided by this application are as follows:

[0006] The present application provides a model building method, the method comprising:

[0007] Initialize the stylized image generation model using a pre-built real image generation model;

[0008] Get the hidden code to be processed;

[0009] Determine a real image generation result corresponding to the hidden code to be processed by using the real image generation model, and determine a stylized image generation result corresponding to the hidden code to be processed by using the stylized image generation model;

[0010] The stylized image generation model is updated according to the color difference representation data between the real image generation result and the stylized image generation result.

[0011] In a possible implementation manner, the real image generation result includes real image segmentation representation data;

[0012] The stylized image generation result includes stylized image segmentation representation data;

[0013] The color difference representation data is determined based on the real image segmentation representation data and the stylized image segmentation representation data.

[0014] In a possible implementation manner, the real image segmentation representation data is used to describe first segmented regions corresponding to a plurality of parts; the stylized image segmentation representation data is used to describe second segmented regions corresponding to a plurality of parts;

[0015] The process of determining the color difference characterization data includes:

[0016] Performing pixel color statistical analysis on a first segmented area corresponding to a target part to obtain first color representation data corresponding to the target part; the target part is any one of the several parts;

[0017] Performing pixel color statistical analysis on the second segmented area corresponding to the target part to obtain second color representation data corresponding to the target part;

[0018] Determining the color similarity corresponding to the target part according to the similarity between the first color representation data corresponding to the target part and the second color representation data corresponding to the target part;

[0019] The color difference representation data is determined according to the sum of the color similarities corresponding to the plurality of parts.

[0020] In a possible implementation manner, before initializing the stylized image generation model using the pre-built real image generation model, the method further includes:

[0021] The real image generation model is constructed based on at least one real image sample and actual image segmentation representation data corresponding to each of the real image samples.

[0022] In a possible implementation, the real image generation model and the stylized image generation model are both generative adversarial network models.

[0023] In a possible implementation, the stylized image generation model includes a stylized image generator;

[0024] The updating of the stylized image generation model according to the color difference representation data between the real image generation result and the stylized image generation result comprises:

[0025] The stylized image generator is updated according to the color difference representation data between the real image generation result and the stylized image generation result.

[0026] In a possible implementation, the stylized image generation model includes a stylized image discriminator;

[0027] The stylized image discriminator is trained according to at least one stylized image sample.

[0028] In a possible implementation manner, after updating the stylized image generation model according to the color difference characterization data between the real image generation result and the stylized image generation result, the method further includes:

[0029] Continue to execute the step of obtaining the hidden code to be processed until a preset stopping condition is reached.

[0030] The present application provides an image generation method, the method comprising:

[0031] Get the target hidden code;

[0032] Determine the real image corresponding to the target latent code by using a pre-built real image generation model;

[0033] A stylized image corresponding to the target latent code is determined using a pre-constructed stylized image generation model; the stylized image generation model is determined using the model construction method provided in the present application; the real image and the stylized image are used to construct a pair of cross-domain images.

[0034] The present application provides a model building device, comprising:

[0035] An initialization unit, used to initialize the stylized image generation model using a pre-built real image generation model;

[0036] A first acquisition unit, used to acquire a latent code to be processed;

[0037] A first determining unit, configured to determine a real image generation result corresponding to the hidden code to be processed by using the real image generation model, and to determine a stylized image generation result corresponding to the hidden code to be processed by using the stylized image generation model;

[0038] A model updating unit is used to update the stylized image generation model according to the color difference representation data between the real image generation result and the stylized image generation result.

[0039] The present application provides an image generation device, comprising:

[0040] A second acquisition unit, used for acquiring a target latent code;

[0041] A second determining unit is used to determine the real image corresponding to the target latent code by using a pre-built real image generation model;

[0042] The third determination unit is used to determine the stylized image corresponding to the target latent code using a pre-constructed stylized image generation model; the stylized image generation model is determined using the model construction method provided in the present application; the real image and the stylized image are used to construct a pair of cross-domain images.

[0043] The present application provides an electronic device, the device comprising: a processor and a memory;

[0044] The memory is used to store instructions or computer programs;

[0045] The processor is used to execute the instructions or computer programs in the memory so that the electronic device executes the model building method or image generation method provided in the present application.

[0046] The present application provides a computer-readable medium, characterized in that instructions or computer programs are stored in the computer-readable medium. When the instructions or computer programs are executed on a device, the device executes the model building method or image generation method provided in the present application.

[0047] The present application provides a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program contains program codes for executing the model building method or image generation method provided by the present application.

[0048] Compared with the prior art, this application has at least the following advantages:

[0049] In the technical solution provided by the present application, a real image generation model is first pre-constructed so that the real image generation model can perform image generation processing for a hidden code; then, the stylized image generation model is initialized using the real image generation model so that the stylized image generation model can also perform image generation processing for a hidden code; then, the stylized image generation model is updated based on the color difference representation data between the image generation results determined by the two models for the same hidden code, so that the color usage of different parts in the image data generated by the updated stylized image generation model for a hidden code is as close as possible to the color usage of the corresponding parts in the image data generated by the real image generation model for the hidden code, so that the color usage rule of the stylized image generation model finally constructed is consistent with the color usage rule of the real image generation model, so as to ensure that the color used for the same part in the two images generated by the two models for the same hidden code is the same, and thus the adverse effects caused by the use of different colors for the same part in the two images can be effectively overcome (for example, because the same part in the paired cross-domain images uses different colors, the availability of the pair of cross-domain images is relatively low). BRIEF DESCRIPTION OF THE DRAWINGS

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

[0051] Figure 1 A flowchart of a model building method provided for this application;

[0052] Figure 2 A schematic diagram of a segmentation diagram provided in an embodiment of the present application;

[0053] Figure 3 A schematic diagram of a construction process of a stylized image generation model provided in an embodiment of the present application;

[0054] Figure 4 A flowchart of an image generation method provided in an embodiment of the present application;

[0055] Figure 5 A schematic diagram of the structure of a model building device provided in an embodiment of the present application;

[0056] Figure 6 A schematic diagram of the structure of an image generating device provided in an embodiment of the present application;

[0057] Figure 7 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0058] Research has found that for paired cross-domain images, it is usually necessary to ensure that the same part in the pair of images uses the same color (for example, the hair is all black). However, this color requirement is difficult to meet, which makes it very challenging to generate such paired cross-domain images (real images, stylized images).

[0059] Based on the above findings, the present application provides a model construction method, which includes: first pre-constructing a real image generation model so that the real image generation model can perform image generation processing for a hidden code; then using the real image generation model to initialize a stylized image generation model so that the stylized image generation model can also perform image generation processing for a hidden code; then, based on color difference representation data between image generation results determined by the two models for the same hidden code, updating the stylized image generation model so that the color usage of different parts in the image data generated by the updated stylized image generation model for a hidden code is as close as possible to the color usage of the corresponding parts in the image data generated by the real image generation model for the hidden code, so that the color usage rules of the stylized image generation model finally constructed are consistent with the color usage rules of the real image generation model, so as to ensure that the colors used for the same part in the two images generated by the two models for the same hidden code are the same, and thus the adverse effects caused by the use of different colors for the same part in the two images can be effectively overcome (for example, because the same part in a pair of cross-domain images uses different colors, the availability of the pair of cross-domain images is relatively low).

[0060] In addition, the present application does not limit the execution subject of the model construction method provided in the embodiment of the present application. For example, the model construction method provided in the embodiment of the present application can be applied to a device with a data processing function such as a terminal device or a server. For another example, the model construction method provided in the embodiment of the present application can also be implemented by means of a data communication process between different devices (for example, a terminal device and a server, two terminal devices, or two servers). Among them, the terminal device can be a smart phone, a computer, a personal digital assistant (PDA) or a tablet computer. The server can be a stand-alone server, a cluster server or a cloud server.

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

[0062] In order to better understand the technical solution provided by this application, the model building method provided by this application is described below with reference to some drawings. Figure 1 As shown, the model building method provided in the embodiment of the present application includes the following S101-S105. Figure 1 A flowchart of a model building method provided in this application.

[0063] S101: Initialize a stylized image generation model using a pre-built real image generation model.

[0064] The real image generation model is used to perform image generation processing on the input data (e.g., a hidden code) of the real image generation model to obtain the real image corresponding to the input data and the image segmentation representation data corresponding to the real image, so that the image segmentation representation data can represent the area where each part in the real image is located in the real image. It should be noted that the present application does not limit the implementation method of the image segmentation representation data. For example, it can adopt a segmentation map (e.g., Figure 2 For example, it can also be implemented with the help of a mask map.

[0065] In addition, the present application does not limit the implementation of the above “real image generation model”, for example, it can be implemented using a Generative Adversarial Nets (GAN) model. That is, in one possible implementation, the real image generation model belongs to a GAN model.

[0066] In addition, the present application does not limit the construction process of the above-mentioned "real image generation model", for example, it can be specifically: based on at least one real image sample and the actual image segmentation representation data corresponding to each real image sample, the real image generation model is constructed, so that the constructed real image generation model can generate a real image and its corresponding image segmentation representation data for any hidden code. Among them, the real image sample refers to the image data required to use when constructing the real image generation model; and the real image sample is used to present the image in a real style (that is, similar to the image style of the image data directly collected from the real object in the real world), so that the real image sample can represent the state of an object (for example, a face, an object, a creature, a building, etc.) in the real world, and the present application does not limit the acquisition method of the real image sample, for example, it can be collected by an image acquisition device (for example, a camera, etc.). The "actual image segmentation representation data corresponding to the real image sample" is used to represent the actual area where each part in the real image is located in the real image; and the present application does not limit the method of obtaining the "actual image segmentation representation data corresponding to the real image sample". For example, it can be implemented by any existing or future method that can perform image segmentation processing on the real image (for example, with the help of a pre-built machine learning model with real image segmentation function, etc.).

[0067] To facilitate understanding of the above content, the following example is used to illustrate.

[0068] As an example, when the above “real image generation model” belongs to a GAN model, the construction process of the “real image generation model” can be specifically as follows: using at least one real image sample and the actual image segmentation representation data corresponding to each real image sample, a GAN model that can simultaneously output a real image and the image segmentation representation data corresponding to the real image is trained as the real image generation model, so that the real image generation model can generate a real image and the image segmentation representation data (for example, a segmentation map) corresponding to the real image for any hidden code. The hidden code refers to the input data of the generator in the GAN model; and the present application does not limit the method for obtaining the hidden code. For example, it can be implemented using any existing or future hidden code generation method (for example, random generation, etc.).

[0069] It should be noted that the present application is not limited to the implementation method of the above-mentioned "at least one real image sample and the actual image segmentation representation data corresponding to each real image sample". For example, in some application scenarios (for example, facial image processing scenarios), it can be implemented using real facial images recorded in some existing open source data sets and the facial segmentation maps corresponding to the real facial images.

[0070] Based on the above content of “real image generation model”, in a possible implementation, the real image generation model can be implemented using a GAN model, so that the real image generation model includes a real image generator and a real image discriminator. The real image generator is used for a hidden code (for example, Figure 3 The hidden code 1 or hidden code 2 shown in the figure is used to perform image generation processing to obtain and output a real image (for example, Figure 3 The real image 1 or the real image 2 shown) and the image segmentation representation data corresponding to the real image (for example, Figure 3 The real image discriminator is used to perform true and false discrimination processing on the real image output by the real image generator and the above “real image sample” during the training process of the real image generation model, so that the model parameters in the real image generation model can be updated based on the discrimination result. It should be noted that the present application does not limit the implementation methods of the real image generator and the real image discriminator.

[0071] The above-mentioned "stylized image generation model" is used to perform image generation processing on the input data (for example, a latent code) of the stylized image generation model to obtain a stylized image corresponding to the input data and image segmentation representation data corresponding to the stylized image, so that the image segmentation representation data can represent the area where each part of the stylized image is located in the stylized image. Among them, the stylized image refers to image data presented in accordance with a target style (for example, a cartoon style, an ink painting style, etc.). In addition, the target style is different from the above-mentioned "real style"; and the present application does not limit the target style. For example, it can be specifically: the objects involved in the image data presented in accordance with the target style (for example, faces, characters, etc.) often do not belong to the real world, and may belong to a virtual world (for example, game scenes, cartoons, etc.).

[0072] In addition, the present application does not limit the implementation of the above “stylized image generation model”. For example, the model type to which the stylized image generation model belongs is the same as the model type described in the above “real image generation model”. It can be seen that in one possible implementation, when the real image generation model belongs to a GAN model, the stylized image generation model also belongs to a GAN model.

[0073] Based on the above content, it can be known that in a possible implementation, the above stylized image generation model can be implemented using a GAN model, so that the stylized image generation model includes a stylized image generator and a stylized image discriminator. The stylized image generator is used for a hidden code (for example, Figure 3 The hidden code 2 shown in the figure is used to generate the image and obtain and output a stylized image (for example, Figure 3 The stylized image shown) and the image segmentation representation data corresponding to the stylized image (for example, Figure 3 The stylized image discriminator is used to perform true and false discrimination processing on the stylized image output by the stylized image generator and the “stylized image sample” below during the training process of the stylized image generation model, so that the model parameters in the stylized image generation model can be updated based on the discrimination result and the “color difference characterization data” below. It should be noted that the present application does not limit the implementation methods of the stylized image generator and the stylized image discriminator.

[0074] In addition, the present application does not limit the implementation of the above S101. For example, it may specifically be: determining a pre-constructed real image generation model as the initial state of the stylized image generation model.

[0075] Based on the relevant content of S101 above, it can be known that in a possible implementation mode, some real image samples and the actual image segmentation representation data corresponding to each real image sample can be used to train a GAN model that can simultaneously output a real image and the image segmentation representation data corresponding to the real image, as the real image generation model, so that the real image generation model can generate a real image and the image segmentation representation data (for example, a segmentation map) corresponding to the real image for any hidden code; and then use the real image generation model to initialize the stylized image generation model (that is, use the real image generation model as the pre-trained model corresponding to the stylized image generation model), so that the model structure and model parameters of the initialized stylized image generation model are consistent with the model structure and model parameters of the real image generation model. The model parameters are kept consistent so that the fine-tuned stylized image generation model can be obtained by fine-tuning some or all of the network parameters in the stylized image generation model in the future, so that the fine-tuned stylized image generation model can generate a stylized image and image segmentation representation data corresponding to the stylized image for any latent code, so that when a pair of cross-domain images with different styles are generated by the stylized image generation model and the real image generation model for the same latent code, the pair of cross-domain images with different styles not only match similarly (that is, look like the same person), but also the same or similar colors are used for the same part in the pair of cross-domain images, so that the color matching requirements proposed by the paired cross-domain images can be better met, thereby helping to improve the quality of the paired cross-domain images.

[0076] It should be noted that the present application does not limit the determination process of "some or all network parameters in the stylized image generation model" in the above paragraph. For example, it can be set in advance according to the application scenario. As an example, for a pair of cross-domain images, if you only want the textures in the pair of cross-domain images to be different, but keep everything else the same, you can only update the model parameters that can affect the image texture in the fine-tuning process of the stylized image generation model, so that the "some or all network parameters in the stylized image generation model" refers to the parameters involved in the network layer that exists in the stylized image generation model and is used to affect the image texture.

[0077] S102: Obtain latent code to be processed.

[0078] The latent code to be processed refers to the latent code required to be used when fine-tuning the stylized image generation model. For example, the latent code to be processed can be Figure 3 Hidden code 2 is shown.

[0079] It should be noted that the method for obtaining the hidden code to be processed above is similar to the relevant content of the hidden code provided in S101 above, and for the sake of brevity, it will not be repeated here.

[0080] S103: Determine the real image generation result corresponding to the hidden code to be processed by using the real image generation model.

[0081] The real image generation result refers to the result obtained by performing image generation processing on the latent code to be processed using the above “real image generation model”. For example, when the real image generation model is Figure 3 The real image generation model shown in Figure 1 is shown in Figure 2, and the latent code to be processed is Figure 3 When the hidden code is 2, the real image generation result corresponding to the hidden code to be processed may include Figure 3 The “real image 2” and the “segmentation map corresponding to the real image 2” are shown.

[0082] In addition, the present application does not limit the implementation method of the above "real image generation result corresponding to the hidden code to be processed", for example, it may at least include the real image segmentation representation data corresponding to the hidden code to be processed. The real image segmentation representation data is used to represent the image segmentation result of the real image corresponding to the hidden code to be processed, so that the real image segmentation representation data can describe the area where different parts of the real image are located in the real image. The "real image corresponding to the hidden code to be processed" refers to the image data generated for the hidden code to be processed using the above "real image generation model".

[0083] In addition, the present application does not limit the implementation of the above “real image segmentation representation data corresponding to the latent code to be processed”. For example, it may include the segmentation map corresponding to the latent code to be processed (for example, Figure 2 The segmentation map shown in the figure) is used to make the "segmentation map corresponding to the hidden code to be processed" directly represent the image segmentation result of the "real image corresponding to the hidden code to be processed" above, so that the "segmentation map corresponding to the hidden code to be processed" can describe the area where different parts of the "real image corresponding to the hidden code to be processed" are located. For another example, the "real image segmentation representation data corresponding to the hidden code to be processed" can also be implemented with the help of at least one mask map, so that different mask maps can represent the area where different parts of the "real image corresponding to the hidden code to be processed" are located.

[0084] In fact, in one possible implementation, the above "real image generation result corresponding to the latent code to be processed" may not only include the above "real image segmentation representation data corresponding to the latent code to be processed", but may also include the "real image corresponding to the latent code to be processed", so that the "real image corresponding to the latent code to be processed" can represent the image data generated by the above "real image generation model" for the latent code to be processed and conforming to the real style.

[0085] In addition, the present application does not limit the determination process of the above "real image generation result corresponding to the latent code to be processed". For example, it can be specifically: input the latent code to be processed into a pre-constructed real image generation model, and obtain the real image generation result corresponding to the latent code to be processed output by the real image generation model.

[0086] It can be seen that in one possible implementation, after obtaining the latent code to be processed, the latent code to be processed can be input into the above-mentioned real image generation model, so that the real image generation model performs image generation processing on the latent code to be processed, and obtains and outputs the real image generation result corresponding to the latent code to be processed (for example, a real image and its corresponding segmentation map, etc.), so that the real image generation result can be used later to determine the color usage presented by the real image generation model in the real style, so that the color usage can be used later as guidance information to guide the learning process of the stylized image generation model in terms of color usage.

[0087] Based on the relevant content of S103 above, it can be known that in a possible implementation mode, when the above real image generation model belongs to a GAN model, after obtaining the hidden code to be processed, the hidden code to be processed can be input into the real image generation model, so that the generator in the real image generation model performs image generation processing on the hidden code to be processed, and obtains and outputs the real image generation result corresponding to the hidden code to be processed (for example, a real image and its corresponding segmentation map, etc.), so that the real image generation result can be used subsequently to determine the color usage presented by the real image generation model in the real style, so that the color usage can be used as guidance information to guide the learning process of the stylized image generation model in terms of color usage.

[0088] S104: Determine a stylized image generation result corresponding to the latent code to be processed by using the stylized image generation model.

[0089] The stylized image generation result refers to the result obtained by performing image generation processing on the latent code to be processed using the above “stylized image generation model”. For example, when the stylized image generation model is Figure 3 The stylized image generation model shown in Figure 1 is used, and the latent code to be processed is Figure 3 When the hidden code is 2, the stylized image generation result corresponding to the hidden code to be processed may include Figure 3 The “stylized image” and the “segmentation map corresponding to the stylized image” are shown.

[0090] In addition, the present application does not limit the implementation method of the above "stylized image generation result corresponding to the hidden code to be processed", for example, it may at least include stylized image segmentation representation data corresponding to the hidden code to be processed. The stylized image segmentation representation data is used to represent the image segmentation result of the stylized image corresponding to the hidden code to be processed, so that the stylized image segmentation representation data can describe the areas where different parts of the stylized image are located in the stylized image. The "stylized image corresponding to the hidden code to be processed" refers to the image data generated for the hidden code to be processed using the above "stylized image generation model".

[0091] In addition, the present application does not limit the implementation method of the above "stylized image segmentation representation data corresponding to the hidden code to be processed", for example, it may include a segmentation map corresponding to the hidden code to be processed, so that the "segmentation map corresponding to the hidden code to be processed" can directly represent the image segmentation result for the above "stylized image corresponding to the hidden code to be processed", so that the "segmentation map corresponding to the hidden code to be processed" can describe the area where different parts of the "stylized image corresponding to the hidden code to be processed" are located in the "stylized image corresponding to the hidden code to be processed". For another example, the "stylized image segmentation representation data corresponding to the hidden code to be processed" can also be implemented with the help of at least one mask map, so that different mask maps can represent the area where different parts of the "stylized image corresponding to the hidden code to be processed" are located in the "stylized image corresponding to the hidden code to be processed".

[0092] In fact, in a possible implementation, the above "the stylized image generation result corresponding to the latent code to be processed" may include not only the above "the stylized image segmentation representation data corresponding to the latent code to be processed", but also the "stylized image corresponding to the latent code to be processed", so that the "stylized image corresponding to the latent code to be processed" can represent the image data generated by the above "stylized image generation model" for the latent code to be processed and conforming to the above target style.

[0093] In addition, the present application does not limit the determination process of the above "stylized image generation result corresponding to the latent code to be processed". For example, it can be specifically: inputting the latent code to be processed into a pre-built stylized image generation model, and obtaining the stylized image generation result corresponding to the latent code to be processed output by the stylized image generation model.

[0094] It can be seen that in one possible implementation, after obtaining the latent code to be processed, the latent code to be processed can be input into the above stylized image generation model, so that the stylized image generation model performs image generation processing on the latent code to be processed, and obtains and outputs the stylized image generation result corresponding to the latent code to be processed (for example, a stylized image and its corresponding segmentation map, etc.), so that the stylized image generation result can be used later to determine the color usage presented by the stylized image generation model under the target style, so that the color usage can be used later to measure the difference between the color usage status of the stylized image generation model and the color usage status of the above real image generation model.

[0095] It can be seen that for the stylized image generation model provided by the present application, it can not only generate a stylized image based on a hidden code, but also simultaneously generate stylized image segmentation representation data (e.g., segmentation map) corresponding to the stylized image, so that the two tasks of stylized image generation and stylized image segmentation can be completed simultaneously using a stylized image generation model. Among them, because these two tasks are completed by the same model, when the model performs the stylized image segmentation task, it can refer to some more detailed and detailed information involved in the execution process of the stylized image generation task, so that the stylized image segmentation task can refer to as comprehensive information as possible, so that the stylized image segmentation effect (e.g., accuracy) can be effectively improved.

[0096] Based on the relevant content of S104 above, it can be known that in a possible implementation mode, when the above stylized image generation model belongs to a GAN model, after obtaining the latent code to be processed, the latent code to be processed can be input into the stylized image generation model, so that the generator in the stylized image generation model performs image generation processing on the latent code to be processed, and obtains and outputs a stylized image generation result corresponding to the latent code to be processed (for example, a stylized image and its corresponding segmentation map, etc.), so that the stylized image generation result can be used later to determine the color usage presented by the stylized image generation model under the target style, so that the color usage can be used later to measure the gap between the color usage status of the stylized image generation model and the color usage status of the above real image generation model.

[0097] It should be noted that the present application does not limit the execution order between the above S104 and the above S103, for example, the two can be executed simultaneously. For another example, the two can be executed in sequence according to a preset order (for example, first execute S103 and then execute S104, or first execute S104 and then execute S103).

[0098] S105: updating the stylized image generation model according to the color difference representation data between the real image generation result and the stylized image generation result.

[0099] Among them, the color difference characterization data is used to represent the color usage difference between the real image involved in the above "real image generation result" and the stylized image involved in the above "stylized image generation result" (especially, the color usage difference presented for the same part), so that the "color difference characterization data" can represent the difference between the color usage state of the above stylized image generation model and the color usage state of the above real image generation model.

[0100] In addition, the present application does not limit the determination process of the above "color difference characterization data". For example, when the above "real image generation result" at least includes real image segmentation characterization data, and the above "stylized image generation result" at least includes stylized image segmentation characterization data, the determination process of the "color difference characterization data" may specifically be: determining the above "color difference characterization data between the real image generation result and the stylized image generation result" according to the real image segmentation characterization data and the stylized image segmentation characterization data. For ease of understanding, the following is an explanation with reference to an example.

[0101] As an example, when the above "real image segmentation representation data" is used to describe the first segmentation area corresponding to several parts, and the above "stylized image segmentation representation data" is used to describe the second segmentation area corresponding to several parts, the determination process of the above "color difference representation data" can specifically include the following steps 11-14.

[0102] Step 11: Perform pixel color statistical analysis on the first segmented area corresponding to the target part to obtain first color representation data corresponding to the target part; the target part is any one of the multiple parts.

[0103] The “several parts” mentioned above refer to the parts that exist in the “real image corresponding to the hidden code to be processed” and also exist in the “real image corresponding to the hidden code to be processed”. For example, if the “real image corresponding to the hidden code to be processed” and the “real image corresponding to the hidden code to be processed” are both facial images, then the “several parts” may include hair, ears, cheeks, etc.

[0104] The first segmented region corresponding to the nth part refers to the region where the nth part is located in the above “real image corresponding to the hidden code to be processed”; and the “first segmented region corresponding to the nth part” is determined according to the segmentation result recorded for the nth part in the above “real image segmentation representation data”. Where n is a positive integer, n≤N, N is a positive integer, and N represents the number of parts in the above “several parts”.

[0105] The above “target part” is used to represent any one of the above “several parts”. For example, the “target part” may be the above “nth part”. Where n is a positive integer, n≤N.

[0106] The above “first segmented area corresponding to the target part” refers to the area where the target part is located in the above “real image corresponding to the latent code to be processed”; and the “first segmented area corresponding to the target part” is determined based on the segmentation result recorded for the target part in the above “real image segmentation representation data”.

[0107] The above “first color representation data corresponding to the target part” is used to indicate the color usage status of the target part in the above “real image corresponding to the latent code to be processed”.

[0108] In addition, the present application does not limit the determination process of the above "first color representation data corresponding to the target part" (that is, the implementation method of the "pixel color statistical analysis processing" in the above step 11), for example, it may specifically include the following steps 111-112.

[0109] Step 111: using the first segmented region corresponding to the target part, determine the real part image corresponding to the target part.

[0110] The above “real part image corresponding to the target part” is used to describe the image state (for example, color usage state, etc.) of the target part in the above “real image corresponding to the latent code to be processed”.

[0111] In addition, the present application does not limit the determination process of the above-mentioned "real part image corresponding to the target part". For example, it can be specifically as follows: according to the first segmented area corresponding to the target part, the above-mentioned "real image corresponding to the hidden code to be processed" is subjected to image interception processing to obtain the real part image corresponding to the target part, so that the real part image can include all pixel points located in the first segmented area in the "real image corresponding to the hidden code to be processed", so that the real part image can represent the color usage status of the target part in the above-mentioned "real image corresponding to the hidden code to be processed".

[0112] Step 112: According to preset statistical index items, statistical analysis is performed on the real part image corresponding to the target part to obtain first color representation data corresponding to the target part.

[0113] The preset statistical index item may be preset, for example, it may be an index item such as an average value, a median value, or a mode.

[0114] It can be seen that in one possible implementation, after obtaining the real part image corresponding to the target part, the color values ​​of all pixels in the real part image can be averaged to obtain a color average value, and the color average value is determined as the first color representation data corresponding to the target part, so that the first color representation data can represent the average color state of the target part in the above "real image corresponding to the hidden code to be processed".

[0115] Based on the relevant content of step 11 above, it can be known that after the first segmented area corresponding to the nth part is determined by using the above “real image segmentation representation data”, the image can be intercepted and processed according to the first segmented area corresponding to the nth part for the above “real image corresponding to the hidden code to be processed” to obtain the real part image corresponding to the nth part, so that the real part image can include all the pixels in the first segmented area in the “real image corresponding to the hidden code to be processed”, so that the real part image can represent the color usage status of the nth part in the above “real image corresponding to the hidden code to be processed”; then, according to the preset statistical index items, the real part image corresponding to the nth part is statistically analyzed and processed to obtain the first color representation data corresponding to the nth part, so that the first color representation data can represent the color usage status (for example, average color, etc.) of the target part in the above “real image corresponding to the hidden code to be processed”. Wherein, n is a positive integer, n≤N.

[0116] Step 12: Perform pixel color statistical analysis on the second segmented area corresponding to the target part to obtain second color representation data corresponding to the target part.

[0117] The second segmented region corresponding to the nth part refers to the region where the nth part is located in the above “stylized image corresponding to the hidden code to be processed”; and the “second segmented region corresponding to the nth part” is determined according to the segmentation result recorded for the nth part in the above “stylized image segmentation representation data”. Where n is a positive integer, n≤N, N is a positive integer, and N represents the number of parts in the above “several parts”.

[0118] The above “second segmented area corresponding to the target part” refers to the area where the target part is located in the above “stylized image corresponding to the latent code to be processed”; and the “second segmented area corresponding to the target part” is determined based on the segmentation result recorded for the target part in the above “stylized image segmentation representation data”.

[0119] The above “second color representation data corresponding to the target part” is used to indicate the color usage status of the target part in the above “stylized image corresponding to the latent code to be processed”. In addition, the determination process of “the second color representation data corresponding to the target part” is similar to the determination process of “the first color representation data corresponding to the target part”, and for the sake of brevity, it will not be repeated here.

[0120] Based on the relevant content of step 12 above, it can be known that after the second segmented area corresponding to the nth part is determined by using the above “stylized image segmentation representation data”, the image can be firstly intercepted and processed according to the second segmented area corresponding to the nth part for the above “stylized image corresponding to the hidden code to be processed” to obtain the stylized part image corresponding to the nth part, so that the stylized part image can include all the pixels in the second segmented area in the “stylized image corresponding to the hidden code to be processed”, so that the stylized part image can represent the color usage status of the nth part in the above “stylized image corresponding to the hidden code to be processed”; then, according to the preset statistical index items, the stylized part image corresponding to the nth part is statistically analyzed and processed to obtain the second color representation data corresponding to the nth part, so that the second color representation data can represent the color usage status (for example, average color, etc.) of the target part in the above “stylized image corresponding to the hidden code to be processed”. Wherein, n is a positive integer, n≤N.

[0121] Step 13: Determine the color similarity corresponding to the target part according to the degree of similarity between the first color representation data corresponding to the target part and the second color representation data corresponding to the target part, so that the "color similarity corresponding to the target part" can represent the difference between the color usage state presented for the target part in the above "real image corresponding to the hidden code to be processed" and the color usage state presented for the target part in the above "stylized image corresponding to the hidden code to be processed".

[0122] It should be noted that the present application does not limit the method for determining the "similarity between the first color representation data corresponding to the target part and the second color representation data corresponding to the target part" in step 13 above. For example, it can be implemented with the help of Manhattan distance (that is, L1 distance) or Euclidean distance (that is, L2 distance).

[0123] Step 14: Determine the above color difference representation data according to the sum of the color similarities corresponding to the plurality of parts.

[0124] The color similarity corresponding to the nth part refers to the similarity between the first color representation data corresponding to the nth part and the second color representation data corresponding to the nth part, so that the "color similarity corresponding to the nth part" can represent the difference between the color usage state presented for the nth part in the above "real image corresponding to the hidden code to be processed" and the color usage state presented for the nth part in the above "stylized image corresponding to the hidden code to be processed". Where n is a positive integer, n≤N.

[0125] In addition, the implementation of step 14 of the present application above, for example, can be implemented using the following formula (1).

[0126]

[0127] Where, L color represents the above “color difference representation data between the real image generation result and the stylized image generation result” (also known as color prediction loss); z represents the above “hidden code to be processed”; G real (z) represents the “real image generation result corresponding to the hidden code to be processed” mentioned above, that is, the image generation result determined by the “real image generation model” mentioned above performing image generation processing on the hidden code to be processed; Indicates the above "first color representation data corresponding to the nth part", so that the G can represent the color usage status (e.g., average color, etc.) present in the image region of the nth part in the “real image generation result corresponding to the hidden code to be processed”; style (z) represents the above “stylized image generation result corresponding to the hidden code to be processed”, that is, the image generation result determined by the above “stylized image generation model” performing image generation processing on the hidden code to be processed; Indicates the above "the second color representation data corresponding to the nth part", so that the Able to indicate the color usage status (e.g., average color, etc.) present in the image region of the nth part in the “stylized image generation result corresponding to the hidden code to be processed”; Indicates that With the The L2 distance between The similarity between the “first color representation data corresponding to the n-th part” and the “second color representation data corresponding to the n-th part” can be indicated.

[0128] In addition, the present application does not limit the implementation of S105 above. For example, when the above “stylized image generation model” belongs to a GAN model, and the stylized image generation model includes a stylized image generator, S105 may specifically be: updating the stylized image generator according to the color difference characterization data between the above real image generation result and the above stylized image generation result. The stylized image generator refers to a generator existing in the stylized image generation model, so that the stylized image generation model can perform image generation processing for a hidden code.

[0129] It can be seen that when the above “stylized image generation model” belongs to a GAN model, in the fine-tuning process of the stylized image generation model, only the color difference representation data between the paired real image generation results and the stylized image generation results can be used to update the model parameters of the generator in the stylized image generation model (that is, the above “stylized image generator”) so that the generator can perform a learning process in terms of color usage.

[0130] Based on the above two paragraphs, it can be known that for the above “stylized image generation model”, when the above “stylized image generation model” belongs to a GAN model, the stylized image generation model may include a stylized image generator and a stylized image discriminator, and in the fine-tuning process of the stylized image generation model, the stylized image generator is used to perform image generation processing for a hidden code to obtain and output a stylized image and image segmentation representation data corresponding to the stylized image (for example, a segmentation map, etc.); the stylized image discriminator is used to perform true and false discrimination processing on the stylized image output by the stylized image generator. In addition, in the fine-tuning process of the stylized image generation model, the model parameters involved in the stylized image generator are updated based on the above “color difference representation data” and the generator training loss function pre-set for the stylized image generator, but the stylized image discriminator is only updated based on the discriminator training loss function pre-set for the stylized image discriminator.

[0131] The above “generator training loss function” refers to a loss function that is pre-set for the generator in the above “stylized image generation model” and is required to be used when training the generator, and is used to represent the prediction performance of the stylized image generation model in aspects other than color usage. In addition, the present application does not limit the implementation method of the “generator training loss function”. For example, it can be implemented using any existing or future training loss function that can be used when training the generator (for example, a discriminator can be used to first determine the true and false discrimination result for the stylized image output by the generator; and then the true and false discrimination result can be used to determine the loss value presented by the generator on the training loss function, etc.).

[0132] The above “discriminator training loss function” refers to a loss function that is pre-set for the discriminator in the above “stylized image generation model” and is required to be used when training the discriminator to represent the prediction performance of the stylized image generation model. In addition, the present application does not limit the implementation method of the “discriminator training loss function”. For example, it can be implemented using any existing or future training loss function that can be used when training the discriminator (for example, the discriminator can be used to determine the true and false discrimination results for the stylized image output by the generator in the stylized image generation model and some stylized image samples; and then use these true and false discrimination results to determine the loss value presented by the discriminator on the training loss function, etc.). It can be seen that in one possible implementation method, the above “stylized image discriminator” is trained based on at least one stylized image sample.

[0133] The stylized image sample refers to the image data required to construct the stylized image generation model; and the stylized image sample is used to present the image according to the target style, so that the stylized image sample can represent the state of an object (for example, a face, an object, a creature, a building, etc.) in a virtual world with the target style. In addition, the present application does not limit the method for obtaining the stylized image sample. For example, it can be specifically: using a stylized engine pre-built for the target style, randomly generating some image data under the target style, all of which are determined as stylized image samples. The stylized engine refers to an image generation device pre-built for the target style, so that the stylized engine can automatically generate image data under the target style according to some parameters input by the user (for example, hair configuration parameters, cheek configuration parameters, etc.) or some parameters automatically obtained.

[0134] Based on the relevant contents of S101 to S105 above, it can be known that for the model construction method provided in the embodiment of the present application, a real image generation model is first pre-constructed so that the real image generation model can perform image generation processing for a hidden code; then, the stylized image generation model is initialized using the real image generation model so that the stylized image generation model can also perform image generation processing for a hidden code; then, based on the color difference representation data between the image generation results determined by the two models for the same hidden code, the stylized image generation model is updated so that the updated stylized image generation model can generate different parts of the image data generated for a hidden code. The color usage of the stylized image generation model is as close as possible to the color usage of the corresponding part in the image data generated by the real image generation model for the latent code, so as to ensure that the color usage rules of the stylized image generation model finally constructed are consistent with the color usage rules of the real image generation model, thereby ensuring that the colors used for the same part in the two images generated by the two models for the same latent code are the same, and thus effectively overcoming the adverse effects caused by the use of different colors for the same part in the two images (for example, because the same part in the paired cross-domain images uses different colors, the availability of the pair of cross-domain images is relatively low).

[0135] In fact, for the above “stylized image generation model”, in order to better improve the generation effect of the stylized image generation model for image data under the target style, multiple rounds of iterative update processing can be performed on the stylized image generation model. Based on this, the present application also provides a possible implementation of the above model construction method, which can specifically include the following steps 21 to 27.

[0136] Step 21: Initialize the stylized image generation model using the pre-built real image generation model.

[0137] It should be noted that for the relevant content of step 21, please refer to the relevant content of S101 above.

[0138] Step 22: Get the latent code to be processed.

[0139] It should be noted that for the relevant content of step 22, please refer to the relevant content of S102 above.

[0140] It should also be noted that in some application scenarios, the latent codes to be processed used in different rounds of training are different.

[0141] Step 23: Use the real image generation model to determine the real image generation result corresponding to the hidden code to be processed.

[0142] It should be noted that for the relevant content of step 23, please refer to the relevant content of S103 above.

[0143] Step 24: Use the stylized image generation model to determine the stylized image generation result corresponding to the latent code to be processed.

[0144] It should be noted that for the relevant content of step 24, please refer to the relevant content of S104 above.

[0145] Step 25: Determine whether the preset stop condition is reached, if so, execute step 27 below; if not, execute step 26 below.

[0146] Among them, the preset stop condition can be pre-set, and the present application does not limit the implementation method of the preset stop condition. For example, it can be specifically: the model loss value of the above stylized image generation model is lower than the preset loss value. For another example, it can also be: the rate of change of the model loss value of the stylized image generation model is less than the preset change rate threshold. For another example, it can also be: the number of updates of the stylized image generation model reaches the preset number threshold. Among them, the preset loss value, the preset change rate threshold and the preset number threshold can all be pre-set.

[0147] The above “model loss value of the stylized image generation model” is used to characterize the model performance of the stylized image generation model; and the present application does not limit the implementation method of the “model loss value of the stylized image generation model”. For example, when the stylized image generation model belongs to a GAN model, and the stylized image generation model includes a stylized image generator and a stylized image discriminator, the “model loss value of the stylized image generation model” may include the loss value of the stylized image generator presented in the above “generator training loss function”, the above “color difference characterization data”, and the loss value of the stylized image discriminator presented in the above “discriminator training loss function”.

[0148] In addition, the present application does not limit the implementation method of the above “the model loss value of the stylized image generation model is lower than the preset loss value”. For example, when the preset loss value includes a first loss threshold and a second loss threshold, and the above “the model loss value of the stylized image generation model” includes the loss value presented by the above stylized image generator in the above “generator training loss function”, the above “color difference characterization data”, and the above stylized image discriminator in the above “discriminator training loss function”. When the fine-tuning process for the stylized image generation model is carried out by If the training process for the stylized image generator and the training process for the stylized image discriminator are implemented in an alternating manner, when it is determined that the sum of the loss value presented by the stylized image generator in the above "generator training loss function" and the "color difference characterization data" is lower than the first loss threshold, and when it is determined that the loss value presented by the stylized image discriminator in the above "discriminator training loss function" is lower than the second loss threshold, it can be determined that the model loss value of the stylized image generation model is lower than the preset loss value, and thus it can be determined that the preset stop condition is reached.

[0149] It should be noted that the present application is not limited to the implementation method of "alternating the training process for the stylized image generator and the training process for the stylized image discriminator" in the previous paragraph. For example, it can be implemented by any existing or future method that can alternately train the generator and the discriminator in the GAN model.

[0150] Step 26: When it is determined that the preset stop condition is not met, the stylized image generation model is updated according to the color difference representation data between the above real image generation result and the above stylized image generation result, and the process returns to continue to execute the above step 22 and its subsequent steps.

[0151] It should be noted that the relevant contents of "updating the stylized image generation model according to the color difference representation data between the above real image generation result and the above stylized image generation result" in step 26 can be found in the relevant contents of S105 above, and for the sake of brevity, they will not be repeated here. Figure 3 As shown, during the execution of step 26, the parameters of the real image generation model can be frozen, and only the parameters of the stylized image generation model can be updated.

[0152] To facilitate understanding of the above content, the following example is used to illustrate.

[0153] As an example, when the fine-tuning process for the stylized image generation model is implemented by alternating the training process for the stylized image generator and the training process for the stylized image discriminator, step 26 may specifically be as follows: when it is determined that the preset stop condition has not been reached, if it is in the training period for the stylized image generator, then according to the above “color difference characterization data between the real image generation result and the stylized image generation result” and the loss value of the stylized image generator in the above “generator training loss function”, update the stylized image generator in the stylized image generation model, and return to continue to execute step 22 and its subsequent steps; if it is in the training period for the stylized image discriminator, then according to the loss value of the stylized image discriminator in the above “discriminator training loss function”, update the stylized image discriminator in the stylized image generation model, and return to continue to execute step 22 and its subsequent steps.

[0154] Step 27: When it is determined that the preset stop condition is reached, the fine-tuning process for the above stylized image generation model is directly terminated.

[0155] Based on the relevant contents of steps 21 to 26 above, it can be known that in one possible implementation mode, the fine-tuning process of the stylized image generation model can be completed with the help of multiple rounds of iterative update processes for the stylized image generation model above, so that the fine-tuned stylized image generation model has better stylized image generation performance, so that when a pair of cross-domain images with different styles are generated for the same latent code using the stylized image generation model and the real image generation model above, the pair of cross-domain images with different styles not only match similarly (that is, look like the same person), but also the same color is used for the same part in the pair of cross-domain images, so that the color matching requirements proposed by the paired cross-domain images can be better met, which is beneficial to improve the quality of the paired cross-domain images.

[0156] Based on the relevant content of the above model construction method, this application also provides an image generation method. Figure 4 Explain and illustrate. Figure 4 As shown, the image generation method provided in the embodiment of the present application includes the following S401-S404. Figure 4 A flowchart of an image generation method provided in an embodiment of the present application.

[0157] S401: Obtain target latent code.

[0158] Among them, the target latent code refers to the latent code required to be used when obtaining paired cross-domain images; and the relevant content of the target latent code is similar to the relevant content of the latent code provided in S101 above, and for the sake of brevity, it will not be repeated here.

[0159] S402: Determine the real image corresponding to the target latent code using a pre-built real image generation model.

[0160] For the relevant content of the real image generation model, please refer to the relevant content of S101 above, and for the sake of brevity, it will not be repeated here.

[0161] The above “real image corresponding to the target latent code” refers to the image data obtained by performing real image generation processing on the target latent code using the above real image generation model, so that the “real image corresponding to the target latent code” is image data under a real style.

[0162] In addition, the relevant content of the above “real image corresponding to the target hidden code” is similar to the relevant content of the above “real image corresponding to the hidden code to be processed”. For the sake of brevity, it will not be repeated here.

[0163] S403: Determine a stylized image corresponding to a target latent code using a pre-constructed stylized image generation model; the stylized image generation model is determined using any implementation of the model construction method provided in the present application; the real image and the stylized image are used to construct a pair of cross-domain images.

[0164] For the relevant content of the stylized image generation model, please refer to the relevant content of the "model construction method" above. For the sake of brevity, it will not be repeated here.

[0165] The above “stylized image corresponding to the target latent code” refers to the image data obtained by performing stylized image generation processing on the target latent code using the above stylized image generation model, so that the “stylized image corresponding to the target latent code” belongs to the image data under the target style.

[0166] In addition, the relevant content of the above “the stylized image corresponding to the target latent code” is similar to the relevant content of the above “the stylized image corresponding to the latent code to be processed”. For the sake of brevity, it will not be repeated here.

[0167] It should be noted that the present application does not limit the execution order between the above S403 and the above S402, for example, the two can be executed simultaneously. For another example, the two can be executed in sequence according to a preset order (for example, first execute S402 and then execute S403, or first execute S403 and then execute S402).

[0168] In fact, after obtaining the above "real image corresponding to the target latent code" and the above "stylized image corresponding to the target latent code", a tuple (real image corresponding to the target latent code, stylized image corresponding to the target latent code) can be constructed and used as a pair of cross-domain images so that this pair of cross-domain images can be used to perform other image tasks later.

[0169] Based on the relevant contents of S401 to S403 above, it can be known that for the image generation method provided in the embodiment of the present application, a pair of real image generation models and stylized image generation models can be pre-constructed to ensure that the color usage rules of the stylized image generation model are consistent with the color usage rules of the real image generation model, thereby ensuring that the colors used for the same part in the two images generated by the two models for the same latent code (for example, the target latent code above) are the same, so that when the real image and the stylized image are combined into a pair of cross-domain images, it can be ensured that the colors used for the same part in the pair of cross-domain images are the same, which can effectively overcome the adverse effects caused by the use of different colors for the same part in the paired cross-domain images (for example, resulting in low usability of the pair of cross-domain images), thereby helping to improve the generation effect of the paired cross-domain images.

[0170] In addition, the present application does not limit the execution subject of the above image generation method. For example, the image generation method provided in the embodiment of the present application can be applied to a device with data processing function such as a terminal device or a server. For another example, the image generation method provided in the embodiment of the present application can also be implemented by means of a data communication process between different devices (for example, a terminal device and a server, two terminal devices, or two servers).

[0171] Based on the model building method provided in the embodiment of the present application, the embodiment of the present application also provides a model building device. Figure 5 Explain and illustrate. Figure 5 This is a schematic diagram of the structure of a model building device provided in an embodiment of the present application. It should be noted that for the technical details of the model building device provided in an embodiment of the present application, please refer to the relevant content of the model building method above.

[0172] like Figure 5 As shown, the model building device 500 provided in the embodiment of the present application includes:

[0173] An initialization unit 501 is used to initialize a stylized image generation model using a pre-built real image generation model;

[0174] A first acquisition unit 502, used to acquire a hidden code to be processed;

[0175] A first determining unit 503 is used to determine a real image generation result corresponding to the hidden code to be processed by using the real image generation model, and to determine a stylized image generation result corresponding to the hidden code to be processed by using the stylized image generation model;

[0176] The model updating unit 504 is configured to update the stylized image generation model according to the color difference representation data between the real image generation result and the stylized image generation result.

[0177] In a possible implementation manner, the real image generation result includes real image segmentation representation data;

[0178] The stylized image generation result includes stylized image segmentation representation data;

[0179] The color difference representation data is determined based on the real image segmentation representation data and the stylized image segmentation representation data.

[0180] In a possible implementation manner, the real image segmentation representation data is used to describe first segmented regions corresponding to a plurality of parts; the stylized image segmentation representation data is used to describe second segmented regions corresponding to a plurality of parts;

[0181] The model building device 500 further includes:

[0182] A first statistical unit is used to perform pixel color statistical analysis on a first segmented area corresponding to a target part to obtain first color representation data corresponding to the target part; the target part is any one of the several parts;

[0183] A second statistical unit, configured to perform pixel color statistical analysis on a second segmented area corresponding to the target part to obtain second color representation data corresponding to the target part;

[0184] A fifth determining unit, configured to determine a color similarity corresponding to the target part according to a similarity between the first color representation data corresponding to the target part and the second color representation data corresponding to the target part;

[0185] The color difference representation data is determined according to the sum of the color similarities corresponding to the plurality of parts.

[0186] In a possible implementation manner, the model building device 500 further includes:

[0187] The model building unit is used to build the real image generation model based on at least one real image sample and the actual image segmentation representation data corresponding to each of the real image samples.

[0188] In a possible implementation, the real image generation model and the stylized image generation model are both generative adversarial network models.

[0189] In a possible implementation, the stylized image generation model includes a stylized image generator;

[0190] The model updating unit 504 is specifically configured to update the stylized image generator according to the color difference representation data between the real image generation result and the stylized image generation result.

[0191] In a possible implementation, the stylized image generation model includes a stylized image discriminator;

[0192] The stylized image discriminator is trained according to at least one stylized image sample.

[0193] In one possible implementation, the model updating unit 504 is specifically used to: update the stylized image generation model according to the color difference representation data between the real image generation result and the stylized image generation result, and return to the first acquisition unit 502 to continue to execute the step of acquiring the hidden code to be processed until a preset stop condition is reached.

[0194] Based on the relevant contents of the above-mentioned model building device 500, it can be known that for the model building device 500 provided in the embodiment of the present application, a real image generation model is first pre-built so that the real image generation model can perform image generation processing for a hidden code; then, the stylized image generation model is initialized using the real image generation model so that the stylized image generation model can also perform image generation processing for a hidden code; then, based on the color difference representation data between the image generation results determined by the two models for the same hidden code, the stylized image generation model is updated so that the updated stylized image generation model can generate images for a hidden code. The color usage of the same part is as close as possible to the color usage of the corresponding part in the image data generated by the real image generation model for the latent code, so as to ensure that the color usage rules of the stylized image generation model finally constructed are consistent with the color usage rules of the real image generation model, thereby ensuring that the colors used for the same part in the two images generated by the two models for the same latent code are the same, and thus effectively overcoming the adverse effects caused by using different colors for the same part in the two images (for example, because the same part in the paired cross-domain images uses different colors, the usability of the pair of cross-domain images is relatively low).

[0195] Based on the image generation method provided in the embodiment of the present application, the embodiment of the present application also provides an image generation device. Figure 6 Explain and illustrate. Figure 6 This is a schematic diagram of the structure of an image generating device provided in an embodiment of the present application. It should be noted that for the technical details of the image generating device provided in an embodiment of the present application, please refer to the relevant contents of the image generating method above.

[0196] like Figure 6 As shown, the image generating device 600 provided in the embodiment of the present application includes:

[0197] A second acquisition unit, used for acquiring a target latent code;

[0198] A second determining unit is used to determine the real image corresponding to the target latent code by using a pre-built real image generation model;

[0199] The third determination unit is used to determine the stylized image corresponding to the target latent code by using a pre-constructed stylized image generation model; the stylized image generation model is determined by any implementation of the model construction method provided in the present application; the real image and the stylized image are used to construct a pair of cross-domain images.

[0200] Based on the relevant content of the above-mentioned image generating device 600, it can be known that for the image generating device 600 provided in the embodiment of the present application, a pair of real image generation models and stylized image generation models can be pre-constructed to ensure that the color usage rules of the stylized image generation model are consistent with the color usage rules of the real image generation model, thereby ensuring that the colors used for the same part in the two images generated by the two models for the same latent code (for example, the target latent code above) are the same, so that when the real image and the stylized image are combined into a pair of cross-domain images, it can be ensured that the colors used for the same part in the pair of cross-domain images are the same, which can effectively overcome the adverse effects caused by the use of different colors for the same part in the paired cross-domain images (for example, resulting in low usability of the pair of cross-domain images), thereby helping to improve the generation effect of the paired cross-domain images.

[0201] In addition, an embodiment of the present application also provides an electronic device, which includes a processor and a memory: the memory is used to store instructions or computer programs; the processor is used to execute the instructions or computer programs in the memory, so that the electronic device executes any implementation of the model building method or image generation method provided in the embodiment of the present application.

[0202] See also Figure 7, which shows a schematic diagram of the structure of an electronic device 700 suitable for implementing the embodiment of the present disclosure. The terminal device in the embodiment of the present disclosure may include but is not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), vehicle terminals (such as vehicle navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 7 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.

[0203] like Figure 7 As shown, the electronic device 700 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 701, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 702 or a program loaded from a storage device 708 into a random access memory (RAM) 703. In the RAM 703, various programs and data required for the operation of the electronic device 700 are also stored. The processing device 701, the ROM 702, and the RAM 703 are connected to each other via a bus 704. An input / output (I / O) interface 705 is also connected to the bus 704.

[0204] Typically, the following devices may be connected to the I / O interface 705: an input device 706 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 707 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 708 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 709. The communication device 709 may allow the electronic device 700 to communicate with other devices wirelessly or by wire to exchange data. Although Figure 7 The electronic device 700 is shown with various devices, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.

[0205] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication device 709, or installed from the storage device 708, or installed from the ROM 702. When the computer program is executed by the processing device 701, the above-mentioned functions defined in the method of the embodiment of the present disclosure are executed.

[0206] The electronic device provided by the embodiment of the present disclosure and the method provided by the above embodiment belong to the same inventive concept, and the technical details not fully described in this embodiment can be referred to the above embodiment, and this embodiment has the same beneficial effects as the above embodiment.

[0207] An embodiment of the present application also provides a computer-readable medium, in which instructions or computer programs are stored. When the instructions or computer programs are executed on a device, the device executes any implementation of the model building method or image generation method provided in the embodiment of the present application.

[0208] It should be noted that the computer-readable medium disclosed above may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in combination with an instruction execution system, device or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer-readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. The computer readable signal medium may also be any computer readable medium other than a computer readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.

[0209] In some embodiments, the client and the server may communicate using any currently known or future developed network protocol such as HTTP (Hyper Text Transfer Protocol), and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or future developed network.

[0210] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.

[0211] The computer-readable medium carries one or more programs, and when the one or more programs are executed by the electronic device, the electronic device can execute the method.

[0212] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages ​​or a combination thereof, including, but not limited to, object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).

[0213] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0214] The units involved in the embodiments described in the present disclosure may be implemented by software or hardware, wherein the name of a unit / module does not, in some cases, constitute a limitation on the unit itself.

[0215] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.

[0216] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0217] It should be noted that the various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments, and the same or similar parts between the various embodiments can be referred to each other. For the system or device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part description.

[0218] It should be understood that in the present application, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.

[0219] It should also be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.

[0220] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.

[0221] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A model building method, characterized in that: The method comprises: Initialize the stylized image generation model using a pre-built real image generation model; Get the hidden code to be processed; Determine a real image generation result corresponding to the hidden code to be processed by using the real image generation model, and determine a stylized image generation result corresponding to the hidden code to be processed by using the stylized image generation model; The stylized image generation model is updated according to the color difference representation data between the real image generation result and the stylized image generation result.

2. The method according to claim 1, characterized in that The real image generation result includes real image segmentation representation data; The stylized image generation result includes stylized image segmentation representation data; The color difference representation data is determined based on the real image segmentation representation data and the stylized image segmentation representation data.

3. The method according to claim 2, characterized in that The real image segmentation representation data is used to describe first segmented regions corresponding to a plurality of parts; the stylized image segmentation representation data is used to describe second segmented regions corresponding to a plurality of parts; The process of determining the color difference characterization data includes: Performing pixel color statistical analysis on a first segmented area corresponding to a target part to obtain first color representation data corresponding to the target part; the target part is any one of the several parts; Performing pixel color statistical analysis on the second segmented area corresponding to the target part to obtain second color representation data corresponding to the target part; Determining the color similarity corresponding to the target part according to the similarity between the first color representation data corresponding to the target part and the second color representation data corresponding to the target part; The color difference representation data is determined according to the sum of the color similarities corresponding to the plurality of parts.

4. The method according to claim 1, characterized in that: Before initializing the stylized image generation model using the pre-built real image generation model, the method further includes: The real image generation model is constructed based on at least one real image sample and actual image segmentation representation data corresponding to each of the real image samples.

5. The method according to claim 1, characterized in that The real image generation model and the stylized image generation model both belong to generative adversarial network models.

6. The method according to claim 5, characterized in that The stylized image generation model includes a stylized image generator; The updating of the stylized image generation model according to the color difference representation data between the real image generation result and the stylized image generation result comprises: The stylized image generator is updated according to the color difference representation data between the real image generation result and the stylized image generation result.

7. The method according to claim 5, characterized in that The stylized image generation model includes a stylized image discriminator; The stylized image discriminator is trained according to at least one stylized image sample.

8. The method according to claim 1, characterized in that After updating the stylized image generation model according to the color difference characterization data between the real image generation result and the stylized image generation result, the method further includes: Continue to execute the step of obtaining the hidden code to be processed until a preset stopping condition is reached.

9. An image generation method, characterized in that: The method comprises: Get the target hidden code; Determine the real image corresponding to the target latent code by using a pre-built real image generation model; Using a pre-built stylized image generation model, a stylized image corresponding to the target latent code is determined; the stylized image generation model is determined using the model construction method described in any one of claims 1-8; the real image and the stylized image are used to construct a pair of cross-domain images.

10. A model building device, characterized in that: include: An initialization unit, used to initialize the stylized image generation model using a pre-built real image generation model; A first acquisition unit, used to acquire a latent code to be processed; A first determining unit, configured to determine a real image generation result corresponding to the hidden code to be processed by using the real image generation model, and to determine a stylized image generation result corresponding to the hidden code to be processed by using the stylized image generation model; A model updating unit is used to update the stylized image generation model according to the color difference representation data between the real image generation result and the stylized image generation result.

11. An image generating device, characterized in that: include: A second acquisition unit, used for acquiring a target latent code; A second determining unit is used to determine the real image corresponding to the target latent code by using a pre-built real image generation model; A third determination unit is used to determine the stylized image corresponding to the target latent code using a pre-constructed stylized image generation model; the stylized image generation model is determined using the model construction method described in any one of claims 1-8; the real image and the stylized image are used to construct a pair of cross-domain images.

12. An electronic device, characterized in that: The device comprises: a processor and a memory; The memory is used to store instructions or computer programs; The processor is used to execute the instructions or computer programs in the memory so that the electronic device executes the method according to any one of claims 1 to 9.

13. A computer readable medium, characterized in that The computer-readable medium stores instructions or computer programs, and when the instructions or computer programs are executed on a device, the device executes the method according to any one of claims 1 to 9.

Citation Information

Cited By

  • Unsupervised training method and device for re-recognition model and medium

    CN118690822A