CN113870372A - Video hair color conversion method based on deep learning - Google Patents
Video hair color conversion method based on deep learning Download PDFInfo
- Publication number
- CN113870372A CN113870372A CN202111012366.7A CN202111012366A CN113870372A CN 113870372 A CN113870372 A CN 113870372A CN 202111012366 A CN202111012366 A CN 202111012366A CN 113870372 A CN113870372 A CN 113870372A
- Authority
- CN
- China
- Prior art keywords
- hair
- hair color
- color
- target image
- image
- 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.)
- Granted
Links
- 230000037308 hair color Effects 0.000 title claims abstract description 71
- 238000000034 method Methods 0.000 title claims abstract description 26
- 238000006243 chemical reaction Methods 0.000 title claims abstract description 21
- 238000013135 deep learning Methods 0.000 title claims description 9
- 210000004209 hair Anatomy 0.000 claims abstract description 52
- 238000000605 extraction Methods 0.000 claims description 35
- 238000012549 training Methods 0.000 claims description 12
- 230000003806 hair structure Effects 0.000 claims description 11
- 230000002123 temporal effect Effects 0.000 claims description 9
- 208000037170 Delayed Emergence from Anesthesia Diseases 0.000 claims description 7
- 238000010586 diagram Methods 0.000 claims description 7
- 230000006870 function Effects 0.000 claims description 6
- 238000011176 pooling Methods 0.000 claims description 6
- 238000005286 illumination Methods 0.000 claims description 4
- 238000005070 sampling Methods 0.000 claims description 4
- OAICVXFJPJFONN-UHFFFAOYSA-N Phosphorus Chemical compound [P] OAICVXFJPJFONN-UHFFFAOYSA-N 0.000 claims 1
- 125000004122 cyclic group Chemical group 0.000 claims 1
- 230000009191 jumping Effects 0.000 claims 1
- 230000008447 perception Effects 0.000 claims 1
- 230000008901 benefit Effects 0.000 abstract description 3
- 238000013528 artificial neural network Methods 0.000 abstract 1
- 230000001427 coherent effect Effects 0.000 abstract 1
- 239000003086 colorant Substances 0.000 description 4
- 238000010606 normalization Methods 0.000 description 3
- 230000000694 effects Effects 0.000 description 2
- 230000008569 process Effects 0.000 description 2
- 230000011218 segmentation Effects 0.000 description 2
- 238000013459 approach Methods 0.000 description 1
- 235000019580 granularity Nutrition 0.000 description 1
- 230000003779 hair growth Effects 0.000 description 1
- 230000003694 hair properties Effects 0.000 description 1
- 239000000203 mixture Substances 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000001537 neural effect Effects 0.000 description 1
- 230000008521 reorganization Effects 0.000 description 1
- 230000003068 static effect Effects 0.000 description 1
- 238000012360 testing method Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T11/00—2D [Two Dimensional] image generation
- G06T11/001—Texturing; Colouring; Generation of texture or colour
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F18/00—Pattern recognition
- G06F18/20—Analysing
- G06F18/21—Design or setup of recognition systems or techniques; Extraction of features in feature space; Blind source separation
- G06F18/214—Generating training patterns; Bootstrap methods, e.g. bagging or boosting
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T7/00—Image analysis
- G06T7/90—Determination of colour characteristics
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T2207/00—Indexing scheme for image analysis or image enhancement
- G06T2207/10—Image acquisition modality
- G06T2207/10024—Color image
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02T—CLIMATE CHANGE MITIGATION TECHNOLOGIES RELATED TO TRANSPORTATION
- Y02T10/00—Road transport of goods or passengers
- Y02T10/10—Internal combustion engine [ICE] based vehicles
- Y02T10/40—Engine management systems
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Physics & Mathematics (AREA)
- Computer Vision & Pattern Recognition (AREA)
- Data Mining & Analysis (AREA)
- Bioinformatics & Computational Biology (AREA)
- Bioinformatics & Cheminformatics (AREA)
- Evolutionary Biology (AREA)
- Evolutionary Computation (AREA)
- Artificial Intelligence (AREA)
- General Engineering & Computer Science (AREA)
- Life Sciences & Earth Sciences (AREA)
- Image Analysis (AREA)
- Image Processing (AREA)
Abstract
本发明提供了一种基于深度神经网络的视频头发颜色转换方法,该方法首次引入亮度图(Luminance map)代表头发的几何结构并提出在时间和空间上做标准化进一步保证连续帧的稳定性及生成结果与参考图像的一致性。本发明还设计了颜色,结构和背景三个条件模块以进一步解耦头发的属性。由于luminance map对颜色的高度解耦,且针对头发各个属性单独设计了对应的模块,头发的颜色,结构及光照以及图像的背景高度解耦,利用这一优势,该方法实现了高保真的头发颜色转换。该发明还引入判别器及循环一致性损失函数以生成更真实,时间相干性更强的结果。
The invention provides a video hair color conversion method based on a deep neural network. The method first introduces a luminance map (Luminance map) to represent the geometric structure of the hair, and proposes standardization in time and space to further ensure the stability and generation of continuous frames. The results are consistent with the reference image. The present invention also designs three conditional modules of color, structure and background to further decouple the properties of hair. Since the luminance map is highly decoupled from color, and the corresponding modules are separately designed for each property of the hair, the color, structure and lighting of the hair and the background of the image are highly decoupled. Taking advantage of this advantage, this method achieves high-fidelity hair. Color conversion. The invention also introduces a discriminator and a cycle consistency loss function to generate more realistic and temporally coherent results.
Description
技术领域technical field
本发明属于计算机视觉领域,尤其涉及一种基于深度学习的视频头发颜色转换方法。The invention belongs to the field of computer vision, in particular to a video hair color conversion method based on deep learning.
背景技术Background technique
头发是肖像描绘中最重要的组成部分之一,这也引发了计算机视觉领域大量优秀的工作,然而现有的工作都只停留在静态头发上,对于视频序列的相关工作仍然不足,此外,与人脸的大部分部位不同,头发非常精致、多变和复杂。它由数以千计的细线组成,并受到光照、运动和遮挡的影响,因此难以分析、表示和生成。现有的研究都利用gabor filter提取发丝的生长方向作为头发的几何并与颜色解耦,然而这种做法的一个常见缺点是:gabor filter会损失许多细节信息,导致生成的视频序列不保真且容易抖动。Hair is one of the most important components in portrait depiction, which has also led to a lot of excellent work in the field of computer vision. However, the existing work only stays on static hair, and the related work for video sequences is still insufficient. In addition, with Most parts of the human face are different, and the hair is very delicate, varied and complex. It consists of thousands of thin lines and is affected by lighting, motion, and occlusion, making it difficult to analyze, represent, and generate. Existing studies have used gabor filter to extract the hair growth direction as the geometry of the hair and decouple it from color. However, a common disadvantage of this approach is that the gabor filter will lose a lot of detail information, resulting in unfidelity of the generated video sequence. and easy to shake.
发明内容SUMMARY OF THE INVENTION
本发明针对现有技术的不足,提出了一种基于深度学习的视频头发颜色转换方法,利用标准化后的luminance map表示头发的几何结构,针对头发各个属性设计了三个条件模块,将头发属性高度解耦并重组达到头发颜色转换的效果,整个训练流程无需任何成对数据。提出了循环一致性损失(cycle consistency loss)并使用判别器(discriminator)去除生成过程中可能造成的抖动,并增强了生成结果与参考图像的一致性。Aiming at the shortcomings of the prior art, the present invention proposes a video hair color conversion method based on deep learning. The standardized luminance map is used to represent the geometric structure of the hair, and three condition modules are designed for each attribute of the hair. Decoupling and reorganization achieves the effect of hair color conversion, and the entire training process does not require any paired data. A cycle consistency loss is proposed and a discriminator is used to remove the jitter that may be caused during the generation process and enhance the consistency of the generated results with the reference image.
本发明是通过以下技术方案来实现的:The present invention is achieved through the following technical solutions:
一种基于深度学习的视频头发颜色转换方法,包括以下步骤:A deep learning-based video hair color conversion method includes the following steps:
步骤一:将包含待转换头发颜色的目标图像的视频中每一帧从RGB空间转换为LAB空间,提取L空间并在时间和空间上做标准化,并利用结构特征提取模块获取目标图像包含头发结构和光照的特征图。Step 1: Convert each frame of the video containing the target image of the hair color to be converted from RGB space to LAB space, extract the L space and standardize it in time and space, and use the structural feature extraction module to obtain the target image containing the hair structure. and lighting feature maps.
其中,L空间(luminance map)代表亮度,亮度的强弱即可表达发丝的结构并保留原有的光照,最重要的一点是Luminance map能保留所有微小的细节,以重建出更真实的图像。由于亮度也关系到颜色的深浅,为了弥补不同图像不同光照条件带来的影响,本发明提出在时间和空间上对luminance map进行标准化并用标准化后的结果来表示头发的几何结构,这样既能保证发丝的结构又能保证原有的光照条件,生成更真实的结果。Among them, the L space (luminance map) represents the brightness. The intensity of the brightness can express the structure of the hair and retain the original lighting. The most important point is that the Luminance map can retain all the tiny details to reconstruct a more realistic image. . Since the brightness is also related to the depth of the color, in order to compensate for the influence of different lighting conditions in different images, the present invention proposes to standardize the luminance map in time and space, and use the standardized result to represent the geometric structure of the hair, which can ensure that both The structure of the hair can also ensure the original lighting conditions, resulting in more realistic results.
步骤二:选取带有预转换头发颜色的参考图像并利用颜色特征提取模块提取参考图像的头发颜色特征,并将头发颜色特征叠加至目标图像的头发掩模上获得头发颜色掩模;Step 2: Select a reference image with pre-converted hair color and use a color feature extraction module to extract the hair color feature of the reference image, and superimpose the hair color feature on the hair mask of the target image to obtain a hair color mask;
步骤三:根据目标图像头发掩模利用背景区域特征提取模块提取目标图像除头发以外的背景区域特征图;Step 3: According to the target image hair mask, use the background area feature extraction module to extract the background area feature map of the target image except for the hair;
步骤四:将步骤一提取到的目标图像包含头发结构和光照的特征图、步骤二中提取到的头发颜色掩模及步骤三提取到的背景区域特征图输入至一个主干生成网络整合生成具有参考图像头发颜色的目标图像。Step 4: Input the target image extracted in step 1 including the feature map of hair structure and lighting, the hair color mask extracted in step 2 and the background region feature map extracted in step 3 into a backbone generation network to integrate and generate a reference image. The target image for the image hair color.
其中,所述结构特征提取模块、颜色特征提取模块、背景区域特征提取模块、主干生成网络通过收集的视频训练获得。Wherein, the structural feature extraction module, the color feature extraction module, the background region feature extraction module, and the backbone generation network are obtained by training videos collected.
进一步地,所述步骤1中,将包含待转换头发颜色的目标图像的视频中每一帧从RGB空间转换为LAB空间,提取L空间并在时间和空间上做标准化,具体为:Further, in the step 1, each frame in the video containing the target image of the hair color to be converted is converted from the RGB space to the LAB space, and the L space is extracted and standardized in time and space, specifically:
(1.1)将包含待转换头发颜色的目标图像的视频中每一帧图像从CIE RGB转化到CIE XYZ颜色空间再从CIE XYZ转换到LAB颜色空间。(1.1) Convert each frame of image in the video containing the target image of the hair color to be converted from CIE RGB to CIE XYZ color space and then from CIE XYZ to LAB color space.
(1.2)提取L空间并计算一整个视频序列所有像素点的L值的均值及方差,利用公式Lt norm=(Lt-mean(L))/V对L空间进行标准化。其中mean(L)代表L的均值,V代表方差,t为图像的索引。(1.2) Extract the L space and calculate the mean and variance of the L values of all pixels in an entire video sequence, and use the formula L t norm =(L t -mean(L))/V to standardize the L space. where mean(L) represents the mean of L, V represents the variance, and t is the index of the image.
进一步地,所述步骤(1.2)中,计算一整个视频序列中头发区域对应像素点的L值的均值及方差。Further, in the step (1.2), the mean and variance of the L values of the pixels corresponding to the hair region in an entire video sequence are calculated.
进一步地,所述颜色特征提取模块包括4层下采样的部分卷积网络(partialconvolution)和一个实例级平均池化层(instance-wise average pooling)。Further, the color feature extraction module includes a 4-layer down-sampling partial convolution network (partial convolution) and an instance-wise average pooling layer.
通过使用partial convolution基于mask提取特征这一优势来提取参考图像头发区域的特征,避免头发区域以外的特征干扰,并使用实例级平均池化层将特征压缩为一个特征向量,得到参考图像的全局颜色特征。By using the advantage of partial convolution to extract features based on masks, the features of the hair region of the reference image are extracted to avoid the interference of features outside the hair region, and the instance-level average pooling layer is used to compress the features into a feature vector to obtain the global color of the reference image. feature.
进一步地,所述结构特征提取模块包括依次连接的多个上采样模块和残差块,所述主干生成网络包括依次连接的多个残差块和下采样模块,结构特征提取模块与主干生成网络呈对称结构,。所述步骤四中,将步骤一提取到的目标图像包含头发结构和光照的特征图、步骤二中提取到的头发颜色掩模在特征通道上连接后输入主干生成网络的多个残差块提取特征后,输入至上采样模块,上采样模块与结构特征提取模块的下采样模块通过跳跃连接获得多尺度特征,并且在最后n个下采样模块中结合步骤三提取到的背景区域特征图最终获得具有参考图像头发颜色的目标图像,n为背景区域特征图的数量。Further, the structural feature extraction module includes a plurality of upsampling modules and residual blocks connected in sequence, the backbone generation network includes a plurality of residual blocks and downsampling modules connected in sequence, and the structural feature extraction module and the backbone generation network. Symmetrical structure. In the step 4, the target image extracted in step 1 contains the feature map of hair structure and lighting, and the hair color mask extracted in step 2 is connected on the feature channel and then input into the backbone generation network to extract multiple residual blocks. After the feature, it is input to the upsampling module, the upsampling module and the downsampling module of the structural feature extraction module obtain multi-scale features through skip connection, and combine the background region feature map extracted in step 3 in the last n downsampling modules to finally obtain The target image for the hair color of the reference image, and n is the number of feature maps in the background region.
进一步地,当包含连续的多帧待转换头发颜色的目标图像时,将当前待转换头发颜色的目标图像的前k帧目标图像转换结果反馈至结构特征提取模块与当前待转换头发颜色的目标图像作为共同输入以保证生成视频序列的时间相干性。Further, when the target image of the hair color to be converted is contained in multiple consecutive frames, the first k frames of target image conversion results of the target image of the current hair color to be converted are fed back to the structural feature extraction module and the target image of the current hair color to be converted. as a common input to guarantee the temporal coherence of the generated video sequences.
进一步地,所述训练采用的损失函数包括:生成的具有参考图像头发颜色的目标图像与真值的L1损失和感知损失、网络的生成对抗损失、生成的具有参考图像头发颜色的目标图像与真值的特征匹配损失、时间相干性损失和循环一致性损失,表示为:Further, the loss function used in the training includes: the generated target image with the hair color of the reference image and the L1 loss and the perceptual loss of the true value, the generation confrontation loss of the network, the generated target image with the hair color of the reference image and the true value. The feature matching loss, temporal coherence loss, and cycle consistency loss of the value, expressed as:
其中,分别是网络输出图像与真值的L1损失和感知损失,是网络的生成对抗损失,是网络输出图像与真值的特征匹配损失,是时间相干性损失(Temporal coherence),和是循环一致性损失;λ为对应损失的权重,为实数。in, are the L1 loss and perceptual loss of the network output image and the ground truth, respectively, is the generative adversarial loss of the network, is the feature matching loss between the network output image and the ground truth, is the temporal coherence loss, and is the cycle consistency loss; λ is the weight of the corresponding loss, which is a real number.
进一步地,所述循环一致性损失训练具体为对于两个视频序列X和Y,首先以视频序列Y作为参考图像,使用本发明方法上述步骤将视频序列X的头发颜色转换生成视频序列X*,再以视频序列X*作为参考图像,视频序列Y作为待转换头发颜色的视频序列,重复上述步骤生成新的视频序列Y*,损失函数如下:Further, the cycle consistency loss training is specifically for two video sequences X and Y, firstly, using the video sequence Y as a reference image, using the above steps of the method of the present invention to convert the hair color of the video sequence X to generate a video sequence X*, Then take the video sequence X* as the reference image and the video sequence Y as the video sequence of the hair color to be converted, repeat the above steps to generate a new video sequence Y*, the loss function is as follows:
其中,I是目标图像,Iref代表参考图像,G表示主干生成网络的输出,表示一次头发颜色转换的结果,Icyc代表经过两次转换得到的结果,k+1代表反馈的输入图像张数;表示VGG网络第j层的输出,t为视频序列的索引,下标l表示对应图像的l空间,即图像I的亮度图;D表示判别器discriminator的输出,表示期望;M表示模板图像的头发掩模,Mref表示参考图像的头发掩模,||*||1表示L1正则化。where I is the target image, Iref represents the reference image, G represents the output of the backbone generation network, Represents the result of one hair color conversion, I cyc represents the result obtained after two conversions, and k+1 represents the number of input images fed back; Represents the output of the jth layer of the VGG network, t is the index of the video sequence, and the subscript l represents the l space of the corresponding image, that is, the brightness map of the image I; D represents the output of the discriminator, denotes the expectation; M denotes the hair mask of the template image, Mref denotes the hair mask of the reference image, and ||*|| 1 denotes L1 regularization.
循环一致性损失进一步保证了生成结果的颜色与参考图像的一致性。The cycle consistency loss further ensures that the colors of the generated results are consistent with the reference image.
本发明的突出贡献是:The outstanding contributions of the present invention are:
本发明提出了iHairRecolorer,第一个基于深度学习将参考图像的头发颜色转换到视频中的方法,第一次提出使用LAB空间中的L空间替代传统的orientation map作为头发的结构并对其进行了时间和空间上的标准化,使luminance map不仅能保留细微的结构特征及原有光照条件还能与头发的色彩高度结构。此外采用了一种新颖的循环一致性损失来更好地匹配生成结果和参考图像之间的颜色。该发明不依赖任何成对数据即可训练并能在测试数据上依然鲁棒稳定。该发明还引入了discriminator以保证生成视频序列的时间一致性,得到更真实更平滑的结果,优于目前已有的所有方法。The invention proposes iHairRecolorer, the first method to convert the hair color of the reference image into the video based on deep learning, and the first time to use the L space in the LAB space to replace the traditional orientation map as the structure of the hair and carry out The normalization in time and space enables the luminance map not only to retain the subtle structural features and the original lighting conditions, but also to be highly structured with the color of the hair. Furthermore, a novel cycle-consistency loss is employed to better match colors between the generated results and reference images. The invention does not rely on any paired data for training and remains robust and stable on test data. The invention also introduces a discriminator to ensure the temporal consistency of the generated video sequences, resulting in more realistic and smoother results, which are superior to all existing methods.
附图说明Description of drawings
图1是本发明的网络管线结构图;Fig. 1 is the network pipeline structure diagram of the present invention;
图2是本发明的头发颜色转换结果图。FIG. 2 is a graph of the hair color conversion result of the present invention.
具体实施方式Detailed ways
由于头发非常精致、多变和复杂。它由数以千计的细线组成,并受到光照、运动和遮挡的影响,因此难以分析、表示和生成。本发明的目标是得到头发结构高度还原原始视频且发色与参考图像保持一致的新的视频序列。这需要结构与颜色高度解耦,一般来说采用gabor filter计算。本发明针对上述问题,提出使用luminance map表示头发的结构并对齐进行时间和空间上的标准化。并利用partial convolution等三个精心设计的条件模块及所提出的损失函数完成视频头发颜色转换模型的训练。具体包括如下步骤:Because hair is very delicate, varied and complex. It consists of thousands of thin lines and is affected by lighting, motion, and occlusion, making it difficult to analyze, represent, and generate. The goal of the present invention is to obtain a new video sequence in which the hair structure is highly restored to the original video and the hair color is consistent with the reference image. This requires a high degree of decoupling of structure and color, which is generally calculated using a gabor filter. In view of the above problems, the present invention proposes to use a luminance map to represent the structure of the hair and to align it for temporal and spatial standardization. And three well-designed conditional modules such as partial convolution and the proposed loss function are used to complete the training of the video hair color conversion model. Specifically include the following steps:
步骤一:将包含待转换头发颜色的目标图像的视频中每一帧从RGB空间转换为LAB空间,提取L空间并在时间和空间上做标准化,并利用结构特征提取模块获取目标图像包含头发结构和光照的特征图。Step 1: Convert each frame of the video containing the target image of the hair color to be converted from RGB space to LAB space, extract the L space and standardize it in time and space, and use the structural feature extraction module to obtain the target image containing the hair structure. and lighting feature maps.
步骤二:选取带有预转换头发颜色的参考图像并利用颜色特征提取模块提取参考图像的头发颜色特征,并将头发颜色特征叠加至目标图像的头发掩模上获得头发颜色掩模;Step 2: Select a reference image with pre-converted hair color and use a color feature extraction module to extract the hair color feature of the reference image, and superimpose the hair color feature on the hair mask of the target image to obtain a hair color mask;
步骤三:根据目标图像头发掩模利用背景区域特征提取模块提取目标图像除头发以外的背景区域特征图;Step 3: According to the target image hair mask, use the background area feature extraction module to extract the background area feature map of the target image except for the hair;
步骤四:将步骤一提取到的目标图像包含头发结构和光照的特征图、步骤二中提取到的头发颜色掩模及步骤三提取到的背景区域特征图输入至一个主干生成网络整合生成具有参考图像头发颜色的目标图像。Step 4: Input the target image extracted in step 1 including the feature map of hair structure and lighting, the hair color mask extracted in step 2 and the background region feature map extracted in step 3 into a backbone generation network to integrate and generate a reference image. The target image for the image hair color.
其中,所述结构特征提取模块、颜色特征提取模块、背景区域特征提取模块、主干生成网络通过收集的视频训练获得。Wherein, the structural feature extraction module, the color feature extraction module, the background region feature extraction module, and the backbone generation network are obtained by training videos collected.
图1说明了本发明中网络的结构及数据流通方向。下面,结合一个具体的实施例对本发明方法作进一步说明:Figure 1 illustrates the structure of the network and the direction of data flow in the present invention. Below, in conjunction with a specific embodiment, the inventive method is further described:
对于一个给定T帧的视频序列I(T)={I1,I2,...,IT},及参考图像Iref,我们的目标是删除I(T)中的原始头发颜色,并转换为与参考图像中头发相同的颜色,同时保持其他头发属性不变。因此,首先对视频序列中头发的属性做分解,将其分解为形状,结构,光照,颜色及头发以外区域。For a given video sequence I(T)={ I1 , I2 ,...,IT} of T frames, and reference image Iref , our goal is to remove the original hair color in I(T), and converted to the same color as the hair in the reference image, while keeping other hair properties unchanged. Therefore, the properties of hair in the video sequence are first decomposed into shape, structure, lighting, color and areas other than hair.
其中结构特征的提取使用了LAB空间独有的亮度与颜色的高度解耦性,并且将L空间使用如下公式进行标准化:The extraction of structural features uses the unique high degree of decoupling of brightness and color in the LAB space, and the L space is standardized using the following formula:
其中M表示目标图像头发区域的掩模mask,表示第T帧图像对应的亮度图(luminance map),i表示亮度图中某一像素,表示标准化后第T帧图像对应的亮度图。本发明中利用M*L移除了背景对亮度图标准化的影响。同时,将一个视频序列的所有帧同时计算亮度图,统一标准化的方差和均值,消除亮度图序列的抖动以生成更加平滑的结果。亮度图生成结果如图1所示(Clip X)。最后,目标图像的亮度图经过结构特征提取模块(luminance module)提取获得包含头发结构和光照的特征图;本实施例中,亮度模块由3层下采样及4个残差块(Resnet Block)结构组成。where M represents the mask mask of the hair region of the target image, Represents the luminance map corresponding to the T-th frame image, i represents a pixel in the luminance map, Indicates the luminance map corresponding to the T-th frame image after normalization. In the present invention, M*L is used to remove the influence of the background on the normalization of the luminance map. At the same time, the luminance map is calculated simultaneously for all frames of a video sequence, the standardized variance and mean are unified, and the jitter of the luminance map sequence is eliminated to generate smoother results. The result of luminance map generation is shown in Figure 1 (Clip X). Finally, the luminance map of the target image is extracted by a structural feature extraction module (luminance module) to obtain a feature map including hair structure and illumination; in this embodiment, the luminance module consists of 3 layers of downsampling and 4 residual blocks (Resnet Block) structure composition.
针对带有预转换头发颜色的参考图像,利用如图1所示的颜色特征提取模块(Color Module),所述颜色特征提取模块包括4层下采样的部分卷积网络(partialconvolution)和一个实例级平均池化层(instance-wise average pooling),首先使用头发分割网络获得参考图像头发区域的头发掩模,经过4层下采样的partial convolution,每层下采样都会使图像分辨率降低,相应的,每次头发掩模也会随之更新以避免头发以外特征的干扰。经过4次下采样后获得的特征图(feature map)进一步的使用一个实例级平均池化层压缩为一个512维的特征向量(feature vector)。这不仅保留了头发颜色的全局信息还去除了头发形状及结构差异带来的影响。进一步地,将提取到的特征向量通过以下公式与目标图像的头发掩模叠加:For the reference image with pre-converted hair color, a Color Module as shown in Figure 1 is used, which includes a 4-layer down-sampling partial convolution network and an instance-level The average pooling layer (instance-wise average pooling), firstly uses the hair segmentation network to obtain the hair mask of the reference image hair area, after 4 layers of partial convolution of downsampling, each downsampling will reduce the image resolution, correspondingly, The hair mask is also updated each time to avoid interference from features other than hair. The feature map obtained after 4 downsampling is further compressed into a 512-dimensional feature vector using an instance-level average pooling layer. This not only preserves the global information of hair color but also removes the effects of differences in hair shape and structure. Further, the extracted feature vector is superimposed with the hair mask of the target image by the following formula:
其中A′ref表示参考图像提取到的特征向量,Mref表示参考图像的头发掩模,M表示目标图像的头发掩模。A即为feature vector叠加到M上的关于颜色的特征图,即头发颜色掩模。where A'ref represents the feature vector extracted from the reference image, Mref represents the hair mask of the reference image, and M represents the hair mask of the target image. A is the feature map of color superimposed on M by the feature vector, that is, the hair color mask.
进一步地,利用如图1所示背景区域特征提取模块(Background Module)提取目标图像除头发以外的背景区域特征图,具体地,首先使用分割获得的目标图像头发掩模去除头发区域,保留其余区域不变,将剩余区域输入神经背景区域特征提取模块,经过两次下采样获得不同粒度的特征并在主干生成网络(backbone Generator)的最后两层与新生成的头发特征组合。Further, utilize the background region feature extraction module (Background Module) as shown in Figure 1 to extract the background region feature map of the target image except the hair, specifically, first use the target image hair mask obtained by segmentation to remove the hair region, and retain the remaining regions. Unchanged, the remaining area is input into the neural background area feature extraction module, and the features of different granularities are obtained after two downsampling and combined with the newly generated hair features in the last two layers of the backbone generator network.
如图1所示,主干生成网络,包括4个resBlock和3层上采样,与Luminance Module具有对称的网络结构,其输入为获取目标图像包含头发结构和光照的特征图与头发颜色掩模在特征通道上连接后的组合特征,经过4个resBlock进一步提取特征后通过skipconnection结合Luminance Module中的下采样中多尺度的特征,并且在最后2层与背景特征组合生成具有参考图像头发颜色的图像。As shown in Figure 1, the backbone generation network, including 4 resBlocks and 3 layers of upsampling, has a symmetric network structure with the Luminance Module, and its input is the feature map of the target image containing hair structure and lighting and the hair color mask in the feature map. The combined features connected on the channel are further extracted through 4 resBlocks, and then combined with the multi-scale features in the downsampling in the Luminance Module through skipconnection, and combined with the background features in the last 2 layers to generate an image with the hair color of the reference image.
作为一优选方案,若是需要连续转换视频中的多张目标图像的头发颜色,可以将待转换目标图像的前k帧图像经头发颜色转换后的生成的图像一同作为网络的输入即可生成更加平滑,时间相干性更强的视频序列。其中,为了保证输入一致,第一张、第二张的输入为相同的三张图像。As a preferred solution, if the hair color of multiple target images in the video needs to be continuously converted, the images generated by the hair color conversion of the first k frames of the target images to be converted can be used as the input of the network to generate a smoother image. , a video sequence with stronger temporal coherence. Among them, in order to ensure that the input is consistent, the input of the first and second images is the same three images.
其中,结构特征提取模块、颜色特征提取模块、背景区域特征提取模块、主干生成网络通过通过如下方法根据收集的视频训练获得:Among them, the structural feature extraction module, the color feature extraction module, the background region feature extraction module, and the backbone generation network are obtained by training the collected videos through the following methods:
如图1循环一致性所示,对于两个视频序列X和Y,首先以视频序列Y作为参考图像,使用本发明方法上述步骤将视频序列X的头发颜色转换生成视频序列X*,再以视频序列X*作为参考图像,视频序列Y作为待转换头发颜色的视频序列,重复上述步骤生成新的视频序列Y*,Y*应当与视频序列Y相同,因此可以利用以下损失函数约束:As shown in Fig. 1 , for two video sequences X and Y, the video sequence Y is used as a reference image, and the above steps of the method of the present invention are used to convert the hair color of the video sequence X to generate a video sequence X*, and then use the video sequence Y as a reference image. The sequence X* is used as the reference image, and the video sequence Y is used as the video sequence of the hair color to be converted. Repeat the above steps to generate a new video sequence Y*. Y* should be the same as the video sequence Y, so the following loss function constraints can be used:
其中,分别是网络输出图像与真值的L1损失和感知损失,是网络的生成对抗损失,是网络输出图像与真值的特征匹配损失,是时间相干性损失(Temporal coherence)。in, are the L1 loss and perceptual loss of the network output image and the ground truth, respectively, is the generative adversarial loss of the network, is the feature matching loss between the network output image and the ground truth, is the temporal coherence loss.
I是目标图像,Iref代表参考图像,G表示主干生成网络的输出,表示一次头发颜色转换的结果,Icyc∈Y*代表经过两次转换得到的结果,k+1代表结构特征提取模块输入图像张数,本实施例中为3;表示VGG网络第j层的输出,下标l表示对应图像的l空间,即图像I的亮度图;D表示判别器discriminator的输出,表示期望。I is the target image, Iref represents the reference image, G represents the output of the backbone generative network, represents the result of one hair color conversion, I cyc ∈ Y* represents the result obtained after two conversions, and k+1 represents the number of input images of the structural feature extraction module, which is 3 in this embodiment; Represents the output of the jth layer of the VGG network, and the subscript l represents the l space of the corresponding image, that is, the brightness map of the image I; D represents the output of the discriminator, express expectations.
λ为对应损失的权重,本实施例中分别取值λ1=10、λp=10、λadv=0.1、λchromatic=10、λstable=1,最终训练获得网络,图2是利用本发明的头发颜色转换结果图,从图中可以看出,本发明可以适应不同发型,从长到短,简单到复杂,也可以适应各种颜色,包括一些混合色,生成的目标图像能保持与参考图像保持一致,同时生成的目标图像也保留了源图像中的光照条件。λ is the weight of the corresponding loss, in this embodiment, the values λ 1 =10, λ p =10, λ adv =0.1, λ chromatic = 10, λ stable = 1, and finally the network is obtained by training. Fig. 2 is the result of hair color conversion using the present invention. It can be seen from the figure that the present invention can adapt to different hairstyles, from long to short, simple to complex , can also adapt to various colors, including some mixed colors, the generated target image can keep the same as the reference image, and the generated target image also retains the lighting conditions in the source image.
显然,上述实施例仅仅是为清楚地说明所作的举例,而并非对实施方式的限定。对于所属领域的普通技术人员来说,在上述说明的基础上还可以做出其他不同形式的变化或变动。这里无需也无法把所有的实施方式予以穷举。而由此所引申出的显而易见的变化或变动仍处于本发明的保护范围。Obviously, the above-mentioned embodiments are only examples for clear description, and are not intended to limit the implementation manner. For those of ordinary skill in the art, changes or modifications in other different forms can also be made on the basis of the above description. All implementations need not and cannot be exhaustive here. However, the obvious changes or changes derived from this are still within the protection scope of the present invention.
Claims (8)
Priority Applications (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111012366.7A CN113870372B (en) | 2021-08-31 | 2021-08-31 | A video hair color conversion method based on deep learning |
PCT/CN2021/126912 WO2023029184A1 (en) | 2021-08-31 | 2021-10-28 | Video hair color conversion method based on deep learning |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111012366.7A CN113870372B (en) | 2021-08-31 | 2021-08-31 | A video hair color conversion method based on deep learning |
Publications (2)
Publication Number | Publication Date |
---|---|
CN113870372A true CN113870372A (en) | 2021-12-31 |
CN113870372B CN113870372B (en) | 2024-06-21 |
Family
ID=78988977
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202111012366.7A Active CN113870372B (en) | 2021-08-31 | 2021-08-31 | A video hair color conversion method based on deep learning |
Country Status (2)
Country | Link |
---|---|
CN (1) | CN113870372B (en) |
WO (1) | WO2023029184A1 (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114596370A (en) * | 2022-03-04 | 2022-06-07 | 深圳万兴软件有限公司 | Video color conversion method, device, computer equipment and storage medium |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102881011A (en) * | 2012-08-31 | 2013-01-16 | 北京航空航天大学 | Region-segmentation-based portrait illumination transfer method |
CN108629819A (en) * | 2018-05-15 | 2018-10-09 | 北京字节跳动网络技术有限公司 | Image hair dyeing treating method and apparatus |
CN110458906A (en) * | 2019-06-26 | 2019-11-15 | 重庆邮电大学 | A medical image colorization method based on depth color transfer |
WO2020037965A1 (en) * | 2018-08-21 | 2020-02-27 | 北京大学深圳研究生院 | Method for multi-motion flow deep convolutional network model for video prediction |
US11017560B1 (en) * | 2019-04-15 | 2021-05-25 | Facebook Technologies, Llc | Controllable video characters with natural motions extracted from real-world videos |
CN113313657A (en) * | 2021-07-29 | 2021-08-27 | 北京航空航天大学杭州创新研究院 | Unsupervised learning method and system for low-illumination image enhancement |
Family Cites Families (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US10679328B2 (en) * | 2018-05-23 | 2020-06-09 | Adobe Inc. | Machine learning techniques for increasing color consistency across videos |
CN109658330B (en) * | 2018-12-10 | 2023-12-26 | 广州市久邦数码科技有限公司 | Color development adjusting method and device |
CN110969631B (en) * | 2019-11-25 | 2023-04-11 | 杭州小影创新科技股份有限公司 | Method and system for dyeing hair by refined photos |
CN111524205A (en) * | 2020-04-23 | 2020-08-11 | 北京信息科技大学 | Image colorization processing method and device based on recurrent generative adversarial network |
CN112614060B (en) * | 2020-12-09 | 2024-10-18 | 深圳数联天下智能科技有限公司 | Face image hair rendering method and device, electronic equipment and medium |
CN112529914B (en) * | 2020-12-18 | 2021-08-13 | 北京中科深智科技有限公司 | Real-time hair segmentation method and system |
-
2021
- 2021-08-31 CN CN202111012366.7A patent/CN113870372B/en active Active
- 2021-10-28 WO PCT/CN2021/126912 patent/WO2023029184A1/en active Application Filing
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102881011A (en) * | 2012-08-31 | 2013-01-16 | 北京航空航天大学 | Region-segmentation-based portrait illumination transfer method |
CN108629819A (en) * | 2018-05-15 | 2018-10-09 | 北京字节跳动网络技术有限公司 | Image hair dyeing treating method and apparatus |
WO2020037965A1 (en) * | 2018-08-21 | 2020-02-27 | 北京大学深圳研究生院 | Method for multi-motion flow deep convolutional network model for video prediction |
US11017560B1 (en) * | 2019-04-15 | 2021-05-25 | Facebook Technologies, Llc | Controllable video characters with natural motions extracted from real-world videos |
CN110458906A (en) * | 2019-06-26 | 2019-11-15 | 重庆邮电大学 | A medical image colorization method based on depth color transfer |
CN113313657A (en) * | 2021-07-29 | 2021-08-27 | 北京航空航天大学杭州创新研究院 | Unsupervised learning method and system for low-illumination image enhancement |
Non-Patent Citations (1)
Title |
---|
伍克煜;刘峰江;许浩;张浩天;王贝贝: "合成生物学基因设计软件:iGEM设计综述", 生物信息学, no. 001, 31 December 2020 (2020-12-31) * |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114596370A (en) * | 2022-03-04 | 2022-06-07 | 深圳万兴软件有限公司 | Video color conversion method, device, computer equipment and storage medium |
Also Published As
Publication number | Publication date |
---|---|
CN113870372B (en) | 2024-06-21 |
WO2023029184A1 (en) | 2023-03-09 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
Huang et al. | Deep learning for image colorization: Current and future prospects | |
CN109509248B (en) | A Neural Network-Based Photon Mapping Rendering Method and System | |
CN111145290B (en) | Image colorization method, system and computer readable storage medium | |
Gao et al. | Multi-modal convolutional dictionary learning | |
CN110443768A (en) | Single-frame image super-resolution reconstruction method based on Multiple Differential consistency constraint and symmetrical redundant network | |
CN111783658B (en) | A Two-Stage Expression Animation Generation Method Based on Dual Generative Adversarial Networks | |
CN112001843B (en) | A deep learning-based infrared image super-resolution reconstruction method | |
CN115170559A (en) | Personalized human head nerve radiation field substrate representation and reconstruction method based on multilevel Hash coding | |
CN112767283A (en) | Non-uniform image defogging method based on multi-image block division | |
CN114972036A (en) | Blind image super-resolution reconstruction method and system based on fusion degradation prior | |
Hang et al. | Prinet: A prior driven spectral super-resolution network | |
CN113870372B (en) | A video hair color conversion method based on deep learning | |
Que et al. | Integrating spectral and spatial bilateral pyramid networks for pansharpening | |
CN111723840A (en) | A method for clustering and style transfer of ultrasound images | |
CN110443754B (en) | Method for improving resolution of digital image | |
Cheng et al. | Characteristic regularisation for super-resolving face images | |
Lin et al. | PixWizard: Versatile image-to-image visual assistant with open-language instructions | |
CN111275620A (en) | Image super-resolution method based on Stacking ensemble learning | |
CN114663802B (en) | Cross-modal video migration method of surveillance videos based on feature spatiotemporal constraints | |
Neagoe | An optimum 2d color space for pattern recognition. | |
Muqeet et al. | Video face re-aging: Toward temporally consistent face re-aging | |
CN114638761A (en) | Hyperspectral image panchromatic sharpening method, device and medium | |
Kim et al. | RPF: Reference-based progressive face super-resolution without losing details and identity | |
Wu et al. | RUN: Rethinking the UNet Architecture for Efficient Image Restoration | |
Wang et al. | Dual Degradation-Inspired Deep Unfolding Network for Low-Light Image Enhancement |
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 | ||
GR01 | Patent grant | ||
GR01 | Patent grant |