A portrait key point detection method and system based on feature fusion
By combining the Transformer and Convolution feature fusion networks, the problem of high resolution requirements and insufficient rendering caused by heat map regression in the existing technology is solved, efficient portrait key point detection is achieved, and detection accuracy and speed are improved.
Patent Information
- Application Number
- CN202210648008.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-09
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2042-06-09
AI Technical Summary
Existing portrait key point detection algorithms rely on heat map regression, which results in high resolution requirements and insufficient rendering, making it difficult to effectively detect facial key points.
A regression network based on Transformer and Convolution feature fusion is used to perform face detection through the lightweight face detection network YOLOV5-n-face. The adaptive Wing loss and skip connection are used to fuse low-level semantic features and high-level semantic features to generate a Gaussian distribution map. Improve detection accuracy and speed.
It improves the accuracy and running speed of portrait key point detection, reduces the calculation amount and model complexity, and achieves results comparable to traditional convolution models.
Smart Images

Figure CN114863539B
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of computer vision technology, and specifically relates to a method and system for detecting key points of a portrait based on feature fusion. Background Art
[0002] In recent years, with the rapid development of Convolution networks and deep learning in the field of computer vision, computer vision tasks related to face images have also been put into practical use. Among them, portrait key point detection technology based on deep learning is one of the hot research topics in the current image detection field. Face key point detection has a clear development trend in virtual reality, expression recognition, face reconstruction, face tracking, and portrait beauty.
[0003] The Transformer network was not born out of the booming development of the computer vision field. The Transformer model was proposed by the Google team in 2017 for application in the NLP field (natural language processing). The self-attention mechanism in the Transformer model does not adopt the sequential structure of RNN, so that the Transformer model can be trained in parallel and have global information. In 2020, Carion proposed an end-to-end Transformer object detection model, which successfully combined the Transformer model in the NLP field with the computer vision field. Since then, visual Transformers have begun to develop rapidly and have achieved results comparable to traditional convolutions. Some Transformer network structures have even surpassed traditional convolution models.
[0004] The technology of facial key point detection has developed rapidly. Among them, the ASM (Active Shape Model) algorithm proposed by Cootes et al. is characterized by being based on point distribution. It obtains features through network training through a pre-calibrated training set, and then matches the feature positions through the positions of key points. Subsequently, in 2010, Dollar proposed CPR (Cascaded Pose Regression). CPR gradually refines a specified initial prediction value through a series of regressors. Each regressor relies on the output of the previous regressor to perform simple image operations, and the entire system can automatically learn from training samples. Finally, we entered the era of deep learning. The most representative one is that Zhang et al. proposed a multi-task cascaded convolutional neural network (MTCNN, Multi-task Cascaded Convolutional Networks) to simultaneously handle face detection and facial key point location problems. The author believes that there is often a potential connection between the two tasks of face detection and facial key point detection. However, most methods fail to effectively combine the two tasks. In order to make full use of the potential connection between the two tasks, this paper proposes a multi-task cascade face detection framework that performs face detection and facial key point detection simultaneously.
[0005] However, the current mainstream portrait key point detection algorithms all use the form of heat map regression. This method requires rendering a Gaussian heat map, because the maximum value point in the heat map directly corresponds to the key point, which leads to two problems. First, this type of algorithm needs to maintain a relatively high-resolution heat map, which makes this type of regression network difficult to regress. Second, in this type of algorithm, the maximum value point in the heat map directly represents the corresponding key point position, and rendering an accurate heat map by simply relying on the traditional method of deepening the number of convolutional layers is often insufficient. Summary of the invention
[0006] The object of the present invention is to provide a method and system for detecting key points of a portrait based on feature fusion, which method and system are conducive to improving detection accuracy and operating speed.
[0007] To achieve the above object, the technical solution adopted by the present invention is: a method for detecting key points of a portrait based on feature fusion, comprising the following steps:
[0008] Step S1: Send the pictures in the portrait dataset to the lightweight face detection network YOLOV5-n-face for face detection and cropping, discard the redundant background information, obtain the processed portrait pictures, normalize the original coordinate information in the portrait pictures, and convert them into heat maps through Gaussian distribution;
[0009] Step S2: The portrait image obtained in step S1 is sent to a regression network based on the fusion of Transformer and Convolution features for training. The heat map obtained in step S1 is used for supervised learning, and the loss function adopts the adaptive Wing loss. The regression network is a parallel structure. The low-level semantic features of the portrait image are captured by Convolution, and the high-level semantic features in the portrait image are captured by Transformer. The feature maps obtained by Convolution and Transformer are jump-connected, that is, the channels are connected, and the heat map containing coordinate information is jointly encoded.
[0010] Step S3: Based on the regression network of Convolution and Transformer feature fusion, the N heat maps of N key points are combined in the same channel to generate a single-channel heat map with boundary information, and output N+1 channels with a resolution of 64*64. N is the number of key points, and each channel is a Gaussian distribution map of the key points. The maximum probability is the key point to be sought.
[0011] Step S4: The output heat map is passed through a decoding function, and the first N heat maps are decoded to obtain accurate coordinate information of N key points.
[0012] Furthermore, in step S2, a feature map of a fusion of low-level semantic features and high-level semantic features is obtained through the regression network, and the method is as follows: the Convolution and Transformer parallel structures are used to obtain feature maps of different scales and different feature spaces, and after downsampling operations, feature fusion is performed in a skip connection, i.e., a channel connection mode, so as to construct a regression network based on the fusion of Convolution and Transformer features; the backbone module of the regression network based on the fusion of Convolution and Transformer features is constructed by the convolution module blocks in the CNN convolutional neural network ConvNeXt, assisted by the Transformer to capture long-distance semantic related information to further fuse features.
[0013] Furthermore, Transformer converts the sequence input into Token through an Embedding operation, with the format of (N,C,H*W), where N is the number of images input to the network during one training, C is the number of image channels, and H and W are the height and width of the image respectively; the Embedding layer uses two-dimensional convolution with different convolution kernel sizes to apply to the feature map of (N,C,H,W), and then performs bilinear interpolation on the feature maps of different resolutions to the same resolution size, and uses channel connection to obtain feature maps of different resolutions. The format of this feature map is changed from (N,C,H,W) to (N,C,H*W) and then sent to the self-attention mechanism of Transformer.
[0014] Furthermore, the Embedding operation in Transformer is as follows: the input feature maps are parallelly passed through two-dimensional convolutions with kernel sizes of 1*1, 3*3, 7*7, 9*9 and step sizes of 1, 1, 2, 2, respectively, to obtain four feature maps with different resolutions; then the four feature maps with different resolutions are converted into four feature maps of the same resolution through bilinear interpolation for channel connection, and finally the size of the feature map is changed to a size suitable for the self-attention layer in Transformer through the format change function.
[0015] Furthermore, the linear layer operation of the Self-attention in the Transformer structure is changed to a position convolution CoordConv operation, which further strengthens the self-attention layer to capture the features of long-distance high-level semantics and adds position information through convolution.
[0016] The present invention also provides a portrait key point detection system based on feature fusion, including a memory, a processor, and computer program instructions stored in the memory and capable of being executed by the processor. When the processor executes the computer program instructions, the above-mentioned method steps can be implemented.
[0017] Compared with the prior art, the present invention has the following beneficial effects: it provides a method and system for detecting key points of a portrait based on feature fusion, which designs a feature fusion network combining a Convolution module and a Transformer module, can combine the advantages of Transformer and Convolution, can capture global information while extracting low-level semantic features, and can reduce the amount of calculation and model complexity, while maintaining high detection accuracy, reduce the amount of model parameters, and improve the running speed of the model. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] Figure 1 It is a flow chart of the method implementation of the embodiment of the present invention.
[0019] Figure 2 Schematic diagram of a network structure based on heat map regression in an embodiment of the present invention.
[0020] Figure 3 Schematic diagram of projection of key points on an image in an embodiment of the present invention.
[0021] Figure 4 It is a heat map of a portrait with boundary information after encoding in an embodiment of the present invention.
[0022] Figure 5 It is a schematic diagram of the CoordConv (position convolution) structure in an embodiment of the present invention.
[0023] Figure 6 It is a schematic diagram of the structure of the convolution module (Conv Blocks) in an embodiment of the present invention. DETAILED DESCRIPTION
[0024] The present invention will be further described below in conjunction with the accompanying drawings and embodiments.
[0025] It should be noted that the following detailed descriptions are exemplary and are intended to provide further explanation of the present application. Unless otherwise specified, all technical and scientific terms used herein have the same meanings as those commonly understood by those skilled in the art to which the present application belongs.
[0026] It should be noted that the terms used herein are only for describing specific embodiments and are not intended to limit the exemplary embodiments according to the present application. As used herein, unless the context clearly indicates otherwise, the singular form is also intended to include the plural form. In addition, it should be understood that when the terms "comprise" and / or "include" are used in this specification, it indicates the presence of features, steps, operations, devices, components and / or combinations thereof.
[0027] This embodiment provides a method for detecting key points of a portrait based on feature fusion, and the implementation steps are as follows: Figure 1 As shown, including:
[0028] Step 1: Encode the two-dimensional digital coordinates in the training data set into a heat map through Gaussian model encoding. The maximum value point in the heat map represents this two-dimensional digital coordinate. There are N two-dimensional digital coordinates, and there are N heat maps. Set the resolution of the input image to 256*256, and according to experience, set the resolution of the output heat map to 64*64.
[0029] Step 2: According to this network, digital coordinates are regressed in the form of heat maps. Different loss functions have different effects on the results of training neural networks. The present invention sets Adaptive Wing Loss as the loss function. Adaptive Wing Loss gathers the maximum points of N heat maps into one map by drawing points, such as Figure 4 As shown, the effect of accurate facial boundary positioning is achieved.
[0030] The network structure of this embodiment is as follows Figure 2 As shown in the figure, after the initial feature extraction through the convolution preprocessing network, the obtained feature map is subjected to the Convolution operation and the Transformer operation in parallel. The embedding method in the Transformer operation is a two-dimensional convolution method, which further reduces the resolution of the input feature map and increases the number of channels. The Convolution operation will pass through a Conv Blocks. The structure of the convolution module is as follows Figure 6 As shown in the figure, the resolution of the feature map obtained is twice that of the Transformer operation. The feature map obtained by the Convolution operation is downsampled and jump-connected with the feature map obtained by the Transformer, and sent to the next stage using a channel connection.
[0031] The present invention introduces Coord Conv (position convolution) in the self-attention layer of Transformer to replace the ordinary linear layer operation. The structure of position convolution is as follows Figure 5 As shown in Figure 1, ordinary convolutional neural networks have defects in transforming spatial representation and cannot learn to transform Cartesian coordinates into pixel space coordinates. However, position convolutional neural networks can solve the problem of coordinate transformation in a perfect generalization method by learning complete translation invariance or different degrees of translation dependence.
[0032] Step 3: The network output is N+1 heat maps, which are converted into digital coordinate information through the decoding function. Figure 3 is the projection of the two-dimensional key point coordinates on the image.
[0033] The two-dimensional digital coordinates are converted into heat map coordinates through the Gaussian model, and the Gaussian model formula is:
[0034]
[0035] is the reference coordinate in the data set, and X is the image pixel. When the two are equal, the maximum value 1 is obtained, which is the maximum value point in the heat map.
[0036] The Adaptive Wing Loss formula is:
[0037]
[0038] is the key point prediction heat map output by the network, y is the key point heat map of reference, a, w, θ are all constants, where:
[0039] C=(θA-ωln(1+(θ / ∈) α-y ))
[0040] A=ω(1 / (1+(θ / ∈) (α-y) ))(α-y)((θ / ∈) (α-y-1) )(1 / ∈)
[0041] We compare the extracted coordinate vector with the reference coordinate vector and verify the correctness of this method through specific experimental data. The experimental results obtained by this method are compared with the existing algorithms, and the results are shown in Table 1 and Table 2.
[0042] Table 1 Performance comparison of ESR, SDM, CFSS, DVLD and this method on the WFLW dataset
[0043] Method NME ESR 11.13 SDM 10.20 CFSS 9.07 DVLD 6.08 This method 4.32
[0044] Table 2 Comparison of network parameters among SDM, SAN, LAB, PFLD and this method
[0045]
[0046]
[0047] This embodiment also provides a portrait key point detection system based on feature fusion, including a memory, a processor, and computer program instructions stored in the memory and capable of being executed by the processor. When the processor executes the computer program instructions, the above-mentioned method steps can be implemented.
[0048] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0049] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0050] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0051] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0052] The above is only a preferred embodiment of the present invention, and does not limit the present invention in other forms. Any technician familiar with the profession may use the above disclosed technical content to change or modify it into an equivalent embodiment with equivalent changes. However, any simple modification, equivalent change and modification made to the above embodiment according to the technical essence of the present invention without departing from the technical solution of the present invention still belongs to the protection scope of the technical solution of the present invention.
Claims
1. A method for detecting key points of a portrait based on feature fusion, characterized in that: The following steps are involved: Step S1: Send the pictures in the portrait dataset to the lightweight face detection network YOLOV5-n-face for face detection and cropping, discard the redundant background information, obtain the processed portrait pictures, normalize the original coordinate information in the portrait pictures, and convert them into heat maps through Gaussian distribution; Step S2: The portrait image obtained in step S1 is sent to a regression network based on the fusion of Transformer and Convolution features for training. The heat map obtained in step S1 is used for supervised learning, and the loss function adopts the adaptive Wingloss. The regression network is a parallel structure. The low-level semantic features of the portrait image are captured by Convolution, and the high-level semantic features in the portrait image are captured by Transformer. The feature maps obtained by Convolution and Transformer are jump-connected, that is, the channels are connected, and the heat map containing coordinate information is jointly encoded. Step S3: Based on the regression network of Convolution and Transformer feature fusion, the N heat maps of N key points are combined in the same channel to generate a single-channel heat map with boundary information, and output N+1 channels with a resolution of 64*64. N is the number of key points, and each channel is a Gaussian distribution map of the key points. The maximum probability is the key point to be sought. Step S4: The output heat map is passed through a decoding function, and the first N heat maps are decoded to obtain accurate coordinate information of N key points; In step S2, a feature map of low-level semantic features and high-level semantic features is obtained through the regression network, and the method is as follows: a Convolution and a Transformer parallel structure is used to obtain feature maps of different scales and different feature spaces, and after a downsampling operation, feature fusion is performed in a skip connection, that is, a channel connection mode, so as to construct a regression network based on the fusion of Convolution and Transformer features; The backbone module of the regression network based on Convolution and Transformer feature fusion is constructed by the convolutional blocks in the CNN convolutional neural network ConvNeXt, supplemented by Transformer to capture long-distance semantic related information and further fuse features; Transformer converts the sequence input into Token through an Embedding operation. The format is (N, C, H*W), where N is the number of images input to the network during one training, C is the number of image channels, and H and W are the height and width of the image respectively. The Embedding layer uses two-dimensional convolution with different convolution kernel sizes to apply to the feature map of (N, C, H, W), and then performs bilinear interpolation on the feature maps of different resolutions to the same resolution. The feature map with different resolutions is obtained by channel connection. The format of this feature map is changed from (N, C, H, W) to (N, C, H*W) and then sent to the self-attention mechanism of Transformer. The embedding operation in Transformer is as follows: the input feature maps are parallelized through two-dimensional convolutions with kernel sizes of 1*1, 3*3, 7*7, 9*9 and step sizes of 1, 1, 2, 2, respectively, to obtain four feature maps with different resolutions; then the four feature maps with different resolutions are converted into four feature maps of the same resolution through bilinear interpolation for channel connection, and finally the size of the feature map is changed to a size suitable for the self-attention layer in Transformer through the format change function; The linear layer operation of the Self-attention in the Transformer structure is changed to a positional convolution CoordConv operation, further strengthening the self-attention layer to capture the features of long-distance high-level semantics and adding position information through convolution.
2. A portrait key point detection system based on feature fusion, characterized in that: The method comprises a memory, a processor and computer program instructions stored in the memory and capable of being executed by the processor. When the processor executes the computer program instructions, the method steps as claimed in claim 1 can be implemented.
