Image conversion model training method, image conversion method and device
Patent Information
- Application Number
- CN202211613822.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-15
- Publication Date
- 2026-10-27
- Estimated Expiration
- 2042-12-15
AI Technical Summary
[0004]只单独使用循环图像生成网络模型作为主框架时,图像转换模型无法判别生成的图像是否为真实图像,难以及时对图像转换模型的参数进行调整,导致图像转换模型进行图像转换的准确率降低
[0026]本公开的上述各个实施例具有如下有益效果:通过本公开的一些实施例的图像转换模型训练方法,可以提高图像转换模型进行图像转换的准确率。具体来说,造成图像转换模型进行图像转换的准确率降低的原因在于:只单独使用循环图像生成网络模型作为主框架时,图像转换模型无法判别生成的图像是否为真实图像并及时对图像转换模型的参数进行调整,导致图像转换模型进行图像转换的准确率降低。基于此,本公开的一些实施例的图像转换模型训练方法,首先,获取样本图像集和初始图像转换模型,其中,上述初始图像转换模型包括第一初始图像转换模型和第二初始图像转换模型,上述第一初始图像转换模型包括第一图像生成模型和第一图像判别模型,上述第二初始图像转换模型包括第二图像生成模型和第二图像判别模型。因此,将图像生成模型和图像判别模型作为图像转换模型的框架,可以对图像生成模型生成的图像进行进一步判断,从而可以提高图像转换模型的准确率。然后,基于上述样本图像集和至少一个预设的损失函数,对上述初始图像转换模型进行训练,得到训练后的图像转换模型,其中,上述至少一个预设的损失函数包括以下至少一项:循环对抗损失函数、循环一致损失函数和循环位置损失函数。由此,可以利用样本图像对初始图像转换模型进行训练,以提高训练后的图像转换模型对图像进行转换的准确率。从而,可以提高图像转换模型进行图像转换的准确率。
Smart Images

Figure CN116071224B_ABST
Abstract
Description
Technical Field
[0001] The embodiments disclosed herein relate to the field of computer technology, and specifically to an image conversion model training method, an image conversion method, and an apparatus. Background Technology
[0002] Image transfer models can perform style transfer on target images, which helps to find useful macroscopic information in images. Currently, the training of image transfer models usually involves training an image transfer model with a Cycle-Consistent Generative Adversarial Network (CERNA) as the main framework using a large number of sample images.
[0003] However, the inventors discovered that when training the image conversion model using the above method, the following technical problems often occur:
[0004] When using a recurrent image generation network model as the main framework alone, the image conversion model cannot determine whether the generated image is a real image, making it difficult to adjust the parameters of the image conversion model in a timely manner, resulting in a decrease in the accuracy of image conversion.
[0005] The information disclosed in this background section is only intended to enhance the understanding of the background of the inventive concept, and therefore may contain information that does not constitute prior art known to those skilled in the art. Summary of the Invention
[0006] The summary portion of this disclosure is intended to provide a brief overview of the concepts, which will be described in detail in the detailed description portion. This summary portion is not intended to identify key or essential features of the claimed technical solutions, nor is it intended to limit the scope of the claimed technical solutions.
[0007] Some embodiments of this disclosure provide image conversion model training methods, image conversion methods, apparatuses, electronic devices, and computer-readable media to solve one or more of the technical problems mentioned in the background section above.
[0008] In a first aspect, some embodiments of this disclosure provide an image conversion model training method, the method comprising: acquiring a sample image set and an initial image conversion model, wherein the initial image conversion model includes a first initial image conversion model and a second initial image conversion model, the first initial image conversion model includes a first image generation model and a first image discrimination model, and the second initial image conversion model includes a second image generation model and a second image discrimination model; training the initial image conversion model based on the sample image set and at least one preset loss function to obtain a trained image conversion model, wherein the at least one preset loss function includes at least one of the following: a cyclic adversarial loss function, a cyclic consistent loss function, and a cyclic position loss function.
[0009] Optionally, training the initial image conversion model based on the sample image set and at least one preset loss function to obtain a trained image conversion model includes: selecting sample images from the sample image set and performing the following training steps on the initial image conversion model: inputting the sample images into a first image generation model to obtain first feature information, wherein the first feature information includes a first feature image; inputting the first feature image into a first image discrimination model to obtain a first discrimination result; in response to determining that the first discrimination result meets a preset condition, inputting the first feature image into a second image conversion model to obtain second feature information, wherein the second feature information includes a second feature image; inputting the second feature image into a second image discrimination model to obtain a second discrimination result; in response to determining that the second discrimination result meets a preset condition, determining a total cyclic loss value based on at least one preset loss function; and in response to determining that the total cyclic loss value is less than a target value, determining the initial image conversion model as an image conversion model.
[0010] Optionally, the above method further includes: in response to determining that the first discrimination result does not meet the preset conditions, adjusting the relevant parameters in the initial image conversion model to obtain the adjusted initial image conversion model; reselecting sample images from the sample image set, determining the adjusted initial image conversion model as the initial image conversion model, and continuing to execute the above training steps.
[0011] Optionally, the above method further includes: in response to determining that the second discrimination result does not meet the preset conditions, adjusting the relevant parameters in the initial image conversion model to obtain the adjusted initial image conversion model; reselecting sample images from the sample image set, determining the adjusted initial image conversion model as the initial image conversion model, and continuing to execute the above training steps.
[0012] Optionally, the above method further includes: in response to determining that the total cyclic loss value is greater than or equal to the target value, adjusting the relevant parameters in the initial image conversion model to obtain an adjusted initial image conversion model; reselecting sample images from the sample image set, determining the adjusted initial image conversion model as the initial image conversion model, and continuing to perform the above training steps.
[0013] Optionally, the first feature information further includes a first block vector sequence, and the second feature information further includes a second block vector sequence; and determining the total cyclic loss value based on at least one preset loss function includes: determining a cyclic adversarial loss value based on the cyclic adversarial loss function and the first feature information; determining a cyclic consistency loss value based on the cyclic consistent loss function, the first feature image, and the second feature image; determining a cyclic position loss value based on the cyclic position loss function, the first block vector sequence, and the second block vector sequence; and performing a weighted summation of the first cyclic adversarial loss value, the cyclic consistent loss value, and the cyclic position loss value to obtain the total cyclic loss value.
[0014] Optionally, determining the cyclic position loss value based on the cyclic position loss function, the first block vector sequence, and the second block vector sequence includes: for each first block vector in the first block vector sequence, performing the following steps: determining the first block vector as the target block vector; determining the second block vector in the second block vector sequence corresponding to the target block vector as the positive sample block vector; determining the second block vector sequence after removing the positive sample block vectors as the negative sample block vector sequence; and determining the cyclic position loss value based on the target block vector, the positive sample block vector and negative sample vector sequences, and the cyclic position loss function.
[0015] Secondly, some embodiments of this disclosure provide an image conversion method, the method comprising: acquiring an initial image; inputting the initial image into a pre-trained image conversion model to obtain a converted image, wherein the image conversion model is generated by a method as described in any of the implementations of the first aspect above.
[0016] Thirdly, some embodiments of this disclosure provide an image conversion model training apparatus, the apparatus comprising: an acquisition unit configured to acquire a sample image set and an initial image conversion model, wherein the initial image conversion model includes a first initial image conversion model and a second initial image conversion model, the first initial image conversion model includes a first image generation model and a first image discrimination model, and the second initial image conversion model includes a second image generation model and a second image discrimination model; and a training unit configured to train the initial image conversion model based on the sample image set and at least one preset loss function to obtain a trained image conversion model, wherein the at least one preset loss function includes at least one of the following: a cyclic adversarial loss function, a cyclic consistent loss function, and a cyclic position loss function.
[0017] Optionally, the training unit is further configured to: select sample images from the sample image set and perform the following training steps on the initial image conversion model: input the sample images into a first image generation model to obtain first feature information, wherein the first feature information includes a first feature image; input the first feature image into a first image discrimination model to obtain a first discrimination result; in response to determining that the first discrimination result meets a preset condition, input the first feature image into a second image conversion model to obtain second feature information, wherein the second feature information includes a second feature image; input the second feature image into a second image discrimination model to obtain a second discrimination result; in response to determining that the second discrimination result meets a preset condition, determine a total cyclic loss value based on at least one preset loss function; in response to determining that the total cyclic loss value is less than a target value, determine the initial image conversion model as an image conversion model.
[0018] Optionally, the image conversion model training device further includes: a first adjustment unit configured to: adjust relevant parameters in the initial image conversion model in response to determining that the first discrimination result does not meet the preset conditions, to obtain an adjusted initial image conversion model; and a first determination unit configured to reselect sample images from the sample image set, determine the adjusted initial image conversion model as the initial image conversion model, and continue to execute the training steps.
[0019] Optionally, the image conversion model training device further includes: a second adjustment unit configured to: adjust the relevant parameters in the initial image conversion model in response to determining that the second discrimination result does not meet the preset conditions, to obtain an adjusted initial image conversion model; and a second determination unit configured to reselect sample images from the sample image set, determine the adjusted initial image conversion model as the initial image conversion model, and continue to execute the training steps.
[0020] Optionally, the image conversion model training device further includes: a third adjustment unit configured to: adjust relevant parameters in the initial image conversion model in response to determining that the total cyclic loss value is greater than or equal to the target value, to obtain an adjusted initial image conversion model; and a third determination unit configured to reselect sample images from the sample image set, determine the adjusted initial image conversion model as the initial image conversion model, and continue to execute the training steps.
[0021] Optionally, the first feature information further includes a first block vector sequence, and the second feature information further includes a second block vector sequence; and the training unit is further configured to: determine a cyclic adversarial loss value based on the cyclic adversarial loss function and the first feature information; determine a cyclic consistency loss value based on the cyclic consistency loss function, the first feature image, and the second feature image; determine a cyclic position loss value based on the cyclic position loss function, the first block vector sequence, and the second block vector sequence; and perform a weighted summation of the first cyclic adversarial loss value, the cyclic consistency loss value, and the cyclic position loss value to obtain the total cyclic loss value.
[0022] Optionally, the training unit is further configured to perform the following steps for each first block vector in the first block vector sequence: determining the first block vector as the target block vector; determining the second block vector in the second block vector sequence corresponding to the target block vector as the positive sample block vector; determining the second block vector sequence after removing the positive sample block vector as the negative sample block vector sequence; and determining the cyclic position loss value based on the target block vector, the positive sample block vector and the negative sample block vector sequence and the cyclic position loss function.
[0023] Fourthly, some embodiments of this disclosure provide an image conversion apparatus, the apparatus comprising: an acquisition unit configured to acquire an initial image; and an input unit configured to input the initial image into a pre-trained image conversion model to obtain a converted image, wherein the image conversion model is generated by a method as described in any implementation of the first aspect.
[0024] Fifthly, some embodiments of this disclosure provide an electronic device, including: one or more processors; and a storage device having one or more programs stored thereon, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the method described in any of the implementations of the first aspect above.
[0025] Sixthly, some embodiments of this disclosure provide a computer-readable medium having a computer program stored thereon, wherein the program, when executed by a processor, implements the method described in any of the implementations of the first aspect above.
[0026] The above embodiments of this disclosure have the following beneficial effects: the image conversion model training method of some embodiments of this disclosure can improve the accuracy of image conversion model in image conversion. Specifically, the reason for the decrease in the accuracy of image conversion model in image conversion is that when only a recurrent image generation network model is used as the main framework, the image conversion model cannot determine whether the generated image is a real image and adjust the parameters of the image conversion model in a timely manner, resulting in a decrease in the accuracy of image conversion model in image conversion. Based on this, the image conversion model training method of some embodiments of this disclosure first obtains a sample image set and an initial image conversion model, wherein the initial image conversion model includes a first initial image conversion model and a second initial image conversion model, the first initial image conversion model includes a first image generation model and a first image discrimination model, and the second initial image conversion model includes a second image generation model and a second image discrimination model. Therefore, by using the image generation model and the image discrimination model as the framework of the image conversion model, the images generated by the image generation model can be further judged, thereby improving the accuracy of the image conversion model. Then, based on the aforementioned sample image set and at least one preset loss function, the initial image conversion model is trained to obtain a trained image conversion model. The at least one preset loss function includes at least one of the following: a cyclic adversarial loss function, a cyclic consistent loss function, and a cyclic positional loss function. Therefore, the initial image conversion model can be trained using sample images to improve the accuracy of the trained image conversion model in converting images. This improves the accuracy of the image conversion model in performing image conversions. Attached Figure Description
[0027] The above and other features, advantages, and aspects of the embodiments of this disclosure will become more apparent from the accompanying drawings and the following detailed description. Throughout the drawings, the same or similar reference numerals denote the same or similar elements. It should be understood that the drawings are schematic, and elements are not necessarily drawn to scale.
[0028] Figure 1 This is a schematic diagram illustrating an application scenario of the image conversion model training method according to some embodiments of this disclosure;
[0029] Figure 2 This is a schematic diagram illustrating an application scenario of the image conversion and recognition method according to some embodiments of this disclosure;
[0030] Figure 3This is a flowchart of some embodiments of the image conversion model training method according to the present disclosure;
[0031] Figure 4 These are flowcharts of some other embodiments of the image conversion model training method according to this disclosure;
[0032] Figure 5 This is a flowchart of some embodiments of the image conversion and recognition method according to the present disclosure;
[0033] Figure 6 These are schematic diagrams illustrating the structure of some embodiments of the image conversion model training apparatus according to the present disclosure;
[0034] Figure 7 These are schematic diagrams illustrating the structure of some embodiments of the image conversion apparatus according to the present disclosure;
[0035] Figure 8 This is a schematic diagram of the structure of an electronic device suitable for implementing some embodiments of the present disclosure. Detailed Implementation
[0036] Embodiments of this disclosure will now be described in more detail with reference to the accompanying drawings. While some embodiments of this disclosure are shown in the drawings, it should be understood that this disclosure can be implemented in various forms and should not be construed as limited to the embodiments set forth herein. Rather, these embodiments are provided to provide a more thorough and complete understanding of this disclosure. It should be understood that the accompanying drawings and embodiments of this disclosure are for illustrative purposes only and are not intended to limit the scope of protection of this disclosure.
[0037] It should also be noted that, for ease of description, only the parts relevant to the invention are shown in the accompanying drawings. Unless otherwise specified, the embodiments and features described in this disclosure can be combined with each other.
[0038] It should be noted that the concepts of "first" and "second" mentioned in this disclosure are used only to distinguish different devices, modules or units, and are not used to limit the order of functions performed by these devices, modules or units or their interdependencies.
[0039] It should be noted that the terms "a" and "a plurality of" used in this disclosure are illustrative rather than restrictive, and those skilled in the art should understand that, unless otherwise expressly indicated in the context, they should be understood as "one or more".
[0040] The names of messages or information exchanged between multiple devices in the embodiments of this disclosure are for illustrative purposes only and are not intended to limit the scope of such messages or information.
[0041] This disclosure will now be described in detail with reference to the accompanying drawings and embodiments.
[0042] Figure 1 This is a schematic diagram of an application scenario of a title entity recognition model training method according to some embodiments of the present disclosure.
[0043] exist Figure 1 In the application scenario, firstly, the electronic device 101 can acquire a sample image set 102 and an initial image conversion model 103. Then, the electronic device 101 can determine the trained text encoding model 1041 and the preset decoding network 105 as the initial title entity recognition model 106. Finally, the electronic device 101 can train the initial image conversion model 103 based on the sample image set 102 and at least one preset loss function 104 to obtain the trained image conversion model 105.
[0044] It should be noted that the aforementioned electronic device 101 can be either hardware or software. When the electronic device is hardware, it can be implemented as a distributed cluster consisting of multiple servers or terminal devices, or as a single server or a single terminal device. When the electronic device is software, it can be installed in the hardware devices listed above. It can be implemented as, for example, multiple software programs or software modules used to provide distributed services, or as a single software program or software module. No specific limitations are made here.
[0045] It should be understood that Figure 1 The number of electronic devices shown is merely illustrative. Any number of electronic devices can be used depending on the implementation requirements.
[0046] Figure 2 This is a schematic diagram of an application scenario of an image conversion method according to some embodiments of the present disclosure.
[0047] exist Figure 2 In the application scenario, firstly, the electronic device 201 can acquire an initial image 202. Then, the electronic device 201 can input the acquired initial image 202 into a pre-trained image conversion model 203 to obtain a converted image 204. The image conversion model 203 is generated using a method described in any implementation of the first aspect.
[0048] It should be noted that the aforementioned electronic device 201 can be either hardware or software. When the electronic device is hardware, it can be implemented as a distributed cluster consisting of multiple servers or terminal devices, or as a single server or a single terminal device. When the electronic device is software, it can be installed in the hardware devices listed above. It can be implemented as, for example, multiple software programs or software modules used to provide distributed services, or as a single software program or software module. No specific limitations are made here.
[0049] It should be understood that Figure 2 The number of electronic devices shown is merely illustrative. Any number of electronic devices can be used depending on the implementation requirements.
[0050] Continue to refer to Figure 3 The diagram illustrates flow 300 of some embodiments of a title entity recognition model training method according to the present disclosure. This image conversion model training method includes the following steps:
[0051] Step 301: Obtain the sample image set and the initial image conversion model.
[0052] In some embodiments, the execution entity of the image conversion model training method (e.g. Figure 1 The electronic device 101 shown can acquire a sample image set and an initial image conversion model from a terminal device via a wired or wireless connection. The initial image conversion model includes a first initial image conversion model and a second initial image conversion model. The first initial image conversion model includes a first image generation model and a first image discrimination model, and the second initial image conversion model includes a second image generation model and a second image discrimination model.
[0053] As an example, the sample images in the above sample image set can be, but are not limited to, images of cats or dogs. The first image generation model can be, but is not limited to, a Cycle Generative Adversarial Network (CGN) model or a GcGan (Geometry-consistency Generative Adversarial Network) model. The second image generation model is similar to the first image generation model and will not be described further here. The first image discrimination model can be a neural network model that takes a feature image as input and outputs a discrimination result. The second image discrimination model is similar to the first image discrimination model and will not be described further here.
[0054] Step 302: Based on the sample image set and at least one preset loss function, train the initial image conversion model to obtain the trained image conversion model.
[0055] In some embodiments, the execution entity may train the initial image conversion model based on the sample image set and at least one preset loss function to obtain a trained image conversion model. The at least one preset loss function includes, but is not limited to, at least one of the following: a cyclic adversarial loss function, a cyclic consistent loss function, and a cyclic positional loss function.
[0056] In some optional implementations of certain embodiments, the execution entity trains the initial image conversion model based on the sample image set and at least one preset loss function to obtain a trained image conversion model. Sample images can be selected from the sample image set to perform the following training steps on the initial image conversion model:
[0057] The first step is to input the sample image into the first image generation model to obtain the first feature information. This first feature information includes a first feature image and a first block vector sequence.
[0058] The second step involves inputting the first feature image into the first image discrimination model to obtain a first discrimination result. This first discrimination result characterizes the authenticity of the first feature image.
[0059] As an example, when the first discrimination result is greater than 0.5, it can be characterized that the first feature image is a real image. When the first discrimination result is less than 0.5, it can be characterized that the first feature image is not a real image.
[0060] Thirdly, in response to determining that the first discrimination result satisfies the first preset condition, the first feature image is input into the second image conversion model to obtain second feature information. The second feature information includes the second feature image and the second block vector sequence. The first preset condition can be that the first discrimination result is greater than 0.5. One first block vector in the first block vector sequence can correspond to one second block vector sequence in the second block vector sequence.
[0061] The fourth step involves inputting the second feature image into the second image discrimination model to obtain the second discrimination result. This second discrimination result characterizes the authenticity of the second feature image.
[0062] As an example, when the second discrimination result is greater than 0.5, it can be characterized that the second feature image is a real image. When the second discrimination result is less than 0.5, it can be characterized that the second feature image is not a real image.
[0063] Fifth step: In response to determining that the second discrimination result satisfies the second preset condition, determine the total cyclic loss value based on at least one preset loss function. The second preset condition may be that the second discrimination result is greater than 0.5.
[0064] Step 6: In response to the determination that the total cyclic loss value is less than the target value, the initial image conversion model is determined as the image conversion model. The setting of the target value is not limited; for example, the target value could be 0.1.
[0065] Optionally, the aforementioned implementing entity may also perform the following steps:
[0066] The first step, in response to the determination that the first discrimination result does not meet the preset conditions, is to adjust the relevant parameters in the initial image conversion model to obtain the adjusted initial image conversion model. Methods such as backpropagation and stochastic gradient descent can be used to propagate the error value from the last layer of the model forward to adjust the parameters of each layer. Alternatively, depending on the needs, network dropout can be used to keep the network parameters of some layers unchanged; no restrictions are placed on this approach.
[0067] The second step is to reselect sample images from the above sample image set, determine the adjusted initial image conversion model as the initial image conversion model, and continue to perform the above training steps.
[0068] Optionally, the aforementioned implementing entity may also perform the following steps:
[0069] The first step, in response to the determination that the second discrimination result does not meet the preset conditions, is to adjust the relevant parameters in the initial image conversion model to obtain the adjusted initial image conversion model. Methods such as backpropagation and stochastic gradient descent can be used to propagate the error value from the last layer of the model forward to adjust the parameters of each layer. Alternatively, depending on the needs, network dropout can be used to keep the network parameters of some layers unchanged; no restrictions are placed on this approach.
[0070] The second step is to reselect sample images from the above sample image set, determine the adjusted initial image conversion model as the initial image conversion model, and continue to perform the above training steps.
[0071] Optionally, the aforementioned implementing entity may also perform the following steps:
[0072] The first step, in response to the determination that the total cyclic loss value is greater than or equal to the target value, is to adjust the relevant parameters in the initial image conversion model to obtain the adjusted initial image conversion model. Methods such as backpropagation and stochastic gradient descent can be used to propagate the error value from the last layer of the model forward to adjust the parameters of each layer. Alternatively, depending on the needs, network dropout can be used to keep the network parameters of some layers unchanged; there are no restrictions on this approach.
[0073] The second step is to reselect sample images from the above sample image set, determine the adjusted initial image conversion model as the initial image conversion model, and continue to perform the above training steps.
[0074] In some optional implementations of certain embodiments, the execution entity determines the total cyclic loss value based on at least one preset loss function, which may include the following steps:
[0075] The first step is to determine the recurrent adversarial loss value based on the aforementioned recurrent adversarial loss function and the first feature information. The recurrent adversarial loss function can be, but is not limited to, mean squared error loss (MSE), hinge loss function (SVM), cross-entropy loss function, 0-1 loss function, absolute value loss function, logarithmic loss function, squared loss function, exponential loss function, etc.
[0076] The second step involves determining the cycle-consistent loss value based on the aforementioned cycle-consistent loss function, the first feature information, and the second feature information. The cycle-consistent loss function can be, but is not limited to, mean squared error loss (MSE), hinge loss function (SVM), cross-entropy loss function, 0-1 loss function, absolute value loss function, logarithmic loss function, squared loss function, exponential loss function, etc.
[0077] The third step involves determining the cyclic position loss value based on the aforementioned cyclic position loss function, the first block vector sequence, and the second block vector sequence. The cyclic position loss function can be, but is not limited to, the mean squared error loss function (MSE), the hinge loss function (SVM), the cross-entropy loss function, the 0-1 loss function, the absolute value loss function, the logarithmic loss function, the squared loss function, the exponential loss function, etc.
[0078] The fourth step is to perform a weighted summation of the first cycle adversarial loss value, the cycle consistency loss value, and the cycle position loss value to obtain the total cycle loss value.
[0079] In some optional implementations of certain embodiments, the execution entity determines the cyclic position loss value based on the cyclic position loss function, the first block vector sequence, and the second block vector sequence, which may include the following steps:
[0080] For each first block vector in the above first block vector sequence, perform the following sub-steps:
[0081] The first sub-step is to determine the first block vector as the target block vector.
[0082] The second sub-step involves determining the second block vector in the second block vector sequence that corresponds to the target block vector as the positive sample block vector.
[0083] The third sub-step involves determining the second block vector sequence, from which the positive sample block vectors have been removed, as the negative sample block vector sequence.
[0084] The fourth sub-step involves determining the cyclic position loss value based on the target block vector, the sequence of positive and negative sample block vectors, and the cyclic position loss function.
[0085] The above embodiments of this disclosure have the following beneficial effects: the image conversion model training method of some embodiments of this disclosure can improve the accuracy of image conversion model in image conversion. Specifically, the reason for the decrease in the accuracy of image conversion model in image conversion is that when only a recurrent image generation network model is used as the main framework, the image conversion model cannot determine whether the generated image is a real image and adjust the parameters of the image conversion model in a timely manner, resulting in a decrease in the accuracy of image conversion model in image conversion. Based on this, the image conversion model training method of some embodiments of this disclosure first obtains a sample image set and an initial image conversion model, wherein the initial image conversion model includes a first initial image conversion model and a second initial image conversion model, the first initial image conversion model includes a first image generation model and a first image discrimination model, and the second initial image conversion model includes a second image generation model and a second image discrimination model. Therefore, by using the image generation model and the image discrimination model as the framework of the image conversion model, the images generated by the image generation model can be further judged, thereby improving the accuracy of the image conversion model. Then, based on the aforementioned sample image set and at least one preset loss function, the initial image conversion model is trained to obtain a trained image conversion model. The at least one preset loss function includes at least one of the following: a cyclic adversarial loss function, a cyclic consistent loss function, and a cyclic positional loss function. Therefore, the initial image conversion model can be trained using sample images to improve the accuracy of the trained image conversion model in converting images. This improves the accuracy of the image conversion model in performing image conversions.
[0086] Further reference Figure 4 , Figure 4 A flow 400 of another embodiment of the image conversion model training method according to the present disclosure is shown. The image conversion model training method includes the following steps:
[0087] Step 401: Obtain the sample image set and the initial image conversion model.
[0088] In some embodiments, the specific implementation of step 401 and its resulting technical effects can be found in [reference needed]. Figure 3 Step 301 in the corresponding embodiment will not be repeated here.
[0089] Step 402: Select sample images from the sample image set and perform the following training steps on the initial image transformation model:
[0090] Step 4021: Input the sample image into the first image generation model to obtain the first feature information.
[0091] In some embodiments, the execution entity of the image conversion model training method (e.g. Figure 1 The electronic device 101 shown can input a sample image into a first image generation model to obtain first feature information. The first feature information includes a first feature image and a first block vector sequence.
[0092] Step 4022: Input the first feature image into the first image discrimination model to obtain the first discrimination result.
[0093] In some embodiments, the execution entity may input the first feature image into a first image discrimination model to obtain a first discrimination result. The first discrimination result can characterize the authenticity of the first feature image.
[0094] As an example, when the first discrimination result is greater than 0.5, it can be characterized that the first feature image is a real image. When the first discrimination result is less than 0.5, it can be characterized that the first feature image is not a real image.
[0095] Step 4023: In response to determining that the first discrimination result meets the first preset condition, the first feature image is input into the second image conversion model to obtain the second feature information.
[0096] In some embodiments, in response to determining that the first discrimination result meets a preset condition, the execution entity can input the first feature image into the second image conversion model to obtain second feature information. The second feature information includes the second feature image and a second block vector sequence. The first preset condition may be that the first discrimination result is greater than 0.5. One first block vector in the first block vector sequence may correspond to one second block vector sequence in the second block vector sequence.
[0097] Step 4024: Input the second feature image into the second image discrimination model to obtain the second discrimination result.
[0098] In some embodiments, the execution entity may input the second feature image into a second image discrimination model to obtain a second discrimination result. The second discrimination result can characterize the authenticity of the second feature image.
[0099] As an example, when the second discrimination result is greater than 0.5, it can be characterized that the second feature image is a real image. When the second discrimination result is less than 0.5, it can be characterized that the second feature image is not a real image.
[0100] Step 4025: In response to determining that the second discrimination result satisfies the second preset condition, the total cyclic loss value is determined based on at least one preset loss function. The second preset condition may be that the second discrimination result is greater than 0.5.
[0101] In some embodiments, in response to determining that the second discrimination result meets a preset condition, the executing entity can determine the total cyclic loss value based on at least one preset loss function. The preset condition may be that the first discrimination result is greater than 0.5.
[0102] In some optional implementations of certain embodiments, the execution entity determines the total cyclic loss value based on at least one preset loss function, which may include the following steps:
[0103] The first step is to determine the recurrent adversarial loss value based on the aforementioned recurrent adversarial loss function and the first feature information. The recurrent adversarial loss function can be, but is not limited to, mean squared error loss (MSE), hinge loss function (SVM), cross-entropy loss function, 0-1 loss function, absolute value loss function, logarithmic loss function, squared loss function, exponential loss function, etc.
[0104] The second step involves determining the cycle-consistent loss value based on the aforementioned cycle-consistent loss function, the first feature information, and the second feature information. The cycle-consistent loss function can be:
[0105]
[0106] Among them, Loss cycle (F, C, x, y) represent the adversarial loss values mentioned above. x represents the sample image mentioned above. data (x) represents the true data probability distribution defined in the above sample images. F(x) represents the first feature information mentioned above. G(y) represents the numerical value corresponding to the second feature information mentioned above. y represents the first feature image mentioned above. p data (y) represents the true data probability distribution defined in the first feature image above. G(F(x)) represents the numerical value corresponding to the second feature information above. F(G(y)) represents the numerical value corresponding to the feature information obtained after the second feature image is input into the first image generation network above. ||G(F(x))-x||1 represents the value of the first sparse rule operator. ||F(G(y))-y||1 represents the value of the second sparse rule operator.
[0107] The third step is to determine the cyclic position loss value based on the above-mentioned cyclic position loss function, the above-mentioned first block vector sequence, and the above-mentioned second block vector sequence.
[0108] The fourth step is to perform a weighted summation of the first cycle adversarial loss value, the cycle consistency loss value, and the cycle position loss value to obtain the total cycle loss value.
[0109] In some optional implementations of certain embodiments, the execution entity determines the cyclic position loss value based on the cyclic position loss function, the first block vector sequence, and the second block vector sequence, which may include the following steps:
[0110] For each first block vector in the above first block vector sequence, perform the following sub-steps:
[0111] The first sub-step is to determine the first block vector as the target block vector.
[0112] The second sub-step involves determining the second block vector in the second block vector sequence that corresponds to the target block vector as the positive sample block vector.
[0113] The third sub-step involves determining the second block vector sequence, from which the positive sample block vectors have been removed, as the negative sample block vector sequence.
[0114] The fourth sub-step involves determining the cyclic position loss value based on the target block vector, the positive sample block vector, the negative sample block vector sequence, and the cyclic position loss function. The cyclic position loss function can be:
[0115]
[0116] Among them, l loc (v,v + v - ) represents the aforementioned cyclic position loss value. v represents the aforementioned target block vector. v + This represents the positive sample block vector mentioned above. - Let represent the negative sample block vectors mentioned above. n represents the index of the negative sample block vector in the sequence. N represents the number of negative sample block vectors in the sequence. τ represents the loss coefficient.
[0117] Step 4046: In response to determining that the total cyclic loss value is less than the target value, the initial image conversion model is determined as the image conversion model.
[0118] In some embodiments, in response to determining that the total cyclic loss value is less than the target value, the execution entity may determine the initial image conversion model as the image conversion model. The setting of the target value is not limited; for example, the first preset difference value may be 0.1.
[0119] Optionally, the aforementioned implementing entity may also perform the following steps:
[0120] The first step, in response to the determination that the first discrimination result does not meet the preset conditions, is to adjust the relevant parameters in the initial image conversion model to obtain the adjusted initial image conversion model. Methods such as backpropagation and stochastic gradient descent can be used to propagate the error value from the last layer of the model forward to adjust the parameters of each layer. Alternatively, depending on the needs, network dropout can be used to keep the network parameters of some layers unchanged; no restrictions are placed on this approach.
[0121] The second step is to reselect sample images from the above sample image set, determine the adjusted initial image conversion model as the initial image conversion model, and continue to perform the above training steps.
[0122] Optionally, the aforementioned implementing entity may also perform the following steps:
[0123] The first step, in response to the determination that the second discrimination result does not meet the preset conditions, is to adjust the relevant parameters in the initial image conversion model to obtain the adjusted initial image conversion model. Methods such as backpropagation and stochastic gradient descent can be used to propagate the error value from the last layer of the model forward to adjust the parameters of each layer. Alternatively, depending on the needs, network dropout can be used to keep the network parameters of some layers unchanged; no restrictions are placed on this approach.
[0124] The second step is to reselect sample images from the above sample image set, determine the adjusted initial image conversion model as the initial image conversion model, and continue to perform the above training steps.
[0125] Optionally, the aforementioned implementing entity may also perform the following steps:
[0126] The first step, in response to the determination that the total cyclic loss value is greater than or equal to the target value, is to adjust the relevant parameters in the initial image conversion model to obtain the adjusted initial image conversion model. Methods such as backpropagation and stochastic gradient descent can be used to propagate the error value from the last layer of the model forward to adjust the parameters of each layer. Alternatively, depending on the needs, network dropout can be used to keep the network parameters of some layers unchanged; there are no restrictions on this approach.
[0127] The second step is to reselect sample images from the above sample image set, determine the adjusted initial image conversion model as the initial image conversion model, and continue to perform the above training steps.
[0128] from Figure 4 It can be seen from this that, with Figure 3 Compared to the description of some corresponding embodiments, Figure 4 The flowchart 400 of the image conversion model training method in some corresponding embodiments further highlights the specific steps of the image conversion model training described above. Thus, the schemes described in these embodiments utilize cyclic adversarial loss functions, cyclic consistent loss functions, and cyclic positional loss functions to train the initial image conversion model, thereby enhancing the accuracy of the trained image conversion model in converting images.
[0129] Further reference Figure 5 The following diagram illustrates some embodiments of an image conversion method according to the present disclosure. The image conversion method includes the following steps:
[0130] Step 501: Obtain the initial image.
[0131] In some embodiments, the entity executing the image conversion method (e.g. Figure 2 The electronic device 201 shown can acquire the initial image from the terminal device via a wired or wireless connection.
[0132] As an example, the initial image mentioned above could be an image of a cat or a dog.
[0133] Step 502: Input the initial image into the pre-trained image conversion model to obtain the converted image.
[0134] In some embodiments, the execution entity may input the initial image into a pre-trained image conversion model to obtain a converted image. The pre-trained image conversion model may be generated using the image conversion model training method of some embodiments of this disclosure.
[0135] from Figure 5 As can be seen, the image conversion method of some embodiments of this disclosure can convert the initial image to obtain an accurate converted image.
[0136] Further reference Figure 6 As an implementation of the methods shown in the above figures, this disclosure provides some embodiments of an image conversion model training device, which are similar to... Figure 3 Corresponding to the image conversion model training method embodiments shown, the image conversion model training device can be specifically applied to various electronic devices.
[0137] like Figure 6 As shown, an image conversion model training device 600 in some embodiments includes: an acquisition unit 601 and a training unit 602. The acquisition unit 601 is configured to acquire a sample image set and an initial image conversion model, wherein the initial image conversion model includes a first initial image conversion model and a second initial image conversion model. The first initial image conversion model includes a first image generation model and a first image discrimination model, and the second initial image conversion model includes a second image generation model and a second image discrimination model. The training unit 603 is configured to train the initial image conversion model based on the sample image set and at least one preset loss function to obtain a trained image conversion model, wherein the at least one preset loss function includes at least one of the following: a cyclic adversarial loss function, a cyclic consistent loss function, and a cyclic position loss function.
[0138] Optionally, the training unit 602 is further configured to: select sample images from the sample image set and perform the following training steps on the initial image conversion model: input the sample images into a first image generation model to obtain first feature information, wherein the first feature information includes a first feature image; input the first feature image into a first image discrimination model to obtain a first discrimination result; in response to determining that the first discrimination result meets a preset condition, input the first feature image into a second image conversion model to obtain second feature information, wherein the second feature information includes a second feature image; input the second feature image into a second image discrimination model to obtain a second discrimination result; in response to determining that the second discrimination result meets a preset condition, determine a total cyclic loss value based on at least one preset loss function; in response to determining that the total cyclic loss value is less than a target value, determine the initial image conversion model as an image conversion model.
[0139] Optionally, the image conversion model training device further includes: a first adjustment unit configured to: adjust relevant parameters in the initial image conversion model in response to determining that the first discrimination result does not meet the preset conditions, to obtain an adjusted initial image conversion model; and a first determination unit configured to reselect sample images from the sample image set, determine the adjusted initial image conversion model as the initial image conversion model, and continue to execute the training steps.
[0140] Optionally, the image conversion model training device further includes: a second adjustment unit configured to: adjust the relevant parameters in the initial image conversion model in response to determining that the second discrimination result does not meet the preset conditions, to obtain an adjusted initial image conversion model; and a second determination unit configured to reselect sample images from the sample image set, determine the adjusted initial image conversion model as the initial image conversion model, and continue to execute the training steps.
[0141] Optionally, the image conversion model training device further includes: a third adjustment unit configured to: adjust relevant parameters in the initial image conversion model in response to determining that the total cyclic loss value is greater than or equal to the target value, to obtain an adjusted initial image conversion model; and a third determination unit configured to reselect sample images from the sample image set, determine the adjusted initial image conversion model as the initial image conversion model, and continue to execute the training steps.
[0142] Optionally, the first feature information further includes a first block vector sequence, and the second feature information further includes a second block vector sequence; and the training unit 602 is further configured to: determine a cyclic adversarial loss value based on the cyclic adversarial loss function and the first feature information; determine a cyclic consistency loss value based on the cyclic consistency loss function, the first feature image, and the second feature image; determine a cyclic position loss value based on the cyclic position loss function, the first block vector sequence, and the second block vector sequence; and perform a weighted summation of the first cyclic adversarial loss value, the cyclic consistency loss value, and the cyclic position loss value to obtain the total cyclic loss value.
[0143] Optionally, the training unit 602 is further configured to perform the following steps for each first block vector in the first block vector sequence: determining the first block vector as the target block vector; determining the second block vector in the second block vector sequence corresponding to the target block vector as the positive sample block vector; determining the second block vector sequence after removing the positive sample block vector as the negative sample block vector sequence; and determining the cyclic position loss value based on the target block vector, the positive sample block vector and the negative sample block vector sequence and the cyclic position loss function.
[0144] It is understandable that the units described in the image conversion model training device 600 are related to the reference... Figure 3 The steps in the described image conversion model training method correspond to each other. Therefore, the operations, features, and beneficial effects described above for the image conversion model training method also apply to the image conversion model training device 600 and the units contained therein, and will not be repeated here.
[0145] Further reference Figure 7 As an implementation of the methods shown in the above figures, this disclosure provides some embodiments of an image conversion apparatus, which are similar to... Figure 5 Corresponding to the method embodiments shown, this image conversion device can be specifically applied to various electronic devices.
[0146] like Figure 7 As shown, an image conversion apparatus 700 in some embodiments includes an acquisition unit 701 and an input unit 702. The acquisition unit 701 is configured to acquire an initial image; the input unit 702 is configured to input the initial image into a pre-trained image conversion model to obtain a converted image, wherein the image conversion model is generated by a method as described in any implementation of the first aspect.
[0147] It is understandable that the units described in the image conversion device 700 are related to the reference. Figure 5 The steps in the described image conversion method correspond to each other. Therefore, the operations, features, and beneficial effects described above for the image conversion method also apply to the image conversion apparatus 700 and the units contained therein, and will not be repeated here.
[0148] The following is for reference. Figure 8 This document illustrates a schematic diagram of an electronic device 800 suitable for implementing some embodiments of the present disclosure. The electronic devices in some embodiments of the present disclosure may include, but are not limited to, mobile terminals such as mobile phones, laptops, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and fixed terminals such as digital TVs and desktop computers. Figure 8 The terminal device shown is merely an example and should not be construed as limiting the functionality and scope of the embodiments of this disclosure.
[0149] like Figure 8 As shown, the electronic device 800 may include a processing device (e.g., a central processing unit, a graphics processor, etc.) 801, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 802 or a program loaded from a storage device 808 into a random access memory (RAM) 803. The RAM 803 also stores various programs and data required for the operation of the electronic device 800. The processing device 801, ROM 802, and RAM 803 are interconnected via a bus 804. An input / output (I / O) interface 805 is also connected to the bus 804.
[0150] Typically, the following devices can be connected to I / O interface 805: input devices 806 including, for example, touchscreens, touchpads, keyboards, mice, cameras, microphones, accelerometers, gyroscopes, etc.; output devices 807 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; storage devices 808 including, for example, magnetic tapes, hard disks, etc.; and communication devices 809. Communication device 809 allows electronic device 800 to communicate wirelessly or wiredly with other devices to exchange data. Although Figure 8 An electronic device 800 with various devices is shown; however, it should be understood that it is not required to implement or possess all of the devices shown. More or fewer devices may be implemented or possessed alternatively. Figure 7 Each box shown can represent a device or multiple devices as needed.
[0151] In particular, according to some embodiments of this disclosure, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, some embodiments of this disclosure include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device 809, or installed from a storage device 808, or installed from a ROM 802. When the computer program is executed by the processing device 801, it performs the functions defined in the methods of some embodiments of this disclosure.
[0152] It should be noted that, in some embodiments of this disclosure, the computer-readable medium may be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable storage medium may be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In some embodiments of this disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In some embodiments of this disclosure, a computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium can be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wires, optical fibers, RF (radio frequency), etc., or any suitable combination thereof.
[0153] In some implementations, clients and servers can communicate using any currently known or future-developed network protocol such as HTTP (Hypertext Transfer Protocol) and can interconnect with digital data communication (e.g., communication networks) of any form or medium. Examples of communication networks include local area networks (“LANs”), wide area networks (“WANs”), the Internet (e.g., the Internet of Things), and end-to-end networks (e.g., ad hoc end-to-end networks), as well as any currently known or future-developed networks.
[0154] The aforementioned computer-readable medium may be included in the aforementioned electronic device; or it may exist independently and not assembled into the electronic device. The aforementioned computer-readable medium carries one or more programs, which, when executed by the electronic device, cause the electronic device to: acquire a sample image set and an initial image conversion model, wherein the initial image conversion model includes a first initial image conversion model and a second initial image conversion model, the first initial image conversion model includes a first image generation model and a first image discrimination model, and the second initial image conversion model includes a second image generation model and a second image discrimination model; and train the initial image conversion model based on the aforementioned sample image set and at least one preset loss function to obtain a trained image conversion model, wherein the at least one preset loss function includes at least one of the following: a cyclic adversarial loss function, a cyclic consistent loss function, and a cyclic position loss function.
[0155] Computer program code for performing operations of some embodiments of this disclosure can be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, and C++, and conventional procedural programming languages such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone 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 remote computers, the remote computer can be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0156] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0157] The units described in some embodiments of this disclosure can be implemented in software or hardware. The described units can also be housed in a processor; for example, a processor may be described as including an acquisition unit and a training unit. The names of these units do not necessarily limit the unit itself; for example, an acquisition unit may also be described as "a unit for acquiring a set of sample images and an initial image transformation model."
[0158] The functions described above in this document can be performed, at least in part, by one or more hardware logic components. For example, exemplary types of hardware logic components that can be used, without limitation, include: Field Programmable Gate Arrays (FPGAs), Application-Specific Integrated Circuits (ASICs), Application Standard Products (ASSPs), System-on-Chip (SoCs), Complex Programmable Logic Devices (CPLDs), and so on.
[0159] The above description is merely a selection of preferred embodiments of this disclosure and an explanation of the technical principles employed. Those skilled in the art should understand that the scope of the invention involved in the embodiments of this disclosure is not limited to technical solutions formed by specific combinations of the above-described technical features, but should also cover other technical solutions formed by arbitrary combinations of the above-described technical features or their equivalents without departing from the above-described inventive concept. For example, technical solutions formed by substituting the above-described features with (but not limited to) technical features with similar functions disclosed in the embodiments of this disclosure.
Claims
1. A method for training an image conversion model, comprising: A sample image set and an initial image conversion model are obtained. The initial image conversion model includes a first initial image conversion model and a second initial image conversion model. The first initial image conversion model includes a first image generation model and a first image discrimination model. The second initial image conversion model includes a second image generation model and a second image discrimination model. The first feature information is obtained by inputting the sample images included in the sample image set into the first image generation model. The first feature information includes a first feature image and a first block vector sequence. The second feature information is obtained by inputting the first feature image into the second image generation model. The second feature information includes a second feature image and a second block vector sequence. Based on the sample image set and at least one preset loss function, the initial image conversion model is trained to obtain a trained image conversion model. The at least one preset loss function includes: a cyclic adversarial loss function, a cyclic consistent loss function, and a cyclic position loss function. Based on the cyclic position loss function, the first block vector sequence, and the second block vector sequence, the cyclic position loss value corresponding to the cyclic position loss function is determined, including: For each first block vector in the first block vector sequence, perform the following steps: The first block vector is determined as the target block vector; The second block vector in the second block vector sequence that corresponds to the target block vector is determined as the positive sample block vector; The second block vector sequence, from which the positive sample block vectors have been removed, is determined as the negative sample block vector sequence; Based on the target block vector, the sequence of positive sample block vectors and negative sample block vectors, and the cyclic position loss function, the cyclic position loss value is determined, wherein the cyclic position loss function is: in, This represents the loss value at the cyclic position. This represents the target block vector. This represents the positive sample block vector. This represents the negative sample block vector. This indicates the index of the negative sample block vector in the negative sample block vector sequence. This represents the number of negative sample block vectors in the negative sample block vector sequence. This represents the loss coefficient.
2. The method according to claim 1, wherein, The step of training the initial image conversion model based on the sample image set and at least one preset loss function to obtain the trained image conversion model includes: Select sample images from the sample image set and perform the following training steps on the initial image transformation model: The sample image is input into the first image generation model to obtain the first feature information, wherein the first feature information includes the first feature image; The first feature image is input into the first image discrimination model to obtain the first discrimination result; In response to determining that the first discrimination result satisfies the first preset condition, the first feature image is input into the second image conversion model to obtain the second feature information, wherein the second feature information includes the second feature image; The second feature image is input into the second image discrimination model to obtain the second discrimination result; In response to determining that the second discrimination result satisfies the second preset condition, the total cyclic loss value is determined based on at least one preset loss function; In response to the determination that the total cyclic loss is less than the target value, the initial image conversion model is determined as the image conversion model.
3. The method according to claim 2, wherein, The method further includes: In response to determining that the first discrimination result does not meet the preset condition, the relevant parameters in the initial image conversion model are adjusted to obtain the adjusted initial image conversion model; Select new sample images from the sample image set, determine the adjusted initial image conversion model as the initial image conversion model, and continue to execute the training steps.
4. The method according to claim 2, wherein, The method further includes: In response to determining that the second discrimination result does not meet the preset condition, the relevant parameters in the initial image conversion model are adjusted to obtain the adjusted initial image conversion model; Select new sample images from the sample image set, determine the adjusted initial image conversion model as the initial image conversion model, and continue to execute the training steps.
5. The method according to claim 2, wherein, The method further includes: In response to determining that the total cyclic loss value is greater than or equal to the target value, the relevant parameters in the initial image conversion model are adjusted to obtain the adjusted initial image conversion model; Select new sample images from the sample image set, determine the adjusted initial image conversion model as the initial image conversion model, and continue to execute the training steps.
6. The method according to claim 2, wherein, The first feature information further includes: a first block vector sequence; the second feature information further includes: a second block vector sequence; and Determining the total cyclic loss value based on the at least one preset loss function includes: Based on the recurrent adversarial loss function and the first feature information, the first recurrent adversarial loss value is determined; The cycle-consistent loss value is determined based on the cycle-consistent loss function, the first feature information, and the second feature information; Based on the cyclic position loss function, the first block vector sequence, and the second block vector sequence, the cyclic position loss value is determined; The first cyclic adversarial loss value, the cyclic consistency loss value, and the cyclic position loss value are weighted and summed to obtain the total cyclic loss value.
7. An image conversion method, comprising: Get the initial image; The initial image is input into a pre-trained image conversion model to obtain a converted image, wherein the image conversion model is generated by the method described in any one of claims 1-6.
8. An image conversion model training device, comprising: The acquisition unit is configured to acquire a sample image set and an initial image conversion model, wherein the initial image conversion model includes a first initial image conversion model and a second initial image conversion model. The first initial image conversion model includes a first image generation model and a first image discrimination model. The second initial image conversion model includes a second image generation model and a second image discrimination model. The first feature information is obtained by inputting the sample images included in the sample image set into the first image generation model. The first feature information includes a first feature image and a first block vector sequence. The second feature information is obtained by inputting the first feature image into the second image generation model. The second feature information includes a second feature image and a second block vector sequence. A training unit is configured to train the initial image conversion model based on the sample image set and at least one preset loss function to obtain a trained image conversion model. The at least one preset loss function includes: a cyclic adversarial loss function, a cyclic consistent loss function, and a cyclic position loss function. Based on the cyclic position loss function, the first block vector sequence, and the second block vector sequence, the cyclic position loss value corresponding to the cyclic position loss function is determined, including: for each first block vector in the first block vector sequence, performing the following steps: determining the first block vector as the target block vector; determining the second block vector in the second block vector sequence corresponding to the target block vector as a positive sample block vector; determining the second block vector sequence after removing the positive sample block vectors as a negative sample block vector sequence; and determining the cyclic position loss value based on the target block vector, the positive sample vector and negative sample vector sequences, and the cyclic position loss function, wherein the cyclic position loss function is: in, This represents the loss value at the cyclic position. This represents the target block vector. This represents the positive sample block vector. This represents the negative sample block vector. This indicates the index of the negative sample block vector in the negative sample block vector sequence. This represents the number of negative sample block vectors in the negative sample block vector sequence. This represents the loss coefficient.
9. An image conversion apparatus, comprising: The acquisition unit is configured to acquire the initial image; An input unit is configured to input the initial image into a pre-trained image conversion model to obtain a converted image, wherein the image conversion model is generated by the method described in any one of claims 1-6.
10. An electronic device, comprising: One or more processors; A storage device on which one or more programs are stored; When the one or more programs are executed by the one or more processors, the one or more processors implement the method as described in any one of claims 1-7.
11. A computer-readable medium having a computer program stored thereon, wherein, When the computer program is executed by a processor, it implements the method as described in any one of claims 1-7.
12. A computer program product comprising a computer program that, when executed by a processor, implements the method according to any one of claims 1-7.
Citation Information
Patent Citations
Image processing method and device and image processing system
CN111145097A