CN116309018A - Image processing method and device - Google Patents

Image processing method and device Download PDF

Info

Publication number
CN116309018A
CN116309018A CN202310155787.8A CN202310155787A CN116309018A CN 116309018 A CN116309018 A CN 116309018A CN 202310155787 A CN202310155787 A CN 202310155787A CN 116309018 A CN116309018 A CN 116309018A
Authority
CN
China
Prior art keywords
image
network model
target
residual
processed
Prior art date
Legal status (The legal status 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 status listed.)
Pending
Application number
CN202310155787.8A
Other languages
Chinese (zh)
Inventor
邓世豪
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Vivo Mobile Communication Co Ltd
Original Assignee
Vivo Mobile Communication Co Ltd
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 Vivo Mobile Communication Co Ltd filed Critical Vivo Mobile Communication Co Ltd
Priority to CN202310155787.8A priority Critical patent/CN116309018A/en
Publication of CN116309018A publication Critical patent/CN116309018A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T3/00Geometric image transformations in the plane of the image
    • G06T3/04Context-preserving transformations, e.g. by using an importance map
    • 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
    • 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

Landscapes

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

Abstract

本申请公开了一种图像处理的方法及其装置,属于人工智能技术领域。该图像处理的方法包括:获取待处理图像;将目标图像区域输入至目标残差网络模型,得到所述目标残差网络模型的残差输出;其中,所述目标图像区域包括:所述待处理图像中显示有头发和额头的图像区域;将所述残差输出叠加到所述待处理图像,得到所述待处理图像增发后的目标图像。

Figure 202310155787

The application discloses an image processing method and device thereof, belonging to the technical field of artificial intelligence. The image processing method includes: acquiring an image to be processed; inputting a target image area into a target residual network model to obtain a residual output of the target residual network model; wherein, the target image area includes: the target image area to be processed An image area with hair and forehead is displayed in the image; the residual output is superimposed on the image to be processed to obtain a target image after additional issuance of the image to be processed.

Figure 202310155787

Description

图像处理的方法及其装置Method and device for image processing

技术领域technical field

本申请属于人工智能技术领域,具体涉及一种图像处理的方法及其装置。The present application belongs to the technical field of artificial intelligence, and specifically relates to an image processing method and device thereof.

背景技术Background technique

随着年纪的不断增长以及社会压力方面的各种因素,越来越多的人逐渐开始脱发,并为脱发而烦恼。发量的减少给部分人群带来极大的影响。目前,可以利用StyleGAN(风格生成对抗网络)模型生成增发后的效果图。这样,即使用户的发量较少,也可以生成发量较多的增发效果图。With the continuous growth of age and various factors in social pressure, more and more people gradually start to lose their hair and worry about it. The reduction in hair volume has a great impact on some people. Currently, the StyleGAN (Style Generative Adversarial Network) model can be used to generate renderings after issuance. In this way, even if the user's hair volume is small, it is also possible to generate an additional hair effect map with a large hair volume.

如图1所示,为利用StyleGAN模型生成增发后的效果图的过程示意图。其中,Encode(编码器)11的作用是将输入的图片编码为W+,W+为一系列数字组成的矩阵用以来表示用户信息。StyleGAN12通过对W+信息进行解码,同时通过对头发信息进行调整,从而实现了增发。As shown in Figure 1, it is a schematic diagram of the process of using the StyleGAN model to generate the effect map after additional issuance. Among them, the function of Encode (encoder) 11 is to encode the input picture into W+, and W+ is a matrix composed of a series of numbers to represent user information. StyleGAN12 achieves additional issuance by decoding W+ information and adjusting hair information.

然而,上述利用StyleGAN模型进行增发对硬件部分的性能要求较高,且功耗开销较大。However, the above-mentioned use of the StyleGAN model for additional issuance has high performance requirements for the hardware part, and the power consumption overhead is relatively large.

发明内容Contents of the invention

本申请实施例的目的是提供一种图像处理的方法及其装置,能够解决相关技术中实现人物的增发效果时对硬件部分的性能要求较高,且功耗开销较大的问题。The purpose of the embodiments of the present application is to provide an image processing method and device thereof, which can solve the problems in the related art that the performance of the hardware part is high and the power consumption is relatively high when realizing the effect of additional issuance of characters.

第一方面,本申请实施例提供了一种图像处理的方法,该方法包括:In the first aspect, the embodiment of the present application provides an image processing method, the method comprising:

获取待处理图像;Get the image to be processed;

将目标图像区域输入至目标残差网络模型,得到所述目标残差网络模型的残差输出;其中,所述目标图像区域包括:所述待处理图像中显示有头发和额头的图像区域;The target image area is input to the target residual network model to obtain the residual output of the target residual network model; wherein, the target image area includes: an image area showing hair and forehead in the image to be processed;

将所述残差输出叠加到所述待处理图像,得到所述待处理图像增发后的目标图像。The residual output is superimposed on the image to be processed to obtain a target image of the image to be processed.

第二方面,本申请实施例提供了一种图像处理的装置,该装置包括:In the second aspect, the embodiment of the present application provides an image processing device, which includes:

第一获取模块,用于获取待处理图像;The first acquisition module is used to acquire the image to be processed;

残差模块,用于将目标图像区域输入至目标残差网络模型,得到所述目标残差网络模型的残差输出;其中,所述目标图像区域包括:所述待处理图像中显示有头发和额头的图像区域;The residual module is used to input the target image area into the target residual network model to obtain the residual output of the target residual network model; wherein, the target image area includes: the image to be processed is displayed with hair and the image area of the forehead;

处理模块,用于将所述残差输出叠加到所述待处理图像,得到所述待处理图像增发后的目标图像。A processing module, configured to superimpose the residual output on the image to be processed to obtain a target image after the image to be processed is added.

第三方面,本申请实施例提供了一种电子设备,该电子设备包括处理器和存储器,所述存储器存储可在所述处理器上运行的程序或指令,所述程序或指令被所述处理器执行时实现如第一方面所述的方法的步骤。In the third aspect, the embodiment of the present application provides an electronic device, the electronic device includes a processor and a memory, the memory stores programs or instructions that can run on the processor, and the programs or instructions are processed by the The steps of the method described in the first aspect are realized when the controller is executed.

第四方面,本申请实施例提供了一种可读存储介质,所述可读存储介质上存储程序或指令,所述程序或指令被处理器执行时实现如第一方面所述的方法的步骤。In a fourth aspect, an embodiment of the present application provides a readable storage medium, on which a program or an instruction is stored, and when the program or instruction is executed by a processor, the steps of the method described in the first aspect are implemented .

第五方面,本申请实施例提供了一种芯片,所述芯片包括处理器和通信接口,所述通信接口和所述处理器耦合,所述处理器用于运行程序或指令,实现如第一方面所述的方法。In the fifth aspect, the embodiment of the present application provides a chip, the chip includes a processor and a communication interface, the communication interface is coupled to the processor, and the processor is used to run programs or instructions, so as to implement the first aspect the method described.

第六方面,本申请实施例提供一种计算机程序产品,该程序产品被存储在存储介质中,该程序产品被至少一个处理器执行以实现如第一方面的方法。In a sixth aspect, an embodiment of the present application provides a computer program product, the program product is stored in a storage medium, and the program product is executed by at least one processor to implement the method in the first aspect.

本申请实施例中,针对待处理图像,将其显示有头发和额头的目标图像区域输入至目标残差网络模型,可以得到表征待处理图像增发前后差别的残差输出。进而通过将残差输出叠加到待处理图像,可以得到待处理图像增发后的目标图像。由于目标残差网络模型利用了对硬件性能要求较低,且功耗开销较小的残差网络。因此本申请可以在实现增发效果的基础上,降低对硬件的性能要求,同时降低硬件的功耗开销。In the embodiment of the present application, for the image to be processed, the target image area displaying hair and forehead is input to the target residual network model, and the residual output representing the difference before and after the image to be processed can be obtained. Furthermore, by superimposing the residual output on the image to be processed, the target image after additional issuance of the image to be processed can be obtained. Since the target residual network model utilizes a residual network with low hardware performance requirements and low power consumption overhead. Therefore, the present application can reduce the performance requirements of the hardware and reduce the power consumption of the hardware on the basis of realizing the effect of additional issuance.

附图说明Description of drawings

图1是当前利用StyleGAN模型生成增发后的效果图的过程示意图;Figure 1 is a schematic diagram of the current process of using the StyleGAN model to generate the effect map after additional issuance;

图2是本申请实施例提供的一种图像处理的方法的步骤流程图;FIG. 2 is a flow chart of the steps of an image processing method provided by an embodiment of the present application;

图3是本申请实施例提供中待处理图像增发前后的变化示意图;Fig. 3 is a schematic diagram of changes before and after additional issuance of images to be processed provided in the embodiment of the present application;

图4是本申请实施例提供的训练风格生成对抗网络模型的示意图;Fig. 4 is a schematic diagram of the training style generation confrontation network model provided by the embodiment of the present application;

图5是本申请实施例提供的得到一对增发前后对比图像的示意图;Fig. 5 is a schematic diagram of obtaining a pair of comparison images before and after additional issuance provided by the embodiment of the present application;

图6是本申请实施例提供的图像处理的方法的实际应用示意图;FIG. 6 is a schematic diagram of a practical application of the image processing method provided by the embodiment of the present application;

图7是本申请实施例提供的一种图像处理的装置的结构框图;FIG. 7 is a structural block diagram of an image processing device provided in an embodiment of the present application;

图8是本申请实施例提供的电子设备的硬件结构示意图之一;FIG. 8 is one of the schematic diagrams of the hardware structure of the electronic device provided by the embodiment of the present application;

图9是本申请实施例提供的电子设备的硬件结构示意图之二。FIG. 9 is a second schematic diagram of the hardware structure of the electronic device provided by the embodiment of the present application.

具体实施方式Detailed ways

下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚地描述,显然,所描述的实施例是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员获得的所有其他实施例,都属于本申请保护的范围。The following will clearly describe the technical solutions in the embodiments of the present application with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, but not all of them. All other embodiments obtained by persons of ordinary skill in the art based on the embodiments in this application belong to the protection scope of this application.

本申请的说明书和权利要求书中的术语“第一”、“第二”等是用于区别类似的对象,而不用于描述特定的顺序或先后次序。应该理解这样使用的术语在适当情况下可以互换,以便本申请的实施例能够以除了在这里图示或描述的那些以外的顺序实施,且“第一”、“第二”等所区分的对象通常为一类,并不限定对象的个数,例如第一对象可以是一个,也可以是多个。此外,说明书以及权利要求中“和/或”表示所连接对象的至少其中之一,字符“/”,一般表示前后关联对象是一种“或”的关系。The terms "first", "second" and the like in the specification and claims of the present application are used to distinguish similar objects, and are not used to describe a specific sequence or sequence. It is to be understood that the terms so used are interchangeable under appropriate circumstances such that the embodiments of the application are capable of operation in sequences other than those illustrated or described herein and that references to "first", "second", etc. to distinguish Objects are generally of one type, and the number of objects is not limited. For example, there may be one or more first objects. In addition, "and/or" in the specification and claims means at least one of the connected objects, and the character "/" generally means that the related objects are an "or" relationship.

下面结合附图,通过具体的实施例及其应用场景对本申请实施例提供的图像处理的方法进行详细地说明。The image processing method provided by the embodiment of the present application will be described in detail below through specific embodiments and application scenarios with reference to the accompanying drawings.

如图2所示,为本申请实施例提供的一种图像处理的方法的步骤示意图,该图像处理的方法可以包括:As shown in FIG. 2, it is a schematic diagram of the steps of an image processing method provided in the embodiment of the present application. The image processing method may include:

步骤201:获取待处理图像。Step 201: Obtain an image to be processed.

本步骤中,待处理图像为需要添加增发效果的图像,即增发前图像。其可以为手机、相机等电子设备拍摄得到的图像。这里,可以从本地获取待处理图像,例如,本申请所提供的方法应用于手机,待处理图像可以为手机中存储的本地图像。当然,也可以接收其它电子设备传输而来的待处理图像。例如,本申请所提供的方法应用于服务器,待处理图像可以为手机用户上传至服务器的图像。In this step, the image to be processed is the image to which additional issuance effects need to be added, that is, the image before additional issuance. It can be an image captured by electronic devices such as mobile phones and cameras. Here, the image to be processed may be obtained locally. For example, the method provided in this application is applied to a mobile phone, and the image to be processed may be a local image stored in the mobile phone. Of course, images to be processed transmitted from other electronic devices may also be received. For example, the method provided in this application is applied to a server, and the image to be processed may be an image uploaded to the server by a mobile phone user.

可以理解的是,待处理图像的图像内容至少包括头发和额头。具体的,待处理图像包括显示有发际线的图像。值得注意的是,这里对待处理图像的尺寸并不做限定。也就是说,待处理图像的尺寸可以为任意尺寸。例如待处理图像的尺寸可以为1536*768、4096*4096,但不限于此。It can be understood that the image content of the image to be processed includes at least hair and forehead. Specifically, the image to be processed includes an image showing a hairline. It is worth noting that the size of the image to be processed is not limited here. That is to say, the size of the image to be processed can be any size. For example, the size of the image to be processed may be 1536*768, 4096*4096, but not limited thereto.

步骤202:将目标图像区域输入至目标残差网络模型,得到目标残差网络模型的残差输出。Step 202: Input the target image region into the target residual network model to obtain a residual output of the target residual network model.

应当说明的是,目标图像区域包括:待处理图像中显示有头发和额头的图像区域。具体的,目标图像区域为待处理图像的全部图像区域或部分图像区域。在目标图像区域为待处理图像的部分图像区域的情况下,该部分图像区域为显示有头发和额头的图像区域。It should be noted that the target image area includes: an image area displaying hair and forehead in the image to be processed. Specifically, the target image area is all or part of the image area of the image to be processed. In the case that the target image area is a partial image area of the image to be processed, the partial image area is an image area displaying hair and forehead.

目标残差网络模型用于计算人物增发前后差别。具体的,目标残差网络模型为基于残差网络搭建的模型。该目标残差网络模型可以计算出人物增发前后的差别,并将该差别作为残差输出。其中,人物增发指的是人物头发或发量的增多。人物增发后的发量明显高于增发前的发量。The target residual network model is used to calculate the difference before and after the additional issuance of characters. Specifically, the target residual network model is a model based on a residual network. The target residual network model can calculate the difference before and after the additional issuance of characters, and output the difference as a residual. Among them, the additional hair of a character refers to the increase of the hair or hair volume of a character. The amount of hair after the additional issuance of characters is significantly higher than that before the additional issuance.

步骤203:将残差输出叠加到待处理图像,得到待处理图像增发后的目标图像。Step 203: Superimpose the residual output on the image to be processed to obtain the target image after the image to be processed is added.

应当说明的是,该残差输出即为人物增发前后的差别。这里,将待处理图像作为人物增发前的图像,从而通过残差输出与人物增发前的图像进行叠加,可以得到人物增发后的图像,即待处理图像增发后的目标图像。可以理解的是,增发的位置可以为待处理图像的发际线所处位置。从而使得目标图像相比于待处理图像,看起来像是人物的发际线向额头部分进行了移动。如图3所示,待处理图像31与残差输出32叠加后可以得到目标图像33。很明显,相比于待处理图像31,目标图像33中的发际线更加靠近面部,使得露出的额头面积更小。当然,增发的位置也可以为待处理图像中头发较为稀疏的位置,从而使得目标图像相比于待处理图像,看起来像是人物头发稀疏的部分变得头发茂密。It should be noted that the residual output is the difference before and after the additional issuance of characters. Here, the image to be processed is taken as the image before the person is added, so that the image after the person is added can be obtained by superimposing the residual output with the image before the person is added, that is, the target image after the image to be processed is added. It can be understood that the location of additional issuance may be the location of the hairline of the image to be processed. Therefore, compared with the image to be processed, the target image looks like the hairline of the character has moved toward the forehead. As shown in FIG. 3 , the target image 33 can be obtained after superimposing the image to be processed 31 and the residual output 32 . Obviously, compared with the image to be processed 31, the hairline in the target image 33 is closer to the face, so that the exposed forehead area is smaller. Of course, the location of additional issuance may also be a location where the hair is thinner in the image to be processed, so that compared with the image to be processed, the part of the target image that looks like a character with thin hair becomes denser.

本申请实施例中,针对待处理图像,将其显示有头发和额头的目标图像区域输入至目标残差网络模型,可以得到表征待处理图像增发前后差别的残差输出。进而通过将残差输出叠加到待处理图像,可以得到待处理图像增发后的目标图像。由于目标残差网络模型利用了对硬件性能要求较低,且功耗开销较小的残差网络。因此本申请可以在实现增发效果的基础上,降低对硬件的性能要求,同时降低硬件的功耗开销。In the embodiment of the present application, for the image to be processed, the target image area displaying hair and forehead is input to the target residual network model, and the residual output representing the difference before and after the image to be processed can be obtained. Furthermore, by superimposing the residual output on the image to be processed, the target image after additional issuance of the image to be processed can be obtained. Since the target residual network model utilizes a residual network with low hardware performance requirements and low power consumption overhead. Therefore, the present application can reduce the performance requirements of the hardware and reduce the power consumption of the hardware on the basis of realizing the effect of additional issuance.

可选地,在将目标图像区域输入至目标残差网络模型,得到目标残差网络模型的残差输出之前,该方法还包括:Optionally, before inputting the target image region into the target residual network model to obtain the residual output of the target residual network model, the method further includes:

获取多对增发前后对比图像;其中,每对增发对比图像包括一幅增发前图像和一幅增发后图像。Acquiring multiple pairs of comparison images before and after issuance; wherein, each pair of comparison images includes an image before issuance and an image after issuance.

将增发前图像作为输入,并将增发后图像作为真实值,对初始残差网络模型进行训练,得到目标残差网络模型。Taking the image before additional issuance as input and the image after additional issuance as the real value, the initial residual network model is trained to obtain the target residual network model.

应当说明的是,初始残差网络模型为基于残差网络搭建的未经训练的模型。其中,残差网络可以采用编码+解码结构的网络形式搭建,例如残差网络可以采用UNet搭建。在对初始残差网络模型进行训练的过程中,可以根据经验自行设置学习率以及损失函数。例如学习率可以设置为0.001,损失函数可以采用LPIPS(学习感知图像块相似度,LearnedPerceptual Image Patch Similarity)损失函数+L1损失函数的组合方式,但不限于此。多对增发前后对比图像中,每一对增发前后对比图像为同一个人物的图像,即该人物增发前的图像和该人物增发后的图像,且该人物增发后的图像是在增发前的图像的基础上,增加了发量得到的图像。在获取多对增发前后对比图像时,可以先获取一定数量的人物图像,然后针对每一个人物图像绘制一幅增发后的人物图像,或者利用目前可以实现增发效果的应用程序生成增发后的人物图像,将该人物图像和增发后的该人物图像作为一对增发前后对比图像,但不限于此。It should be noted that the initial residual network model is an untrained model based on the residual network. Among them, the residual network can be built in the network form of encoding + decoding structure, for example, the residual network can be built using UNet. In the process of training the initial residual network model, the learning rate and loss function can be set according to experience. For example, the learning rate can be set to 0.001, and the loss function can adopt a combination of LPIPS (Learned Perceptual Image Patch Similarity) loss function + L1 loss function, but not limited thereto. Among the multiple pairs of comparison images before and after additional issuance, each pair of comparison images before and after additional issuance is an image of the same person, that is, the image of the person before the additional issuance and the image of the person after the additional issuance, and the image of the person after the additional issuance is the image before the additional issuance Based on the obtained image, increase the hair volume. When obtaining multiple pairs of comparison images before and after additional issuance, you can first obtain a certain number of person images, and then draw a person image after additional issuance for each person image, or use the current application that can achieve the effect of additional issuance to generate additional person images , the image of the person and the image of the person after additional issuance are used as a pair of comparison images before and after additional issuance, but it is not limited thereto.

多对增发前后对比图像用于对初始残差网络模型进行模型训练,从而得到训练好的模型,即目标残差网络模型。这里,对于增发前后对比图像的数量,这里不做限制。具体的,每一对增发前后对比图像可以作为一次模型训练的样本。采用监督学习的方式,利用多对增发前后对比图像对初始残差网络模型进行模型训练,直至模型收敛或训练次数达到阈值。值得注意的是,针对残差网络的监督学习,在每一模型训练过程中,将一对增发前后对比图像中的增发前图像作为输入(INPUT),增发后图像作为真实值(ground truth,简称GT),展开模型训练。通过不断的模型训练使得模型中的残差输出可以逐渐准确的表征人物增发前后的差别。Multiple pairs of comparison images before and after additional issuance are used to perform model training on the initial residual network model, so as to obtain a trained model, that is, the target residual network model. Here, there is no limit to the number of comparison images before and after additional issuance. Specifically, each pair of comparison images before and after additional issuance can be used as a sample for model training. In the way of supervised learning, the initial residual network model is trained by using multiple pairs of comparison images before and after additional issuance until the model converges or the number of training times reaches the threshold. It is worth noting that for the supervised learning of the residual network, in the training process of each model, the pre-increment image in a pair of comparison images before and after the increase is used as the input (INPUT), and the image after the increase is used as the real value (ground truth, referred to as GT), expand the model training. Through continuous model training, the residual output in the model can gradually and accurately represent the difference before and after the additional issuance of characters.

本申请实施例中,将多对增发前后对比图像作为训练样本,然后利用训练样本对初始残差网络模型进行训练,从而可以得到用于计算人物增发前后差别的目标残差网络模型。In the embodiment of the present application, multiple pairs of comparison images before and after additional issuance are used as training samples, and then the training samples are used to train the initial residual network model, so that the target residual network model for calculating the difference before and after additional issuance of characters can be obtained.

可选地,获取多对增发前后对比图像,包括:Optionally, obtain multiple pairs of comparison images before and after additional issuance, including:

获取符合高斯分布的多个三维矩阵。Get multiple 3-D matrices that fit a Gaussian distribution.

针对每一个三维矩阵,分别基于预先训练好的风格生成对抗网络模型,生成一对增发前后对比图像。For each three-dimensional matrix, the adversarial network model is generated based on the pre-trained style, and a pair of comparison images before and after additional issuance are generated.

应当说明的是,训练好的风格生成对抗网络模型的模型输入为符合高斯分布的多个三维矩阵,模型输出为包含头发和额头的图像。也就是说,将任一符合高斯分布的三维矩阵输入训练好的风格生成对抗网络模型,均可以得到一幅包含头发和额头的图像。最后,利用模型输出可以得到一对均包含头发和额头的图像作为一对增发前后对比图像。较佳地,这里获取的三维矩阵为随机生成的三维矩阵。It should be noted that the model input of the trained style generation confrontational network model is a plurality of three-dimensional matrices conforming to the Gaussian distribution, and the model output is an image containing hair and forehead. That is to say, any three-dimensional matrix conforming to the Gaussian distribution is input into the trained style generation confrontation network model, and an image containing hair and forehead can be obtained. Finally, using the model output, a pair of images containing hair and forehead can be obtained as a pair of comparison images before and after additional issuance. Preferably, the three-dimensional matrix acquired here is a randomly generated three-dimensional matrix.

本申请实施例中,基于三维矩阵和预先训练好的风格生成对抗网络模型,可以快速生成增发前后对比图像,同时简化了增发前后对比图像的制作过程。In the embodiment of the present application, based on the three-dimensional matrix and the pre-trained style generation confrontation network model, it is possible to quickly generate comparison images before and after additional issuance, and at the same time simplify the production process of comparison images before and after additional issuance.

可选地,在针对每一个三维矩阵,分别基于预先训练好的风格生成对抗网络模型,生成一对增发前后对比图像之前,该方法还包括:Optionally, before each three-dimensional matrix generates a confrontational network model based on a pre-trained style, and generates a pair of comparison images before and after additional issuance, the method further includes:

获取训练样本集;其中,训练样本集包括符合高斯分布的多个随机三维矩阵、包含额头和头发的训练图像;Obtain a training sample set; wherein, the training sample set includes a plurality of random three-dimensional matrices conforming to Gaussian distribution, training images including forehead and hair;

基于训练样本集对目标模型进行训练,得到预先训练好的风格生成对抗网络模型;Based on the training sample set, the target model is trained to obtain a pre-trained style generation confrontation network model;

其中,目标模型包括:初始风格生成对抗网络模型和判别器模型,且初始风格生成对抗网络模型的输出和训练图像作为判别器模型的输入。Among them, the target model includes: an initial style generation confrontation network model and a discriminator model, and the output of the initial style generation confrontation network model and the training image are used as the input of the discriminator model.

应当说明的是,训练样本集用于目标模型的训练。由于训练好的风格生成对抗网络模型可以生成包含头发和额头的图像。因此,需要使用包含额头和头发的训练图像。这里并不限制训练图像的尺寸,但需要各训练图像具有相同的尺寸。具体的,在获取训练图像时,可以先获取利用单反相机拍摄得到的高清人像数据;然后对高清人像数据进行人脸检测和人脸旋转矫正对齐。最后对旋转对齐后的人脸进行头发区域裁剪,统一裁剪为宽度*高度为2:1的尺寸(其他尺寸也可以,这里以1536*768为例),裁剪后的图像即为训练图像。It should be noted that the training sample set is used for training the target model. Thanks to the trained style GAN model can generate images containing hair and forehead. Therefore, training images containing foreheads and hair need to be used. There is no limit to the size of the training images, but it is required that each training image has the same size. Specifically, when obtaining training images, first obtain high-definition portrait data captured by a single-lens reflex camera; then perform face detection and face rotation correction alignment on the high-definition portrait data. Finally, crop the hair area of the rotated and aligned face, and uniformly crop it to a size of 2:1 width*height (other sizes are also available, here we take 1536*768 as an example), and the cropped image is the training image.

由于目标模型包括:初始风格生成对抗网络模型和判别器模型,且初始风格生成对抗网络模型的输出和训练图像作为判别器模型的输入。因此,训练目标模型的过程即为训练目标模型中的初始风格生成对抗网络模型的过程,该训练完成后的初始风格生成对抗网络模型即为训练好的风格生成对抗网络模型。其中,初始风格生成对抗网络模型作为生成器,可以基于符合高斯分布的随机三维矩阵生成一幅图像。所以,这里的初始风格生成对抗网络模型也可以理解为由映射网络(Mapping network)和合成网络(Synthesisnetwork)构成的风格生成对抗网络模型中的合成网络部分。可以理解的是,对目标模型进行的每次训练过程中,需要向初始风格生成对抗网络模型输入一个随机三维矩阵,进而将初始风格生成对抗网络模型的模型输出和一幅训练图像输入判别器模型,得到判别器模型的模型输出。在计算模型损失之后,利用反向传播算法对初始风格生成对抗网络模型和判别器模型的模型参数进行反向更新。在初始风格生成对抗网络模型完全收敛之后,停止模型训练。Since the target model includes: the initial style generation confrontation network model and the discriminator model, and the output of the initial style generation confrontation network model and the training image are used as the input of the discriminator model. Therefore, the process of training the target model is the process of training the initial style generative adversarial network model in the target model, and the initial style generative adversarial network model after the training is the trained style generative adversarial network model. Among them, the initial style generation confrontation network model is used as a generator, which can generate an image based on a random three-dimensional matrix conforming to the Gaussian distribution. Therefore, the initial style generation adversarial network model here can also be understood as the synthesis network part of the style generation adversarial network model composed of a mapping network (Mapping network) and a synthesis network (Synthesis network). It is understandable that during each training process of the target model, a random three-dimensional matrix needs to be input to the initial style generation confrontational network model, and then the model output of the initial style generation confrontational network model and a training image are input into the discriminator model , to get the model output of the discriminator model. After calculating the model loss, the model parameters of the initial style generative adversarial network model and the discriminator model are reversely updated using the backpropagation algorithm. After the initial style generative adversarial network model has fully converged, the model training is stopped.

具体的,如图4所示,可以先初始化一个生成器41,初始化一个判别器模型42。Specifically, as shown in FIG. 4 , a generator 41 may be initialized first, and a discriminator model 42 may be initialized.

首先执行步骤401:随机生成符合高斯分布的三维矩阵W+,将W+输入生成器41,得到生成器41输出的RGB图像43,其中,RGB代表红、绿、蓝三个通道的颜色。此时将一幅训练图像44作为真头发图片,并设置其对应的标签为True(正确)。将RGB图像43作为假头发图片,并设置其对应的标签为False(错误),此时使用损失函数公式1计算损失,并反向传播更新判别器模型的模型参数;First execute step 401: randomly generate a three-dimensional matrix W+ conforming to the Gaussian distribution, and input W+ into the generator 41 to obtain an RGB image 43 output by the generator 41, wherein RGB represents the colors of three channels of red, green and blue. Now use a training image 44 as a real hair picture, and set its corresponding label as True (correct). Use the RGB image 43 as a fake hair picture, and set its corresponding label as False (wrong), at this time, use the loss function formula 1 to calculate the loss, and backpropagate to update the model parameters of the discriminator model;

loss=log(exp(D(G(W+)))+1)+log(exp(-D(x))+1) (1)loss=log(exp(D(G(W+)))+1)+log(exp(-D(x))+1) (1)

其中,G(W+)表示RGB图像43,x训练图像44,D表示判别器模型42。Among them, G(W+) represents RGB image 43 , x training image 44 , and D represents discriminator model 42 .

执行步骤402:重新随机生成符合高斯分布的三维矩阵W+’,将W+’输入生成器41,得到一幅新的RGB图像。此时有训练过的判别器模型42以及一幅新的RGB图像,此时通过损失函数公式2计算损失,并反向传播更新生成器41的权重;Execute step 402: re-randomly generate a three-dimensional matrix W+' conforming to the Gaussian distribution, and input W+' into the generator 41 to obtain a new RGB image. At this time, there is a trained discriminator model 42 and a new RGB image. At this time, the loss is calculated by the loss function formula 2, and the weight of the generator 41 is updated through backpropagation;

loss=-log(exp(D(G(W+)))+1) (2)loss=-log(exp(D(G(W+)))+1) (2)

通过按照步骤401、步骤402的顺序重复执行这两个步骤,可以实现对生成器41的训练,直至生成器41完全收敛为止。此时,将得到一个W+到1536*768图像的映射关系。任意随机一个符合高斯分布的三维矩阵输入至生成器41都将得到一个对应的1536*768的包含头发和额头的图像。By repeatedly executing these two steps in the order of step 401 and step 402, the generator 41 can be trained until the generator 41 converges completely. At this point, a mapping relationship from W+ to 1536*768 images will be obtained. Any random three-dimensional matrix conforming to the Gaussian distribution is input to the generator 41 and a corresponding 1536*768 image including hair and forehead will be obtained.

本申请实施例中,利用随机三维矩阵和包含额头和头发的训练图像,可以实现对风格生成对抗网络模型的训练,从而得到用于利用三维矩阵生成包含额头和头发的图像的网络模型。In the embodiment of the present application, the training of the style generation confrontation network model can be realized by using the random three-dimensional matrix and the training image containing the forehead and hair, so as to obtain the network model used to generate the image containing the forehead and hair using the three-dimensional matrix.

可选地,针对每一个三维矩阵,分别基于预先训练好的风格生成对抗网络模型,生成一对增发前后对比图像,包括:Optionally, for each three-dimensional matrix, generate an adversarial network model based on the pre-trained style respectively, and generate a pair of comparison images before and after additional issuance, including:

将多个三维矩阵分别输入风格生成对抗网络模型,分别得到风格生成对抗网络模型输出的增发前图像。Multiple three-dimensional matrices are respectively input into the style generation confrontation network model, and the pre-issued images output by the style generation confrontation network model are respectively obtained.

基于风格生成对抗网络模型的输出和引导图像对风格生成对抗网络模型的输入进行反向调整,直至反向调整的次数达到目标次数;其中,引导图像为基于增发前图像绘制的增发后的对比图像。Based on the output of the style generation confrontation network model and the guide image, the input of the style generation confrontation network model is reversely adjusted until the number of reverse adjustments reaches the target number of times; wherein, the guide image is a comparison image after issuance based on the image before issuance .

将最后一次反向调整后,风格生成对抗网络模型的输出确定为增发后图像。After the last reverse adjustment, the output of the style generation confrontational network model is determined as the additional image.

应当说明的是,针对每一个三维矩阵可以生成一对增发前后对比图像,本申请实施例仅针对一个三维矩阵生成一对增发前后对比图像为例进行说明。由于任意随机一个符合高斯分布的三维矩阵输入至风格生成对抗网络模型都将得到一个对应的包含头发和额头的图像。因此,将首次得到的图像作为一对增发前后对比图像中的增发前图像。然后基于增发前图像绘制增发后的对比图像,并将增发后的对比图像作为引导图像,反向调整三维矩阵。在反向调整次数达到目标次数的情况下,风格生成对抗网络模型输出的图像将十分接近引导图像,从而将此时输出的图像作为一对增发前后对比图像中的增发后图像。It should be noted that a pair of comparison images before and after additional issuance can be generated for each three-dimensional matrix, and this embodiment of the present application only uses a three-dimensional matrix to generate a pair of comparison images before and after additional issuance as an example. Since any random three-dimensional matrix conforming to the Gaussian distribution is input to the style generation confrontation network model, a corresponding image containing hair and forehead will be obtained. Therefore, the image obtained for the first time is taken as the pre-issue image in a pair of comparison images before and after additional issuance. Then, based on the image before the additional issuance, a comparison image after the additional issuance is drawn, and the comparison image after the additional issuance is used as a guide image to reversely adjust the three-dimensional matrix. When the number of reverse adjustments reaches the target number, the image output by the style generation confrontational network model will be very close to the guide image, so the output image at this time can be used as the post-issue image in a pair of comparison images before and after the increase.

如图5所示,为得到一对增发前后对比图像中的增发前图像51和增发后图像52的流程图,具体的,包括:As shown in Figure 5, in order to obtain a flow chart of the pre-issue image 51 and the image 52 after the additional issue in a pair of comparison images before and after the additional issue, specifically, it includes:

步骤501:将符合高斯分布的一个三维矩阵W+输入至风格生成对抗网络模型53,得到增发前图像51,并存储该增发前图像51作为一对增发前后对比图像中的增发前图像。Step 501: Input a three-dimensional matrix W+ conforming to the Gaussian distribution into the style generation confrontational network model 53 to obtain the pre-issue image 51, and store the pre-issue image 51 as the pre-issue image in a pair of comparison images before and after the increase.

步骤502:使用画笔在增发前图像51中画出增发区域的头发(可以仅画出头发颜色即可),生成引导图像54。Step 502: Use a paintbrush to draw the hair of the hair growth area in the image 51 before the hair growth (only the hair color can be drawn), and generate the guide image 54 .

步骤503:使用L1损失函数计算增发前图像51和引导图像54之间的差值,得到两图的效果差距loss=|增发前图像51-引导图像54|。Step 503: Use the L1 loss function to calculate the difference between the pre-issued image 51 and the guide image 54, and obtain the effect gap loss=|before-issued image 51−guided image 54| of the two images.

步骤504:将模型训练过程中的学习率设置为0.01,并将优化器设置为Adam(自适应矩估计,Adaptive Moment Estimation)优化器,使用反向传播方法对损失沿着风格生成对抗网络模型53的反向传播到三维矩阵W+,此时通过反向传播来的梯度更新三维矩阵W+内的数字得到新的三维矩阵W+*。Step 504: The learning rate in the model training process is set to 0.01, and the optimizer is set to Adam (Adaptive Moment Estimation, Adaptive Moment Estimation) optimizer, using the backpropagation method to generate an adversarial network model 53 along the style of loss The backpropagation to the three-dimensional matrix W+, at this time, the gradient in the backpropagation is used to update the numbers in the three-dimensional matrix W+ to obtain a new three-dimensional matrix W+*.

步骤505:将新的三维矩阵W+*输入至风格生成对抗网络模型53,得到新的增发前图像。Step 505: Input the new three-dimensional matrix W+* into the style generation confrontational network model 53 to obtain a new image before additional issuance.

步骤506:使用L1损失函数计算新的增发前图像和引导图像54之间的差值,得到两图的效果差距loss=|新的增发前图像-引导图像54|。Step 506: Use the L1 loss function to calculate the difference between the new pre-issue image and the guide image 54, and obtain the effect gap loss=|new pre-issue image-guidance image 54| of the two images.

重复执行步骤504~步骤506,且重复执行目标次数。其中,在重复执行的过程中,风格生成对抗网络模型53会参考引导图像54来逐步对增发前图像51进行头发增长,并填充头发纹理。目标次数可以任意设置,例如目标次数可以为100次,但不限于此。将风格生成对抗网络模型53最后输出的图像作为一对增发前后对比图像中的增发后图像。Steps 504 to 506 are repeatedly executed for a target number of times. Among them, in the process of repeated execution, the style generation confrontation network model 53 will refer to the guide image 54 to gradually grow the hair on the image 51 before additional issuance, and fill in the hair texture. The target number of times can be set arbitrarily, for example, the target number of times can be 100 times, but it is not limited thereto. The image finally output by the style generation confrontational network model 53 is used as the post-issue image in a pair of comparison images before and after additional issue.

本申请实施例中,在生成增发前图像之后,以绘制的增发后的对比图像为引导图像。通过对风格生成对抗网络模型的输入进行不断的反向调整,可以得到增发后图像,且增发前图像和增发后图像的尺寸相同。In the embodiment of the present application, after the image before additional issuance is generated, the drawn comparison image after additional issuance is used as the guiding image. By continuously adjusting the input of the style generation confrontational network model in reverse, the image after the increase can be obtained, and the size of the image before and after the increase is the same.

可选地,目标残差网络模型的输入为第一尺寸的图像,在待处理图像的尺寸小于或大于第一尺寸的情况下,将目标图像区域输入至目标残差网络模型,得到目标残差网络模型的残差输出,包括:Optionally, the input of the target residual network model is an image of the first size, and when the size of the image to be processed is smaller or larger than the first size, the target image area is input to the target residual network model to obtain the target residual The residual output of the network model, including:

对目标图像区域进行仿射变换,生成第一尺寸的第一中间图像;Affine transformation is performed on the target image area to generate a first intermediate image of the first size;

将第一中间图像输入至目标残差网络模型,得到目标残差网络模型的残差输出;The first intermediate image is input to the target residual network model to obtain the residual output of the target residual network model;

将残差输出叠加到待处理图像,得到待处理图像增发后的目标图像,包括:Superimpose the residual output on the image to be processed to obtain the target image after the additional image to be processed, including:

对残差输出进行逆仿射变换,生成第二尺寸的第二中间图像,其中,第二尺寸为待处理图像的尺寸;Performing an inverse affine transformation on the residual output to generate a second intermediate image of a second size, where the second size is the size of the image to be processed;

将第二中间图像叠加到待处理图像,得到目标图像。The second intermediate image is superimposed on the image to be processed to obtain the target image.

应当说明的是,目标残差网络模型为预先训练好的网络模型,在训练结束之后,其输入图像的尺寸将会固定下来。由于待处理图像的尺寸并不一定符合目标残差网络模型对输入图像的尺寸要求。因此,可以先行检测待处理图像的尺寸。若其尺寸为第一尺寸,即待处理图像的尺寸符合目标残差网络模型对输入图像的尺寸要求,则可以直接使用待处理图像。否则需要经过仿射变换,并针对残差输出进行逆仿射变换,使得残差输出的尺寸与待处理图像的尺寸一致,避免由于尺寸不一致导致的各种问题。例如,使用1024分辨率的图像训练得到目标残差网络模型。在原图(待处理图像)是4096分辨率的情况下,利用仿射变换下采样到1024分辨率,然后喂入目标残差网络模型,生成1024分辨率的残差输出,再将残差输出放大至4096分辨率叠加到原图。It should be noted that the target residual network model is a pre-trained network model, and the size of its input image will be fixed after the training. Since the size of the image to be processed does not necessarily meet the size requirements of the target residual network model for the input image. Therefore, the size of the image to be processed can be detected in advance. If its size is the first size, that is, the size of the image to be processed meets the size requirement of the target residual network model for the input image, then the image to be processed can be used directly. Otherwise, affine transformation is required, and an inverse affine transformation is performed on the residual output, so that the size of the residual output is consistent with the size of the image to be processed, and various problems caused by inconsistent sizes are avoided. For example, use 1024 resolution image training to get the target residual network model. When the original image (image to be processed) is 4096 resolution, use affine transformation to downsample to 1024 resolution, then feed the target residual network model to generate 1024 resolution residual output, and then enlarge the residual output Up to 4096 resolution superimposed on the original image.

本申请实施例中,通过对待处理图像进行仿射变换以及对残差输出进行逆仿射变换,可以对各种尺寸的待处理图像进行处理,且不会影响目标图像的清晰度。In the embodiment of the present application, by performing affine transformation on the image to be processed and performing inverse affine transformation on the residual output, images to be processed of various sizes can be processed without affecting the definition of the target image.

可选地,对目标图像区域进行仿射变换,生成第一尺寸的第一中间图像,包括:Optionally, affine transformation is performed on the target image area to generate a first intermediate image of the first size, including:

裁剪待处理图像中的目标图像区域,得到裁剪图像。Crop the target image area in the image to be processed to obtain a cropped image.

对裁剪图像进行仿射变换,生成第一尺寸的第一中间图像。Affine transformation is performed on the cropped image to generate a first intermediate image of the first size.

应当说明的是,由于本申请所提供的方法是对待处理图像实现增发效果。因此,可以仅针对待处理图像中的目标图像区域进行处理即可。这里,将目标图像区域裁剪出来,得到裁剪图像。It should be noted that, since the method provided by the present application is to achieve the effect of additional issuance of the image to be processed. Therefore, only the target image area in the image to be processed can be processed. Here, the target image area is cropped to obtain a cropped image.

本申请实施例中,通过将待处理图像中的目标图像区域裁剪出来,可以得到裁剪图像。进而利用裁剪图像得到残差输出,可以避免待处理图像中除目标图像区域之外的其它图像区域的信息所造成的影响。In the embodiment of the present application, the cropped image can be obtained by cropping the target image area in the image to be processed. Furthermore, the cropped image is used to obtain the residual output, which can avoid the influence caused by the information of other image areas in the image to be processed except the target image area.

如图6所示,为本申请实施例提供的图像处理的方法的实际应用示意图;本申请将分辨率作为图像的尺寸,针对尺寸为4096*4096的待处理图像61,生成其增发后的目标图像62。假设已经训练好的目标残差网络模型63的输入图像的尺寸为1536*768。则该过程包括:As shown in Figure 6, it is a schematic diagram of the practical application of the image processing method provided by the embodiment of this application; this application regards the resolution as the size of the image, and generates an additional target for the image 61 to be processed with a size of 4096*4096 Image 62. Assume that the size of the input image of the trained target residual network model 63 is 1536*768. The process then includes:

步骤601:获取尺寸为4096*4096的待处理图像61。Step 601: Obtain an image 61 to be processed with a size of 4096*4096.

步骤602:针对待处理图像61,检测人脸框并将头发和额头的图像区域裁剪出来得到裁剪图像64。Step 602 : For the image to be processed 61 , detect the frame of the human face and crop the hair and forehead image areas to obtain a cropped image 64 .

步骤603:将裁剪图像64放缩至1536*768,得到原始中间图像65。Step 603: Scale the cropped image 64 to 1536*768 to obtain the original intermediate image 65.

步骤604:将1536*768的原始中间图像65输入目标残差网络模型63后得到1536*768的残差输出66。其中,残差输出66可以理解为对应原始中间图像65的残差。Step 604: Input the original intermediate image 65 of 1536*768 into the target residual network model 63 to obtain a residual output 66 of 1536*768. Wherein, the residual output 66 can be understood as the residual corresponding to the original intermediate image 65 .

步骤605:将1536*768的残差输出66缩放为4096*4096的中间残差输出67。其中,中间残差输出67可以理解为对应裁剪图像64。Step 605: Scale the residual output 66 of 1536*768 to an intermediate residual output 67 of 4096*4096. Wherein, the intermediate residual output 67 can be understood as corresponding to the cropped image 64 .

步骤606:基于中间残差输出67,生成对应待处理图像61的残差,即目标残差68。将目标残差68叠加至待处理图像61的裁剪区域得到最终效果图,即目标图像62。Step 606 : Based on the intermediate residual output 67 , generate a residual corresponding to the image to be processed 61 , that is, a target residual 68 . The target residual 68 is superimposed on the clipped area of the image 61 to be processed to obtain the final rendering, namely the target image 62 .

本申请实施例中,通过设计残差网络实现了能够在控制性能功耗的情况下,提升最终图片的清晰度,解决了传统风格生成对抗网络路线下的清晰度下降、性能功耗过高和算子不支持的缺点。In the embodiment of the present application, by designing the residual network, it is possible to improve the definition of the final picture while controlling the performance and power consumption, and solve the problem of the reduction of definition, excessive performance and power consumption, and Operators do not support the disadvantages.

需要说明的是,本申请实施例提供的图像处理的方法,执行主体可以为图像处理的装置,或者图像处理的装置中的用于执行图像处理的方法的控制模块。本申请实施例中以图像处理的装置执行图像处理的方法为例,说明本申请实施例提供的图像处理的装置。It should be noted that, the image processing method provided in the embodiment of the present application may be executed by an image processing device, or a control module in the image processing device for executing the image processing method. In the embodiment of the present application, the image processing device provided in the embodiment of the present application is described by taking an image processing device performing an image processing method as an example.

如图7所示,本申请实施例还提供了一种图像处理的装置,该装置包括:As shown in Figure 7, the embodiment of the present application also provides an image processing device, which includes:

第一获取模块71,用于获取待处理图像;A first acquisition module 71, configured to acquire an image to be processed;

残差模块72,用于将目标图像区域输入至目标残差网络模型,得到目标残差网络模型的残差输出;其中,目标图像区域包括:待处理图像中显示有头发和额头的图像区域;The residual module 72 is used to input the target image area to the target residual network model to obtain the residual output of the target residual network model; wherein, the target image area includes: an image area showing hair and forehead in the image to be processed;

处理模块73,用于将残差输出叠加到待处理图像,得到待处理图像增发后的目标图像。The processing module 73 is configured to superimpose the residual output on the image to be processed to obtain a target image after the image to be processed is added.

可选地,该装置还包括:Optionally, the device also includes:

第二获取模块,用于获取多对增发前后对比图像;其中,每对增发对比图像包括一幅增发前图像和一幅增发后图像;The second acquisition module is used to acquire multiple pairs of comparison images before and after issuance; wherein, each pair of comparison images includes an image before issuance and an image after issuance;

第一训练模块,用于将增发前图像作为输入,并将增发后图像作为真实值,对初始残差网络模型进行训练,得到目标残差网络模型。The first training module is used to train the initial residual network model by using the pre-issued image as input and the post-issued image as a real value to obtain a target residual network model.

可选地,第二获取模块,包括:Optionally, the second acquisition module includes:

获取单元,用于获取符合高斯分布的多个三维矩阵;An acquisition unit, configured to acquire a plurality of three-dimensional matrices conforming to Gaussian distribution;

生成单元,用于针对每一个三维矩阵,分别基于预先训练好的风格生成对抗网络模型,生成一对增发前后对比图像。The generation unit is configured to generate a confrontational network model based on a pre-trained style for each three-dimensional matrix, and generate a pair of comparison images before and after additional issuance.

可选地,该装置还包括:Optionally, the device also includes:

第三获取模块,用于获取训练样本集;其中,训练样本集包括符合高斯分布的多个随机三维矩阵、包含额头和头发的训练图像;The third acquisition module is used to acquire a training sample set; wherein, the training sample set includes a plurality of random three-dimensional matrices conforming to Gaussian distribution, training images including forehead and hair;

第二训练模块,用于基于训练样本集对目标模型进行训练,得到预先训练好的风格生成对抗网络模型;The second training module is used to train the target model based on the training sample set to obtain a pre-trained style generation confrontation network model;

其中,目标模型包括:初始风格生成对抗网络模型和判别器模型,且初始风格生成对抗网络模型的输出和训练图像作为判别器模型的输入。Among them, the target model includes: an initial style generation confrontation network model and a discriminator model, and the output of the initial style generation confrontation network model and the training image are used as the input of the discriminator model.

可选地,生成单元,具体用于:Optionally, generate units, specifically for:

将多个三维矩阵分别输入风格生成对抗网络模型,分别得到风格生成对抗网络模型输出的增发前图像;Input multiple three-dimensional matrices into the style generation confrontation network model respectively, and respectively obtain the pre-issued images output by the style generation confrontation network model;

基于风格生成对抗网络模型的输出和引导图像对风格生成对抗网络模型的输入进行反向调整,直至反向调整的次数达到目标次数;其中,引导图像为基于增发前图像绘制的增发后的对比图像;Based on the output of the style generation confrontation network model and the guide image, the input of the style generation confrontation network model is reversely adjusted until the number of reverse adjustments reaches the target number of times; wherein, the guide image is a comparison image after issuance based on the image before issuance ;

将最后一次反向调整后,风格生成对抗网络模型的输出确定为增发后图像。After the last reverse adjustment, the output of the style generation confrontational network model is determined as the additional image.

可选地,目标残差网络模型的输入为第一尺寸的图像,在待处理图像的尺寸小于或大于第一尺寸的情况下,残差模块72,包括:Optionally, the input of the target residual network model is an image of the first size, and when the size of the image to be processed is smaller or larger than the first size, the residual module 72 includes:

仿射变换单元,用于对目标图像区域进行仿射变换,生成第一尺寸的第一中间图像;An affine transformation unit, configured to perform affine transformation on the target image area to generate a first intermediate image of the first size;

残差单元,用于将第一中间图像输入至目标残差网络模型,得到目标残差网络模型的残差输出;The residual unit is used to input the first intermediate image to the target residual network model to obtain the residual output of the target residual network model;

处理模块73,包括:Processing module 73, comprising:

逆仿射变换单元,用于对残差输出进行逆仿射变换,生成第二尺寸的第二中间图像,其中,第二尺寸为待处理图像的尺寸;An inverse affine transformation unit, configured to perform inverse affine transformation on the residual output to generate a second intermediate image of a second size, where the second size is the size of the image to be processed;

处理单元,用于将第二中间图像叠加到待处理图像,得到目标图像。The processing unit is configured to superimpose the second intermediate image on the image to be processed to obtain the target image.

可选地,仿射变换单元,具体用于:Optionally, an affine transformation unit, specifically for:

裁剪待处理图像中的目标图像区域,得到裁剪图像;Crop the target image area in the image to be processed to obtain a cropped image;

对裁剪图像进行仿射变换,生成第一尺寸的第一中间图像。Affine transformation is performed on the cropped image to generate a first intermediate image of the first size.

本申请实施例中,针对待处理图像,将其显示有头发和额头的目标图像区域输入至目标残差网络模型。由于目标残差网络模型用于计算人物增发前后差别,所以可以得到表征待处理图像增发前后差别的残差输出。进而通过将残差输出叠加到待处理图像,可以得到待处理图像增发后的目标图像。由于目标残差网络模型利用了对硬件性能要求较低,且功耗开销较小的残差网络。因此本申请可以在实现增发效果的基础上,降低对硬件的性能要求,同时降低硬件的功耗开销。In the embodiment of the present application, for the image to be processed, the target image area displaying hair and forehead is input to the target residual network model. Since the target residual network model is used to calculate the difference before and after the person is added, the residual output representing the difference before and after the image to be processed can be obtained. Furthermore, by superimposing the residual output on the image to be processed, the target image after additional issuance of the image to be processed can be obtained. Since the target residual network model utilizes a residual network with low hardware performance requirements and low power consumption overhead. Therefore, the present application can reduce the performance requirements of the hardware and reduce the power consumption of the hardware on the basis of realizing the effect of additional issuance.

本申请实施例中的图像处理的装置可以是电子设备,也可以是电子设备中的部件,例如集成电路或芯片。该电子设备可以是终端,也可以为除终端之外的其他设备。示例性的,电子设备可以为手机、平板电脑、笔记本电脑、掌上电脑、车载电子设备、移动上网装置(Mobile Internet Device,MID)、增强现实(augmented reality,AR)/虚拟现实(virtual reality,VR)设备、机器人、可穿戴设备、超级移动个人计算机(ultra-mobilepersonal computer,UMPC)、上网本或者个人数字助理(personal digital assistant,PDA)等,还可以为服务器、网络附属存储器(Network Attached Storage,NAS)、个人计算机(personal computer,PC)、电视机(television,TV)、柜员机或者自助机等,本申请实施例不作具体限定。The image processing apparatus in the embodiment of the present application may be an electronic device, or may be a component in the electronic device, such as an integrated circuit or a chip. The electronic device may be a terminal, or other devices other than the terminal. Exemplarily, the electronic device may be a mobile phone, a tablet computer, a notebook computer, a handheld computer, a vehicle electronic device, a mobile Internet device (Mobile Internet Device, MID), an augmented reality (augmented reality, AR)/virtual reality (virtual reality, VR ) equipment, robots, wearable devices, ultra-mobile personal computer (ultra-mobilepersonal computer, UMPC), netbook or personal digital assistant (personal digital assistant, PDA), etc. ), a personal computer (personal computer, PC), a television (television, TV), a teller machine or a self-service machine, etc., which are not specifically limited in this embodiment of the present application.

本申请实施例中的图像处理的装置可以为具有操作系统的装置。该操作系统可以为安卓(Android)操作系统,可以为iOS操作系统,还可以为其他可能的操作系统,本申请实施例不作具体限定。The image processing device in the embodiment of the present application may be a device with an operating system. The operating system may be an Android operating system, an iOS operating system, or other possible operating systems, which are not specifically limited in this embodiment of the present application.

本申请实施例提供的图像处理的装置能够实现图2-图6的方法实施例实现的各个过程,实现相同的技术效果,为避免重复,这里不再赘述。The image processing device provided by the embodiment of the present application can implement the various processes realized by the method embodiments in Fig. 2-Fig. 6 and achieve the same technical effect. In order to avoid repetition, details are not repeated here.

可选地,如图8所示,本申请实施例还提供一种电子设备800,包括处理器801和存储器802,存储器802上存储有可在所述处理器801上运行的程序或指令,该程序或指令被处理器801执行时实现上述图像处理的方法实施例的各个步骤,且能达到相同的技术效果,为避免重复,这里不再赘述。Optionally, as shown in FIG. 8 , the embodiment of the present application also provides an electronic device 800, including a processor 801 and a memory 802, and the memory 802 stores programs or instructions that can run on the processor 801. The When the programs or instructions are executed by the processor 801, the various steps of the above image processing method embodiments can be realized, and the same technical effect can be achieved, so in order to avoid repetition, details are not repeated here.

需要说明的是,本申请实施例中的电子设备包括上述所述的移动电子设备和非移动电子设备。It should be noted that the electronic devices in the embodiments of the present application include the above-mentioned mobile electronic devices and non-mobile electronic devices.

图9为实现本申请实施例的一种电子设备的硬件结构示意图。FIG. 9 is a schematic diagram of a hardware structure of an electronic device implementing an embodiment of the present application.

该电子设备900包括但不限于:射频单元901、网络模块902、音频输出单元903、输入单元904、传感器905、显示单元906、用户输入单元907、接口单元908、存储器909、以及处理器910等部件。The electronic device 900 includes, but is not limited to: a radio frequency unit 901, a network module 902, an audio output unit 903, an input unit 904, a sensor 905, a display unit 906, a user input unit 907, an interface unit 908, a memory 909, and a processor 910, etc. part.

本领域技术人员可以理解,电子设备900还可以包括给各个部件供电的电源(比如电池),电源可以通过电源管理系统与处理器910逻辑相连,从而通过电源管理系统实现管理充电、放电、以及功耗管理等功能。图9中示出的电子设备结构并不构成对电子设备的限定,电子设备可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件布置,在此不再赘述。Those skilled in the art can understand that the electronic device 900 can also include a power supply (such as a battery) for supplying power to various components, and the power supply can be logically connected to the processor 910 through the power management system, so that the management of charging, discharging, and function can be realized through the power management system. Consumption management and other functions. The structure of the electronic device shown in FIG. 9 does not constitute a limitation to the electronic device. The electronic device may include more or fewer components than shown in the figure, or combine some components, or arrange different components, which will not be repeated here. .

处理器910,用于获取待处理图像。Processor 910, configured to acquire images to be processed.

处理器910,还用于将目标图像区域输入至目标残差网络模型,得到目标残差网络模型的残差输出;其中,目标图像区域包括:待处理图像中显示有头发和额头的图像区域。The processor 910 is further configured to input the target image area into the target residual network model to obtain the residual output of the target residual network model; wherein, the target image area includes: an image area showing hair and forehead in the image to be processed.

处理器910,还用于将残差输出叠加到待处理图像,得到待处理图像增发后的目标图像。The processor 910 is further configured to superimpose the residual output on the image to be processed to obtain a target image after the image to be processed is added.

本申请实施例中,针对待处理图像,将其显示有头发和额头的目标图像区域输入至目标残差网络模型,可以得到表征待处理图像增发前后差别的残差输出。进而通过将残差输出叠加到待处理图像,可以得到待处理图像增发后的目标图像。由于目标残差网络模型利用了对硬件性能要求较低,且功耗开销较小的残差网络。因此本申请可以在实现增发效果的基础上,降低对硬件的性能要求,同时降低硬件的功耗开销。In the embodiment of the present application, for the image to be processed, the target image area displaying hair and forehead is input to the target residual network model, and the residual output representing the difference before and after the image to be processed can be obtained. Furthermore, by superimposing the residual output on the image to be processed, the target image after additional issuance of the image to be processed can be obtained. Since the target residual network model utilizes a residual network with low hardware performance requirements and low power consumption overhead. Therefore, the present application can reduce the performance requirements of the hardware and reduce the power consumption of the hardware on the basis of realizing the effect of additional issuance.

应理解的是,本申请实施例中,输入单元904可以包括图形处理器(GraphicsProcessing Unit,GPU)9041和麦克风9042,图形处理器9041对在视频捕获模式或图像捕获模式中由图像捕获装置(如摄像头)获得的静态图片或视频的图像数据进行处理。显示单元906可包括显示面板9061,可以采用液晶显示器、有机发光二极管等形式来配置显示面板9061。用户输入单元907包括触控面板9071以及其他输入设备9072中的至少一种。触控面板9071,也称为触摸屏。触控面板9071可包括触摸检测装置和触摸控制器两个部分。其他输入设备9072可以包括但不限于物理键盘、功能键(比如音量控制按键、开关按键等)、轨迹球、鼠标、操作杆,在此不再赘述。It should be understood that, in this embodiment of the present application, the input unit 904 may include a graphics processing unit (Graphics Processing Unit, GPU) 9041 and a microphone 9042, and the graphics processing unit 9041 is compatible with an image capture device (such as Camera) to process the image data of still pictures or videos. The display unit 906 may include a display panel 9061, and the display panel 9061 may be configured in the form of a liquid crystal display, an organic light emitting diode, or the like. The user input unit 907 includes at least one of a touch panel 9071 and other input devices 9072 . The touch panel 9071 is also called a touch screen. The touch panel 9071 may include two parts, a touch detection device and a touch controller. Other input devices 9072 may include, but are not limited to, physical keyboards, function keys (such as volume control keys, switch keys, etc.), trackballs, mice, and joysticks, which will not be repeated here.

存储器909可用于存储软件程序以及各种数据。存储器909可主要包括存储程序或指令的第一存储区和存储数据的第二存储区,其中,第一存储区可存储操作系统、至少一个功能所需的应用程序或指令(比如声音播放功能、图像播放功能等)等。此外,存储器909可以包括易失性存储器或非易失性存储器,或者,存储器x09可以包括易失性和非易失性存储器两者。其中,非易失性存储器可以是只读存储器(Read-Only Memory,ROM)、可编程只读存储器(Programmable ROM,PROM)、可擦除可编程只读存储器(Erasable PROM,EPROM)、电可擦除可编程只读存储器(Electrically EPROM,EEPROM)或闪存。易失性存储器可以是随机存取存储器(Random Access Memory,RAM),静态随机存取存储器(Static RAM,SRAM)、动态随机存取存储器(Dynamic RAM,DRAM)、同步动态随机存取存储器(Synchronous DRAM,SDRAM)、双倍数据速率同步动态随机存取存储器(Double Data Rate SDRAM,DDRSDRAM)、增强型同步动态随机存取存储器(Enhanced SDRAM,ESDRAM)、同步连接动态随机存取存储器(Synch link DRAM,SLDRAM)和直接内存总线随机存取存储器(Direct Rambus RAM,DRRAM)。本申请实施例中的存储器909包括但不限于这些和任意其它适合类型的存储器。The memory 909 can be used to store software programs as well as various data. The memory 909 may mainly include a first storage area for storing programs or instructions and a second storage area for storing data, wherein the first storage area may store an operating system, an application program or instructions required by at least one function (such as a sound playing function, image playback function, etc.), etc. Furthermore, memory 909 may include volatile memory or nonvolatile memory, or memory x09 may include both volatile and nonvolatile memory. Wherein, the non-volatile memory may be a read-only memory (Read-Only Memory, ROM), a programmable read-only memory (Programmable ROM, PROM), an erasable programmable read-only memory (Erasable PROM, EPROM), an electronically programmable Erase Programmable Read-Only Memory (Electrically EPROM, EEPROM) or Flash. Volatile memory can be random access memory (Random Access Memory, RAM), static random access memory (Static RAM, SRAM), dynamic random access memory (Dynamic RAM, DRAM), synchronous dynamic random access memory (Synchronous DRAM, SDRAM), double data rate synchronous dynamic random access memory (Double Data Rate SDRAM, DDRSDRAM), enhanced synchronous dynamic random access memory (Enhanced SDRAM, ESDRAM), synchronous connection dynamic random access memory (Synch link DRAM , SLDRAM) and Direct Memory Bus Random Access Memory (Direct Rambus RAM, DRRAM). The memory 909 in the embodiment of the present application includes but is not limited to these and any other suitable types of memory.

处理器910可包括一个或多个处理单元;可选地,处理器910集成应用处理器和调制解调处理器,其中,应用处理器主要处理涉及操作系统、用户界面和应用程序等的操作,调制解调处理器主要处理无线通信信号,如基带处理器。可以理解的是,上述调制解调处理器也可以不集成到处理器910中。The processor 910 may include one or more processing units; optionally, the processor 910 integrates an application processor and a modem processor, wherein the application processor mainly handles operations related to the operating system, user interface, and application programs, etc., Modem processors mainly process wireless communication signals, such as baseband processors. It can be understood that the foregoing modem processor may not be integrated into the processor 910 .

本申请实施例还提供一种可读存储介质,所述可读存储介质上存储有程序或指令,该程序或指令被处理器执行时实现上述图像处理的方法实施例的各个过程,且能达到相同的技术效果,为避免重复,这里不再赘述。The embodiment of the present application also provides a readable storage medium, the readable storage medium stores a program or an instruction, and when the program or instruction is executed by a processor, each process of the above-mentioned image processing method embodiment is realized, and can achieve The same technical effects are not repeated here to avoid repetition.

其中,所述处理器为上述实施例中所述的电子设备中的处理器。所述可读存储介质,包括计算机可读存储介质,如计算机只读存储器(Read-Only Memory,ROM)、随机存取存储器(Random Access Memory,RAM)、磁碟或者光盘等。Wherein, the processor is the processor in the electronic device described in the above embodiments. The readable storage medium includes a computer readable storage medium, such as a computer read-only memory (Read-Only Memory, ROM), a random access memory (Random Access Memory, RAM), a magnetic disk or an optical disk, and the like.

本申请实施例另提供了一种芯片,所述芯片包括处理器和通信接口,所述通信接口和所述处理器耦合,所述处理器用于运行程序或指令,实现上述图像处理的方法实施例的各个过程,且能达到相同的技术效果,为避免重复,这里不再赘述。The embodiment of the present application further provides a chip, the chip includes a processor and a communication interface, the communication interface is coupled to the processor, the processor is used to run programs or instructions, and implement the above image processing method embodiment Each process, and can achieve the same technical effect, in order to avoid repetition, will not repeat them here.

应理解,本申请实施例提到的芯片还可以称为系统级芯片、系统芯片、芯片系统或片上系统芯片等。It should be understood that the chips mentioned in the embodiments of the present application may also be called system-on-chip, system-on-chip, system-on-a-chip, or system-on-a-chip.

本申请实施例提供一种计算机程序产品,该程序产品被存储在存储介质中,该程序产品被至少一个处理器执行以实现如上述图像处理的方法实施例的各个过程,且能达到相同的技术效果,为避免重复,这里不再赘述。An embodiment of the present application provides a computer program product, the program product is stored in a storage medium, and the program product is executed by at least one processor to implement the various processes in the above image processing method embodiment, and can achieve the same technology Effect, in order to avoid repetition, will not repeat them here.

需要说明的是,在本文中,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者装置不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者装置所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括该要素的过程、方法、物品或者装置中还存在另外的相同要素。此外,需要指出的是,本申请实施方式中的方法和装置的范围不限按示出或讨论的顺序来执行功能,还可包括根据所涉及的功能按基本同时的方式或按相反的顺序来执行功能,例如,可以按不同于所描述的次序来执行所描述的方法,并且还可以添加、省去、或组合各种步骤。另外,参照某些示例所描述的特征可在其他示例中被组合。It should be noted that, in this document, the term "comprising", "comprising" or any other variation thereof is intended to cover a non-exclusive inclusion such that a process, method, article or apparatus comprising a set of elements includes not only those elements, It also includes other elements not expressly listed, or elements inherent in the process, method, article, or device. Without further limitations, an element defined by the phrase "comprising a ..." does not preclude the presence of additional identical elements in the process, method, article, or apparatus comprising that element. In addition, it should be pointed out that the scope of the methods and devices in the embodiments of the present application is not limited to performing functions in the order shown or discussed, and may also include performing functions in a substantially simultaneous manner or in reverse order according to the functions involved. Functions are performed, for example, the described methods may be performed in an order different from that described, and various steps may also be added, omitted, or combined. Additionally, features described with reference to certain examples may be combined in other examples.

通过以上的实施方式的描述,本领域的技术人员可以清楚地了解到上述实施例方法可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬件,但很多情况下前者是更佳的实施方式。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分可以以计算机软件产品的形式体现出来,该计算机软件产品存储在一个存储介质(如ROM/RAM、磁碟、光盘)中,包括若干指令用以使得一台终端(可以是手机,计算机,服务器,或者网络设备等)执行本申请各个实施例所述的方法。Through the description of the above embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus a necessary general-purpose hardware platform, and of course also by hardware, but in many cases the former is better implementation. Based on such an understanding, the technical solution of the present application can be embodied in the form of computer software products, which are stored in a storage medium (such as ROM/RAM, magnetic disk, etc.) , optical disc), including several instructions to enable a terminal (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods described in various embodiments of the present application.

上面结合附图对本申请的实施例进行了描述,但是本申请并不局限于上述的具体实施方式,上述的具体实施方式仅仅是示意性的,而不是限制性的,本领域的普通技术人员在本申请的启示下,在不脱离本申请宗旨和权利要求所保护的范围情况下,还可做出很多形式,均属于本申请的保护之内。The embodiments of the present application have been described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementations. The above-mentioned specific implementations are only illustrative and not restrictive. Those of ordinary skill in the art will Under the inspiration of this application, without departing from the purpose of this application and the scope of protection of the claims, many forms can also be made, all of which belong to the protection of this application.

Claims (10)

1.一种图像处理的方法,其特征在于,所述方法包括:1. A method for image processing, characterized in that the method comprises: 获取待处理图像;Get the image to be processed; 将目标图像区域输入至目标残差网络模型,得到所述目标残差网络模型的残差输出;其中,所述目标图像区域包括:所述待处理图像中显示有头发和额头的图像区域;The target image area is input to the target residual network model to obtain the residual output of the target residual network model; wherein, the target image area includes: an image area showing hair and forehead in the image to be processed; 将所述残差输出叠加到所述待处理图像,得到所述待处理图像增发后的目标图像。The residual output is superimposed on the image to be processed to obtain a target image of the image to be processed. 2.根据权利要求1所述的方法,其特征在于,在所述将目标图像区域输入至目标残差网络模型,得到所述目标残差网络模型的残差输出之前,所述方法还包括:2. The method according to claim 1, characterized in that, before the target image region is input to the target residual network model to obtain the residual output of the target residual network model, the method further comprises: 获取多对增发前后对比图像;其中,每对增发对比图像包括一幅增发前图像和一幅增发后图像;Obtaining multiple pairs of comparison images before and after issuance; wherein, each pair of comparison images includes an image before issuance and an image after issuance; 将所述增发前图像作为输入,并将所述增发后图像作为真实值,对初始残差网络模型进行训练,得到所述目标残差网络模型。Using the pre-issued image as an input and the post-issued image as a real value, train an initial residual network model to obtain the target residual network model. 3.根据权利要求2所述的方法,其特征在于,所述获取多对增发前后对比图像,包括:3. The method according to claim 2, wherein said acquiring multiple pairs of comparison images before and after additional issuance comprises: 获取符合高斯分布的多个三维矩阵;Obtain multiple three-dimensional matrices conforming to Gaussian distribution; 针对每一个所述三维矩阵,分别基于预先训练好的风格生成对抗网络模型,生成一对增发前后对比图像。For each of the three-dimensional matrices, an adversarial network model is generated based on a pre-trained style, and a pair of comparison images before and after additional issuance are generated. 4.根据权利要求3所述的方法,其特征在于,所述针对每一个所述三维矩阵,分别基于预先训练好的风格生成对抗网络模型,生成一对增发前后对比图像,包括:4. The method according to claim 3, wherein, for each of the three-dimensional matrices, generating an adversarial network model based on a pre-trained style respectively, generating a pair of comparison images before and after additional issuance, including: 将所述多个三维矩阵分别输入所述风格生成对抗网络模型,分别得到所述风格生成对抗网络模型输出的所述增发前图像;Inputting the plurality of three-dimensional matrices into the style generation confrontational network model respectively, and respectively obtaining the pre-issued images output by the style generation confrontational network model; 基于所述风格生成对抗网络模型的输出和引导图像对所述风格生成对抗网络模型的输入进行反向调整,直至反向调整的次数达到目标次数;其中,所述引导图像为基于所述增发前图像绘制的增发后的对比图像;Based on the output of the style generation confrontation network model and the guide image, the input of the style generation confrontation network model is reversely adjusted until the number of reverse adjustments reaches the target number of times; wherein, the guide image is based on the pre-issued The comparison image after the additional issuance of the image drawing; 将最后一次反向调整后,所述风格生成对抗网络模型的输出确定为所述增发后图像。After the last reverse adjustment, the output of the style generation adversarial network model is determined as the additional image. 5.根据权利要求1所述的方法,其特征在于,所述目标残差网络模型的输入为第一尺寸的图像,在所述待处理图像的尺寸小于或大于所述第一尺寸的情况下,所述将目标图像区域输入至目标残差网络模型,得到所述目标残差网络模型的残差输出,包括:5. The method according to claim 1, wherein the input of the target residual network model is an image of a first size, and when the size of the image to be processed is smaller or larger than the first size , the target image area is input to the target residual network model, and the residual output of the target residual network model is obtained, including: 对所述目标图像区域进行仿射变换,生成第一尺寸的第一中间图像;performing affine transformation on the target image area to generate a first intermediate image of a first size; 将所述第一中间图像输入至所述目标残差网络模型,得到所述目标残差网络模型的残差输出;Inputting the first intermediate image into the target residual network model to obtain a residual output of the target residual network model; 所述将所述残差输出叠加到所述待处理图像,得到所述待处理图像增发后的目标图像,包括:The superimposing the residual output on the image to be processed to obtain the target image after additional issuance of the image to be processed includes: 对所述残差输出进行逆仿射变换,生成第二尺寸的第二中间图像,其中,所述第二尺寸为所述待处理图像的尺寸;performing an inverse affine transformation on the residual output to generate a second intermediate image of a second size, wherein the second size is the size of the image to be processed; 将所述第二中间图像叠加到所述待处理图像,得到所述目标图像。Superimposing the second intermediate image on the image to be processed to obtain the target image. 6.一种图像处理的装置,其特征在于,所述装置包括:6. A device for image processing, characterized in that the device comprises: 第一获取模块,用于获取待处理图像;The first acquisition module is used to acquire the image to be processed; 残差模块,用于将目标图像区域输入至目标残差网络模型,得到所述目标残差网络模型的残差输出;其中,所述目标图像区域包括:所述待处理图像中显示有头发和额头的图像区域;The residual module is used to input the target image area into the target residual network model to obtain the residual output of the target residual network model; wherein, the target image area includes: the image to be processed is displayed with hair and the image area of the forehead; 处理模块,用于将所述残差输出叠加到所述待处理图像,得到所述待处理图像增发后的目标图像。A processing module, configured to superimpose the residual output on the image to be processed to obtain a target image after the image to be processed is added. 7.根据权利要求6所述的装置,其特征在于,所述装置还包括:7. The device according to claim 6, further comprising: 第二获取模块,用于获取多对增发前后对比图像;其中,每对增发对比图像包括一幅增发前图像和一幅增发后图像;The second acquisition module is used to acquire multiple pairs of comparison images before and after issuance; wherein, each pair of comparison images includes an image before issuance and an image after issuance; 第一训练模块,用于将所述增发前图像作为输入,并将所述增发后图像作为真实值,对初始残差网络模型进行训练,得到所述目标残差网络模型。The first training module is configured to use the image before issuance as input and the image after issuance as a real value to train an initial residual network model to obtain the target residual network model. 8.根据权利要求7所述的装置,其特征在于,所述第二获取模块,包括:8. The device according to claim 7, wherein the second acquiring module comprises: 获取单元,用于获取符合高斯分布的多个三维矩阵;An acquisition unit, configured to acquire a plurality of three-dimensional matrices conforming to Gaussian distribution; 生成单元,用于针对每一个所述三维矩阵,分别基于预先训练好的风格生成对抗网络模型,生成一对增发前后对比图像。The generating unit is configured to generate a confrontational network model based on a pre-trained style for each of the three-dimensional matrices, and generate a pair of comparison images before and after additional issuance. 9.根据权利要求8所述的装置,其特征在于,所述生成单元,具体用于:9. The device according to claim 8, wherein the generating unit is specifically used for: 将所述多个三维矩阵分别输入所述风格生成对抗网络模型,分别得到所述风格生成对抗网络模型输出的所述增发前图像;Inputting the plurality of three-dimensional matrices into the style generation confrontational network model respectively, and respectively obtaining the pre-issued images output by the style generation confrontational network model; 基于所述风格生成对抗网络模型的输出和引导图像对所述风格生成对抗网络模型的输入进行反向调整,直至反向调整的次数达到目标次数;其中,所述引导图像为基于所述增发前图像绘制的增发后的对比图像;Based on the output of the style generation confrontation network model and the guide image, the input of the style generation confrontation network model is reversely adjusted until the number of reverse adjustments reaches the target number of times; wherein, the guide image is based on the pre-issued The comparison image after the additional issuance of the image drawing; 将最后一次反向调整后,所述风格生成对抗网络模型的输出确定为所述增发后图像。After the last reverse adjustment, the output of the style generation adversarial network model is determined as the additional image. 10.根据权利要求6所述的装置,其特征在于,所述目标残差网络模型的输入为第一尺寸的图像,在所述待处理图像的尺寸小于或大于所述第一尺寸的情况下,所述残差模块,包括:10. The device according to claim 6, wherein the input of the target residual network model is an image of a first size, and when the size of the image to be processed is smaller or larger than the first size , the residual module includes: 仿射变换单元,用于对所述目标图像区域进行仿射变换,生成第一尺寸的第一中间图像;an affine transformation unit, configured to perform affine transformation on the target image area to generate a first intermediate image of a first size; 残差单元,用于将所述第一中间图像输入至所述目标残差网络模型,得到所述目标残差网络模型的残差输出;a residual unit, configured to input the first intermediate image into the target residual network model, and obtain a residual output of the target residual network model; 所述处理模块,包括:The processing module includes: 逆仿射变换单元,用于对所述残差输出进行逆仿射变换,生成第二尺寸的第二中间图像,其中,所述第二尺寸为所述待处理图像的尺寸;an inverse affine transformation unit, configured to perform inverse affine transformation on the residual output to generate a second intermediate image of a second size, wherein the second size is the size of the image to be processed; 处理单元,用于将所述第二中间图像叠加到所述待处理图像,得到所述目标图像。A processing unit, configured to superimpose the second intermediate image on the image to be processed to obtain the target image.
CN202310155787.8A 2023-02-21 2023-02-21 Image processing method and device Pending CN116309018A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310155787.8A CN116309018A (en) 2023-02-21 2023-02-21 Image processing method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310155787.8A CN116309018A (en) 2023-02-21 2023-02-21 Image processing method and device

Publications (1)

Publication Number Publication Date
CN116309018A true CN116309018A (en) 2023-06-23

Family

ID=86835295

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310155787.8A Pending CN116309018A (en) 2023-02-21 2023-02-21 Image processing method and device

Country Status (1)

Country Link
CN (1) CN116309018A (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110276728A (en) * 2019-05-28 2019-09-24 河海大学 A Face Video Enhancement Method Based on Residual Generative Adversarial Network
CN112184876A (en) * 2020-09-28 2021-01-05 北京达佳互联信息技术有限公司 Image processing method, image processing device, electronic equipment and storage medium
CN113066005A (en) * 2021-04-25 2021-07-02 广州虎牙科技有限公司 Image processing method and device, electronic equipment and readable storage medium
CN113449613A (en) * 2021-06-15 2021-09-28 北京华创智芯科技有限公司 Multitask long-tail distribution image recognition method, multitask long-tail distribution image recognition system, electronic device and medium
WO2022057837A1 (en) * 2020-09-16 2022-03-24 广州虎牙科技有限公司 Image processing method and apparatus, portrait super-resolution reconstruction method and apparatus, and portrait super-resolution reconstruction model training method and apparatus, electronic device, and storage medium
CN114742725A (en) * 2022-03-30 2022-07-12 北京达佳互联信息技术有限公司 Image processing method, image processing device, electronic equipment and storage medium

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110276728A (en) * 2019-05-28 2019-09-24 河海大学 A Face Video Enhancement Method Based on Residual Generative Adversarial Network
WO2022057837A1 (en) * 2020-09-16 2022-03-24 广州虎牙科技有限公司 Image processing method and apparatus, portrait super-resolution reconstruction method and apparatus, and portrait super-resolution reconstruction model training method and apparatus, electronic device, and storage medium
CN112184876A (en) * 2020-09-28 2021-01-05 北京达佳互联信息技术有限公司 Image processing method, image processing device, electronic equipment and storage medium
CN113066005A (en) * 2021-04-25 2021-07-02 广州虎牙科技有限公司 Image processing method and device, electronic equipment and readable storage medium
CN113449613A (en) * 2021-06-15 2021-09-28 北京华创智芯科技有限公司 Multitask long-tail distribution image recognition method, multitask long-tail distribution image recognition system, electronic device and medium
CN114742725A (en) * 2022-03-30 2022-07-12 北京达佳互联信息技术有限公司 Image processing method, image processing device, electronic equipment and storage medium

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
李泽文;李子铭;费天禄;王瑞琳;谢在鹏;: "基于残差生成对抗网络的人脸图像复原", 计算机科学, no. 1, 15 June 2020 (2020-06-15), pages 240 - 246 *

Similar Documents

Publication Publication Date Title
US11410284B2 (en) Face beautification method and apparatus, computer device, and storage medium
WO2021129642A1 (en) Image processing method, apparatus, computer device, and storage medium
CN110084775B (en) Image processing method and device, electronic equipment and storage medium
WO2022078041A1 (en) Occlusion detection model training method and facial image beautification method
US11030733B2 (en) Method, electronic device and storage medium for processing image
US11308692B2 (en) Method and device for processing image, and storage medium
WO2021169307A1 (en) Makeup try-on processing method and apparatus for face image, computer device, and storage medium
CN106682632B (en) Method and device for processing face image
WO2023151511A1 (en) Model training method and apparatus, image moire removal method and apparatus, and electronic device
CN111340691A (en) Image processing method, device, electronic device and storage medium
US20240013358A1 (en) Method and device for processing portrait image, electronic equipment, and storage medium
CN112508773A (en) Image processing method and device, electronic device and storage medium
WO2024027583A1 (en) Image processing method and apparatus, and electronic device and readable storage medium
US20220284642A1 (en) Method for training convolutional neural network, and method and device for stylizing video
CN111028318A (en) Virtual face synthesis method, system, device and storage medium
CN112561787A (en) Image processing method, image processing device, electronic equipment and storage medium
CN116309018A (en) Image processing method and device
CN115861110A (en) Image processing method, device, electronic device and storage medium
WO2022258013A1 (en) Image processing method and apparatus, electronic device and readable storage medium
CN115243025A (en) Three-dimensional rendering method and device, terminal equipment and storage medium
CN114049473A (en) Image processing method and device
US11954779B2 (en) Animation generation method for tracking facial expression and neural network training method thereof
US20240265499A1 (en) Photorealistic image color style transfer compression
CN119887831A (en) Image processing method, image processing apparatus, electronic device, storage medium, and computer program product
CN118747833A (en) Light source estimation model training, light source estimation method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination