WO2022252883A1 - Training method for image inpainting model and image inpainting method, apparatus, and device - Google Patents

Training method for image inpainting model and image inpainting method, apparatus, and device Download PDF

Info

Publication number
WO2022252883A1
WO2022252883A1 PCT/CN2022/089428 CN2022089428W WO2022252883A1 WO 2022252883 A1 WO2022252883 A1 WO 2022252883A1 CN 2022089428 W CN2022089428 W CN 2022089428W WO 2022252883 A1 WO2022252883 A1 WO 2022252883A1
Authority
WO
WIPO (PCT)
Prior art keywords
image
pixel quality
real
quality image
pixel
Prior art date
Application number
PCT/CN2022/089428
Other languages
French (fr)
Chinese (zh)
Inventor
王伟
袁泽寰
王长虎
Original Assignee
北京有竹居网络技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 北京有竹居网络技术有限公司 filed Critical 北京有竹居网络技术有限公司
Publication of WO2022252883A1 publication Critical patent/WO2022252883A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • G06N3/045Combinations of networks
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • G06N3/047Probabilistic or stochastic networks
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T5/00Image enhancement or restoration

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Artificial Intelligence (AREA)
  • General Health & Medical Sciences (AREA)
  • Biomedical Technology (AREA)
  • Biophysics (AREA)
  • Computational Linguistics (AREA)
  • Data Mining & Analysis (AREA)
  • Evolutionary Computation (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Molecular Biology (AREA)
  • Computing Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Health & Medical Sciences (AREA)
  • Mathematical Physics (AREA)
  • Software Systems (AREA)
  • Probability & Statistics with Applications (AREA)
  • Image Processing (AREA)

Abstract

The present application discloses a training method for an image inpainting model, and an image inpainting method, apparatus, and device. By means of extracting image features from a real first pixel quality image and an artificially synthesized first pixel quality image, and by means of a real first pixel quality image generator and a real second pixel quality image generator, a regenerated real first pixel quality image, a pseudo-real first pixel quality image, and a reconstructed second pixel quality image are obtained. Domain alignment loss, image generation loss and image reconstruction loss are calculated respectively, and training is executed by using the obtained losses. An image inpainting model obtained after training has better generalization capabilities, has relatively accurate image inpainting, and exhibits relatively good model performance. An image feature encoder and the real second pixel quality image generator obtained by training are used to inpaint a first pixel quality image to be inpainted, so that a second pixel quality image having a relatively good inpainting effect can be obtained, and requirements for image use are met.

Description

图像修复模型的训练方法及图像修复方法、装置及设备Image restoration model training method, image restoration method, device and equipment
本申请要求于2021年5月31日提交中国国家知识产权局、申请号为202110604235.1、发明名称为“图像修复模型的训练方法及图像修复方法、装置及设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims the priority of the Chinese patent application submitted to the State Intellectual Property Office of China on May 31, 2021, with the application number 202110604235.1, and the title of the invention is "the training method of the image restoration model and the image restoration method, device and equipment". The entire contents are incorporated by reference in this application.
技术领域technical field
本发明属于移动通信技术领域,具体涉及一种图像修复模型的训练方法、装置及设备,和一种图像修复方法、装置及设备。The invention belongs to the technical field of mobile communication, and in particular relates to a training method, device and equipment for an image restoration model, and an image restoration method, device and equipment.
背景技术Background technique
在图像的生成以及处理的过程中,可能会受到设备的影响,导致图像的像素质量较低,不能满足图像使用的需要。为了提高较低像素质量图像的像素质量,可以采用图像超分辨率重建技术对较低像素质量的图像进行处理,提高较低像素质量图像的像素质量,得到具有较高像素质量的图像。In the process of image generation and processing, it may be affected by the equipment, resulting in low pixel quality of the image, which cannot meet the needs of image use. In order to improve the pixel quality of an image with lower pixel quality, image super-resolution reconstruction technology can be used to process the image with lower pixel quality, improve the pixel quality of the image with lower pixel quality, and obtain an image with higher pixel quality.
目前,图像超分辨率重建技术具体可以通过由卷积神经网络构建的图像修复模型实现。图像修复模型需要通过训练图像训练生成。用于训练图像修复模型的训练图像对生成的图像修复模型的性能会产生较大的影响。训练图像一般使用人工构造的较低像素质量图像和较高像素质量图像。而人工构造的较低像素质量图像的质量较低,导致训练得到的图像修复模型的性能较差,不能满足图像像素质量修复的需要。因此,如何训练生成性能较好的图像修复模型,生成质量较高的修复图像是亟待解决的问题。At present, the image super-resolution reconstruction technology can be realized through the image restoration model constructed by the convolutional neural network. The image inpainting model needs to be generated through training image training. The training images used to train the image inpainting model will have a large impact on the performance of the resulting image inpainting model. The training images generally use artificially constructed lower pixel quality images and higher pixel quality images. However, the artificially constructed lower pixel quality images have lower quality, resulting in poor performance of the trained image restoration model, which cannot meet the needs of image pixel quality restoration. Therefore, how to train and generate image inpainting models with better performance and generate inpainted images with higher quality is an urgent problem to be solved.
发明内容Contents of the invention
有鉴于此,本申请实施例提供一种图像修复模型的训练方法、装置及设备,和一种图像修复方法、装置及设备,能够训练得到性能较好的图像修复模型,并基于图像修复模型实现对较低像素质量图像进行修复,得到较为准确的较高像素质量图像。In view of this, the embodiment of the present application provides an image restoration model training method, device and equipment, and an image restoration method, device and equipment, which can train an image restoration model with better performance, and realize The lower pixel quality image is repaired to obtain a more accurate higher pixel quality image.
为解决上述问题,本申请实施例提供的技术方案如下:In order to solve the above problems, the technical solutions provided by the embodiments of the present application are as follows:
第一方面,本申请实施例提供一种图像修复模型的训练方法,所述方法包括:In the first aspect, the embodiment of the present application provides a method for training an image restoration model, the method comprising:
将真实第一像素质量图像输入图像特征编码器,得到第一图像特征;Inputting the real first pixel quality image into the image feature encoder to obtain the first image feature;
将人工合成第一像素质量图像输入所述图像特征编码器,得到第二图像特征;所述人工合成第一像素质量图像是由真实第二像素质量图像进行模糊处理得到的;Inputting the artificially synthesized first pixel quality image into the image feature encoder to obtain the second image feature; the artificially synthesized first pixel quality image is obtained by blurring the real second pixel quality image;
将所述第一图像特征输入真实第一像素质量图像生成器,得到重新生成的真实第一像素质量图像;Inputting the first image feature into a real first pixel quality image generator to obtain a regenerated real first pixel quality image;
将所述第二图像特征输入所述真实第一像素质量图像生成器,得到伪真实第一像素质量图像;Inputting the second image feature into the real first pixel quality image generator to obtain a pseudo-true first pixel quality image;
将所述第二图像特征输入真实第二像素质量图像生成器,得到重建第二像素质量图像;Inputting the second image feature into a real second pixel quality image generator to obtain a reconstructed second pixel quality image;
根据所述第一图像特征以及所述第二图像特征计算域对齐损失;calculating a domain alignment loss based on the first image feature and the second image feature;
根据所述重新生成的真实第一像素质量图像、所述伪真实第一像素质量图像以及所述真实第一像素质量图像计算图像生成损失;calculating an image generation loss based on the regenerated true first pixel quality image, the pseudo true first pixel quality image, and the true first pixel quality image;
根据所述重建第二像素质量图像以及所述真实第二像素质量图像计算图像重建损失;calculating an image reconstruction loss based on the reconstructed second pixel quality image and the true second pixel quality image;
根据所述域对齐损失、所述图像生成损失以及所述图像重建损失,训练所述图像特征编码器、所述真实第一像素质量图像生成器以及所述真实第二像素质量图像生成器,重复执行所述将真实第一像素质量图像输入图像特征编码器,得到第一图像特征以及后续步骤,直到达到预设条件;Train the image feature encoder, the true first pixel quality image generator, and the true second pixel quality image generator based on the domain alignment loss, the image generation loss, and the image reconstruction loss, repeating Execute said inputting the real first pixel quality image into the image feature encoder to obtain the first image feature and subsequent steps until reaching the preset condition;
其中,第一像素质量的图像清晰度低于第二像素质量的图像清晰度。Wherein, the image definition of the first pixel quality is lower than the image definition of the second pixel quality.
第二方面,本申请实施例提供一种图像修复方法,所述方法包括:In a second aspect, an embodiment of the present application provides an image restoration method, the method comprising:
将待修复第一像素质量图像输入图像特征编码器,得到目标图像特征;Input the first pixel quality image to be repaired into the image feature encoder to obtain the target image feature;
将所述目标图像特征输入真实第二像素质量图像生成器,得到修复后的第二像素质量图像;The target image feature is input into a real second pixel quality image generator to obtain a repaired second pixel quality image;
所述图像特征编码器以及所述真实第二像素质量图像生成器是根据上述任一项实施例所述的图像修复模型的训练方法训练得到的。The image feature encoder and the real second pixel quality image generator are obtained through training according to the training method of the image inpainting model described in any one of the above embodiments.
第三方面,本申请实施例提供一种图像修复模型的训练装置,所述装置包括:In a third aspect, the embodiment of the present application provides a training device for an image restoration model, the device comprising:
第一执行单元,用于将真实第一像素质量图像输入图像特征编码器,得到第一图像特征;The first execution unit is used to input the real first pixel quality image into the image feature encoder to obtain the first image feature;
第二执行单元,用于将人工合成第一像素质量图像输入所述图像特征编码器,得到第二图像特征;所述人工合成第一像素质量图像是由真实第二像素质量图像进行模糊处理得到的;The second execution unit is configured to input the artificially synthesized first pixel quality image into the image feature encoder to obtain the second image feature; the artificially synthesized first pixel quality image is obtained by blurring the real second pixel quality image of;
第三执行单元,用于将所述第一图像特征输入真实第一像素质量图像生成器,得到重新生成的真实第一像素质量图像;A third execution unit, configured to input the first image feature into a real first pixel quality image generator to obtain a regenerated real first pixel quality image;
第四执行单元,用于将所述第二图像特征输入所述真实第一像素质量图像生成器,得到伪真实第一像素质量图像;A fourth execution unit, configured to input the second image feature into the real first pixel quality image generator to obtain a pseudo-real first pixel quality image;
第五执行单元,用于将所述第二图像特征输入真实第二像素质量图像生成器,得到重建第二像素质量图像;The fifth execution unit is configured to input the second image feature into the real second pixel quality image generator to obtain a reconstructed second pixel quality image;
第一计算单元,用于根据所述第一图像特征以及所述第二图像特征计算域对齐损失;A first calculation unit, configured to calculate a domain alignment loss according to the first image feature and the second image feature;
第二计算单元,用于根据所述重新生成的真实第一像素质量图像、所述伪真实第一像素质量图像以及所述真实第一像素质量图像计算图像生成损失;A second calculation unit, configured to calculate an image generation loss based on the regenerated real first pixel quality image, the pseudo real first pixel quality image, and the real first pixel quality image;
第三计算单元,用于根据所述重建第二像素质量图像以及所述真实第二像素质量图像计算图像重建损失;A third calculation unit, configured to calculate an image reconstruction loss according to the reconstructed second pixel quality image and the real second pixel quality image;
训练单元,用于根据所述域对齐损失、所述图像生成损失以及所述图像重建损失,训练所述图像特征编码器、所述真实第一像素质量图像生成器以及所述真实第二像素质量图像生成器,重复执行所述将真实第一像素质量图像输入图像特征编码器,得到第一图像特征以及后续步骤,直到达到预设条件;a training unit for training the image feature encoder, the true first pixel quality image generator, and the true second pixel quality based on the domain alignment loss, the image generation loss, and the image reconstruction loss The image generator repeatedly executes the steps of inputting the real first pixel quality image into the image feature encoder to obtain the first image feature and subsequent steps until the preset condition is reached;
其中,第一像素质量的图像清晰度低于第二像素质量的图像清晰度。Wherein, the image definition of the first pixel quality is lower than the image definition of the second pixel quality.
第四方面,本申请实施例提供一种图像修复装置,所述装置包括:In a fourth aspect, an embodiment of the present application provides an image restoration device, the device comprising:
第八执行单元,用于将待修复第一像素质量图像输入图像特征编码器,得到目标图像特征;The eighth execution unit is used to input the first pixel quality image to be repaired into the image feature encoder to obtain the target image feature;
第九执行单元,用于将所述目标图像特征输入真实第二像素质量图像生成器,得到修复后的第二像素质量图像;A ninth execution unit, configured to input the features of the target image into a real second pixel quality image generator to obtain a repaired second pixel quality image;
所述图像特征编码器以及所述真实第二像素质量图像生成器是根据上述任一项实施例所述的图像修复模型的训练方法训练得到的。The image feature encoder and the real second pixel quality image generator are obtained through training according to the training method of the image inpainting model described in any one of the above embodiments.
第五方面,本申请实施例提供一种电子设备,包括:In a fifth aspect, the embodiment of the present application provides an electronic device, including:
一个或多个处理器;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 image repair model training method as described in any of the above embodiments, or any of the above implementations The image restoration method described in the example.
第六方面,本申请实施例提供一种计算机可读介质,其上存储有计算机程序,其中,所述程序被处理器执行时实现如上述任一实施例所述的图像修复模型的训练方法,或者上述任一实施例所述的图像修复方法。In a sixth aspect, an embodiment of the present application provides a computer-readable medium on which a computer program is stored, wherein, when the program is executed by a processor, the method for training an image restoration model as described in any of the above-mentioned embodiments is implemented, Or the image restoration method described in any of the above-mentioned embodiments.
由此可见,本申请实施例具有如下有益效果:It can be seen that the embodiment of the present application has the following beneficial effects:
本申请实施例提供一种图像修复模型的训练方法、装置及设备,通过将真实第一像素质量图像和人工合成第一像素质量图像分别输入图像特征编码器,得到对应的第一图像特征和第二图像特征。再将第一图像特征和第二图像特征分别输入真实第一像素质量图像生成器中,对应的得到重新生成的真实第一像素质量图像和伪真实第一像素质量图像。再将第二图像特征输入至真实第二像素质量图像生成器中,得到重建第二像素质量图像。基于得到的图像特征和像素质量图像,分别计算域对齐损失、图像生成损失以及图像重建损失,并基于计算得到的损失训练图像特征编码器、真实第一像素质量图像生成器以及真实第二像素质量图像生成器。重复执行上述训练过程,直到达到预设条件。基于域对齐损失、图像生成损失和图像重建损失,可以更好地减小真实较低像素质量图像与人工合成的较低像素质量图像之间的差距,减小生成的模拟真实场景下较低像素质量图像和实际真实场景下较低像素质量图像之间的差距,减小生成的模拟真实场景下较高像素质量图像与实际真实场景下较高像素质量图像之间的差距,使得基于计算的损失训练得到的图像修复模型具有较好的泛化能力和修复能力, 具有较好的模型性能。本申请实施例提供的图像修复方法、装置及设备,通过利用上述图像修复模型生成的图像特征编码器和第二像素质量图像生成器对待修复第一像素质量图像进行修复,可以得到修复效果较好的第二像素质量图像,符合图像使用需要。The embodiment of the present application provides a training method, device and equipment for an image inpainting model. By inputting the real first pixel quality image and the synthetic first pixel quality image into the image feature encoder respectively, the corresponding first image feature and the first pixel quality image are obtained. Two image features. Then input the first image feature and the second image feature into the real first pixel quality image generator respectively, and correspondingly obtain the regenerated real first pixel quality image and pseudo real first pixel quality image. Then, the second image feature is input into the real second pixel quality image generator to obtain the reconstructed second pixel quality image. Based on the obtained image features and pixel quality images, the domain alignment loss, image generation loss and image reconstruction loss are respectively calculated, and the image feature encoder, true first pixel quality image generator and true second pixel quality are trained based on the calculated losses image generator. Repeat the above training process until the preset condition is reached. Based on domain alignment loss, image generation loss and image reconstruction loss, it can better reduce the gap between real lower pixel quality images and artificially synthesized lower pixel quality images, and reduce the lower pixels in the generated simulated real scene The gap between the quality image and the lower pixel quality image in the actual real scene reduces the gap between the generated higher pixel quality image in the simulated real scene and the higher pixel quality image in the actual real scene, so that the calculation-based loss The trained image repair model has better generalization ability and repair ability, and has better model performance. The image restoration method, device, and equipment provided in the embodiments of the present application can obtain a good repair effect by using the image feature encoder generated by the above-mentioned image restoration model and the second pixel quality image generator to repair the first pixel quality image to be repaired. The second pixel quality image, which meets the needs of image usage.
附图说明Description of drawings
附图用来提供对本发明的进一步理解,并且构成说明书的一部分,与本发明实施例一起用于解释本发明,并不构成对本发明的限制。在附图中:The accompanying drawings are used to provide a further understanding of the present invention, and constitute a part of the description, and are used together with the embodiments of the present invention to explain the present invention, and do not constitute a limitation to the present invention. In the attached picture:
图1为本申请实施例提供的示例性应用场景的框架示意图;FIG. 1 is a schematic framework diagram of an exemplary application scenario provided by an embodiment of the present application;
图2为本申请实施例提供的一种图像修复模型的训练方法的流程图;FIG. 2 is a flow chart of a training method for an image restoration model provided in an embodiment of the present application;
图3为本申请实施例提供的一种图像修复模型的结构示意图;FIG. 3 is a schematic structural diagram of an image restoration model provided by an embodiment of the present application;
图4为本申请实施例提供的另一种图像修复模型的结构示意图;FIG. 4 is a schematic structural diagram of another image restoration model provided by the embodiment of the present application;
图5为本申请实施例提供的另一种图像修复模型的结构示意图;FIG. 5 is a schematic structural diagram of another image restoration model provided by the embodiment of the present application;
图6为本申请实施例提供的一种特征判别器的结构示意图;FIG. 6 is a schematic structural diagram of a feature discriminator provided in an embodiment of the present application;
图7为本申请实施例提供的一种图像特征编码器的结构示意图;FIG. 7 is a schematic structural diagram of an image feature encoder provided in an embodiment of the present application;
图8为本申请实施例提供的一种真实第二像素质量图像生成器的结构示意图;FIG. 8 is a schematic structural diagram of a real second pixel quality image generator provided by an embodiment of the present application;
图9为本申请实施例提供的一种RRDB单元的结构示意图;FIG. 9 is a schematic structural diagram of an RRDB unit provided in an embodiment of the present application;
图10为本申请实施例提供的一种图像修复方法的流程图;FIG. 10 is a flow chart of an image restoration method provided by an embodiment of the present application;
图11为本申请实施例提供的一种图像修复模型的训练装置的结构示意图;FIG. 11 is a schematic structural diagram of a training device for an image restoration model provided by an embodiment of the present application;
图12为本申请实施例提供的一种图像修复装置的结构示意图;Fig. 12 is a schematic structural diagram of an image restoration device provided by an embodiment of the present application;
图13为本申请实施例提供的电子设备的结构示意图。FIG. 13 is a schematic structural diagram of an electronic device provided by an embodiment of the present application.
具体实施方式Detailed ways
为使本申请的上述目的、特征和优点能够更加明显易懂,下面结合附图和具体实施方式对本申请实施例作进一步详细的说明。In order to make the above objects, features and advantages of the present application more obvious and understandable, the embodiments of the present application will be further described in detail below in conjunction with the accompanying drawings and specific implementation methods.
为了便于理解和解释本申请实施例提供的技术方案,下面将先对本申请的背景技术进行说明。In order to facilitate understanding and explanation of the technical solutions provided by the embodiments of the present application, the background technology of the present application will first be described below.
发明人在对传统的图像修复方法进行研究后发现,目前所使用的用于训练图像修复模型的训练图像中的较低像素质量的图像,是通过对较高像素质量的 图像进行图像质量退化得到的。通过人为模拟模糊和噪声,对较高像素质量图像进行处理后得到较低像素质量图像的过程,难以模拟真实较低像素质量图像产生的过程。导致人工合成的较低像素质量图像与真实的较低像素质量图像之间具有较大的分布差异。利用人工合成的较低像素质量图像作为训练数据训练生成的图像修复模型,具有较差的泛化能力,难以对待修复的较低像素质量图像进行较高质量的像素质量重建。After researching traditional image restoration methods, the inventor found that the images with lower pixel quality in the training images currently used to train the image restoration model are obtained by degrading the image quality of images with higher pixel quality of. By artificially simulating blur and noise, the process of obtaining a lower pixel quality image after processing a higher pixel quality image is difficult to simulate the process of producing a real lower pixel quality image. This results in a large distribution difference between the synthetic low-pixel-quality images and the real low-pixel-quality images. Using artificially synthesized images with lower pixel quality as training data to train the generated image inpainting model has poor generalization ability, and it is difficult to reconstruct higher-quality pixel quality images of lower pixel quality images to be repaired.
基于此,本申请实施例提供了一种图像修复模型的训练方法、装置及设备,通过将真实第一像素质量图像和人工合成第一像素质量图像分别输入图像特征编码器,得到对应的第一图像特征和第二图像特征。再将第一图像特征和第二图像特征分别输入真实第一像素质量图像生成器中,对应的得到重新生成的真实第一像素质量图像和伪真实第一像素质量图像。再将第二图像特征输入至真实第二像素质量图像生成器中,得到重建第二像素质量图像。基于得到的图像特征和生成的像素质量图像,分别计算域对齐损失、图像生成损失以及图像重建损失,并基于计算得到的损失图像特征编码器、真实第一像素质量图像生成器以及真实第二像素质量图像生成器。重复执行上述训练过程,直到达到预设条件。基于域对齐损失、图像生成损失和图像重建损失,可以更好地减小真实较低像素质量图像与人工合成的较低像素质量图像之间的差距,减小生成的模拟真实场景下较低像素质量图像和实际真实场景下较低像素质量图像之间的分布差距,减小生成的模拟真实场景下较高像素质量图像与实际真实场景下较高像素质量图像之间的差距,使得基于计算的损失训练得到的图像修复模型具有较好的泛化能力和修复能力,具有较好的模型性能。本申请实施例提供的图像修复方法、装置及设备,通过利用上述图像修复模型生成的图像特征编码器和第二像素质量图像生成器进行对待修复第一像素质量图像进行修复,可以得到修复效果较好的第二像素质量图像,符合图像使用的需要。Based on this, the embodiment of the present application provides a training method, device and equipment for an image inpainting model. By inputting the real first pixel quality image and the synthetic first pixel quality image into the image feature encoder respectively, the corresponding first pixel quality image is obtained. image features and second image features. Then input the first image feature and the second image feature into the real first pixel quality image generator respectively, and correspondingly obtain the regenerated real first pixel quality image and pseudo real first pixel quality image. Then, the second image feature is input into the real second pixel quality image generator to obtain the reconstructed second pixel quality image. Based on the obtained image features and generated pixel-quality images, domain alignment loss, image generation loss, and image reconstruction loss are computed respectively, and based on the computed losses image feature encoder, true first pixel quality image generator, and true second pixel Quality image generator. Repeat the above training process until the preset condition is reached. Based on domain alignment loss, image generation loss and image reconstruction loss, it can better reduce the gap between real lower pixel quality images and artificially synthesized lower pixel quality images, and reduce the lower pixels in the generated simulated real scene The distribution gap between the quality image and the lower pixel quality image in the actual real scene reduces the gap between the generated higher pixel quality image in the simulated real scene and the higher pixel quality image in the actual real scene, so that the calculation-based The image inpainting model obtained by loss training has better generalization ability and inpainting ability, and has better model performance. The image inpainting method, device and equipment provided in the embodiments of the present application, by using the image feature encoder generated by the above-mentioned image inpainting model and the second pixel quality image generator to inpaint the first pixel quality image to be inpainted, can obtain a better inpainting effect. Good second-pixel quality images, suitable for image usage.
为了便于理解本申请实施例提供的图像修复方法,下面结合图1所示的场景示例进行说明。参见图1所示,该图为本申请实施例提供的示例性应用场景的框架示意图。In order to facilitate understanding of the image restoration method provided by the embodiment of the present application, the following description will be made in conjunction with the scene example shown in FIG. 1 . Referring to FIG. 1 , the figure is a schematic framework diagram of an exemplary application scenario provided by an embodiment of the present application.
在实际应用中,存在着图像像素较低的需要进行图像修复的待修复第一像素质量图像,将第一像素质量图像输入至图像特征编码器中,可以对第一像素 质量图像进行图像特征的提取,得到目标图像特征。再将得到的目标图像特征输入至真实第二像素质量图像生成器中,得到修复后的第二像素质量图像。第二像素质量图像为图像像素较高的图像。其中,图像特征编码器和真实第二像素质量图像生成器均是预先通过图像修复模型的训练方法生成的。In practical applications, there is a first pixel quality image to be repaired with low image pixels that needs to be repaired, and the first pixel quality image is input into the image feature encoder, and the image feature of the first pixel quality image can be performed Extract the features of the target image. Then input the obtained target image features into the real second pixel quality image generator to obtain the repaired second pixel quality image. The second pixel quality image is an image with higher image pixels. Wherein, both the image feature encoder and the real second pixel quality image generator are pre-generated through the training method of the image restoration model.
本领域技术人员可以理解,图1所示的框架示意图仅是本申请的实施方式可以在其中得以实现的一个示例。本申请实施方式的适用范围不受到该框架任何方面的限制。Those skilled in the art can understand that the schematic frame diagram shown in FIG. 1 is only an example in which the embodiments of the present application can be implemented. The scope of applicability of the embodiments of the present application is not limited by any aspect of this framework.
为了便于理解本申请,下面结合附图对本申请实施例提供的一种图像修复模型的训练方法进行说明。In order to facilitate understanding of the present application, a method for training an image inpainting model provided by an embodiment of the present application will be described below with reference to the accompanying drawings.
参见图2所示,该图为本申请实施例提供的一种图像修复模型的训练方法的流程图,如图2所示,该方法可以包括S201-S209:Referring to Figure 2, which is a flow chart of a training method for an image repair model provided in an embodiment of the present application, as shown in Figure 2, the method may include S201-S209:
S201:将真实第一像素质量图像输入图像特征编码器,得到第一图像特征。S201: Input a real first pixel quality image into an image feature encoder to obtain a first image feature.
参见图3所示,该图为本申请实施例提供的一种图像修复模型的结构示意图。真实第一像素质量图像为在真实场景下生成的具有较低像素质量的图像。真实第一像素质量图像可以是在图像生成或者是在对图像进行处理过程中,受到设备或者是数据处理的影响,具有一定的模糊和/或噪声的较低像素质量的图像。真实第一像素质量图像可能存在着多种模糊和噪声退化的问题。Refer to FIG. 3 , which is a schematic structural diagram of an image inpainting model provided by an embodiment of the present application. The real first pixel quality image is an image with lower pixel quality generated in a real scene. The real image with the first pixel quality may be an image with a certain blur and/or noise and a relatively low pixel quality that is affected by equipment or data processing during image generation or image processing. Realistic first-pixel-quality images can suffer from multiple blurring and noise degradation problems.
图像特征编码器是用于对图像进行特征提取的编码器。将真实第一像素质量图像输入至图像特征编码器中,可以对真实第一像素质量图像进行特征提取,得到与真实第一像素质量图像相对应的第一图像特征。An image feature encoder is an encoder used to extract features from an image. The real first pixel quality image is input into the image feature encoder, and feature extraction can be performed on the real first pixel quality image to obtain the first image feature corresponding to the real first pixel quality image.
S202:将人工合成第一像素质量图像输入图像特征编码器,得到第二图像特征;人工合成第一像素质量图像是由真实第二像素质量图像进行模糊处理得到的。S202: Input the artificially synthesized first pixel quality image into the image feature encoder to obtain the second image feature; the artificially synthesized first pixel quality image is obtained by blurring the real second pixel quality image.
其中,第一像素质量的图像清晰度低于第二像素质量的图像清晰度。则人工合成第一像素质量图像是由人为构建的较低像素质量的图像。人工合成第一像素质量图像可以是通过对真实第二像素质量图像进行模糊处理得到的。其中,真实第二像素质量图像为在真实场景下生成的较高像素质量的图像。通过对真实第二像素质量图像进行模糊处理,可以使得真实第二像素质量图像的像素质 量退化,得到较低像素质量的人工合成第一像素质量图像。模糊处理为降低像素质量的图像处理方式,具体的,模糊处理可以为对图像添加高斯噪声和高斯模糊。Wherein, the image definition of the first pixel quality is lower than the image definition of the second pixel quality. Then the artificially synthesized first pixel quality image is an artificially constructed image with lower pixel quality. The artificially synthesized first pixel quality image may be obtained by blurring the real second pixel quality image. Wherein, the real second pixel quality image is an image of higher pixel quality generated in a real scene. By blurring the real second pixel quality image, the pixel quality of the real second pixel quality image can be degraded, and a lower pixel quality artificially synthesized first pixel quality image can be obtained. Blurring is an image processing method that reduces pixel quality. Specifically, blurring can add Gaussian noise and Gaussian blur to an image.
需要说明的是,本申请实施例不限定真实第一像素质量图像和真实第二像素质量图像是否为同一内容的图像。真实第一像素质量图像与真实第二像素质量图像可以为同一内容的,仅是像素质量不同的图像,也就是成对的不同像素质量的图像。真实第一像素质量图像与真实第二像素质量图像也可以为不同内容的,像素质量不同的图像,也就是不成对的不同像素质量的图像。It should be noted that the embodiment of the present application does not limit whether the real first pixel quality image and the real second pixel quality image are images of the same content. The real image with the first pixel quality and the real image with the second pixel quality may have the same content, but only images with different pixel qualities, that is, images with different pixel qualities in pairs. The real image of the first pixel quality and the real image of the second pixel quality may also be images of different content and pixel quality, that is, images of different pixel qualities that are not paired.
将人工合成第一像素质量图像输入至图像特征编码器中,对人工合成第一像素质量图像进行特征提取,得到人工合成第一像素质量图像对应的第二图像特征。The artificially synthesized first pixel quality image is input into the image feature encoder, and feature extraction is performed on the artificially synthesized first pixel quality image to obtain a second image feature corresponding to the artificially synthesized first pixel quality image.
S203:将第一图像特征输入真实第一像素质量图像生成器,得到重新生成的真实第一像素质量图像。S203: Input the first image feature into the real first pixel quality image generator to obtain a regenerated real first pixel quality image.
真实第一像素质量图像生成器是用于基于输入的图像特征,生成对应的在真实场景下的较低像素质量的图像。将第一图像特征输入至真实第一像素质量图像生成器中,可以得到重新生成的真实第一像素质量图像。The real first pixel quality image generator is used to generate a corresponding lower pixel quality image in a real scene based on the input image features. The first image feature is input into the real first pixel quality image generator, and a regenerated real first pixel quality image can be obtained.
重新生成的真实第一像素质量图像也为较低像素质量的图像。重新生成的真实第一像素质量图像是与真实第一像素质量图像对应的,模拟真实场景下较低像素质量的图像。The regenerated true first pixel quality image is also a lower pixel quality image. The regenerated real first pixel quality image corresponds to the real first pixel quality image, simulating an image of lower pixel quality in a real scene.
S204:将第二图像特征输入真实第一像素质量图像生成器,得到伪真实第一像素质量图像。S204: Input the second image feature into the real first pixel quality image generator to obtain a pseudo real first pixel quality image.
将第二图像特征输入至真实第一像素质量图像生成器中,可以到伪真实第一像素质量图像。伪真实第一像素质量图像为较低像素质量的图像。伪真实第一像素质量图像是与人工合成第一像素质量图像所对应的,模拟真实场景下较低像素质量的图像。Inputting the second image feature into the real first pixel quality image generator can generate a pseudo real first pixel quality image. The pseudo-true first pixel quality image is an image of lower pixel quality. The pseudo-real first pixel quality image corresponds to the artificially synthesized first pixel quality image, simulating an image of lower pixel quality in a real scene.
S205:将第二图像特征输入真实第二像素质量图像生成器,得到重建第二像素质量图像。S205: Input the second image feature into a real second pixel quality image generator to obtain a reconstructed second pixel quality image.
真实第二像素质量图像生成器是用于基于输入的图像特征,生成对应的在真实场景下的较高像素质量的图像。将第二图像特征输入至真实第二像素质量图像生成器中,可以得到重建第二像素质量图像。The real second pixel quality image generator is used to generate a corresponding higher pixel quality image in a real scene based on the input image features. The second image feature is input into the real second pixel quality image generator to obtain a reconstructed second pixel quality image.
重建第二像素质量图像为较高像素质量的图像。重建第二像素质量图像是与人工合成第一像素质量图像对应的,模拟真实场景下较高像素质量的图像。The second pixel quality image is reconstructed as a higher pixel quality image. The reconstruction of the second pixel quality image corresponds to the artificial synthesis of the first pixel quality image, simulating an image of higher pixel quality in a real scene.
S206:根据第一图像特征以及第二图像特征计算域对齐损失。S206: Calculate a domain alignment loss according to the first image feature and the second image feature.
第一图像特征为真实第一像素质量图像对应的图像特征,而第二图像特征为人工合成第一像素质量图像对应的图像特征。基于第一图像特征和第二图像特征,可以对真实第一像素质量图像和人工合成第一像素质量图像进行比较。The first image feature is an image feature corresponding to the real first pixel quality image, and the second image feature is an image feature corresponding to the artificially synthesized first pixel quality image. Based on the first image feature and the second image feature, the real first pixel quality image and the artificially synthesized first pixel quality image may be compared.
根据得到的第一图像特征以及第二图像特征,可以计算域对齐损失。域对齐损失可以从特征的角度反映真实第一像素质量图像和人工合成第一像素质量图像之间的差距。From the obtained first image features as well as the second image features, a domain alignment loss can be calculated. The domain alignment loss can reflect the gap between real first pixel quality images and artificial first pixel quality images from the perspective of features.
在一种可能的实现方式中,本申请实施例提供一种根据第一图像特征以及第二图像特征计算域对齐损失的具体实施方式,具体请参见下文。In a possible implementation manner, the embodiment of the present application provides a specific implementation manner of calculating a domain alignment loss according to the first image feature and the second image feature, and please refer to the following for details.
S207:根据重新生成的真实第一像素质量图像、伪真实第一像素质量图像以及真实第一像素质量图像计算图像生成损失。S207: Calculate an image generation loss according to the regenerated real first pixel quality image, pseudo real first pixel quality image, and real first pixel quality image.
重新生成的真实第一像素质量图像是通过真实第一像素质量图像生成器基于第一图像特征生成的。伪真实第一像素质量图像是通过真实第一像素质量图像生成器基于第二图像特征生成的。基于重新生成的真实第一像素质量、伪真实第一像素质量图像和真实第一像素质量图像,可以计算得到真实第一像素质量图像生成器在生成模拟真实场景下的较低像素质量图像的损失,也就是图像生成损失。图像生成损失可以对生成的较低像素质量图像和真实的较低像素质量图像之间的差距进行衡量。The regenerated real first pixel quality image is generated based on the first image feature by a real first pixel quality image generator. The pseudo real first pixel quality image is generated based on the second image feature by the real first pixel quality image generator. Based on the regenerated real first pixel quality, pseudo real first pixel quality image and real first pixel quality image, the loss of the real first pixel quality image generator in generating lower pixel quality images in simulated real scenes can be calculated , which is the image generation loss. The image generation loss measures the difference between the generated lower pixel quality image and the real lower pixel quality image.
在一种可能的实现方式中,本申请实施例提供一种根据重新生成的真实第一像素质量图像、伪真实第一像素质量图像以及真实第一像素质量图像计算图像生成损失的具体实现方式,具体请参见下文。In a possible implementation manner, this embodiment of the present application provides a specific implementation manner of calculating the image generation loss according to the regenerated real first pixel quality image, pseudo real first pixel quality image, and real first pixel quality image, See below for details.
S208:根据重建第二像素质量图像以及真实第二像素质量图像计算图像重建损失。S208: Calculate an image reconstruction loss according to the reconstructed second pixel quality image and the real second pixel quality image.
重建第二像素质量图像是通过真实第二像素质量图像生成器基于第二图像特征生成的。重建第二像素质量图像对应的真实场景下的较高像素质量图像为真实第二像素质量图像。基于重建第二像素质量图像和真实第二像素质量图像,可以计算得到真实第二像素质量图像生成器在生成模拟的真实场景下的较高像素质量图像的损失,也就是图像重建损失。图像重建损失可以对生成的较高像素质量图像和真实的较高像素质量图像之间的差距进行衡量。The reconstructed second pixel quality image is generated based on the second image features by the real second pixel quality image generator. The higher pixel quality image in the real scene corresponding to the reconstructed second pixel quality image is a real second pixel quality image. Based on the reconstructed second pixel quality image and the real second pixel quality image, the loss of the higher pixel quality image generated by the real second pixel quality image generator in the simulated real scene, that is, the image reconstruction loss, can be calculated. The image reconstruction loss measures the difference between the generated higher pixel quality image and the real higher pixel quality image.
在一种可能的实现方式中,本申请实施例提供一种根据重建第二像素质量图像以及真实第二像素质量图像计算图像重建损失的具体实施方式,具体请参见下文。In a possible implementation manner, this embodiment of the present application provides a specific implementation manner of calculating an image reconstruction loss according to the reconstructed second pixel-quality image and the real second pixel-quality image. For details, please refer to the following.
S209:根据域对齐损失、图像生成损失以及图像重建损失,训练图像特征编码器、真实第一像素质量图像生成器以及真实第二像素质量图像生成器,重复执行将真实第一像素质量图像输入图像特征编码器,得到第一图像特征以及后续步骤,直到达到预设条件。S209: According to the domain alignment loss, image generation loss and image reconstruction loss, train the image feature encoder, the real first pixel quality image generator and the real second pixel quality image generator, and repeatedly execute the real first pixel quality image input image The feature encoder obtains the features of the first image and performs subsequent steps until a preset condition is reached.
基于计算得到的域对齐损失、图像生成损失以及图像重建损失,可以对图像特征编码器、真实第一像素质量图像生成器以及真实第二像素质量图像生成器进行训练。通过利用计算得到的损失对图像特征编码器、真实第一像素质量图像生成器以及真实第二像素质量图像生成器进行联合调整。并且重复执行上述S201-S209,对图像特征编码器、真实第一像素质量图像生成器和真实第二像素质量图像生成器进行训练。直到满足预设条件后,停止对图像特征编码器、真实第一像素质量图像生成器和真实第二像素质量图像生成器的训练,实现图像修复模型的训练。具体的,预设条件可以是重复进行训练的次数,比如,预设条件可以为重复训练500次。Based on the computed domain alignment loss, image generation loss, and image reconstruction loss, the image feature encoder, true first pixel quality image generator, and true second pixel quality image generator can be trained. The image feature encoder, the real-first pixel-quality image generator, and the real-second pixel-quality image generator are jointly tuned by exploiting the computed loss. And repeatedly execute the above S201-S209 to train the image feature encoder, the real first pixel quality image generator and the real second pixel quality image generator. Until the preset condition is satisfied, the training of the image feature encoder, the real first pixel quality image generator and the real second pixel quality image generator is stopped, so as to realize the training of the image restoration model. Specifically, the preset condition may be the number of repetitions of training, for example, the preset condition may be 500 repetitions of training.
在一种可能的实现方式中,本申请实施例还提供一种根据域对齐损失、图像生成损失以及图像重建损失,训练图像特征编码器、真实第一像素质量图像生成器以及真实第二像素质量图像生成器的具体实施方式,具体请参见下文。In a possible implementation, the embodiment of the present application also provides a training image feature encoder, real first pixel quality image generator and real second pixel quality according to domain alignment loss, image generation loss and image reconstruction loss. For the specific implementation of the image generator, please refer to the following for details.
基于上述S201-S209的相关内容可知,通过利用图像特征编码器提取图像特征,通过真实第一像素质量图像生成器生成对应的较低像素质量图像,通过真实第二像素质量图像生成器生成对应的较高像素质量图像。利用得到的图像特征、生成的较低像素质量图像、生成的较高像素质量图像、对应的真实场 景下的较低像素质量图像以及对应的真实场景下的较高像素质量图像,可以计算得到对应的图像特征损失、图像生成损失以及图像重建损失。基于计算得到的损失,对图像特征编码器、真实第一像素质量图像生成器以及真实第二像素质量图像生成器进行训练,能够减小真实较低像素质量图像与人工合成的较低像素质量图像之间的差距,减小生成的模拟真实场景下较低像素质量图像和实际真实场景下较低像素质量图像之间的差距,减小生成的模拟真实场景下较高像素质量图像与实际真实场景下较高像素质量图像之间的差距,得到泛化能力更好、修复效果更好的图像特征编码器以及真实第二像素质量图像生成器,可以实现基于训练好的图像修复模型得到修复效果更好的较高像素质量图像。Based on the relevant content of S201-S209 above, it can be seen that by using the image feature encoder to extract image features, the corresponding lower pixel quality image is generated by the real first pixel quality image generator, and the corresponding lower pixel quality image is generated by the real second pixel quality image generator. Higher pixel quality images. Using the obtained image features, the generated lower pixel quality image, the generated higher pixel quality image, the corresponding lower pixel quality image in the real scene, and the corresponding higher pixel quality image in the real scene, the corresponding The image feature loss, image generation loss and image reconstruction loss. Based on the computed loss, an image feature encoder, a real first pixel quality image generator, and a real second pixel quality image generator are trained to reduce the real lower pixel quality image and the artificial lower pixel quality image Reduce the gap between the generated low pixel quality image in the simulated real scene and the low pixel quality image in the actual real scene, reduce the generated high pixel quality image in the simulated real scene and the actual real scene Lower the gap between images with higher pixel quality, obtain an image feature encoder with better generalization ability and better repair effect, and a real second pixel quality image generator, which can achieve better repair effect based on the trained image repair model Good higher pixel quality images.
在一种可能的实现方式中,在真实第一像素质量图像生成器的性能不佳时,生成的伪真实第一像素质量图像还可能与人工合成第一像素质量图像在图像内容上存在差异。In a possible implementation manner, when the performance of the real first pixel quality image generator is poor, the generated pseudo real first pixel quality image may also have differences in image content from the artificially synthesized first pixel quality image.
针对上述问题,本申请实施例提供一种图像修复模型的训练方法,除上述S201-S209以外,所述方法还包括以下步骤:In view of the above problems, the embodiment of the present application provides a training method of an image repair model, in addition to the above S201-S209, the method also includes the following steps:
A1:将伪真实第一像素质量图像输入图像特征编码器,得到第三图像特征。A1: Input the pseudo-real first pixel quality image into the image feature encoder to obtain the third image feature.
参见图4所示,该图为本申请实施例提供的另一种图像修复模型的结构示意图。Refer to FIG. 4 , which is a schematic structural diagram of another image inpainting model provided by the embodiment of the present application.
对伪真实第一像素质量图像进行图像特征的提取,将伪真实第一像素质量图像输入至图像特征编码器中,得到伪真实第一像素质量图像对应的第三图像特征。Image features are extracted from the pseudo real first pixel quality image, and the pseudo real first pixel quality image is input into an image feature encoder to obtain a third image feature corresponding to the pseudo real first pixel quality image.
A2:根据第二图像特征以及第三图像特征计算内容一致性损失。A2: Calculate the content consistency loss according to the second image feature and the third image feature.
第二图像特征为人工合成第一像素质量图像的图像特征。根据第二图像特征和第三图像特征,可以计算得到内容一致性损失。内容一致性损失用于衡量人工合成第一像素质量图像和伪真实第一像素质量图像之间的图像差距。基于内容一致性损失可以对真实第一像素质量图像生成器进行调整,使得生成的模拟真实场景下的较低像素质量图像的图像内容与对应的人工合成第一像素质量图像的图像内容不变,仅是图像像素的退化模式发生变化,从而实现提高生 成的模拟真实场景下的较低像素质量图像的图像质量,确保图像内容不发生变化。The second image feature is an image feature of the artificially synthesized first pixel quality image. According to the second image feature and the third image feature, the content consistency loss can be calculated. The content consistency loss is used to measure the image gap between artificially synthesized first pixel quality images and fake real first pixel quality images. Based on the content consistency loss, the real first pixel quality image generator can be adjusted so that the image content of the generated lower pixel quality image in the simulated real scene is unchanged from that of the corresponding artificially synthesized first pixel quality image, Only the degradation mode of the image pixels is changed, so as to improve the image quality of the generated image with lower pixel quality in the simulated real scene, and ensure that the image content does not change.
对应的,本申请实施例提供一种根据域对齐损失、图像生成损失以及图像重建损失,训练图像特征编码器、真实第一像素质量图像生成器以及真实第二像素质量图像生成器的具体实施方式,包括:Correspondingly, the embodiment of the present application provides a specific implementation of training the image feature encoder, the real first pixel quality image generator and the real second pixel quality image generator according to the domain alignment loss, image generation loss and image reconstruction loss ,include:
根据域对齐损失、图像生成损失、图像重建损失以及内容一致性损失,训练图像特征编码器、真实第一像素质量图像生成器以及真实第二像素质量图像生成器。An image feature encoder, a true-first pixel-quality image generator, and a true-second pixel-quality image generator are trained on domain alignment loss, image generation loss, image reconstruction loss, and content consistency loss.
根据计算得到的域对齐损失、图像生成损失、图像重建损失和内容一致性损失,对图像特征编码器、真实第一像素质量图像生成器以及真实第二像素质量图像生成器进行训练。Based on the computed domain alignment loss, image generation loss, image reconstruction loss, and content consistency loss, the image feature encoder, true-first pixel-quality image generator, and true-second pixel-quality image generator are trained.
在一种可能的实现方式中,本申请实施例提供一种根据第二图像特征以及第三图像特征计算内容一致性损失的具体实施方式,具体请参见下文。In a possible implementation manner, this embodiment of the present application provides a specific implementation manner of calculating the content consistency loss according to the second image feature and the third image feature, and please refer to the following for details.
在本申请实施例中,通过计算内容一致性损失,并且利用内容一致性损失对图像特征编码器、真实第一像素质量图像生成器以及真实第二像素质量图像生成器进行训练,可以进一步提高生成的图像修复模型的模型性能,确保修复后的图像与待修复的图像的图像内容一致。In the embodiment of the present application, by calculating the content consistency loss and using the content consistency loss to train the image feature encoder, the real first pixel quality image generator and the real second pixel quality image generator, the generated The model performance of the image inpainting model ensures that the inpainted image is consistent with the image content of the image to be inpainted.
进一步的,还可以通过真实第二像素质量图像生成器,利用得到的第三图像特征得到对应的模拟真实场景下的较高像素质量图像,并计算对应的图像重建损失,并利用图像重建损失训练得到更为性能更好的图像修复模型。Further, the real second pixel quality image generator can also be used to obtain the corresponding higher pixel quality image in the simulated real scene by using the obtained third image features, and calculate the corresponding image reconstruction loss, and use the image reconstruction loss to train A more performant image inpainting model is obtained.
对应的,本申请实施例提供的一种图像修复模型的训练方法还可以包括以下步骤:Correspondingly, a method for training an image inpainting model provided in an embodiment of the present application may further include the following steps:
将第三图像特征输入真实第二像素质量图像生成器,得到伪真实重建第二像素质量图像。The third image feature is input to the real second pixel quality image generator to obtain a pseudo real reconstructed second pixel quality image.
参见图5所示,该图为本申请实施例提供的另一种图像修复模型的结构示意图。Refer to FIG. 5 , which is a schematic structural diagram of another image inpainting model provided by the embodiment of the present application.
第三图像特征为伪真实第一像素质量图像的图像特征。将第三图像特征输入至真实第二像素质量图像生成器中,可以得到对应于伪真实第一像素质量图像的模拟真实场景下的较高像素质量图像,即伪真实重建第二像素质量图像。The third image feature is an image feature of the pseudo-real first pixel quality image. By inputting the third image feature into the real second pixel quality image generator, a higher pixel quality image corresponding to the pseudo-real first pixel quality image in a simulated real scene can be obtained, that is, a pseudo-real reconstructed second pixel quality image.
对应的,本申请实施例提供一种根据重建第二像素质量图像以及真实第二像素质量图像计算图像重建损失的具体实施方式,包括以下两个步骤:Correspondingly, the embodiment of the present application provides a specific implementation manner of calculating the image reconstruction loss according to the reconstructed second pixel quality image and the real second pixel quality image, including the following two steps:
B1:根据重建第二像素质量图像以及真实第二像素质量图像计算第一图像重建损失。B1: Calculate the first image reconstruction loss based on the reconstructed second pixel quality image and the real second pixel quality image.
重建第二像素质量图像是与真实第二像素质量图像对应的生成的模拟真实场景下的较高像素质量图像。根据重建第二像素质量图像和真实第二像素质量图像可以计算得到第一图像重建损失,第一图像重建损失可以用于衡量重建第二像素质量图像和真实第二像素质量图像之间的差距。The reconstructed second pixel quality image is a generated higher pixel quality image in a simulated real scene corresponding to the real second pixel quality image. The first image reconstruction loss can be calculated according to the reconstructed second pixel quality image and the real second pixel quality image, and the first image reconstruction loss can be used to measure the gap between the reconstructed second pixel quality image and the real second pixel quality image.
在一种可能的实现方式中,本申请实施例提供一种根据重建第二像素质量图像以及真实第二像素质量图像计算第一图像重建损失的具体实施方式,具体请参见下文。In a possible implementation manner, this embodiment of the present application provides a specific implementation manner of calculating the reconstruction loss of the first image according to the reconstructed second pixel quality image and the real second pixel quality image. For details, please refer to the following.
B2:根据伪真实重建第二像素质量图像以及真实第二像素质量图像计算第二图像重建损失;第一图像重建损失以及第二图像重建损失组成图像重建损失。B2: Calculating a second image reconstruction loss according to the pseudo real reconstructed second pixel quality image and the real second pixel quality image; the first image reconstruction loss and the second image reconstruction loss constitute an image reconstruction loss.
伪真实重建第二像素质量图像也是与真实第二像素质量图像对应的,由较低像素质量图像生成的模拟真实场景下的较高像素质量图像。根据伪真实重建第二像素质量图像可以计算得到第二图像重建损失,第二图像重建损失可以用于衡量伪真实重建第二像素质量图像和真实第二像素质量图像之间的差距。The pseudo-true reconstruction of the second pixel quality image also corresponds to the real second pixel quality image, which is a higher pixel quality image generated from a lower pixel quality image to simulate a real scene. The second image reconstruction loss can be calculated according to the reconstructed pseudo-real second pixel quality image, and the second image reconstruction loss can be used to measure the gap between the pseudo-real reconstructed second pixel quality image and the real second pixel quality image.
利用得到的第一图像重建损失和第二图像重建损失组成图像重建损失。An image reconstruction loss is composed by using the obtained first image reconstruction loss and the second image reconstruction loss.
基于上述内容可知,通过真实第二像素质量图像,基于第三图像特征生成伪真实重建第二像素质量图像,并基于重建第二像素质量图像和伪真实重建第二像素质量图像分别与真实第二像素质量图像计算图像重建损失。得到的图像重建损失,可以更全面地衡量生成的模拟真实场景下较高像素质量图像与实际真实场景下较高像素质量图像之间的差距,实现对真实第二像素质量图像生成器的生成结果的约束,从而可以基于图像重建损失训练得到模型性能更优的图像修复模型。Based on the above content, it can be seen that through the real second pixel quality image, a pseudo-true reconstructed second pixel quality image is generated based on the third image feature, and based on the reconstructed second pixel quality image and the pseudo-real reconstructed second pixel quality image are respectively compared with the real second pixel quality image. Pixel Quality Image Computing image reconstruction loss. The obtained image reconstruction loss can more comprehensively measure the gap between the higher pixel quality image generated in the simulated real scene and the higher pixel quality image in the actual real scene, and realize the generation result of the real second pixel quality image generator constraints, so that an image inpainting model with better model performance can be obtained based on image reconstruction loss training.
在一种可能的实现方式中,本申请实施例提供一种根据重新生成的真实第一像素质量图像、伪真实第一像素质量图像以及真实第一像素质量图像计算图像生成损失,具体包括以下两个步骤:In a possible implementation, the embodiment of the present application provides an image generation loss calculation method based on the regenerated real first pixel quality image, pseudo real first pixel quality image and real first pixel quality image, specifically including the following two steps:
C1:根据重新生成的真实第一像素质量图像以及真实第一像素质量图像计算第一图像生成损失。C1: Calculate the first image generation loss from the regenerated real first pixel quality image and the real first pixel quality image.
重新生成的真实第一像素质量图像是与真实第一像素质量图像对应的生成的模拟真实场景下的较低像素质量图像。根据重新生成的真实第一像素质量图像和真实第一像素质量图像,可以计算得到第一图像生成损失,第一图像生成损失可以用于衡量重新生成的真实第一像素质量图像和真实第一像素质量图像之间的差距。The regenerated real first pixel quality image is a generated lower pixel quality image in a simulated real scene corresponding to the real first pixel quality image. According to the regenerated true first pixel quality image and the true first pixel quality image, the first image generation loss can be calculated, and the first image generation loss can be used to measure the regenerated true first pixel quality image and the true first pixel quality image The gap between quality images.
在一种可能的实现方式中,本申请实施例提供一种根据重新生成的真实第一像素质量图像以及真实第一像素质量图像计算第一图像生成损失的具体实现方式,具体请参见下文。In a possible implementation manner, this embodiment of the present application provides a specific implementation manner of calculating the first image generation loss according to the regenerated real first pixel quality image and the real first pixel quality image, for details, please refer to the following.
C2:根据伪真实第一像素质量图像以及真实第一像素质量图像计算第二图像生成损失;第一图像生成损失以及第二图像生成损失组成图像生成损失。C2: Calculate the second image generation loss according to the fake real first pixel quality image and the real first pixel quality image; the first image generation loss and the second image generation loss constitute the image generation loss.
伪真实第一像素质量图像是基于人工合成第一像素质量图像,生成的模拟真实场景下的较低像素质量图像。根据伪真实第一像素质量图像和真实第一像素质量图像可以计算得到第二图像生成损失。第二图像生成损失可以用于衡量伪真实第一像素质量图像和真实第一像素质量图像之间的差距。The pseudo-real first pixel quality image is based on artificially synthesizing the first pixel quality image to generate a lower pixel quality image in a simulated real scene. The second image generation loss can be calculated according to the fake real first pixel quality image and the real first pixel quality image. The second image generation loss can be used to measure the gap between the fake real first pixel quality image and the real first pixel quality image.
基于得到的第一图像生成损失和第二图像生成损失,可以组成图像生成损失。Based on the obtained first image generation loss and the second image generation loss, an image generation loss can be composed.
在一种可能的实现方式中,本申请实施例提供一种根据伪真实第一像素质量图像以及真实第一像素质量图像计算第二图像生成损失;第一图像生成损失以及第二图像生成损失组成图像生成损失的具体实施方式,具体参见下文。In a possible implementation, the embodiment of the present application provides a method of calculating the second image generation loss according to the pseudo-true first pixel quality image and the real first pixel quality image; the first image generation loss and the second image generation loss are composed of For the specific implementation of the image generation loss, see below.
在本申请实施例中,利用重新生成的真实第一像素质量图像和真实第一像素质量图像计算得到第一图像生成损失,利用伪真实第一像素质量图像和真实第一像素质量图像计算得到第二图像生成损失。可以基于第一图像生成损失以及第二图像生成损失两个方面得到更为准确的图像生成损失实现对真实第一像素质量图像生成器的生成结果的约束。基于图像生成损失,可以减少生成的较低像素质量图像与真实场景下较低像素质量图像之间的差距,利用得到的图像生成损失训练得到模型性能更优的图像修复模型。In this embodiment of the application, the first image generation loss is calculated by using the regenerated real first pixel quality image and the real first pixel quality image, and the first image generation loss is calculated by using the pseudo real first pixel quality image and the real first pixel quality image Two image generation loss. A more accurate image generation loss can be obtained based on the first image generation loss and the second image generation loss to implement constraints on the generation results of the real first pixel quality image generator. Based on the image generation loss, the gap between the generated lower pixel quality image and the lower pixel quality image in the real scene can be reduced, and the image inpainting model with better model performance can be obtained by training with the obtained image generation loss.
在一种可能的实现方式中,本申请实施例提供一种根据第一图像特征以及第二图像特征计算域对齐损失的具体实施方式,包括以下三个步骤:In a possible implementation, the embodiment of the present application provides a specific implementation of calculating the domain alignment loss according to the first image feature and the second image feature, including the following three steps:
D1:将第一图像特征输入特征判别器,得到第一概率值。D1: Input the first image feature into the feature discriminator to obtain the first probability value.
首先需要说明的是,第一图像特征对应的真实第一像素质量图像和第二图像特征对应的人工合成第一像素质量图像属于对不同的图像进行处理得到的。可以将图像特征输入至特征判别器中,得到对应的概率值,进行域对齐损失的计算。First of all, it needs to be explained that the real first pixel quality image corresponding to the first image feature and the synthetic first pixel quality image corresponding to the second image feature are obtained by processing different images. The image features can be input into the feature discriminator to obtain the corresponding probability value and calculate the domain alignment loss.
参见图6所示,该图为本申请实施例提供的一种特征判别器的结构示意图。特征判别器可以由6个模块组成,每个模块由一个3*3卷积层和一个激活函数层组成。其中,激活函数层具体可以采用LeakyRelu激活函数。Referring to FIG. 6 , this figure is a schematic structural diagram of a feature discriminator provided by an embodiment of the present application. The feature discriminator can be composed of 6 modules, and each module consists of a 3*3 convolutional layer and an activation function layer. Wherein, the activation function layer may specifically adopt the LeakyRelu activation function.
其中,对应于第一图像特征,特征判别器用于输出生成的第一图像特征为真实场景下的图像所对应的图像特征的概率值。通过将第一图像特征输入至特征判别器中,可以得到特征判别器输出的与第一图像特征对应的第一概率值。Wherein, corresponding to the first image feature, the feature discriminator is configured to output a probability value that the generated first image feature is an image feature corresponding to an image in a real scene. By inputting the first image feature into the feature discriminator, a first probability value corresponding to the first image feature output by the feature discriminator can be obtained.
具体的,第一图像特征Fx可以表示为Fx=E C(I X),其中,I X表示真实第一像素质量图像,E C(I X)表示通过图像特征编码器提取的真实第一像素质量图像的第一图像特征,其中E C可以表示图像特征编码器。特征判别器输出的第一概率值可以表示为logD C(Fx)。其中,D C表示针对特征的判别器。 Specifically, the first image feature Fx can be expressed as Fx=E C (I X ), where I X represents the real first pixel quality image, and E C (I X ) represents the real first pixel extracted by the image feature encoder The first image feature of a quality image, where E C can represent an image feature encoder. The first probability value output by the feature discriminator can be expressed as logD C (Fx). where DC denotes the discriminator for features.
D2:将第二图像特征输入特征判别器,得到第二概率值。D2: Input the second image feature into the feature discriminator to obtain the second probability value.
通过将第二图像特征输入至特征判别器中,可以得到特征判别器输出的与第二图像特征对应的第二概率值。By inputting the second image feature into the feature discriminator, a second probability value corresponding to the second image feature output by the feature discriminator can be obtained.
需要说明的是,第二图像特征是人工合成第一像素质量图像的图像特征,需要通过特征判别器得到第二图像特征是模拟真实场景下的图像的图像特征的概率值。It should be noted that the second image feature is the image feature of the artificially synthesized image of the first pixel quality, and the probability value that the second image feature is an image feature of an image in a simulated real scene needs to be obtained through a feature discriminator.
具体的,第二图像特征F Z可以表示为F Z=E C(I Z),其中,I Z表示人工合成第一像素质量图像,E C(I Z)表示通过图像特征编码器提取的人工合成第一像素质量图像的第二图像特征,其中E C可以表示图像特征编码器。特征判别器输出的第二概率值可以表示为log[1-D C(F Z)]。 Specifically, the second image feature F Z can be expressed as F Z =E C (I Z ), wherein, I Z represents the artificial synthesis of the first pixel quality image, and E C (I Z ) represents the artificial Synthesizing a second image feature of the first pixel-quality image, where E C may represent an image feature encoder. The second probability value output by the feature discriminator can be expressed as log[1-D C (F Z )].
D3:根据第一概率值以及第二概率值,计算域对齐损失。D3: Calculate the domain alignment loss according to the first probability value and the second probability value.
基于特征判别器输出的第一概率值和第二概率值,可以计算得到域对齐损失。Based on the first probability value and the second probability value output by the feature discriminator, the domain alignment loss can be calculated.
在一种可能的实现方式中,域对齐损失
Figure PCTCN2022089428-appb-000001
可以通过下式计算得到:
In one possible implementation, the domain alignment loss
Figure PCTCN2022089428-appb-000001
It can be calculated by the following formula:
Figure PCTCN2022089428-appb-000002
Figure PCTCN2022089428-appb-000002
其中,E X[logD C(Fx)]表示对计算得到的第一概率值所对应的期望值,E Z{log[1-D C(F Z)]}表示对计算得到的第二概率值所对应的期望值。通过计算针对第一概率值的期望与针对第二概率值的期望的和,得到域对齐损失。 Among them, E X [logD C (Fx)] represents the expected value corresponding to the calculated first probability value, and E Z {log[1-D C (F Z )]} represents the expected value corresponding to the calculated second probability value corresponding expected value. The domain alignment loss is obtained by computing the sum of the expectation for the first probability value and the expectation for the second probability value.
在本申请实施例中,通过特征判别器计算得到第一图像特征和第二图像特征所对应的概率值,再利用计算得到的概率值计算域对齐损失,得到的域对齐损失较为准确。通过特征判别器可以基于由不同图像处理得到的图像,也就是不成对的图像计算对应的损失值,使得在生成人工合成第一像素质量图像时所使用的真实第二像素质量图像可以与真实第一像素质量图像不是同一内容的图像,减少了生成训练图像的限制。In the embodiment of the present application, the probability value corresponding to the first image feature and the second image feature is calculated by the feature discriminator, and then the calculated probability value is used to calculate the domain alignment loss, and the obtained domain alignment loss is relatively accurate. Through the feature discriminator, the corresponding loss value can be calculated based on the images obtained by different image processing, that is, unpaired images, so that the real second pixel quality image used when generating the artificially synthesized first pixel quality image can be compared with the real first pixel quality image. One-pixel quality images are not images of the same content, reducing the constraints on generating training images.
进一步的,本申请实施例提供一种根据第二图像特征以及第三图像特征计算内容一致性损失的具体实施方式,包括:Further, the embodiment of the present application provides a specific implementation manner of calculating the content consistency loss according to the second image feature and the third image feature, including:
计算第二图像特征以及第三图像特征之间的1-范数;Calculate the 1-norm between the second image feature and the third image feature;
根据第二图像特征以及第三图像特征之间的1-范数,计算内容一致性损失。Based on the 1-norm between the second image feature and the third image feature, a content consistency loss is calculated.
具体的,计算第二图像特征以及第三图像特征之间的1-范数。其中,第二图像特征可以表示为F Z,第三图像特征可以表示为F Z'。对应的第二图像特征以及第三图像特征之间的1-范数可以表示为||F Z'-F Z|| 1Specifically, the 1-norm between the second image feature and the third image feature is calculated. Wherein, the second image feature may be represented as F Z , and the third image feature may be represented as F Z '. The 1-norm between the corresponding second image feature and the third image feature can be expressed as ||F Z′ −F Z || 1 .
基于计算得到的第二图像特征与第三图像特征之间的1-范数,计算得到内容一致性损失。Based on the calculated 1-norm between the second image feature and the third image feature, a content consistency loss is calculated.
在一种可能的实现方式中,内容一致性损失L pix可以通过下式计算得到: In a possible implementation, the content consistency loss L pix can be calculated by the following formula:
L pix(F Z′,F Z)=E Z[||F Z′-F Z|| 1]         (2) L pix (F Z ′, F Z )=E Z [||F Z ′-F Z || 1 ] (2)
其中,E Z[||F Z'-F Z|| 1]表示计算得到的||F Z′-F Z|| 1所对应的期望值,具体可以是针对得到的||F Z′-F Z|| 1计算对应的平均值。 Among them, E Z [||F Z' -F Z || 1 ] represents the expected value corresponding to the calculated ||F Z ′-F Z || 1 , specifically for the obtained ||F Z ′-F Z || 1 computes the corresponding mean.
基于上述内容可知,通过基于计算第二图像特征和第三图像特征之间的1-范数,实现逐像素地进行约束,计算得到的内容一致性损失可以更好地表示人 工合成第一像素质量图像和伪真实第一像素质量图像之间的差距,进而可以通过训练得到性能更好的图像修复模型。Based on the above content, it can be seen that by calculating the 1-norm between the second image feature and the third image feature, the constraints are implemented pixel by pixel, and the calculated content consistency loss can better represent the quality of the artificially synthesized first pixel The gap between the image and the pseudo-real first-pixel quality image can then be trained to obtain a better-performing image inpainting model.
进一步的,本申请实施例提供一种根据重建第二像素质量图像以及真实第二像素质量图像计算第一图像重建损失的具体实施方式,包括:Further, the embodiment of the present application provides a specific implementation method of calculating the reconstruction loss of the first image according to the reconstructed second pixel quality image and the real second pixel quality image, including:
计算重建第二像素质量图像以及真实第二像素质量图像之间的1-范数;calculating the 1-norm between the reconstructed second pixel quality image and the real second pixel quality image;
根据重建第二像素质量图像以及真实第二像素质量图像之间的1-范数,计算第一图像重建损失。The first image reconstruction loss is calculated from the 1-norm between the reconstructed second pixel quality image and the real second pixel quality image.
具体的,重建第二像素质量图像可以通过I Z→Y表示,真实第二像素质量图像可以通过I Y表示。重建第二像素质量图像以及真实第二像素质量图像之间的1-范数可以表示为||I Z→Y-I Y|| 1Specifically, the reconstructed second pixel quality image may be expressed by I Z→Y , and the real second pixel quality image may be expressed by I Y. The 1-norm between the reconstructed second pixel quality image and the real second pixel quality image can be expressed as ||I Z→Y −I Y || 1 .
计算重建第二像素质量图像以及真实第二像素质量图像之间的1-范数。A 1-norm between the reconstructed second pixel quality image and the real second pixel quality image is calculated.
重建第二像素质量图像以及真实第二像素质量图像之间的1-范数可以通过下式表示:The 1-norm between the reconstructed second pixel quality image and the real second pixel quality image can be expressed by the following formula:
L pix(I Z→Y,I Y)=E Y[||I Z→Y-I Y|| 1]       (3) L pix (I Z→Y ,I Y )=E Y [||I Z→Y -I Y || 1 ] (3)
其中,E Y[||I Z→Y-I Y|| 1]表示计算得到的||I Z→Y-I Y|| 1所对应的期望值。 Wherein, E Y [||I Z→Y -I Y || 1 ] represents the calculated expected value corresponding to ||I Z→Y -I Y || 1 .
在本申请实施例中,通过计算重建第二像素质量图像以及真实第二像素质量图像之间的1-范数,可以逐像素地进行约束,可以计算得到较为准确的第一图像重建损失,进而可以通过训练得到性能更好的图像修复模型。In the embodiment of the present application, by calculating the 1-norm between the reconstructed second pixel quality image and the real second pixel quality image, constraints can be performed pixel by pixel, and a more accurate first image reconstruction loss can be calculated, and then Image inpainting models with better performance can be obtained through training.
进一步的,在一种可能的实现方式中,本申请实施例提供一种根据伪真实重建第二像素质量图像以及真实第二像素质量图像计算第二图像重建损失的具体实现方式,包括:Further, in a possible implementation, the embodiment of the present application provides a specific implementation of calculating the reconstruction loss of the second image according to the reconstructed second pixel quality image of the pseudo-truth and the real second pixel quality image, including:
计算伪真实重建第二像素质量图像以及真实第二像素质量图像之间的1-范数;Computing the 1-norm between the pseudo real reconstructed second pixel quality image and the real second pixel quality image;
根据伪真实重建第二像素质量图像以及真实第二像素质量图像之间的1-范数,计算第二图像重建损失。A second image reconstruction loss is computed from the 1-norm between the pseudo real reconstructed second pixel quality image and the real second pixel quality image.
伪真实重建第二像素质量图像是由伪真实第一像素质量图像处理得到的,与真实第二像素质量图像属于对不同的图像进行处理得到的。可以通过特征判别器得到对应的概率值,进行域对齐损失的计算。The pseudo real reconstructed second pixel quality image is obtained by processing the pseudo real first pixel quality image, and is obtained by processing different images from the real second pixel quality image. The corresponding probability value can be obtained through the feature discriminator, and the domain alignment loss can be calculated.
具体的,伪真实重建第二像素质量图像可以通过I Z→X→Y表示,真实第二像 素质量图像可以通过I Y表示。重建第二像素质量图像以及真实第二像素质量图像之间的1-范数可以表示为||I Z→X→Y-I Y|| 1Specifically, the pseudo-true reconstruction of the second pixel quality image may be represented by I Z→X→Y , and the real second pixel quality image may be represented by I Y. The 1-norm between the reconstructed second pixel quality image and the real second pixel quality image can be expressed as ||I Z→X→Y −I Y || 1 .
计算伪真实重建第二像素质量图像以及真实第二像素质量图像之间的1-范数。A 1-norm between the pseudo real reconstructed second pixel quality image and the real second pixel quality image is calculated.
伪真实第二像素质量图像以及真实第二像素质量图像之间的1-范数可以通过下式表示:The 1-norm between the pseudo real second pixel quality image and the real second pixel quality image can be represented by the following formula:
L pix(I Z→X→Y,I Y)=E Y[||I Z→X→Y-I Y|| 1]     (4) L pix (I Z→X→Y ,I Y )=E Y [||I Z→X→Y -I Y || 1 ] (4)
其中,E Y[||I Z→X→Y-I Y|| 1]表示计算得到的||I Z→X→Y-I Y|| 1所对应的期望值。 Among them, E Y [||I Z→X→Y -I Y || 1 ] represents the calculated expected value corresponding to ||I Z→X→Y -I Y || 1 .
在本申请实施例中,通过计算伪真实重建第二像素质量图像和真实第二像素质量图像之间的1-范数,可以逐像素地进行约束,进一步提高第二图像重建损失的准确程度,以便训练得到性能更好的图像修复模型。In the embodiment of the present application, by calculating the 1-norm between the pseudo real reconstructed second pixel quality image and the real second pixel quality image, constraints can be performed pixel by pixel to further improve the accuracy of the second image reconstruction loss, In order to train an image restoration model with better performance.
在一种可能的实现方式中,本申请实施例提供一种根据重新生成的真实第一像素质量图像以及真实第一像素质量图像计算第一图像生成损失,包括:In a possible implementation manner, this embodiment of the present application provides a calculation of the first image generation loss according to the regenerated real first pixel quality image and the real first pixel quality image, including:
计算重新生成的真实第一像素质量图像以及真实第一像素质量图像之间的1-范数;Computing the 1-norm between the regenerated true first pixel quality image and the true first pixel quality image;
根据重新生成的真实第一像素质量图像以及真实第一像素质量图像之间的1-范数,计算第一图像生成损失。Compute the first image generation loss from the regenerated real first pixel quality image and the 1-norm between the real first pixel quality image.
具体的,重新生成的真实第一像素质量图像可以通过I X→X表示,真实第一像素质量图像可以通过I X表示。重新生成的真实第一像素质量图像以及真实第一像素质量图像之间的1-范数可以表示为||I X→X-I X|| 1Specifically, the regenerated real first pixel quality image may be represented by I X→X , and the real first pixel quality image may be represented by I X. The 1-norm between the regenerated true first pixel quality image and the true first pixel quality image can be expressed as ||I X→X − I X || 1 .
重新生成的真实第一像素质量图像以及真实第一像素质量图像之间的1-范数,可以通过下式表示为:The 1-norm between the regenerated true first pixel quality image and the true first pixel quality image can be expressed as:
L pix(I X→X,I X)=E X[||I X→X-I X|| 1]       (5) L pix (I X→X ,I X )=E X [||I X→X -I X || 1 ] (5)
其中,E X[||I X→X-I X|| 1]表示计算得到的||I X→X-I X|| 1所对应的期望值。 Wherein, E X [||I X→X - I X || 1 ] represents the calculated expected value corresponding to ||I X→X - I X || 1 .
在本申请实施例中,通过计算重新生成的真实第一像素质量图像和真实第一像素质量图像之间的1-范数,可以逐像素地进行约束,进一步提高第一图像生成损失的准确程度,以便训练得到性能更好的图像修复模型。In the embodiment of the present application, by calculating the 1-norm between the regenerated real first pixel quality image and the real first pixel quality image, constraints can be performed pixel by pixel, further improving the accuracy of the first image generation loss , in order to train an image inpainting model with better performance.
在一种可能的实现方式中,本申请实施例提供一种根据伪真实第一像素质量图像以及真实第一像素质量图像计算第二图像生成损失,具体包括:In a possible implementation manner, this embodiment of the present application provides a method of calculating the second image generation loss according to the fake real first pixel quality image and the real first pixel quality image, specifically including:
将伪真实第一像素质量图像输入特征判别器,得到第三概率值;Inputting the pseudo-true first pixel quality image into the feature discriminator to obtain a third probability value;
将真实第一像素质量图像输入特征判别器,得到第四概率值;Input the real first pixel quality image into the feature discriminator to obtain the fourth probability value;
根据第三概率值和第四概率值,计算第二图像生成损失。Based on the third probability value and the fourth probability value, a second image generation loss is calculated.
伪真实第一像素质量图像是由人工合成第一像素质量图像处理生成的,与真实第一像素质量图像属于不同的图像。可以通过将伪真实第一像素质图像和真实第一像素质量图像分别输入至特征判别器中,得到对应的概率值,实现第二图像生成损失的计算。The pseudo real first pixel quality image is generated by artificially synthesizing the first pixel quality image, and belongs to a different image from the real first pixel quality image. The calculation of the generation loss of the second image can be realized by inputting the pseudo real first pixel quality image and the real first pixel quality image into the feature discriminator respectively to obtain corresponding probability values.
将伪真实第一像素质量图像输入至特征判别器中,得到特征判别器输出的第三概率值。第三概率值用于表示伪真实第一像素质量图像为模拟真实场景下生成的较低像素质量图像的概率值。The pseudo-real first pixel quality image is input into the feature discriminator, and the third probability value output by the feature discriminator is obtained. The third probability value is used to represent the probability value that the pseudo real first pixel quality image is an image of lower pixel quality generated in a simulated real scene.
具体的,伪真实第一像素质量图像可以表示为I Z→X。对应的,第三概率值可以表示为log[1-D X(I Z→X)]。其中,D X为表示针对图像的判别器。 Specifically, the pseudo-real first pixel quality image can be expressed as I Z→X . Correspondingly, the third probability value may be expressed as log[1-D X (I Z→X )]. Among them, D X represents the discriminator for the image.
将真实第一像素质量图像输入至特征判别器中,得到特征判别器输出的第四概率值。第四概率值用于表示真实第一像素质量图像为真实场景下生成的较低像素质量图像的概率值。The real first pixel quality image is input into the feature discriminator, and the fourth probability value output by the feature discriminator is obtained. The fourth probability value is used to represent the probability value that the real first pixel quality image is a lower pixel quality image generated in a real scene.
具体的,真实第一像素质量图像可以表示为I X。对应的,第四概率值可以表示为logD X(I X)。 Specifically, the true first pixel quality image can be expressed as I X . Correspondingly, the fourth probability value may be expressed as logD X (I X ).
基于特征判别器输出的第三概率值和第四概率值,可以计算得到第二图像生成损失。Based on the third probability value and the fourth probability value output by the feature discriminator, the second image generation loss can be calculated.
在一种可能的实现方式中,第二图像损失L adv可以通过下式计算得到: In a possible implementation, the second image loss L adv can be calculated by the following formula:
L adv(I Z→X,I X)=E X[logD X(I X)]+E Z{log[1-D X(I Z→X)]}    (6) L adv (I Z→X ,I X )=E X [logD X (I X )]+E Z {log[1-D X (I Z→X )]} (6)
其中,E X[logD X(I X)]表示对计算得到的第四概率值所对应的期望值,E Z{log[1-D X(I Z→X)]}表示对计算得到的第三概率值所对应的期望值。通过计算针对第三概率值的期望与针对第四概率值的期望的和,得到第二图像损失。 Among them, E X [logD X (I X )] represents the expected value corresponding to the calculated fourth probability value, E Z {log[1-D X (I Z→X )]} represents the calculated third probability value The expected value corresponding to the probability value. The second image loss is obtained by computing the sum of the expectation for the third probability value and the expectation for the fourth probability value.
在本申请实施例中,通过特征判别器计算得到伪真实第一像素质量图像和真实第一像素质量图像所对应的概率值,再利用计算得到的概率值计算第二图像损失,得到的第二图像损失较为准确。通过特征判别器可以对由不同图像处理得到的图像,也就是不成对的图像进行约束。In the embodiment of the present application, the probability values corresponding to the pseudo-true first pixel quality image and the real first pixel quality image are calculated by the feature discriminator, and then the calculated probability value is used to calculate the second image loss, and the obtained second Image loss is more accurate. The images obtained by different image processing, that is, unpaired images, can be constrained by the feature discriminator.
在一种可能的实现方式中,本申请实施例提供的图像修复模型中,图像特征编码器包括至少一个残差模块;In a possible implementation, in the image inpainting model provided in the embodiment of the present application, the image feature encoder includes at least one residual module;
真实第一像素质量图像生成器包括至少一个残差模块;The true first pixel quality image generator includes at least one residual module;
真实第二像素质量图像生成器包括第一卷积层、基本单元、第二卷积层、上采样层、第三卷积层、激活函数层以及第四卷积层,基本单元包括至少一个RRDB(Residual-in-Residual Dense Block)单元。The real second pixel quality image generator includes a first convolutional layer, a basic unit, a second convolutional layer, an upsampling layer, a third convolutional layer, an activation function layer, and a fourth convolutional layer, and the basic unit includes at least one RRDB (Residual-in-Residual Dense Block) unit.
参见图7所示,该图为本申请实施例提供的一种图像特征编码器的结构示意图。在训练图像修复模型时,图像特征编码器是用于提取图像特征的,可以由多个残差模块组成。其中,每个残差模块可以由3*3的卷积层、激活函数层和3*3的卷积层组成。Referring to FIG. 7 , the figure is a schematic structural diagram of an image feature encoder provided by an embodiment of the present application. When training an image inpainting model, an image feature encoder is used to extract image features and can consist of multiple residual modules. Among them, each residual module can be composed of a 3*3 convolutional layer, an activation function layer, and a 3*3 convolutional layer.
真实第一像素质量图像生成器是用于辅助训练的,可以由多个残差模块组成。真实第一像素质量图像生成器的结构可以与图像特征编码器的结构一致,在此不再赘述。The real first pixel quality image generator is used for auxiliary training and can be composed of multiple residual modules. The structure of the real first pixel quality image generator may be consistent with the structure of the image feature encoder, which will not be repeated here.
参见图8所示,该图为本申请实施例提供的一种真实第二像素质量图像生成器的结构示意图。真实第二像素质量图像生成器是在训练完成后进行图像修复的,需要较为复杂的结构,实现较为准确的图像修复。真实第二像素质量图像生成器由第一卷积层、基本单元、第二卷积层、上采样层、第三卷积层、激活函数层以及第四卷积层组成。其中,第一卷积层和第四卷积层可以为1*1的卷积层,第二卷积层和第三卷积层可以为3*3的卷积层。激活函数层所使用的激活函数具体可以为LeakyRelu激活函数。Refer to FIG. 8 , which is a schematic structural diagram of a real second pixel quality image generator provided by an embodiment of the present application. The real second pixel quality image generator performs image restoration after the training is completed, and requires a more complex structure to achieve more accurate image restoration. The true second pixel quality image generator consists of the first convolutional layer, the basic unit, the second convolutional layer, the upsampling layer, the third convolutional layer, the activation function layer, and the fourth convolutional layer. Wherein, the first convolutional layer and the fourth convolutional layer may be 1*1 convolutional layers, and the second convolutional layer and the third convolutional layer may be 3*3 convolutional layers. The activation function used in the activation function layer may specifically be a LeakyRelu activation function.
其中,具体的,基本单元可以为多个RRDB单元。参见图9所示,该图为本申请实施例提供的一种RRDB单元的结构示意图。RRDB单元中包括五个模块,第一个模块为由一个3*3的卷积层和一个激活函数层组成的,第二个模块至第五个模块为由一个1*1的卷积层、一个3*3的卷积层和一个激活函数层组成的。RRDB单元中的激活函数层所使用的激活函数具体可以为LeakyRelu激活函数。Specifically, the basic unit may be multiple RRDB units. Referring to FIG. 9 , the figure is a schematic structural diagram of an RRDB unit provided by an embodiment of the present application. The RRDB unit includes five modules, the first module is composed of a 3*3 convolutional layer and an activation function layer, and the second to fifth modules are composed of a 1*1 convolutional layer, It consists of a 3*3 convolutional layer and an activation function layer. The activation function used by the activation function layer in the RRDB unit may specifically be a LeakyRelu activation function.
在本申请实施例中,通过采用较为简单的图像特征编码器和真实第一像素质量图像生成器的模型结构,采用较为复杂的真实第二像素质量图像生成器的 模型结构,可以在确保模型结构较为精简的前提下确保生成的图像修复模型的模型性能。In the embodiment of the present application, by adopting the relatively simple model structure of the image feature encoder and the real first pixel quality image generator, and the relatively complex model structure of the real second pixel quality image generator, the model structure can be ensured The model performance of the generated image inpainting model is guaranteed under the premise of being more streamlined.
基于上述实施例提供的一种图像修复模型的训练方法,本申请实施例还提供了一种图像修复方法。Based on the method for training an image inpainting model provided in the foregoing embodiments, an embodiment of the present application further provides an image inpainting method.
参见图10所示,该图为本申请实施例提供的一种图像修复方法的流程图,如图10所示,该方法可以包括S1001-S1002:Referring to Figure 10, which is a flow chart of an image restoration method provided in the embodiment of the present application, as shown in Figure 10, the method may include S1001-S1002:
S1001:将待修复第一像素质量图像输入图像特征编码器,得到目标图像特征。S1001: Input the first pixel quality image to be repaired into an image feature encoder to obtain target image features.
待修复第一像素质量图像是具有较低像素质量的图像,需要进行图像修复,得到对应的具有较高像素质量的图像。The image with the first pixel quality to be repaired is an image with a lower pixel quality, and needs to be repaired to obtain a corresponding image with a higher pixel quality.
将待修复第一像素质量图像输入至图像特征编码器中,对待修复第一像素质量图像的图像特征进行提取,得到对应的目标图像特征。The first pixel quality image to be repaired is input into the image feature encoder, and the image features of the first pixel quality image to be repaired are extracted to obtain corresponding target image features.
其中,图像特征编码器是根据上述图像修复模型训练方法训练生成的。通过上述图像修复模型训练方法训练生成的图像特征编码器可以更好地对待修复第一像素质量图像进行特征提取,从而实现更为准确地图像修复。Wherein, the image feature encoder is trained and generated according to the above image inpainting model training method. The image feature encoder trained by the above image inpainting model training method can better perform feature extraction on the first pixel quality image to be inpainted, so as to achieve more accurate image inpainting.
S1002:将目标图像特征输入真实第二像素质量图像生成器,得到修复后的第二像素质量图像。S1002: Input the features of the target image into a real second pixel quality image generator to obtain a repaired second pixel quality image.
图像特征编码器以及真实第二像素质量图像生成器是根据上述任一实施例的图像修复模型的训练方法训练得到的。The image feature encoder and the real second pixel quality image generator are obtained by training according to the training method of the image inpainting model in any of the above embodiments.
将得到的目标图像特征输入至真实第二像素质量图像生成器中。真实第二像素质量图像生成器是用于基于输入的目标图像特征生成对应的较高像素质量的图像,也就是修复后的第二像素质量图像。The resulting target image features are input into the real second pixel quality image generator. The real second pixel quality image generator is used to generate a corresponding higher pixel quality image based on the input target image features, that is, the repaired second pixel quality image.
真实第二像素质量图像生成器是通过上述图像修复模型训练方法训练生成的。通过上述图像修复模型训练方法训练生成的第二像素质量图像生成器可以基于目标图像特征,能够生成与待修复第一像素质量图像对应的,修复效果更好的修复后的第二像素质量图像。The real second pixel quality image generator is trained and generated by the above-mentioned image inpainting model training method. The generator of the second pixel quality image trained by the above image restoration model training method can generate a repaired second pixel quality image corresponding to the first pixel quality image to be repaired based on the characteristics of the target image, and has a better repair effect.
基于上述S1001-S1002的相关内容可知,通过训练好的图像特征编码器和真实第二像素质量图像生成器,可以更好地对待修复第一像素质量图像进行 图像修复,得到修复效果更好的修复后的第二像素质量图像,满足图像使用的需要。Based on the relevant content of S1001-S1002 above, it can be seen that through the trained image feature encoder and the real second pixel quality image generator, the image repair of the first pixel quality image to be repaired can be better performed, and a repair with better repair effect can be obtained. After the second pixel quality image, to meet the needs of image usage.
基于上述方法实施例提供的一种图像修复模型的训练方法,本申请实施例还提供了一种图像修复模型的训练装置,下面将结合附图对图像修复模型的训练装置进行说明。Based on the method for training an image restoration model provided by the method embodiment above, the embodiment of the present application also provides a training device for an image restoration model. The training device for an image restoration model will be described below with reference to the accompanying drawings.
参见图11所示,该图为本申请实施例提供的一种图像修复模型的训练装置的结构示意图。如图11所示,该图像修复模型的训练装置包括:Refer to FIG. 11 , which is a schematic structural diagram of a training device for an image inpainting model provided by an embodiment of the present application. As shown in Figure 11, the training device of this image restoration model includes:
第一执行单元1101,用于将真实第一像素质量图像输入图像特征编码器,得到第一图像特征;The first execution unit 1101 is configured to input the real first pixel quality image into the image feature encoder to obtain the first image feature;
第二执行单元1102,用于将人工合成第一像素质量图像输入所述图像特征编码器,得到第二图像特征;所述人工合成第一像素质量图像是由真实第二像素质量图像进行模糊处理得到的;The second execution unit 1102 is configured to input the artificially synthesized first pixel quality image into the image feature encoder to obtain the second image feature; the artificially synthesized first pixel quality image is blurred by the real second pixel quality image owned;
第三执行单元1103,用于将所述第一图像特征输入真实第一像素质量图像生成器,得到重新生成的真实第一像素质量图像;The third execution unit 1103 is configured to input the first image feature into a real first pixel quality image generator to obtain a regenerated real first pixel quality image;
第四执行单元1104,用于将所述第二图像特征输入所述真实第一像素质量图像生成器,得到伪真实第一像素质量图像;The fourth execution unit 1104 is configured to input the second image feature into the real first pixel quality image generator to obtain a pseudo-real first pixel quality image;
第五执行单元1105,用于将所述第二图像特征输入真实第二像素质量图像生成器,得到重建第二像素质量图像;The fifth execution unit 1105 is configured to input the second image feature into a real second pixel quality image generator to obtain a reconstructed second pixel quality image;
第一计算单元1106,用于根据所述第一图像特征以及所述第二图像特征计算域对齐损失;A first calculation unit 1106, configured to calculate a domain alignment loss according to the first image feature and the second image feature;
第二计算单元1107,用于根据所述重新生成的真实第一像素质量图像、所述伪真实第一像素质量图像以及所述真实第一像素质量图像计算图像生成损失;The second calculation unit 1107 is configured to calculate an image generation loss according to the regenerated real first pixel quality image, the pseudo real first pixel quality image and the real first pixel quality image;
第三计算单元1108,用于根据所述重建第二像素质量图像以及所述真实第二像素质量图像计算图像重建损失;A third calculation unit 1108, configured to calculate an image reconstruction loss according to the reconstructed second pixel quality image and the real second pixel quality image;
训练单元1109,用于根据所述域对齐损失、所述图像生成损失以及所述图像重建损失,训练所述图像特征编码器、所述真实第一像素质量图像生成器以及所述真实第二像素质量图像生成器,重复执行所述将真实第一像素质量图像输入图像特征编码器,得到第一图像特征以及后续步骤,直到达到预设条件;A training unit 1109, configured to train the image feature encoder, the real first pixel quality image generator and the real second pixel according to the domain alignment loss, the image generation loss and the image reconstruction loss The quality image generator repeatedly executes the steps of inputting the real first pixel quality image into the image feature encoder to obtain the first image feature and subsequent steps until the preset condition is reached;
其中,第一像素质量的图像清晰度低于第二像素质量的图像清晰度。Wherein, the image definition of the first pixel quality is lower than the image definition of the second pixel quality.
在一种可能的实现方式中,所述装置还包括:In a possible implementation manner, the device further includes:
第六执行单元,用于将所述伪真实第一像素质量图像输入所述图像特征编码器,得到第三图像特征;A sixth execution unit, configured to input the pseudo real first pixel quality image into the image feature encoder to obtain a third image feature;
第四计算单元,用于根据所述第二图像特征以及所述第三图像特征计算内容一致性损失;A fourth calculation unit, configured to calculate a content consistency loss according to the second image feature and the third image feature;
所述训练单元1109,具体用于所述根据所述域对齐损失、所述图像生成损失、所述图像重建损失以及所述内容一致性损失,训练所述图像特征编码器、所述真实第一像素质量图像生成器以及所述真实第二像素质量图像生成器。The training unit 1109 is specifically configured to train the image feature encoder, the real first A pixel quality image generator and said true second pixel quality image generator.
在一种可能的实现方式中,所述装置还包括:In a possible implementation manner, the device further includes:
第七执行单元,用于将所述第三图像特征输入所述真实第二像素质量图像生成器,得到伪真实重建第二像素质量图像;A seventh execution unit, configured to input the third image feature into the real second pixel quality image generator to obtain a pseudo-real reconstructed second pixel quality image;
所述第三计算单元1108,包括:The third calculation unit 1108 includes:
第一计算子单元,用于根据所述重建第二像素质量图像以及所述真实第二像素质量图像计算第一图像重建损失;A first calculation subunit, configured to calculate a first image reconstruction loss according to the reconstructed second pixel quality image and the real second pixel quality image;
第二计算子单元,用于根据所述伪真实重建第二像素质量图像以及所述真实第二像素质量图像计算第二图像重建损失;所述第一图像重建损失以及所述第二图像重建损失组成图像重建损失。A second calculation subunit, configured to calculate a second image reconstruction loss based on the pseudo real reconstructed second pixel quality image and the real second pixel quality image; the first image reconstruction loss and the second image reconstruction loss Compose the image reconstruction loss.
在一种可能的实现方式中,所述第二计算单元1107,包括:In a possible implementation manner, the second calculation unit 1107 includes:
第三计算子单元,用于根据所述重新生成的真实第一像素质量图像以及所述真实第一像素质量图像计算第一图像生成损失;A third calculation subunit, configured to calculate a first image generation loss according to the regenerated real first pixel quality image and the real first pixel quality image;
第四计算子单元,用于根据所述伪真实第一像素质量图像以及所述真实第一像素质量图像计算第二图像生成损失;所述第一图像生成损失以及所述第二图像生成损失组成图像生成损失。A fourth calculation subunit, configured to calculate a second image generation loss based on the pseudo-true first pixel quality image and the real first pixel quality image; the first image generation loss and the second image generation loss consist of Image generation loss.
在一种可能的实现方式中,所述第一计算单元1106,具体用于将所述第一图像特征输入特征判别器,得到第一概率值;In a possible implementation manner, the first calculation unit 1106 is specifically configured to input the first image feature into a feature discriminator to obtain a first probability value;
将所述第二图像特征输入所述特征判别器,得到第二概率值;inputting the second image feature into the feature discriminator to obtain a second probability value;
根据所述第一概率值以及所述第二概率值,计算域对齐损失。A domain alignment loss is calculated according to the first probability value and the second probability value.
在一种可能的实现方式中,所述第四计算单元,具体用于计算所述第二图 像特征以及所述第三图像特征之间的1-范数;In a possible implementation manner, the fourth calculation unit is specifically configured to calculate a 1-norm between the second image feature and the third image feature;
根据所述第二图像特征以及所述第三图像特征之间的1-范数,计算内容一致性损失。A content consistency loss is calculated according to a 1-norm between the second image feature and the third image feature.
在一种可能的实现方式中,所述第一计算子单元,具体用于计算所述重建第二像素质量图像以及所述真实第二像素质量图像之间的1-范数;In a possible implementation manner, the first calculation subunit is specifically configured to calculate a 1-norm between the reconstructed second pixel quality image and the real second pixel quality image;
根据所述重建第二像素质量图像以及所述真实第二像素质量图像之间的1-范数,计算第一图像重建损失。A first image reconstruction loss is calculated based on a 1-norm between the reconstructed second pixel quality image and the real second pixel quality image.
在一种可能的实现方式中,所述第二计算子单元,具体用于计算所述伪真实重建第二像素质量图像以及所述真实第二像素质量图像之间的1-范数;In a possible implementation manner, the second calculation subunit is specifically configured to calculate a 1-norm between the pseudo-real reconstructed second pixel quality image and the real second pixel quality image;
根据所述伪真实重建第二像素质量图像以及所述真实第二像素质量图像之间的1-范数,计算第二图像重建损失。A second image reconstruction loss is calculated based on a 1-norm between the pseudo real reconstructed second pixel quality image and the real second pixel quality image.
在一种可能的实现方式中,所述第三计算子单元,具体用于计算所述重新生成的真实第一像素质量图像以及所述真实第一像素质量图像之间的1-范数;In a possible implementation manner, the third calculation subunit is specifically configured to calculate a 1-norm between the regenerated real first pixel quality image and the real first pixel quality image;
根据所述重新生成的真实第一像素质量图像以及所述真实第一像素质量图像之间的1-范数,计算第一图像生成损失。A first image generation loss is calculated based on the regenerated real first pixel quality image and a 1-norm between the real first pixel quality image.
在一种可能的实现方式中,所述第四计算子单元,具体用于将所述伪真实第一像素质量图像输入特征判别器,得到第三概率值;In a possible implementation manner, the fourth calculation subunit is specifically configured to input the pseudo-real first pixel quality image into a feature discriminator to obtain a third probability value;
将所述真实第一像素质量图像输入所述特征判别器,得到第四概率值;inputting the real first pixel quality image into the feature discriminator to obtain a fourth probability value;
根据所述第三概率值和所述第四概率值,计算第二图像生成损失。A second image generation loss is calculated based on the third probability value and the fourth probability value.
在一种可能的实现方式中,所述图像特征编码器包括至少一个残差模块;In a possible implementation manner, the image feature encoder includes at least one residual module;
所述真实第一像素质量图像生成器包括至少一个残差模块;said true first pixel quality image generator comprising at least one residual module;
所述真实第二像素质量图像生成器包括第一卷积层、基本单元、第二卷积层、上采样层、第三卷积层、激活函数层以及第四卷积层,所述基本单元包括至少一个RRDB单元。The real second pixel quality image generator includes a first convolutional layer, a basic unit, a second convolutional layer, an upsampling layer, a third convolutional layer, an activation function layer, and a fourth convolutional layer, and the basic unit Include at least one RRDB unit.
基于上述方法实施例提供的一种图像修复方法,本申请实施例还提供了一种图像修复装置,下面将结合附图对图像修复装置进行说明。Based on the image restoration method provided by the foregoing method embodiments, the embodiment of the present application further provides an image restoration device, which will be described below with reference to the accompanying drawings.
参见图12所示,该图为本申请实施例提供的一种图像修复装置的结构示意图。如图12所示,该图像修复装置包括:Refer to FIG. 12 , which is a schematic structural diagram of an image restoration device provided by an embodiment of the present application. As shown in Figure 12, the image restoration device includes:
第八执行单元1201,用于将待修复第一像素质量图像输入图像特征编码 器,得到目标图像特征;The eighth execution unit 1201 is used to input the first pixel quality image to be repaired into the image feature encoder to obtain the target image feature;
第九执行单元1202,用于将所述目标图像特征输入真实第二像素质量图像生成器,得到修复后的第二像素质量图像;A ninth execution unit 1202, configured to input the features of the target image into a real second pixel quality image generator to obtain a repaired second pixel quality image;
所述图像特征编码器以及所述真实第二像素质量图像生成器是根据上述任一项实施例所述的图像修复模型的训练方法训练得到的。The image feature encoder and the real second pixel quality image generator are obtained through training according to the training method of the image inpainting model described in any one of the above embodiments.
基于上述方法实施例提供的一种图像修复模型的训练方法和图像修复方法,本申请还提供一种电子设备,包括:一个或多个处理器;存储装置,其上存储有一个或多个程序,当所述一个或多个程序被所述一个或多个处理器执行,使得所述一个或多个处理器实现上述任一实施例所述的图像修复模型的训练方法,或者上述任一实施例所述的图像修复方法Based on the image restoration model training method and the image restoration method provided by the above method embodiments, the present application also provides an electronic device, including: 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, so that the one or more processors implement the image restoration model training method described in any of the above embodiments, or any of the above implementations The image inpainting method described in the example
下面参考图13,其示出了适于用来实现本申请实施例的电子设备1300的结构示意图。本申请实施例中的终端设备可以包括但不限于诸如移动电话、笔记本电脑、数字广播接收器、PDA(Personal Digital Assistant,个人数字助理)、PAD(portable android device,平板电脑)、PMP(Portable Media Player,便携式多媒体播放器)、车载终端(例如车载导航终端)等等的移动终端以及诸如数字TV(television,电视机)、台式计算机等等的固定终端。图13示出的电子设备仅仅是一个示例,不应对本申请实施例的功能和使用范围带来任何限制。Referring now to FIG. 13 , it shows a schematic structural diagram of an electronic device 1300 suitable for implementing the embodiment of the present application. The terminal equipment in the embodiment of the present application may include but not limited to mobile phones, notebook computers, digital broadcast receivers, PDA (Personal Digital Assistant, personal digital assistant), PAD (portable android device, tablet computer), PMP (Portable Media Player, portable multimedia player), mobile terminals such as vehicle-mounted terminals (such as vehicle-mounted navigation terminals), and fixed terminals such as digital TVs (television, television sets), desktop computers, and the like. The electronic device shown in FIG. 13 is only an example, and should not limit the functions and scope of use of this embodiment of the present application.
如图13所示,电子设备1300可以包括处理装置(例如中央处理器、图形处理器等)1301,其可以根据存储在只读存储器(ROM)1302中的程序或者从存储装置1306加载到随机访问存储器(RAM)1303中的程序而执行各种适当的动作和处理。在RAM1303中,还存储有电子设备1300操作所需的各种程序和数据。处理装置1301、ROM 1302以及RAM 1303通过总线1304彼此相连。输入/输出(I/O)接口1305也连接至总线1304。As shown in FIG. 13, an electronic device 1300 may include a processing device (such as a central processing unit, a graphics processing unit, etc.) 1301, which may be randomly accessed according to a program stored in a read-only memory (ROM) 1302 or loaded from a storage device 1306. Various appropriate actions and processes are executed by programs in the memory (RAM) 1303 . In the RAM 1303, various programs and data necessary for the operation of the electronic device 1300 are also stored. The processing device 1301, ROM 1302, and RAM 1303 are connected to each other through a bus 1304. An input/output (I/O) interface 1305 is also connected to the bus 1304 .
通常,以下装置可以连接至I/O接口1305:包括例如触摸屏、触摸板、键盘、鼠标、摄像头、麦克风、加速度计、陀螺仪等的输入装置1306;包括例如液晶显示器(LCD)、扬声器、振动器等的输出装置1307;包括例如磁带、硬盘等的存储装置1306;以及通信装置1309。通信装置1309可以允许电子设备1300与其他设备进行无线或有线通信以交换数据。虽然图13示出了具有各 种装置的电子设备1300,但是应理解的是,并不要求实施或具备所有示出的装置。可以替代地实施或具备更多或更少的装置。Typically, the following devices can be connected to the I/O interface 1305: input devices 1306 including, for example, a touch screen, touchpad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; including, for example, a liquid crystal display (LCD), speaker, vibration an output device 1307 such as a computer; a storage device 1306 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 1309. The communication means 1309 may allow the electronic device 1300 to communicate with other devices wirelessly or by wire to exchange data. While FIG. 13 shows electronic device 1300 having various means, it is to be understood that implementing or having all of the means shown is not a requirement. More or fewer means may alternatively be implemented or provided.
特别地,根据本申请的实施例,上文参考流程图描述的过程可以被实现为计算机软件程序。例如,本申请的实施例包括一种计算机程序产品,其包括承载在非暂态计算机可读介质上的计算机程序,该计算机程序包含用于执行流程图所示的方法的程序代码。在这样的实施例中,该计算机程序可以通过通信装置1309从网络上被下载和安装,或者从存储装置1306被安装,或者从ROM1302被安装。在该计算机程序被处理装置1301执行时,执行本申请实施例的方法中限定的上述功能。In particular, according to the embodiments of the present application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, the embodiments of the present application include a computer program product, which includes a computer program carried on a non-transitory computer readable medium, where the computer program includes program code for executing the method shown in the flowchart. In such an embodiment, the computer program may be downloaded and installed from a network via communication means 1309 , or from storage means 1306 , or from ROM 1302 . When the computer program is executed by the processing device 1301, the above-mentioned functions defined in the method of the embodiment of the present application are performed.
本申请实施例提供的电子设备与上述实施例提供的图像修复模型的训练方法和图像修复方法属于同一发明构思,未在本实施例中详尽描述的技术细节可参见上述实施例,并且本实施例与上述实施例具有相同的有益效果。The electronic device provided by the embodiment of the present application belongs to the same inventive concept as the image repair model training method and the image repair method provided by the above-mentioned embodiment. For technical details not described in detail in this embodiment, please refer to the above-mentioned embodiment, and this embodiment It has the same beneficial effect as the above embodiment.
基于上述方法实施例提供的一种图像修复模型的训练方法和图像修复方法,本申请实施例提供一种计算机可读介质,其上存储有计算机程序,其中,所述程序被处理器执行时实现如上述任一实施例所述的图像修复模型的训练方法,或者上述任一实施例所述的图像修复方法。Based on the image restoration model training method and the image restoration method provided by the above method embodiments, the embodiment of the present application provides a computer-readable medium on which a computer program is stored, wherein the program is implemented when the program is executed by a processor. A method for training an image restoration model as described in any of the above embodiments, or an image restoration method as described in any of the above embodiments.
需要说明的是,本申请上述的计算机可读介质可以是计算机可读信号介质或者计算机可读存储介质或者是上述两者的任意组合。计算机可读存储介质例如可以是——但不限于——电、磁、光、电磁、红外线、或半导体的系统、装置或器件,或者任意以上的组合。计算机可读存储介质的更具体的例子可以包括但不限于:具有一个或多个导线的电连接、便携式计算机磁盘、硬盘、随机访问存储器(RAM)、只读存储器(ROM)、可擦式可编程只读存储器(EPROM或闪存)、光纤、便携式紧凑磁盘只读存储器(CD-ROM)、光存储器件、磁存储器件、或者上述的任意合适的组合。在本申请中,计算机可读存储介质可以是任何包含或存储程序的有形介质,该程序可以被指令执行系统、装置或者器件使用或者与其结合使用。而在本申请中,计算机可读信号介质可以包括在基带中或者作为载波一部分传播的数据信号,其中承载了计算机可读的程序代码。这种传播的数据信号可以采用多种形式,包括但不限于电磁信号、光信号或上述的任意合适的组合。计算机可读信号介质还可以是计算机可读存储介 质以外的任何计算机可读介质,该计算机可读信号介质可以发送、传播或者传输用于由指令执行系统、装置或者器件使用或者与其结合使用的程序。计算机可读介质上包含的程序代码可以用任何适当的介质传输,包括但不限于:电线、光缆、RF(射频)等等,或者上述的任意合适的组合。It should be noted that the computer-readable medium mentioned above in this application may be a computer-readable signal medium or a computer-readable storage medium, or any combination of the above two. 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 computer-readable storage media may include, but are not limited to, electrical connections with one or more wires, portable computer diskettes, hard disks, 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 of the above. In the present application, a computer-readable storage medium may be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In this application, however, 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 therein. Such propagated data signals may take many forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the foregoing. The computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium, and the computer-readable signal medium may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device . Program code embodied on a computer readable medium may be transmitted by any appropriate medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
在一些实施方式中,客户端、服务器可以利用诸如HTTP(HyperText Transfer Protocol,超文本传输协议)之类的任何当前已知或未来研发的网络协议进行通信,并且可以与任意形式或介质的数字数据通信(例如,通信网络)互连。通信网络的示例包括局域网(“LAN”),广域网(“WAN”),网际网(例如,互联网)以及端对端网络(例如,ad hoc端对端网络),以及任何当前已知或未来研发的网络。In some embodiments, the client and the server can communicate using any currently known or future network protocols such as HTTP (HyperText Transfer Protocol, Hypertext Transfer Protocol), and can communicate with digital data in any form or medium The communication (eg, communication network) interconnections. Examples of communication networks include local area networks ("LANs"), wide area networks ("WANs"), internetworks (e.g., the Internet), and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any currently known or future developed network of.
上述计算机可读介质可以是上述电子设备中所包含的;也可以是单独存在,而未装配入该电子设备中。The above-mentioned computer-readable medium may be included in the above-mentioned electronic device, or may exist independently without being incorporated into the electronic device.
上述计算机可读介质承载有一个或者多个程序,当上述一个或者多个程序被该电子设备执行时,使得该电子设备执行上述图像修复模型的训练方法或图像修复方法。The above-mentioned computer-readable medium carries one or more programs, and when the above-mentioned one or more programs are executed by the electronic device, the electronic device is made to execute the above-mentioned image restoration model training method or image restoration method.
可以以一种或多种程序设计语言或其组合来编写用于执行本申请的操作的计算机程序代码,上述程序设计语言包括但不限于面向对象的程序设计语言—诸如Java、Smalltalk、C++,还包括常规的过程式程序设计语言—诸如“C”语言或类似的程序设计语言。程序代码可以完全地在用户计算机上执行、部分地在用户计算机上执行、作为一个独立的软件包执行、部分在用户计算机上部分在远程计算机上执行、或者完全在远程计算机或服务器上执行。在涉及远程计算机的情形中,远程计算机可以通过任意种类的网络——包括局域网(LAN)或广域网(WAN)—连接到用户计算机,或者,可以连接到外部计算机(例如利用因特网服务提供商来通过因特网连接)。Computer program code for carrying out the operations of this application may be written in one or more programming languages, or combinations thereof, including but not limited to object-oriented programming languages—such as Java, Smalltalk, C++, and Includes conventional procedural programming languages - such as the "C" language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In cases involving a remote computer, the remote computer can be connected to the user computer through any kind of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computer (such as through an Internet service provider). Internet connection).
附图中的流程图和框图,图示了按照本申请各种实施例的系统、方法和计算机程序产品的可能实现的体系架构、功能和操作。在这点上,流程图或框图中的每个方框可以代表一个模块、程序段、或代码的一部分,该模块、程序段、或代码的一部分包含一个或多个用于实现规定的逻辑功能的可执行指令。也应当注意,在有些作为替换的实现中,方框中所标注的功能也可以以不同于附图 中所标注的顺序发生。例如,两个接连地表示的方框实际上可以基本并行地执行,它们有时也可以按相反的顺序执行,这依所涉及的功能而定。也要注意的是,框图和/或流程图中的每个方框、以及框图和/或流程图中的方框的组合,可以用执行规定的功能或操作的专用的基于硬件的系统来实现,或者可以用专用硬件与计算机指令的组合来实现。The flowchart and block diagrams in the Figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present application. In this regard, each block in a flowchart or block diagram may represent a module, program segment, or portion of code that contains one or more logical functions for implementing specified executable instructions. It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or they may sometimes be executed in the reverse order, depending upon the functionality involved. It should also be noted that each block of the block diagrams and/or flowchart illustrations, and combinations of blocks in the block diagrams and/or flowchart illustrations, can be implemented by a dedicated hardware-based system that performs the specified functions or operations , or may be implemented by a combination of dedicated hardware and computer instructions.
描述于本申请实施例中所涉及到的单元可以通过软件的方式实现,也可以通过硬件的方式来实现。其中,单元/模块的名称在某种情况下并不构成对该单元本身的限定,例如,语音数据采集模块还可以被描述为“数据采集模块”。The units involved in the embodiments described in the present application may be implemented by means of software or by means of hardware. Wherein, the name of the unit/module does not constitute a limitation on the unit itself under certain circumstances, for example, the voice data collection module can also be described as a "data collection module".
本文中以上描述的功能可以至少部分地由一个或多个硬件逻辑部件来执行。例如,非限制性地,可以使用的示范类型的硬件逻辑部件包括:现场可编程门阵列(FPGA)、专用集成电路(ASIC)、专用标准产品(ASSP)、片上系统(SOC)、复杂可编程逻辑设备(CPLD)等等。The functions described herein above 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), System on Chips (SOCs), Complex Programmable Logical device (CPLD) and so on.
在本申请的上下文中,机器可读介质可以是有形的介质,其可以包含或存储以供指令执行系统、装置或设备使用或与指令执行系统、装置或设备结合地使用的程序。机器可读介质可以是机器可读信号介质或机器可读储存介质。机器可读介质可以包括但不限于电子的、磁性的、光学的、电磁的、红外的、或半导体系统、装置或设备,或者上述内容的任何合适组合。机器可读存储介质的更具体示例会包括基于一个或多个线的电气连接、便携式计算机盘、硬盘、随机存取存储器(RAM)、只读存储器(ROM)、可擦除可编程只读存储器(EPROM或快闪存储器)、光纤、便捷式紧凑盘只读存储器(CD-ROM)、光学储存设备、磁储存设备、或上述内容的任何合适组合。In the context of the present application, 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, apparatus, or device. 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, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media would include one or more wire-based electrical connections, portable computer discs, hard drives, random access memory (RAM), read only memory (ROM), erasable programmable read only memory (EPROM or flash memory), optical fiber, compact disk read only memory (CD-ROM), optical storage, magnetic storage, or any suitable combination of the foregoing.
根据本申请的一个或多个实施例,【示例一】提供了一种图像修复模型的训练方法,所述方法包括:According to one or more embodiments of the present application, [Example 1] provides a method for training an image repair model, the method comprising:
将真实第一像素质量图像输入图像特征编码器,得到第一图像特征;Inputting the real first pixel quality image into the image feature encoder to obtain the first image feature;
将人工合成第一像素质量图像输入所述图像特征编码器,得到第二图像特征;所述人工合成第一像素质量图像是由真实第二像素质量图像进行模糊处理得到的;Inputting the artificially synthesized first pixel quality image into the image feature encoder to obtain the second image feature; the artificially synthesized first pixel quality image is obtained by blurring the real second pixel quality image;
将所述第一图像特征输入真实第一像素质量图像生成器,得到重新生成的真实第一像素质量图像;Inputting the first image feature into a real first pixel quality image generator to obtain a regenerated real first pixel quality image;
将所述第二图像特征输入所述真实第一像素质量图像生成器,得到伪真实第一像素质量图像;Inputting the second image feature into the real first pixel quality image generator to obtain a pseudo-true first pixel quality image;
将所述第二图像特征输入真实第二像素质量图像生成器,得到重建第二像素质量图像;Inputting the second image feature into a real second pixel quality image generator to obtain a reconstructed second pixel quality image;
根据所述第一图像特征以及所述第二图像特征计算域对齐损失;calculating a domain alignment loss based on the first image feature and the second image feature;
根据所述重新生成的真实第一像素质量图像、所述伪真实第一像素质量图像以及所述真实第一像素质量图像计算图像生成损失;calculating an image generation loss based on the regenerated true first pixel quality image, the pseudo true first pixel quality image, and the true first pixel quality image;
根据所述重建第二像素质量图像以及所述真实第二像素质量图像计算图像重建损失;calculating an image reconstruction loss based on the reconstructed second pixel quality image and the true second pixel quality image;
根据所述域对齐损失、所述图像生成损失以及所述图像重建损失,训练所述图像特征编码器、所述真实第一像素质量图像生成器以及所述真实第二像素质量图像生成器,重复执行所述将真实第一像素质量图像输入图像特征编码器,得到第一图像特征以及后续步骤,直到达到预设条件;Train the image feature encoder, the true first pixel quality image generator, and the true second pixel quality image generator based on the domain alignment loss, the image generation loss, and the image reconstruction loss, repeating Execute said inputting the real first pixel quality image into the image feature encoder to obtain the first image feature and subsequent steps until reaching the preset condition;
其中,第一像素质量的图像清晰度低于第二像素质量的图像清晰度。Wherein, the image definition of the first pixel quality is lower than the image definition of the second pixel quality.
根据本申请的一个或多个实施例,【示例二】提供了一种图像修复模型的训练方法,所述方法还包括:According to one or more embodiments of the present application, [Example 2] provides a training method for an image repair model, the method further includes:
将所述伪真实第一像素质量图像输入所述图像特征编码器,得到第三图像特征;Inputting the pseudo real first pixel quality image into the image feature encoder to obtain a third image feature;
根据所述第二图像特征以及所述第三图像特征计算内容一致性损失;calculating a content consistency loss based on the second image feature and the third image feature;
所述根据所述域对齐损失、所述图像生成损失以及所述图像重建损失,训练所述图像特征编码器、所述真实第一像素质量图像生成器以及所述真实第二像素质量图像生成器,包括:said training said image feature encoder, said true first pixel quality image generator, and said true second pixel quality image generator based on said domain alignment loss, said image generation loss, and said image reconstruction loss ,include:
所述根据所述域对齐损失、所述图像生成损失、所述图像重建损失以及所述内容一致性损失,训练所述图像特征编码器、所述真实第一像素质量图像生成器以及所述真实第二像素质量图像生成器。The image feature encoder, the true first pixel quality image generator, and the true Second pixel quality image generator.
根据本申请的一个或多个实施例,【示例三】提供了一种图像修复模型的训练方法,所述方法还包括:According to one or more embodiments of the present application, [Example 3] provides a training method for an image repair model, and the method further includes:
将所述第三图像特征输入所述真实第二像素质量图像生成器,得到伪真实重建第二像素质量图像;Inputting the third image feature into the real second pixel quality image generator to obtain a pseudo-real reconstructed second pixel quality image;
所述根据所述重建第二像素质量图像以及所述真实第二像素质量图像计算图像重建损失,包括:The calculating an image reconstruction loss according to the reconstructed second pixel quality image and the real second pixel quality image includes:
根据所述重建第二像素质量图像以及所述真实第二像素质量图像计算第一图像重建损失;calculating a first image reconstruction loss based on the reconstructed second pixel quality image and the true second pixel quality image;
根据所述伪真实重建第二像素质量图像以及所述真实第二像素质量图像计算第二图像重建损失;所述第一图像重建损失以及所述第二图像重建损失组成图像重建损失。calculating a second image reconstruction loss based on the pseudo real reconstructed second pixel quality image and the real second pixel quality image; the first image reconstruction loss and the second image reconstruction loss constitute an image reconstruction loss.
根据本申请的一个或多个实施例,【示例四】提供了一种图像修复模型的训练方法,所述根据所述重新生成的真实第一像素质量图像、所述伪真实第一像素质量图像以及所述真实第一像素质量图像计算图像生成损失,包括:According to one or more embodiments of the present application, [Example 4] provides a training method for an image inpainting model, according to the regenerated real first pixel quality image, the pseudo real first pixel quality image and calculating an image generation loss for the true first pixel quality image, comprising:
根据所述重新生成的真实第一像素质量图像以及所述真实第一像素质量图像计算第一图像生成损失;calculating a first image generation loss based on the regenerated true first pixel quality image and the true first pixel quality image;
根据所述伪真实第一像素质量图像以及所述真实第一像素质量图像计算第二图像生成损失;所述第一图像生成损失以及所述第二图像生成损失组成图像生成损失。A second image generation loss is calculated from the pseudo-true first pixel quality image and the real first pixel quality image; the first image generation loss and the second image generation loss constitute an image generation loss.
根据本申请的一个或多个实施例,【示例五】提供了一种图像修复模型的训练方法,所述根据所述第一图像特征以及所述第二图像特征计算域对齐损失,包括:According to one or more embodiments of the present application, [Example 5] provides a training method for an image inpainting model, wherein the domain alignment loss is calculated according to the first image feature and the second image feature, including:
将所述第一图像特征输入特征判别器,得到第一概率值;Inputting the first image feature into a feature discriminator to obtain a first probability value;
将所述第二图像特征输入所述特征判别器,得到第二概率值;inputting the second image feature into the feature discriminator to obtain a second probability value;
根据所述第一概率值以及所述第二概率值,计算域对齐损失。A domain alignment loss is calculated according to the first probability value and the second probability value.
根据本申请的一个或多个实施例,【示例六】提供了一种图像修复模型的训练方法,所述根据所述第二图像特征以及所述第三图像特征计算内容一致性损失,包括:According to one or more embodiments of the present application, [Example 6] provides a training method for an image inpainting model, wherein the calculation of the content consistency loss according to the second image feature and the third image feature includes:
计算所述第二图像特征以及所述第三图像特征之间的1-范数;calculating a 1-norm between the second image feature and the third image feature;
根据所述第二图像特征以及所述第三图像特征之间的1-范数,计算内容一致性损失。A content consistency loss is calculated according to a 1-norm between the second image feature and the third image feature.
根据本申请的一个或多个实施例,【示例七】提供了一种图像修复模型的训练方法,所述根据所述重建第二像素质量图像以及所述真实第二像素质量图 像计算第一图像重建损失,包括:According to one or more embodiments of the present application, [Example 7] provides an image restoration model training method, the first image is calculated according to the reconstructed second pixel quality image and the real second pixel quality image Reconstruction losses, including:
计算所述重建第二像素质量图像以及所述真实第二像素质量图像之间的1-范数;calculating a 1-norm between the reconstructed second pixel quality image and the true second pixel quality image;
根据所述重建第二像素质量图像以及所述真实第二像素质量图像之间的1-范数,计算第一图像重建损失。A first image reconstruction loss is calculated based on a 1-norm between the reconstructed second pixel quality image and the real second pixel quality image.
根据本申请的一个或多个实施例,【示例八】提供了一种图像修复模型的训练方法,所述根据所述伪真实重建第二像素质量图像以及所述真实第二像素质量图像计算第二图像重建损失,包括:According to one or more embodiments of the present application, [Example 8] provides a training method for an image inpainting model, the second pixel quality image is reconstructed according to the pseudo-truth and the second pixel quality image is calculated according to the real second pixel quality image Two image reconstruction losses, including:
计算所述伪真实重建第二像素质量图像以及所述真实第二像素质量图像之间的1-范数;calculating a 1-norm between the pseudo real reconstructed second pixel quality image and the real second pixel quality image;
根据所述伪真实重建第二像素质量图像以及所述真实第二像素质量图像之间的1-范数,计算第二图像重建损失。A second image reconstruction loss is calculated based on a 1-norm between the pseudo real reconstructed second pixel quality image and the real second pixel quality image.
根据本申请的一个或多个实施例,【示例九】提供了一种图像修复模型的训练方法,所述根据所述重新生成的真实第一像素质量图像以及所述真实第一像素质量图像计算第一图像生成损失,包括:According to one or more embodiments of the present application, [Example 9] provides a training method for an image inpainting model, the calculation based on the regenerated real first pixel quality image and the real first pixel quality image The first image generation loss consists of:
计算所述重新生成的真实第一像素质量图像以及所述真实第一像素质量图像之间的1-范数;calculating a 1-norm between said regenerated true first pixel quality image and said true first pixel quality image;
根据所述重新生成的真实第一像素质量图像以及所述真实第一像素质量图像之间的1-范数,计算第一图像生成损失。A first image generation loss is calculated based on the regenerated real first pixel quality image and a 1-norm between the real first pixel quality image.
根据本申请的一个或多个实施例,【示例十】提供了一种图像修复模型的训练方法,所述根据所述伪真实第一像素质量图像以及所述真实第一像素质量图像计算第二图像生成损失,包括:According to one or more embodiments of the present application, [Example 10] provides a training method for an image inpainting model, wherein the calculation of the second Image generation loss, including:
将所述伪真实第一像素质量图像输入特征判别器,得到第三概率值;Inputting the pseudo real first pixel quality image into a feature discriminator to obtain a third probability value;
将所述真实第一像素质量图像输入所述特征判别器,得到第四概率值;inputting the real first pixel quality image into the feature discriminator to obtain a fourth probability value;
根据所述第三概率值和所述第四概率值,计算第二图像生成损失。A second image generation loss is calculated based on the third probability value and the fourth probability value.
根据本申请的一个或多个实施例,【示例十一】提供了一种图像修复模型的训练方法,所述图像特征编码器包括至少一个残差模块;According to one or more embodiments of the present application, [Example 11] provides a training method for an image inpainting model, the image feature encoder includes at least one residual module;
所述真实第一像素质量图像生成器包括至少一个残差模块;said true first pixel quality image generator comprising at least one residual module;
所述真实第二像素质量图像生成器包括第一卷积层、基本单元、第二卷积 层、上采样层、第三卷积层、激活函数层以及第四卷积层,所述基本单元包括至少一个RRDB单元。The real second pixel quality image generator includes a first convolutional layer, a basic unit, a second convolutional layer, an upsampling layer, a third convolutional layer, an activation function layer, and a fourth convolutional layer, and the basic unit Include at least one RRDB unit.
根据本申请的一个或多个实施例,【示例十二】提供了一种图像修复方法,所述方法包括:According to one or more embodiments of the present application, [Example 12] provides an image restoration method, the method comprising:
将待修复第一像素质量图像输入图像特征编码器,得到目标图像特征;Input the first pixel quality image to be repaired into the image feature encoder to obtain the target image feature;
将所述目标图像特征输入真实第二像素质量图像生成器,得到修复后的第二像素质量图像;The target image feature is input into a real second pixel quality image generator to obtain a repaired second pixel quality image;
所述图像特征编码器以及所述真实第二像素质量图像生成器是根据上述任一示例所述的图像修复模型的训练方法训练得到的。The image feature encoder and the real second pixel quality image generator are obtained by training according to the image restoration model training method described in any of the above examples.
根据本申请的一个或多个实施例,【示例十三】提供了一种图像修复模型的训练装置,所述装置包括:According to one or more embodiments of the present application, [Example 13] provides a training device for an image restoration model, the device comprising:
第一执行单元,用于将真实第一像素质量图像输入图像特征编码器,得到第一图像特征;The first execution unit is used to input the real first pixel quality image into the image feature encoder to obtain the first image feature;
第二执行单元,用于将人工合成第一像素质量图像输入所述图像特征编码器,得到第二图像特征;所述人工合成第一像素质量图像是由真实第二像素质量图像进行模糊处理得到的;The second execution unit is configured to input the artificially synthesized first pixel quality image into the image feature encoder to obtain the second image feature; the artificially synthesized first pixel quality image is obtained by blurring the real second pixel quality image of;
第三执行单元,用于将所述第一图像特征输入真实第一像素质量图像生成器,得到重新生成的真实第一像素质量图像;A third execution unit, configured to input the first image feature into a real first pixel quality image generator to obtain a regenerated real first pixel quality image;
第四执行单元,用于将所述第二图像特征输入所述真实第一像素质量图像生成器,得到伪真实第一像素质量图像;A fourth execution unit, configured to input the second image feature into the real first pixel quality image generator to obtain a pseudo-real first pixel quality image;
第五执行单元,用于将所述第二图像特征输入真实第二像素质量图像生成器,得到重建第二像素质量图像;The fifth execution unit is configured to input the second image feature into the real second pixel quality image generator to obtain a reconstructed second pixel quality image;
第一计算单元,用于根据所述第一图像特征以及所述第二图像特征计算域对齐损失;A first calculation unit, configured to calculate a domain alignment loss according to the first image feature and the second image feature;
第二计算单元,用于根据所述重新生成的真实第一像素质量图像、所述伪真实第一像素质量图像以及所述真实第一像素质量图像计算图像生成损失;A second calculation unit, configured to calculate an image generation loss based on the regenerated real first pixel quality image, the pseudo real first pixel quality image, and the real first pixel quality image;
第三计算单元,用于根据所述重建第二像素质量图像以及所述真实第二像素质量图像计算图像重建损失;A third calculation unit, configured to calculate an image reconstruction loss according to the reconstructed second pixel quality image and the real second pixel quality image;
训练单元,用于根据所述域对齐损失、所述图像生成损失以及所述图像重 建损失,训练所述图像特征编码器、所述真实第一像素质量图像生成器以及所述真实第二像素质量图像生成器,重复执行所述将真实第一像素质量图像输入图像特征编码器,得到第一图像特征以及后续步骤,直到达到预设条件;a training unit for training the image feature encoder, the true first pixel quality image generator, and the true second pixel quality based on the domain alignment loss, the image generation loss, and the image reconstruction loss The image generator repeatedly executes the steps of inputting the real first pixel quality image into the image feature encoder to obtain the first image feature and subsequent steps until the preset condition is reached;
其中,第一像素质量的图像清晰度低于第二像素质量的图像清晰度。Wherein, the image definition of the first pixel quality is lower than the image definition of the second pixel quality.
根据本申请的一个或多个实施例,【示例十四】提供了一种图像修复模型的训练装置,所述装置还包括:According to one or more embodiments of the present application, [Example Fourteen] provides a training device for an image repair model, the device further comprising:
第六执行单元,用于将所述伪真实第一像素质量图像输入所述图像特征编码器,得到第三图像特征;A sixth execution unit, configured to input the pseudo real first pixel quality image into the image feature encoder to obtain a third image feature;
第四计算单元,用于根据所述第二图像特征以及所述第三图像特征计算内容一致性损失;A fourth calculation unit, configured to calculate a content consistency loss according to the second image feature and the third image feature;
所述训练单元,具体用于所述根据所述域对齐损失、所述图像生成损失、所述图像重建损失以及所述内容一致性损失,训练所述图像特征编码器、所述真实第一像素质量图像生成器以及所述真实第二像素质量图像生成器。The training unit is specifically configured to train the image feature encoder, the real first pixel according to the domain alignment loss, the image generation loss, the image reconstruction loss, and the content consistency loss quality image generator and said true second pixel quality image generator.
根据本申请的一个或多个实施例,【示例十五】提供了一种图像修复模型的训练装置,,所述装置还包括:According to one or more embodiments of the present application, [Example 15] provides a training device for an image inpainting model, and the device further includes:
第七执行单元,用于将所述第三图像特征输入所述真实第二像素质量图像生成器,得到伪真实重建第二像素质量图像;A seventh execution unit, configured to input the third image feature into the real second pixel quality image generator to obtain a pseudo-real reconstructed second pixel quality image;
所述第三计算单元,包括:The third calculation unit includes:
第一计算子单元,用于根据所述重建第二像素质量图像以及所述真实第二像素质量图像计算第一图像重建损失;A first calculation subunit, configured to calculate a first image reconstruction loss according to the reconstructed second pixel quality image and the real second pixel quality image;
第二计算子单元,用于根据所述伪真实重建第二像素质量图像以及所述真实第二像素质量图像计算第二图像重建损失;所述第一图像重建损失以及所述第二图像重建损失组成图像重建损失。A second calculation subunit, configured to calculate a second image reconstruction loss based on the pseudo real reconstructed second pixel quality image and the real second pixel quality image; the first image reconstruction loss and the second image reconstruction loss Compose the image reconstruction loss.
根据本申请的一个或多个实施例,【示例十六】提供了一种图像修复模型的训练装置,所述第二计算单元,包括:According to one or more embodiments of the present application, [Example 16] provides a training device for an image inpainting model, and the second calculation unit includes:
第三计算子单元,用于根据所述重新生成的真实第一像素质量图像以及所述真实第一像素质量图像计算第一图像生成损失;A third calculation subunit, configured to calculate a first image generation loss according to the regenerated real first pixel quality image and the real first pixel quality image;
第四计算子单元,用于根据所述伪真实第一像素质量图像以及所述真实第一像素质量图像计算第二图像生成损失;所述第一图像生成损失以及所述第二 图像生成损失组成图像生成损失。A fourth calculation subunit, configured to calculate a second image generation loss based on the pseudo-true first pixel quality image and the real first pixel quality image; the first image generation loss and the second image generation loss consist of Image generation loss.
根据本申请的一个或多个实施例,【示例十七】提供了一种图像修复模型的训练装置,所述第一计算单元,具体用于将所述第一图像特征输入特征判别器,得到第一概率值;According to one or more embodiments of the present application, [Example 17] provides a training device for an image inpainting model, the first computing unit is specifically configured to input the first image feature into a feature discriminator to obtain first probability value;
将所述第二图像特征输入所述特征判别器,得到第二概率值;inputting the second image feature into the feature discriminator to obtain a second probability value;
根据所述第一概率值以及所述第二概率值,计算域对齐损失。A domain alignment loss is calculated according to the first probability value and the second probability value.
根据本申请的一个或多个实施例,【示例十八】提供了一种图像修复模型的训练装置,所述第四计算单元,具体用于计算所述第二图像特征以及所述第三图像特征之间的1-范数;According to one or more embodiments of the present application, [Example 18] provides an image restoration model training device, the fourth calculation unit is specifically used to calculate the second image features and the third image 1-norm between features;
根据所述第二图像特征以及所述第三图像特征之间的1-范数,计算内容一致性损失。A content consistency loss is calculated according to a 1-norm between the second image feature and the third image feature.
根据本申请的一个或多个实施例,【示例十九】提供了一种图像修复模型的训练装置,所述第一计算子单元,具体用于计算所述重建第二像素质量图像以及所述真实第二像素质量图像之间的1-范数;According to one or more embodiments of the present application, [Example 19] provides an image restoration model training device, the first calculation subunit is specifically used to calculate the reconstructed second pixel quality image and the 1-norm between real second pixel quality images;
根据所述重建第二像素质量图像以及所述真实第二像素质量图像之间的1-范数,计算第一图像重建损失。A first image reconstruction loss is calculated based on a 1-norm between the reconstructed second pixel quality image and the real second pixel quality image.
根据本申请的一个或多个实施例,【示例二十】提供了一种图像修复模型的训练装置,所述第二计算子单元,具体用于计算所述伪真实重建第二像素质量图像以及所述真实第二像素质量图像之间的1-范数;According to one or more embodiments of the present application, [Example 20] provides a training device for an image inpainting model, and the second calculation subunit is specifically used to calculate the pseudo-real reconstructed second pixel-quality image and a 1-norm between said true second pixel quality images;
根据所述伪真实重建第二像素质量图像以及所述真实第二像素质量图像之间的1-范数,计算第二图像重建损失。A second image reconstruction loss is calculated based on a 1-norm between the pseudo real reconstructed second pixel quality image and the real second pixel quality image.
根据本申请的一个或多个实施例,【示例二十一】提供了一种图像修复模型的训练装置,所述第三计算子单元,具体用于计算所述重新生成的真实第一像素质量图像以及所述真实第一像素质量图像之间的1-范数;According to one or more embodiments of the present application, [Example 21] provides a training device for an image inpainting model, and the third calculation subunit is specifically configured to calculate the regenerated real first pixel quality a 1-norm between the image and said true first pixel quality image;
根据所述重新生成的真实第一像素质量图像以及所述真实第一像素质量图像之间的1-范数,计算第一图像生成损失。A first image generation loss is calculated based on the regenerated real first pixel quality image and a 1-norm between the real first pixel quality image.
根据本申请的一个或多个实施例,【示例二十二】提供了一种图像修复模型的训练装置,所述第四计算子单元,具体用于将所述伪真实第一像素质量图像输入特征判别器,得到第三概率值;According to one or more embodiments of the present application, [Example 22] provides a training device for an image inpainting model, the fourth calculation subunit is specifically configured to input the pseudo-real first pixel quality image A feature discriminator to obtain a third probability value;
将所述真实第一像素质量图像输入所述特征判别器,得到第四概率值;inputting the real first pixel quality image into the feature discriminator to obtain a fourth probability value;
根据所述第三概率值和所述第四概率值,计算第二图像生成损失。A second image generation loss is calculated based on the third probability value and the fourth probability value.
根据本申请的一个或多个实施例,【示例二十三】提供了一种图像修复模型的训练装置,所述图像特征编码器包括至少一个残差模块;According to one or more embodiments of the present application, [Example 23] provides an image inpainting model training device, the image feature encoder includes at least one residual module;
所述真实第一像素质量图像生成器包括至少一个残差模块;said true first pixel quality image generator comprising at least one residual module;
所述真实第二像素质量图像生成器包括第一卷积层、基本单元、第二卷积层、上采样层、第三卷积层、激活函数层以及第四卷积层,所述基本单元包括至少一个RRDB单元。The real second pixel quality image generator includes a first convolutional layer, a basic unit, a second convolutional layer, an upsampling layer, a third convolutional layer, an activation function layer, and a fourth convolutional layer, and the basic unit Include at least one RRDB unit.
根据本申请的一个或多个实施例,【示例二十四】提供了一种图像修复装置,所述装置包括:According to one or more embodiments of the present application, [Example 24] provides an image restoration device, the device comprising:
第八执行单元,用于将待修复第一像素质量图像输入图像特征编码器,得到目标图像特征;The eighth execution unit is used to input the first pixel quality image to be repaired into the image feature encoder to obtain the target image feature;
第九执行单元,用于将所述目标图像特征输入真实第二像素质量图像生成器,得到修复后的第二像素质量图像;A ninth execution unit, configured to input the features of the target image into a real second pixel quality image generator to obtain a repaired second pixel quality image;
所述图像特征编码器以及所述真实第二像素质量图像生成器是根据上述任一项示例所述的图像修复模型的训练方法训练得到的。The image feature encoder and the real second pixel quality image generator are obtained by training according to the image restoration model training method described in any one of the above examples.
根据本申请的一个或多个实施例,【示例二十五】提供了一种电子设备,包括:According to one or more embodiments of the present application, [Example 25] provides an electronic device, including:
一个或多个处理器;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, so that the one or more processors implement the image restoration model training method as described in any of the above examples, or [Example 12] The image restoration method described above.
根据本申请的一个或多个实施例,【示例二十六】提供了一种计算机可读介质,其上存储有计算机程序,其中,所述程序被处理器执行时实现如上述任一示例所述的图像修复模型的训练方法,或者【示例十二】所述的图像修复方法。According to one or more embodiments of the present application, [Example 26] provides a computer-readable medium, on which a computer program is stored, wherein, when the program is executed by a processor, any of the above-mentioned examples can be implemented. The training method of the image restoration model described above, or the image restoration method described in [Example 12].
以上描述仅为本申请的较佳实施例以及对所运用技术原理的说明。本领域技术人员应当理解,本申请中所涉及的公开范围,并不限于上述技术特征的特 定组合而成的技术方案,同时也应涵盖在不脱离上述公开构思的情况下,由上述技术特征或其等同特征进行任意组合而形成的其它技术方案。例如上述特征与本申请中公开的(但不限于)具有类似功能的技术特征进行互相替换而形成的技术方案。The above description is only a preferred embodiment of the present application and an illustration of the applied technical principle. Those skilled in the art should understand that the scope of disclosure involved in this application is not limited to the technical solutions formed by the specific combination of the above technical features, but also covers the technical solutions made by the above technical features or Other technical solutions formed by any combination of equivalent features. For example, a technical solution formed by replacing the above-mentioned features with technical features with similar functions disclosed in (but not limited to) this application.
此外,虽然采用特定次序描绘了各操作,但是这不应当理解为要求这些操作以所示出的特定次序或以顺序次序执行来执行。在一定环境下,多任务和并行处理可能是有利的。同样地,虽然在上面论述中包含了若干具体实现细节,但是这些不应当被解释为对本申请的范围的限制。在单独的实施例的上下文中描述的某些特征还可以组合地实现在单个实施例中。相反地,在单个实施例的上下文中描述的各种特征也可以单独地或以任何合适的子组合的方式实现在多个实施例中。In addition, while operations are depicted in a particular order, this should not be understood as requiring that the operations be performed in the particular order shown or performed in sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Likewise, while the above discussion contains several specific implementation details, these should not be construed as limitations on the scope of the application. Certain features that are described in the context of separate embodiments can also be implemented in combination in a single embodiment. Conversely, various features that are described in the context of a single embodiment can also be implemented in multiple embodiments separately or in any suitable subcombination.
尽管已经采用特定于结构特征和/或方法逻辑动作的语言描述了本主题,但是应当理解所附权利要求书中所限定的主题未必局限于上面描述的特定特征或动作。相反,上面所描述的特定特征和动作仅仅是实现权利要求书的示例形式。Although the subject matter has been described in language specific to structural features and/or methodological acts, it is to be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are merely example forms of implementing the claims.

Claims (16)

  1. 一种图像修复模型的训练方法,其特征在于,所述方法包括:A training method for an image restoration model, characterized in that the method comprises:
    将真实第一像素质量图像输入图像特征编码器,得到第一图像特征;Inputting the real first pixel quality image into the image feature encoder to obtain the first image feature;
    将人工合成第一像素质量图像输入所述图像特征编码器,得到第二图像特征;所述人工合成第一像素质量图像是由真实第二像素质量图像进行模糊处理得到的;Inputting the artificially synthesized first pixel quality image into the image feature encoder to obtain the second image feature; the artificially synthesized first pixel quality image is obtained by blurring the real second pixel quality image;
    将所述第一图像特征输入真实第一像素质量图像生成器,得到重新生成的真实第一像素质量图像;Inputting the first image feature into a real first pixel quality image generator to obtain a regenerated real first pixel quality image;
    将所述第二图像特征输入所述真实第一像素质量图像生成器,得到伪真实第一像素质量图像;Inputting the second image feature into the real first pixel quality image generator to obtain a pseudo-true first pixel quality image;
    将所述第二图像特征输入真实第二像素质量图像生成器,得到重建第二像素质量图像;Inputting the second image feature into a real second pixel quality image generator to obtain a reconstructed second pixel quality image;
    根据所述第一图像特征以及所述第二图像特征计算域对齐损失;calculating a domain alignment loss based on the first image feature and the second image feature;
    根据所述重新生成的真实第一像素质量图像、所述伪真实第一像素质量图像以及所述真实第一像素质量图像计算图像生成损失;calculating an image generation loss based on the regenerated true first pixel quality image, the pseudo true first pixel quality image, and the true first pixel quality image;
    根据所述重建第二像素质量图像以及所述真实第二像素质量图像计算图像重建损失;calculating an image reconstruction loss based on the reconstructed second pixel quality image and the true second pixel quality image;
    根据所述域对齐损失、所述图像生成损失以及所述图像重建损失,训练所述图像特征编码器、所述真实第一像素质量图像生成器以及所述真实第二像素质量图像生成器,重复执行所述将真实第一像素质量图像输入图像特征编码器,得到第一图像特征以及后续步骤,直到达到预设条件;Train the image feature encoder, the true first pixel quality image generator, and the true second pixel quality image generator based on the domain alignment loss, the image generation loss, and the image reconstruction loss, repeating Execute said inputting the real first pixel quality image into the image feature encoder to obtain the first image feature and subsequent steps until reaching the preset condition;
    其中,第一像素质量的图像清晰度低于第二像素质量的图像清晰度。Wherein, the image definition of the first pixel quality is lower than the image definition of the second pixel quality.
  2. 根据权利要求1所述的方法,其特征在于,所述方法还包括:The method according to claim 1, further comprising:
    将所述伪真实第一像素质量图像输入所述图像特征编码器,得到第三图像特征;Inputting the pseudo real first pixel quality image into the image feature encoder to obtain a third image feature;
    根据所述第二图像特征以及所述第三图像特征计算内容一致性损失;calculating a content consistency loss based on the second image feature and the third image feature;
    所述根据所述域对齐损失、所述图像生成损失以及所述图像重建损失,训练所述图像特征编码器、所述真实第一像素质量图像生成器以及所述真实第二像素质量图像生成器,包括:said training said image feature encoder, said true first pixel quality image generator, and said true second pixel quality image generator based on said domain alignment loss, said image generation loss, and said image reconstruction loss ,include:
    根据所述域对齐损失、所述图像生成损失、所述图像重建损失以及所述内容一致性损失,训练所述图像特征编码器、所述真实第一像素质量图像生成器以及所述真实第二像素质量图像生成器。The image feature encoder, the true first pixel quality image generator and the true second Pixel quality image generator.
  3. 根据权利要求2所述的方法,其特征在于,所述方法还包括:The method according to claim 2, further comprising:
    将所述第三图像特征输入所述真实第二像素质量图像生成器,得到伪真实重建第二像素质量图像;Inputting the third image feature into the real second pixel quality image generator to obtain a pseudo-real reconstructed second pixel quality image;
    所述根据所述重建第二像素质量图像以及所述真实第二像素质量图像计算图像重建损失,包括:The calculating an image reconstruction loss according to the reconstructed second pixel quality image and the real second pixel quality image includes:
    根据所述重建第二像素质量图像以及所述真实第二像素质量图像计算第一图像重建损失;calculating a first image reconstruction loss based on the reconstructed second pixel quality image and the true second pixel quality image;
    根据所述伪真实重建第二像素质量图像以及所述真实第二像素质量图像计算第二图像重建损失;所述第一图像重建损失以及所述第二图像重建损失组成图像重建损失。calculating a second image reconstruction loss based on the pseudo real reconstructed second pixel quality image and the real second pixel quality image; the first image reconstruction loss and the second image reconstruction loss constitute an image reconstruction loss.
  4. 根据权利要求1所述的方法,其特征在于,所述根据所述重新生成的真实第一像素质量图像、所述伪真实第一像素质量图像以及所述真实第一像素质量图像计算图像生成损失,包括:The method according to claim 1, wherein said calculating an image generation loss based on said regenerated real first pixel quality image, said pseudo real first pixel quality image, and said real first pixel quality image ,include:
    根据所述重新生成的真实第一像素质量图像以及所述真实第一像素质量图像计算第一图像生成损失;calculating a first image generation loss based on the regenerated true first pixel quality image and the true first pixel quality image;
    根据所述伪真实第一像素质量图像以及所述真实第一像素质量图像计算第二图像生成损失;所述第一图像生成损失以及所述第二图像生成损失组成图像生成损失。A second image generation loss is calculated from the pseudo-true first pixel quality image and the real first pixel quality image; the first image generation loss and the second image generation loss constitute an image generation loss.
  5. 根据权利要求1所述的方法,其特征在于,所述根据所述第一图像特征以及所述第二图像特征计算域对齐损失,包括:The method according to claim 1, wherein the calculating domain alignment loss according to the first image feature and the second image feature comprises:
    将所述第一图像特征输入特征判别器,得到第一概率值;Inputting the first image feature into a feature discriminator to obtain a first probability value;
    将所述第二图像特征输入所述特征判别器,得到第二概率值;inputting the second image feature into the feature discriminator to obtain a second probability value;
    根据所述第一概率值以及所述第二概率值,计算域对齐损失。A domain alignment loss is calculated according to the first probability value and the second probability value.
  6. 根据权利要求2所述的方法,其特征在于,所述根据所述第二图像特征以及所述第三图像特征计算内容一致性损失,包括:The method according to claim 2, wherein the calculating the content consistency loss according to the second image feature and the third image feature comprises:
    计算所述第二图像特征以及所述第三图像特征之间的1-范数;calculating a 1-norm between the second image feature and the third image feature;
    根据所述第二图像特征以及所述第三图像特征之间的1-范数,计算内容一致性损失。A content consistency loss is calculated according to a 1-norm between the second image feature and the third image feature.
  7. 根据权利要求3所述的方法,其特征在于,所述根据所述重建第二像素质量图像以及所述真实第二像素质量图像计算第一图像重建损失,包括:The method according to claim 3, wherein the calculating the first image reconstruction loss according to the reconstructed second pixel quality image and the real second pixel quality image comprises:
    计算所述重建第二像素质量图像以及所述真实第二像素质量图像之间的1-范数;calculating a 1-norm between the reconstructed second pixel quality image and the true second pixel quality image;
    根据所述重建第二像素质量图像以及所述真实第二像素质量图像之间的1-范数,计算第一图像重建损失。A first image reconstruction loss is calculated based on a 1-norm between the reconstructed second pixel quality image and the real second pixel quality image.
  8. 根据权利要求3所述的方法,其特征在于,所述根据所述伪真实重建第二像素质量图像以及所述真实第二像素质量图像计算第二图像重建损失,包括:The method according to claim 3, wherein the calculating a second image reconstruction loss according to the pseudo-true reconstructed second pixel quality image and the real second pixel quality image comprises:
    计算所述伪真实重建第二像素质量图像以及所述真实第二像素质量图像之间的1-范数;calculating a 1-norm between the pseudo real reconstructed second pixel quality image and the real second pixel quality image;
    根据所述伪真实重建第二像素质量图像以及所述真实第二像素质量图像之间的1-范数,计算第二图像重建损失。A second image reconstruction loss is calculated based on a 1-norm between the pseudo real reconstructed second pixel quality image and the real second pixel quality image.
  9. 根据权利要求4所述的方法,其特征在于,所述根据所述重新生成的真实第一像素质量图像以及所述真实第一像素质量图像计算第一图像生成损失,包括:The method according to claim 4, wherein the calculating the first image generation loss according to the regenerated real first pixel quality image and the real first pixel quality image comprises:
    计算所述重新生成的真实第一像素质量图像以及所述真实第一像素质量图像之间的1-范数;calculating a 1-norm between said regenerated true first pixel quality image and said true first pixel quality image;
    根据所述重新生成的真实第一像素质量图像以及所述真实第一像素质量图像之间的1-范数,计算第一图像生成损失。A first image generation loss is calculated based on the regenerated real first pixel quality image and a 1-norm between the real first pixel quality image.
  10. 根据权利要求4所述的方法,其特征在于,所述根据所述伪真实第一像素质量图像以及所述真实第一像素质量图像计算第二图像生成损失,包括:The method according to claim 4, wherein the calculating the second image generation loss according to the pseudo real first pixel quality image and the real first pixel quality image comprises:
    将所述伪真实第一像素质量图像输入特征判别器,得到第三概率值;Inputting the pseudo real first pixel quality image into a feature discriminator to obtain a third probability value;
    将所述真实第一像素质量图像输入所述特征判别器,得到第四概率值;inputting the real first pixel quality image into the feature discriminator to obtain a fourth probability value;
    根据所述第三概率值和所述第四概率值,计算第二图像生成损失。A second image generation loss is calculated based on the third probability value and the fourth probability value.
  11. 根据权利要求1-10任一项所述的方法,其特征在于,The method according to any one of claims 1-10, characterized in that,
    所述图像特征编码器包括至少一个残差模块;The image feature encoder includes at least one residual module;
    所述真实第一像素质量图像生成器包括至少一个残差模块;said true first pixel quality image generator comprising at least one residual module;
    所述真实第二像素质量图像生成器包括第一卷积层、基本单元、第二卷积层、上采样层、第三卷积层、激活函数层以及第四卷积层,所述基本单元包括至少一个RRDB单元。The real second pixel quality image generator includes a first convolutional layer, a basic unit, a second convolutional layer, an upsampling layer, a third convolutional layer, an activation function layer, and a fourth convolutional layer, and the basic unit Include at least one RRDB unit.
  12. 一种图像修复方法,其特征在于,所述方法包括:An image restoration method, characterized in that the method comprises:
    将待修复第一像素质量图像输入图像特征编码器,得到目标图像特征;Input the first pixel quality image to be repaired into the image feature encoder to obtain the target image feature;
    将所述目标图像特征输入真实第二像素质量图像生成器,得到修复后的第二像素质量图像;The target image feature is input into a real second pixel quality image generator to obtain a repaired second pixel quality image;
    所述图像特征编码器以及所述真实第二像素质量图像生成器是根据权利要求1-11任一项所述的图像修复模型的训练方法训练得到的。The image feature encoder and the real second pixel quality image generator are obtained by training according to the training method of the image inpainting model described in any one of claims 1-11.
  13. 一种图像修复模型的训练装置,其特征在于,所述装置包括:A training device for an image restoration model, characterized in that the device comprises:
    第一执行单元,用于将真实第一像素质量图像输入图像特征编码器,得到第一图像特征;The first execution unit is used to input the real first pixel quality image into the image feature encoder to obtain the first image feature;
    第二执行单元,用于将人工合成第一像素质量图像输入所述图像特征编码器,得到第二图像特征;所述人工合成第一像素质量图像是由真实第二像素质量图像进行模糊处理得到的;The second execution unit is configured to input the artificially synthesized first pixel quality image into the image feature encoder to obtain the second image feature; the artificially synthesized first pixel quality image is obtained by blurring the real second pixel quality image of;
    第三执行单元,用于将所述第一图像特征输入真实第一像素质量图像生成器,得到重新生成的真实第一像素质量图像;A third execution unit, configured to input the first image feature into a real first pixel quality image generator to obtain a regenerated real first pixel quality image;
    第四执行单元,用于将所述第二图像特征输入所述真实第一像素质量图像生成器,得到伪真实第一像素质量图像;A fourth execution unit, configured to input the second image feature into the real first pixel quality image generator to obtain a pseudo-real first pixel quality image;
    第五执行单元,用于将所述第二图像特征输入真实第二像素质量图像生成器,得到重建第二像素质量图像;The fifth execution unit is configured to input the second image feature into the real second pixel quality image generator to obtain a reconstructed second pixel quality image;
    第一计算单元,用于根据所述第一图像特征以及所述第二图像特征计算域对齐损失;A first calculation unit, configured to calculate a domain alignment loss according to the first image feature and the second image feature;
    第二计算单元,用于根据所述重新生成的真实第一像素质量图像、所述伪真实第一像素质量图像以及所述真实第一像素质量图像计算图像生成损失;A second calculation unit, configured to calculate an image generation loss based on the regenerated real first pixel quality image, the pseudo real first pixel quality image, and the real first pixel quality image;
    第三计算单元,用于根据所述重建第二像素质量图像以及所述真实第二像素质量图像计算图像重建损失;A third calculation unit, configured to calculate an image reconstruction loss according to the reconstructed second pixel quality image and the real second pixel quality image;
    训练单元,用于根据所述域对齐损失、所述图像生成损失以及所述图像重建损失,训练所述图像特征编码器、所述真实第一像素质量图像生成器以及所述真实第二像素质量图像生成器,重复执行所述将真实第一像素质量图像输入图像特征编码器,得到第一图像特征以及后续步骤,直到达到预设条件;a training unit for training the image feature encoder, the true first pixel quality image generator, and the true second pixel quality based on the domain alignment loss, the image generation loss, and the image reconstruction loss The image generator repeatedly executes the steps of inputting the real first pixel quality image into the image feature encoder to obtain the first image feature and subsequent steps until the preset condition is reached;
    其中,第一像素质量的图像清晰度低于第二像素质量的图像清晰度。Wherein, the image definition of the first pixel quality is lower than the image definition of the second pixel quality.
  14. 一种图像修复装置,其特征在于,所述装置包括:An image restoration device, characterized in that the device comprises:
    第八执行单元,用于将待修复第一像素质量图像输入图像特征编码器,得到目标图像特征;The eighth execution unit is used to input the first pixel quality image to be repaired into the image feature encoder to obtain the target image feature;
    第九执行单元,用于将所述目标图像特征输入真实第二像素质量图像生成器,得到修复后的第二像素质量图像;A ninth execution unit, configured to input the features of the target image into a real second pixel quality image generator to obtain a repaired second pixel quality image;
    所述图像特征编码器以及所述真实第二像素质量图像生成器是根据权利要求1-11任一项所述的图像修复模型的训练方法训练得到的。The image feature encoder and the real second pixel quality image generator are obtained by training according to the training method of the image inpainting model described in any one of claims 1-11.
  15. 一种电子设备,其特征在于,包括:An electronic device, characterized in that it comprises:
    一个或多个处理器;one or more processors;
    存储装置,其上存储有一个或多个程序,a storage device on which one or more programs are stored,
    当所述一个或多个程序被所述一个或多个处理器执行,使得所述一个或多个处理器实现如权利要求1-11中任一所述的图像修复模型的训练方法,或者权利要求12所述的图像修复方法。When the one or more programs are executed by the one or more processors, the one or more processors implement the image repair model training method according to any one of claims 1-11, or the right The image restoration method described in claim 12.
  16. 一种计算机可读介质,其特征在于,其上存储有计算机程序,其中,所述程序被处理器执行时实现如权利要求1-11中任一所述的图像修复模型的训练方法,或者权利要求12所述的图像修复方法。A computer-readable medium, which is characterized in that a computer program is stored thereon, wherein, when the program is executed by a processor, the method for training an image restoration model according to any one of claims 1-11 is implemented, or the right The image restoration method described in claim 12.
PCT/CN2022/089428 2021-05-31 2022-04-27 Training method for image inpainting model and image inpainting method, apparatus, and device WO2022252883A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202110604235.1 2021-05-31
CN202110604235.1A CN113222144B (en) 2021-05-31 2021-05-31 Training method of image restoration model, image restoration method, device and equipment

Publications (1)

Publication Number Publication Date
WO2022252883A1 true WO2022252883A1 (en) 2022-12-08

Family

ID=77081859

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/089428 WO2022252883A1 (en) 2021-05-31 2022-04-27 Training method for image inpainting model and image inpainting method, apparatus, and device

Country Status (2)

Country Link
CN (1) CN113222144B (en)
WO (1) WO2022252883A1 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113222144B (en) * 2021-05-31 2022-12-27 北京有竹居网络技术有限公司 Training method of image restoration model, image restoration method, device and equipment

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111507898A (en) * 2020-03-16 2020-08-07 徐州工程学院 Image super-resolution reconstruction method based on self-adaptive adjustment
CN111507914A (en) * 2020-04-10 2020-08-07 北京百度网讯科技有限公司 Training method, repairing method, device, equipment and medium of face repairing model
US20200386978A1 (en) * 2019-06-07 2020-12-10 Drvision Technologies Llc Artifact regulation methods in deep model training for image transformation
CN112446835A (en) * 2019-09-04 2021-03-05 华为技术有限公司 Image recovery method, image recovery network training method, device and storage medium
CN113222144A (en) * 2021-05-31 2021-08-06 北京有竹居网络技术有限公司 Training method of image restoration model, image restoration method, device and equipment

Family Cites Families (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2019227479A1 (en) * 2018-06-01 2019-12-05 华为技术有限公司 Method and apparatus for generating face rotation image
CN110570358A (en) * 2018-09-04 2019-12-13 阿里巴巴集团控股有限公司 vehicle loss image enhancement method and device based on GAN network
KR20200075344A (en) * 2018-12-18 2020-06-26 삼성전자주식회사 Detector, method of object detection, learning apparatus, and learning method for domain transformation
US11398013B2 (en) * 2019-10-18 2022-07-26 Retrace Labs Generative adversarial network for dental image super-resolution, image sharpening, and denoising
CN111815523A (en) * 2020-06-08 2020-10-23 天津中科智能识别产业技术研究院有限公司 Image restoration method based on generation countermeasure network
CN111915522A (en) * 2020-07-31 2020-11-10 天津中科智能识别产业技术研究院有限公司 Image restoration method based on attention mechanism
CN111950525B (en) * 2020-08-31 2022-09-16 福州大学 Fine-grained image classification method based on destructive reconstruction learning and GoogLeNet
CN112419151B (en) * 2020-11-19 2023-07-21 北京有竹居网络技术有限公司 Image degradation processing method and device, storage medium and electronic equipment

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20200386978A1 (en) * 2019-06-07 2020-12-10 Drvision Technologies Llc Artifact regulation methods in deep model training for image transformation
CN112446835A (en) * 2019-09-04 2021-03-05 华为技术有限公司 Image recovery method, image recovery network training method, device and storage medium
CN111507898A (en) * 2020-03-16 2020-08-07 徐州工程学院 Image super-resolution reconstruction method based on self-adaptive adjustment
CN111507914A (en) * 2020-04-10 2020-08-07 北京百度网讯科技有限公司 Training method, repairing method, device, equipment and medium of face repairing model
CN113222144A (en) * 2021-05-31 2021-08-06 北京有竹居网络技术有限公司 Training method of image restoration model, image restoration method, device and equipment

Also Published As

Publication number Publication date
CN113222144B (en) 2022-12-27
CN113222144A (en) 2021-08-06

Similar Documents

Publication Publication Date Title
WO2022105638A1 (en) Image degradation processing method and apparatus, and storage medium and electronic device
WO2022227886A1 (en) Method for generating super-resolution repair network model, and method and apparatus for image super-resolution repair
EP4172927A1 (en) Image super-resolution reconstructing
WO2022100735A1 (en) Video processing method and apparatus, electronic device, and storage medium
CN113327318B (en) Image display method, image display device, electronic equipment and computer readable medium
CN114419300A (en) Stylized image generation method and device, electronic equipment and storage medium
CN111935425B (en) Video noise reduction method and device, electronic equipment and computer readable medium
WO2022252883A1 (en) Training method for image inpainting model and image inpainting method, apparatus, and device
WO2023030381A1 (en) Three-dimensional human head reconstruction method and apparatus, and device and medium
WO2023029893A1 (en) Texture mapping method and apparatus, device and storage medium
CN114399814A (en) Deep learning-based obstruction removal and three-dimensional reconstruction method
WO2023179360A1 (en) Video processing method and apparatus, and electronic device and storage medium
CN112752118A (en) Video generation method, device, equipment and storage medium
WO2023197805A1 (en) Image processing method and apparatus, and storage medium and electronic device
CN112785669A (en) Virtual image synthesis method, device, equipment and storage medium
WO2023103682A1 (en) Image processing method and apparatus, device, and medium
WO2020155908A1 (en) Method and apparatus for generating information
CN111369475A (en) Method and apparatus for processing video
WO2023274005A1 (en) Image processing method and apparatus, electronic device, and storage medium
CN114066722B (en) Method and device for acquiring image and electronic equipment
CN111275813B (en) Data processing method and device and electronic equipment
WO2023116711A1 (en) Video texture migration method and apparatus, electronic device and storage medium
WO2023093838A1 (en) Super-resolution image processing method and apparatus, and device and medium
WO2023093481A1 (en) Fourier domain-based super-resolution image processing method and apparatus, device, and medium
WO2023093828A1 (en) Super-resolution image processing method and apparatus based on gan, and device and medium

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 22814930

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE