Living body identification method, electronic device, and storage medium
By using a self-supervised pre-trained neural network to combine background and local features in face recognition, the first detection frame and the second detection frame are generated, and feature information is intercepted from the image, which solves the problem of low stability of living body discrimination in the existing technology. problem, achieving higher recognition accuracy and stability.
Patent Information
- Application Number
- CN202210252551.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-15
- Publication Date
- 2024-09-13
- Estimated Expiration
- 2042-03-15
AI Technical Summary
The existing living body discrimination method is difficult to distinguish the difference between high-definition reproduced images and real living bodies due to the influence of image quality, resulting in low stability.
By generating the first detection frame and the second detection frame in the target image, feature information for the background and local areas are intercepted from the image respectively, and a neural network based on self-supervised pre-training is used for feature extraction and in vivo discrimination, combined with the background and local features.
It improves the stability and generalization of living body discrimination, avoids the limitations of relying solely on image quality, and enhances the ability to identify living and non-living bodies.
Smart Images

Figure CN114627534B
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence technology, and in particular to a method for distinguishing living things, an electronic device, and a storage medium. Background Art
[0002] In face recognition, liveness detection is an important anti-fraud measure used to identify whether the target object in the image is a real human. The existing liveness detection method mainly generates a mask image of the face image, and then performs liveness detection based on the pixel probability value of the mask image. In practice, it is found that this method is greatly affected by image quality and it is difficult to distinguish the difference between high-definition re-shot images (such as high-definition screens or photo paper, etc.) and real live bodies. Therefore, the stability of liveness detection is low. Summary of the invention
[0003] The present application provides a living body identification method, an electronic device, and a storage medium, the main purpose of which is to improve the stability of living body identification.
[0004] To achieve the above object, the present application provides a method for identifying a living body, the method comprising:
[0005] Acquire a target image, and generate a first detection frame and a second detection frame in the target image, wherein the first detection frame and the second detection frame are both used to locate the object to be identified, and a detection area of the first detection frame is larger than a detection area of the second detection frame;
[0006] Using the first detection frame to intercept a first image from the target image, and inputting the first image into a first preset neural network for feature extraction to obtain first feature information, wherein the first preset neural network is obtained based on self-supervised pre-training;
[0007] Using the second detection frame to intercept a second image from the target image, and inputting the second image into a second preset neural network for feature extraction to obtain second feature information;
[0008] The non-living feature is identified according to the first feature information. If the non-living feature is identified, the object to be identified is determined to be a non-living object; if the non-living feature is not identified, liveness identification is performed according to the first feature information and the second feature information to obtain a liveness identification result.
[0009] In some embodiments, the training steps of the first preset neural network and the second preset neural network include:
[0010] Acquire an image sample and a living body discrimination label of the image sample;
[0011] generating a third detection frame and a fourth detection frame in the image sample, wherein a detection area of the third detection frame is larger than a detection area of the fourth detection frame;
[0012] intercepting a third image from the image sample using the third detection frame, and intercepting a fourth image from the image sample using the fourth detection frame;
[0013] generating a self-supervisory feature of the third image according to a preset feature type, wherein the preset feature type is a feature type that is different between a living body image and a non-living body image;
[0014] Using the third image to train a first preset neural network to obtain a first training result, and using the self-supervisory feature to perform self-supervisory learning on the first preset neural network to obtain a self-supervisory result;
[0015] Using the fourth image to train a second preset neural network to obtain a second training result;
[0016] Performing liveness discrimination according to the first training result and the second training result to obtain a target discrimination result;
[0017] The parameters of the first preset neural network and the second preset neural network are adjusted according to the self-supervision result, the target discrimination result and the living body discrimination label until a training end condition is reached.
[0018] In some implementations, the using the third image to train the first preset neural network to obtain a first training result includes:
[0019] Input the third image into a first preset neural network to perform feature extraction N times, to obtain first extraction information corresponding to the Nth feature extraction, where N is a positive integer; and determine the first extraction information as a first training result;
[0020] The using the self-supervisory feature to perform self-supervisory learning on the first preset neural network to obtain a self-supervisory result includes:
[0021] Obtain second extraction information corresponding to the Nm-th feature extraction, where m represents the number of self-supervision layers, m is a positive integer and m∈[1, N-1]; input the second extraction information and the self-supervision feature into the pre-trained self-supervision branch to obtain a self-supervision result.
[0022] In some implementations, generating the self-supervisory feature of the third image according to a preset feature type includes:
[0023] According to a preset feature type, a target feature map of the third image is generated; a preset number of self-supervisory layers is obtained, and a feature map size matching the number of self-supervisory layers is obtained; and the target feature map is resized according to the feature map size to obtain the self-supervisory features of the third image.
[0024] In some implementations, the capturing of a third image from the image sample using the third detection frame includes:
[0025] Extracting a sub-image corresponding to the third detection frame from the image sample; determining the sub-image corresponding to the third detection frame as a third image, or performing data enhancement processing on the sub-image corresponding to the third detection frame to obtain a third image;
[0026] The using the fourth detection frame to intercept a fourth image from the image sample comprises:
[0027] A sub-image corresponding to the fourth detection frame is captured from the image sample; the sub-image corresponding to the fourth detection frame is determined as a fourth image, or data enhancement processing is performed on the sub-image corresponding to the fourth detection frame to obtain a fourth image.
[0028] In some implementations, inputting the first image into a first preset neural network to extract features to obtain first feature information includes:
[0029] Performing standardization processing on the first image to obtain a fifth image; inputting the fifth image into a first preset neural network to perform feature extraction to obtain first feature information;
[0030] The step of inputting the second image into a second preset neural network for feature extraction to obtain second feature information includes:
[0031] The second image is normalized to obtain a sixth image, wherein a first image size corresponding to the fifth image and a second image size corresponding to the sixth image satisfy a specified multiple, and the first image size is larger than the second image size; the sixth image is input into a second preset neural network for feature extraction to obtain second feature information.
[0032] In some implementations, generating a first detection box and a second detection box in the target image includes:
[0033] Generating an initial detection frame in the target image, wherein the initial detection frame is used to locate the object to be identified;
[0034] Determining the initial detection frame as a second detection frame, and performing an outward expansion process on the initial detection frame to obtain a first detection frame;
[0035] Alternatively, the initial detection frame is expanded twice to obtain a first detection frame and a second detection frame, and the detection range of the first detection frame is larger than the detection range of the second detection frame.
[0036] In some embodiments, performing liveness identification according to the first feature information and the second feature information to obtain a liveness identification result includes:
[0037] A pre-trained liveness discrimination model is obtained, wherein the liveness discrimination model includes a fusion unit and a classification unit; the first feature information and the second feature information are input into the fusion unit for feature fusion to obtain target feature information; the target feature information is input into the classification unit to obtain a liveness probability and a non-liveness probability, wherein the liveness probability represents the probability that the object to be discriminated is a live object, and the non-liveness probability represents the probability that the object to be discriminated is a non-live object; and a liveness discrimination result is generated according to the liveness probability and the non-liveness probability.
[0038] To achieve the above purpose, the present application also provides a living body identification device, which includes:
[0039] An acquisition module, used for acquiring a target image;
[0040] A generating module, configured to generate a first detection frame and a second detection frame in the target image, wherein the first detection frame and the second detection frame are both used to locate the object to be identified, and a detection area of the first detection frame is larger than a detection area of the second detection frame;
[0041] A first extraction module, configured to capture a first image from the target image using the first detection frame, and input the first image into a first preset neural network for feature extraction to obtain first feature information, wherein the first preset neural network is obtained based on self-supervised pre-training;
[0042] A second extraction module, configured to intercept a second image from the target image using the second detection frame, and input the second image into a second preset neural network for feature extraction to obtain second feature information;
[0043] an identification module, used for identifying non-living features according to the first feature information;
[0044] The discrimination module is used to determine the object to be discriminated as a non-living object when a non-living feature is identified; and when the non-living feature is not identified, perform liveness discrimination according to the first feature information and the first feature information to obtain a liveness discrimination result.
[0045] To achieve the above objectives, an embodiment of the present application further proposes an electronic device, which includes a memory and a processor, wherein a program is stored in the memory, and the program implements the steps of the above method when executed by the processor.
[0046] To achieve the above objectives, the present application provides a storage medium for computer-readable storage, wherein the storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the steps of the aforementioned method.
[0047] The live body identification method, electronic device, and storage medium proposed in the present application generate a first detection frame and a second detection frame for locating the object to be identified in the target image, so that the detection area of the first detection frame is larger than the detection area of the second detection frame, so that the first detection frame can cover more of the background area of the target image, and the second detection frame focuses on the local area of the target image containing the object to be identified. After that, the first image intercepted from the target image using the first detection frame is input into the first preset neural network to obtain the first feature information, and the second image intercepted using the second detection frame is input into the second preset neural network to obtain the second feature information. Since the first preset neural network is obtained based on self-supervised pre-training, the first preset neural network has the ability to mine image features based on a specific self-supervised learning task, and the input of the first preset neural network is the first image, so the first preset neural network can further mine the global features corresponding to the background area of the image, which is convenient for reflecting the global difference between the live image and the non-live image. Based on this, the non-live feature is identified according to the first feature information, and if the non-live feature is identified, the object to be identified is directly determined as a non-live body. If the non-living features are not identified, liveness identification is performed based on the first feature information and the second feature information to obtain a liveness identification result. This not only realizes the identification of non-living features from the image background level, but also can simultaneously combine local and global image features for liveness identification, rather than being limited to image quality, thereby improving the stability and generalization of liveness identification. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] Figure 1 is a structural block diagram of an electronic device used in an embodiment of the present application;
[0049] Figure 2 It is a flow chart of a living body identification method provided in an embodiment of the present application;
[0050] Figure 3 It is a schematic diagram of a training process of a first preset neural network and a second preset neural network in an embodiment of the present application;
[0051] Figure 4 yes Figure 3 Specific flow diagram of step S340;
[0052] Figure 5 It is a structural schematic diagram of a first preset neural network, a second preset neural network, a self-supervision branch, and a living body discrimination model in an embodiment of the present application;
[0053] Figure 6 It is a structural block diagram of a living body identification device used in an embodiment of the present application. DETAILED DESCRIPTION
[0054] It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0055] In the subsequent description, the suffixes such as "module", "component" or "unit" used to represent elements are only used to facilitate the description of the present application, and have no special meanings. Therefore, "module", "component" or "unit" can be used in a mixed manner.
[0056] The embodiments of the present application can acquire and process relevant data based on artificial intelligence technology. Artificial intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results. Among them, the basic technologies of artificial intelligence generally include technologies such as sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing technology, operation / interaction systems, mechatronics, etc., while artificial intelligence software technology mainly includes computer vision technology (such as face recognition), robotics technology, biometrics technology, speech processing technology, natural language processing technology and machine learning / deep learning and other major directions.
[0057] In face recognition, liveness detection is an important anti-fraud measure used to identify whether the target object in the image is a real human. The existing liveness detection method mainly generates a mask image of the face image, and then performs liveness detection based on the pixel probability value of the mask image. In practice, it is found that this method is greatly affected by image quality and it is difficult to distinguish the difference between high-definition re-shot images (such as high-definition screens or photo paper, etc.) and real live bodies. Therefore, the stability of liveness detection is low.
[0058] In order to solve the above problems, the present application provides a method for identifying a living body, which is applied to an electronic device. Figure 1 As shown, Figure 1 It is a structural block diagram of an electronic device used in an embodiment of the present application.
[0059] In the embodiment of the present application, the electronic device may be a terminal device with computing functions, such as a server, a smart phone, a tablet computer, a portable computer, or a desktop computer.
[0060] The electronic device includes a memory 11 , a processor 12 , a network interface 13 and a data bus 14 .
[0061] The memory 11 includes at least one type of readable storage medium, and at least one type of readable storage medium may be a non-volatile storage medium such as a flash memory, a hard disk, a multimedia card, a card-type memory, etc. In some embodiments, the readable storage medium may be an internal storage unit of an electronic device, such as a hard disk of the electronic device. In other embodiments, the readable storage medium may also be an external memory of the electronic device, such as a plug-in hard disk equipped on the electronic device, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc.
[0062] In this embodiment, the readable storage medium of the memory 11 is generally used to store a living body identification program installed in the electronic device, multiple sample sets and pre-trained models, etc. The memory 11 can also be used to temporarily store data that has been output or is to be output.
[0063] In some embodiments, the processor 12 may be a central processing unit (CPU), a microprocessor or other data processing chip, which is used to run the program code stored in the memory 11 or process data, such as executing a liveness identification program.
[0064] The network interface 13 may optionally include a standard wired interface, a wireless interface (such as a WI-FI interface), and is generally used to establish a communication connection between the electronic device and other electronic devices.
[0065] The data bus 14 is used to realize the connection and communication between these components.
[0066] Optionally, the electronic device may further include a user interface, which may include an input unit such as a keyboard, a voice input device such as a microphone and other devices with voice recognition function, a voice output device such as a speaker, headphones, etc. Optionally, the user interface may also include a standard wired interface or a wireless interface.
[0067] Optionally, the electronic device may further include a display, which may also be referred to as a display screen or a display unit. In some embodiments, it may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, and an organic light-emitting diode (OLED) touch device. The display is used to display information processed in the electronic device and to display a visual user interface.
[0068] Optionally, the electronic device further includes a touch sensor. The area provided by the touch sensor for the user to perform a touch operation is called a touch control area. In addition, the touch sensor here may be a resistive touch sensor, a capacitive touch sensor, etc. Moreover, the touch sensor includes not only a contact touch sensor, but also a proximity touch sensor, etc. In addition, the touch sensor may be a single sensor or a plurality of sensors arranged in an array, for example.
[0069] In addition, the area of the display of the electronic device can be the same as or different from the area of the touch sensor. Optionally, the display and the touch sensor are stacked to form a touch display screen. The device detects a touch operation triggered by a user based on the touch display screen.
[0070] A method for distinguishing a living body disclosed in an embodiment of the present application is described in detail below.
[0071] like Figure 2 As shown, Figure 2 Schematic diagram of a method for distinguishing a living body provided in an embodiment of the present application. Figure 1 In the electronic device shown, the processor 12 implements the following steps S200 to S270 when executing the program stored in the memory 11.
[0072] Step S200: Acquire a target image, and generate a first detection frame and a second detection frame in the target image.
[0073] In the embodiment of the present application, the target image refers to an image containing an object to be identified. The object to be identified can be any object with specific properties (including shape, grayscale, texture, etc.), which is specifically divided into living objects or non-living objects. Living objects include but are not limited to faces and human bodies, and non-living objects include but are not limited to paper, electronic screens, work cards, masks, etc.
[0074] Specifically, the method of obtaining the target image includes but is not limited to: using the camera of the electronic device to photograph the object to be identified; retrieving pre-stored images from a designated database or other storage module; receiving images uploaded to the electronic device through a user interface; receiving images sent to the electronic device by other devices (such as access control cameras or road monitoring devices, etc.).
[0075] In the embodiment of the present application, the first detection frame and the second detection frame are both used to locate the object to be identified, and the detection area of the first detection frame is larger than the detection area of the second detection frame. Therefore, the first detection frame can cover more of the background area of the target image, while the second detection frame focuses on the local area of the target image that contains the object to be identified, which is beneficial to improving the non-living body defense capability.
[0076] Specifically, generating the first detection frame and the second detection frame in the target image may be: generating an initial detection frame in the target image, and the initial detection frame is used to locate the object to be identified. Wherein, the method of generating the initial detection frame includes but is not limited to a single shot multibox detector (SSD) algorithm, an algorithm based on a SSH (SingleStage Headless Face Detector) network, and an algorithm based on a multi-task convolutional neural network (MTCNN). Exemplarily, in practical applications, the target image is directly input into a pre-trained face detection network or model to obtain the detection frame information, and the detection frame information may include at least the vertex coordinates corresponding to the detection frame in the target image (such as the coordinates of the upper left corner of the detection frame), the width and height of the detection frame. Based on the detection frame information, an initial detection frame is generated in the target image. It can be understood that the initial detection frame can cover the main feature area of the object to be identified.
[0077] Based on this, in one implementation, the initial detection frame can be determined as the second detection frame, and the initial detection frame is expanded to obtain the first detection frame. Optionally, when the initial detection frame is expanded, the center coordinates are first determined, and then the initial detection frame is expanded outward by R1 times with the center coordinates as the center. R1 can be a manually specified positive integer. For example, when R1=4, the first detection frame and the second detection frame meet the requirements of high-precision living body discrimination. The center coordinates can be the coordinates of the center point of the image area corresponding to the initial detection frame in the target image; or, the center coordinates can also be calculated based on the coordinates of multiple key points in the above-mentioned image area. The type of key points is related to the object to be discriminated. For example, if the object to be discriminated is a human face, the key points can include but are not limited to the left eye, right eye, nose tip and lips. The center coordinates (x o ,y o )middle, (x i ,y i ) is the coordinate of any key point, a is the number of key point coordinates. There is no specific limitation on the center coordinates.
[0078] In another implementation, the initial detection frame may be expanded twice to obtain a first detection frame and a second detection frame, and the detection range of the first detection frame is greater than the detection range of the second detection frame. That is, the initial detection frame is expanded R2 times to obtain the first detection frame, and the initial detection frame is expanded R3 times to obtain the second detection frame, then R2>R3, R2 and R3 are both artificially specified positive integers, for example, R2=4, R3=2.
[0079] In other implementations, the number of the second detection frames may be two or more, so as to meet the needs of more types of outward expansion multiple processing and enrich the extracted image region information.
[0080] Step S210: using the first detection frame to capture the first image from the target image.
[0081] Optionally, if the first detection frame exceeds the image edge of the target image, when the first image is captured from the target image, no pixel filling operation (ie, padding operation) is performed on the image edge to avoid introducing non-living significant features such as black edges, such as the edge of an electronic device.
[0082] Step S220: Input the first image into a first preset neural network for feature extraction to obtain first feature information, where the first preset neural network is obtained based on self-supervised pre-training.
[0083] In the embodiment of the present application, the first preset neural network can adopt ResNet network, VGG network or other convolutional neural network, etc., without specific limitation. In the training stage of the first preset neural network, a specific self-supervised learning task is used to mine its own supervisory information from large-scale unsupervised data, and the supervisory information is used to train the first preset neural network, so that the first preset neural network learns valuable representations for downstream tasks. Since the input of the first preset neural network is the first image, the first preset neural network can further mine the global features corresponding to the background area of the image, which is convenient for reflecting the global difference between living images and non-living images.
[0084] Step S230: using the second detection frame to capture the second image from the target image.
[0085] Optionally, if the second detection frame exceeds the image edge of the target image, when the second image is captured from the target image, no pixel filling operation (ie, padding operation) is performed on the image edge to avoid introducing non-living significant features such as black edges, such as the edge of an electronic device.
[0086] Step S240: inputting the second image into a second preset neural network for feature extraction to obtain second feature information.
[0087] In the embodiment of the present application, the second preset neural network can adopt a ResNet network, a VGG network, or other convolutional neural networks, etc., without specific limitation.
[0088] In an optional implementation, step S220 may specifically be: performing standardization processing on the first image to obtain a fifth image. Inputting the fifth image into a first preset neural network for feature extraction to obtain first feature information. Correspondingly, step S240 may specifically be: performing standardization processing on the second image to obtain a sixth image, so that the first image size corresponding to the fifth image and the second image size corresponding to the sixth image satisfy a specified multiple, and the first image size is larger than the second image size. Inputting the sixth image into a second preset neural network for feature extraction to obtain second feature information.
[0089] Among them, the standardization process is used to transform the corresponding image into a specified format. The specified format and the above-mentioned specified multiple can be manually set, and the specified format includes but is not limited to at least one of the image size and the image pixel value, without limitation. Exemplarily, the specified multiple can be related to the parameters of the expansion process, such as the specified multiple = N2 ÷ N3. It can be seen that ensuring that the specified size correlation between different images is met is conducive to the accuracy of feature extraction and improves the generalization of the overall mechanism.
[0090] In another optional implementation, the specified first image size and second image size may be determined first, and then the first image may be directly standardized to the first image size, and the second image may be standardized to the second image size, to complete the image adjustment based on the specified size. Specifically, the first image size is W*H*C=224*224*3, and the second image size is W*H*C=112*112*3, where W represents the image width, H represents the image height, and C represents the number of image channels.
[0091] In an alternative implementation, see Figure 3 , Figure 3 Schematic diagram of the training process of a first preset neural network and a second preset neural network in an embodiment of the present application. Figure 3 As shown, the training steps of the first preset neural network and the second preset neural network include:
[0092] Step S300: Obtain image samples and living body discrimination labels of the image samples.
[0093] The image sample includes a target object, the target object is a living object or a non-living object, and the living object discrimination label is used to indicate whether the target object is a living object or a non-living object.
[0094] Step S310: generating a third detection frame and a fourth detection frame in the image sample, wherein the detection area of the third detection frame is larger than the detection area of the fourth detection frame.
[0095] The specific implementation of step S310 may refer to the description of step S200 and will not be repeated here.
[0096] Step S320: using the third detection frame to capture a third image from the image sample, and using the fourth detection frame to capture a fourth image from the image sample.
[0097] In one implementation, using the third detection frame to capture the third image from the image sample may specifically include the following steps: capturing a sub-image corresponding to the third detection frame from the image sample, determining the sub-image corresponding to the third detection frame as the third image, or performing data enhancement processing on the sub-image corresponding to the third detection frame to obtain the third image.
[0098] Correspondingly, using the fourth detection frame to capture the fourth image from the image sample may specifically include the following steps: capturing a sub-image corresponding to the fourth detection frame from the image sample, determining the sub-image corresponding to the fourth detection frame as the fourth image, or performing data enhancement processing on the sub-image corresponding to the fourth detection frame to obtain the fourth image.
[0099] The data enhancement processing includes but is not limited to at least one of flipping, rotating, mirroring, chromaticity conversion, lighting, glass and fogging. It can be seen that in the network training stage, through the data enhancement processing of image samples, the sample types and combinations used for training the network are enriched, which can effectively improve the network accuracy under the premise of limited sample data.
[0100] Step S330: generating a self-supervisory feature of the third image according to a preset feature type, where the preset feature type is a feature type that is different between the living body image and the non-living body image.
[0101] In an embodiment of the present application, the preset feature type can be manually specified, and the preset feature type can specifically include but is not limited to at least one of color texture, non-rigid motion deformation, material (such as skin, paper or mirror, etc.), frequency domain features and feature descriptors (such as histogram of oriented gradients HOG and accelerated robust features SURF, etc.).
[0102] Specifically, for step S330, if the preset feature type includes a feature descriptor, the feature descriptor of the third image can be calculated using the SURF algorithm, and the feature descriptor can be projected into principal components using the principal component analysis (PCA) algorithm, and then the principal component encoding can be performed using the Gaussian mixed model (GMM), and finally the self-supervisory feature of the third image is obtained. If the preset feature type includes a frequency domain feature, the third image can be Fourier transformed to obtain a Fourier frequency domain map as the self-supervisory feature of the third image, and the Fourier frequency domain map has obvious feature differences between living images and non-living images. In other implementations, the third image can also be input into an attention model trained based on the preset feature type to obtain the self-supervisory feature of the third image.
[0103] Step S340: using the third image to train the first preset neural network to obtain a first training result, and using the self-supervised feature to perform self-supervised learning on the first preset neural network to obtain a self-supervised result.
[0104] In one implementation, Figure 4 As shown, the first preset neural network is trained using the third image to obtain a first training result, which specifically includes the following steps S341 to S342:
[0105] Step S341: input the third image into the first preset neural network to perform N-th feature extraction, and obtain first extraction information corresponding to the N-th feature extraction.
[0106] Wherein, N is a positive integer. Specifically, the first preset neural network may include N convolutional layers, and the convolutional parameters of these convolutional layers gradually decrease until the last convolutional layer outputs a feature map of a specified image size, that is, the first extracted information.
[0107] Step S342: Determine the first extracted information as the first training result.
[0108] Accordingly, the self-supervisory features are used to perform self-supervisory learning on the first preset neural network to obtain a self-supervisory result, which specifically includes the following steps S343 to S344:
[0109] Step S343: Obtain the second extraction information corresponding to the Nm-th feature extraction, where m represents the number of self-supervision layers.
[0110] Wherein, m is a positive integer and m∈[1, N-1]. The second extraction information corresponding to the Nm-th feature extraction can be the feature map output by the Nm-th convolutional layer in the first preset neural network. When the self-supervision branch is introduced after the Nm-th convolutional layer in the first preset neural network, the self-supervision result will assist in guiding the feature extraction learning process of the 1st to Nm-1 convolutional layers in the first preset neural network, and ensure that the subsequent convolutional layers extract non-living features more accurately. Therefore, the smaller the value of m, the more convolutional layers will be guided by self-supervision, and the greater the impact of self-supervision. It can be seen that self-supervision based on preset feature types can intervene in specific nodes in the image feature extraction process, and the supervision method is more flexible and diverse.
[0111] Step S344: input the second extracted information and the self-supervisory features into the pre-trained self-supervisory branch to obtain a self-supervisory result.
[0112] Specifically, the self-supervision branch is used to extract the target feature corresponding to the preset feature type from the second extracted information, so the self-supervision branch may include multiple pre-trained convolutional layers. The first loss value between the second extracted information and the target feature is calculated by the self-supervision branch, so that the first loss value is determined as the self-supervision result. The loss function for calculating the first loss value includes but is not limited to the mean squared error (MSE) and the cross entropy loss function. In addition, the self-supervision branch does not participate in the final reasoning deployment, and only plays an auxiliary role in improving the network accuracy during the training stage of the first preset neural network.
[0113] In an optional implementation manner, step S330 may include the following steps:
[0114] According to the preset feature type, a target feature map of the third image is generated. A preset number of self-supervisory layers is obtained, and a feature map size matching the number of self-supervisory layers is obtained. The target feature map is resized according to the feature map size to obtain the self-supervisory features of the third image. The number of self-supervisory layers is related to the number of convolutional layers in the first preset neural network. Specifically, the feature map size matching the number of self-supervisory layers may refer to the image size corresponding to the second extracted information. By resizing, the image size of the self-supervisory feature is ensured to be consistent with the image size of the second extracted information.
[0115] Step S350: using the fourth image to train the second preset neural network to obtain a second training result.
[0116] Step S360: Perform living body identification according to the first training result and the second training result to obtain a target identification result.
[0117] In one implementation, a liveness discrimination branch can be constructed, and the liveness discrimination branch can be trained simultaneously during the training process of the first preset neural network and the second preset neural network, that is, the first training result and the second training result are input into the liveness discrimination branch to obtain the target discrimination result. In another implementation, the first training result and the second training result can also be directly input into the pre-trained liveness discrimination model to obtain the target discrimination result.
[0118] Step S370: adjusting the parameters of the first preset neural network and the second preset neural network according to the self-supervision result, the target discrimination result and the living body discrimination label until the training end condition is reached.
[0119] Specifically, in step S370, the second loss value can be calculated according to the target discrimination result and the living body discrimination label. Verify whether the training end condition is met according to the first loss value and the second loss value. If the training end condition is met, the training ends. If the training end condition is not met, adjust the parameters of the first preset neural network and the second preset neural network (or the first preset neural network, the second preset neural network and the living body discrimination branch) according to the first loss value and the second loss value, and increase the number of samples and re-execute the above training steps.
[0120] The loss function used to calculate the second loss value includes but is not limited to a cross entropy loss function and an edge loss function. It can be seen that adding the loss value of the self-supervised branch as an auxiliary term of the loss function achieves the effect of multi-scale auxiliary loss.
[0121] Optionally, the training end condition includes but is not limited to a specified loss threshold, and whether the training end condition is met is verified based on the first loss value and the second loss value, including: calculating the target loss value based on the first loss value and the second loss value, if the target loss value is less than or equal to the loss threshold, the first preset model meets the training end condition, if the target loss value is greater than the loss threshold, then the first preset model does not meet the training end condition. The method for calculating the target loss value includes but is not limited to: target loss value = first weight × first loss value + second weight × second loss value, the first weight and the second weight can both be manually set weights. In some implementations, the first weight can be related to the value of Nm, for example, the two are in direct proportion.
[0122] It can be seen that by implementing the above steps S300 to S370, during the training process of the first preset neural network and the second preset neural network, self-supervised learning of the first preset grid is performed using self-supervised features based on preset feature types, which can effectively guide the first preset neural network to learn non-living features in the image.
[0123] Step S250: Identify the non-living feature according to the first feature information, and execute step S260 or step S270.
[0124] In the embodiments of the present application, non-living features include black edges, borders, moiré patterns, imaging deformities, and infrared reflected light, etc., which are not limited to this.
[0125] Step S260: If the non-living feature is identified, the object to be identified is determined as a non-living object.
[0126] Step S270: If the non-live feature is not identified, liveness identification is performed based on the first feature information and the second feature information to obtain a liveness identification result.
[0127] It can be seen that based on steps S250 to S270, a preliminary liveness discrimination can be performed in combination with the non-liveness features of the background area in the target image. If the non-liveness features are identified, the object to be identified is directly determined as a non-liveness, which is conducive to improving the discrimination efficiency. If the non-liveness features are not identified, a secondary liveness discrimination is performed in combination with the first feature information and the second feature information, which is conducive to improving the accuracy and rigor of the liveness discrimination.
[0128] In an alternative implementation, please participate Figure 5 , Figure 5 Schematic diagram of the structure of a first preset neural network, a second preset neural network, a self-supervisory branch, and a living body discrimination model in an embodiment of the present application. Figure 5 , performing liveness identification according to the first feature information and the second feature information to obtain a liveness identification result, which may specifically include the following steps:
[0129] Step S271: Obtain a pre-trained living body discrimination model, where the living body discrimination model includes a fusion unit and a classification unit.
[0130] Step S272: Input the first feature information and the second feature information into a fusion unit for feature fusion to obtain target feature information.
[0131] Among them, the feature fusion through the fusion unit can adopt the blending fusion method or the stacking fusion method, etc., without specific limitation. Exemplarily, if the fusion unit adopts the stacking fusion method, the fusion unit may include at least two learners and a fusion layer, and each learner may include a batch normalization layer, a long short-term memory network layer, a pooling layer and a flattening layer, without specific limitation. The first feature information is input into a learner to obtain new first feature information, the second feature information is input into another learner to obtain new second feature information, and then the new first feature information and the second feature information are input into the fusion layer for feature fusion to obtain the target feature information, so as to realize the fusion of local image features and global image features.
[0132] In practical applications, in order to improve the accuracy of image feature fusion, the convolution step size used by the first preset neural network and the second preset neural network meets the specified multiple, so that the first feature information output by the first preset neural network and the second feature information output by the second preset neural network both meet the specified image size. In one implementation, the image size of the first image input to the first preset neural network is 224*224, and the image size of the second image input to the second preset neural network is 112*112, then the convolution step size used by the first preset neural network is 32, and the convolution step size used by the second preset neural network is 16.
[0133] Step S273: Input the target feature information into the classification unit to obtain the live probability and the non-live probability. The live probability indicates the probability that the object to be identified is a live object, and the non-live probability indicates the probability that the object to be identified is a non-live object.
[0134] Among them, the classification unit may include at least a fully connected layer and a softmax classification layer.
[0135] Step S274: Generate a liveness identification result based on the liveness probability and the non-liveness probability.
[0136] For example, in one case, if the probability of being alive is greater than the probability of being non-alive, the object to be identified is determined to be alive, and if the probability of being alive is less than the probability of being non-alive, the object to be identified is determined to be non-alive. In another case, if the probability of being alive is greater than the specified probability, the object to be identified is determined to be alive, otherwise, the object to be identified is determined to be non-alive, and the specified probability is manually specified, such as 0.6 or 0.7, etc., and is not specifically limited to this.
[0137] It can be seen that the implementation of the above method embodiment can not only realize the recognition of non-living features from the image background level, but also can simultaneously combine local and global image features for living body discrimination, rather than being limited to image quality, thereby improving the stability and generalization of living body discrimination.
[0138] The present application also provides a living body identification device. Figure 6 , Figure 6 : is a structural block diagram of a living body identification device used in the embodiment of the present application. Figure 6 As shown, the living body identification device 600 includes an acquisition module 610, a generation module 620, a first extraction module 630, a second extraction module 640, a recognition module 650 and a identification module 660, wherein:
[0139] The acquisition module 610 is used to acquire a target image.
[0140] The generating module 620 is used to generate a first detection frame and a second detection frame in the target image, wherein the first detection frame and the second detection frame are both used to locate the object to be identified, and the detection area of the first detection frame is larger than the detection area of the second detection frame.
[0141] The first extraction module 630 is used to capture a first image from the target image using a first detection frame, and input the first image into a first preset neural network for feature extraction to obtain first feature information, where the first preset neural network is obtained based on self-supervised pre-training.
[0142] The second extraction module 640 is used to capture a second image from the target image using a second detection frame, and input the second image into a second preset neural network for feature extraction to obtain second feature information.
[0143] The identification module 650 is used to identify the non-living feature according to the first feature information.
[0144] The identification module 660 is used to determine the object to be identified as a non-living object when a non-living feature is identified; and when a non-living feature is not identified, perform living body identification according to the first feature information and the first feature information to obtain a living body identification result.
[0145] In some optional implementations, the living body identification device may further include a training module, the training module includes an acquisition unit, a generation unit, a capture unit, a first training unit, a second training unit and a identification unit, wherein:
[0146] An acquisition unit, used for acquiring an image sample and a living body discrimination label of the image sample;
[0147] A generating unit, configured to generate a third detection frame and a fourth detection frame in the image sample, wherein a detection area of the third detection frame is larger than a detection area of the fourth detection frame;
[0148] A capture unit, configured to capture a third image from the image sample using a third detection frame, and capture a fourth image from the image sample using a fourth detection frame;
[0149] A first training unit is used to generate a self-supervised feature of a third image according to a preset feature type, where the preset feature type is a feature type that is different between a living body image and a non-living body image; train a first preset neural network using the third image to obtain a first training result, and perform self-supervised learning on the first preset neural network using the self-supervised feature to obtain a self-supervised result;
[0150] A second training unit, used to train a second preset neural network using a fourth image to obtain a second training result;
[0151] The discrimination unit is used to perform liveness discrimination according to the first training result and the second training result to obtain a target discrimination result; and adjust the parameters of the first preset neural network and the second preset neural network according to the self-supervision result, the target discrimination result and the liveness discrimination label until the training end condition is reached.
[0152] Further, optionally, the first training unit is also used to input the third image into the first preset neural network for N feature extractions to obtain first extraction information corresponding to the Nth feature extraction, where N is a positive integer; determine the first extraction information as the first training result; and obtain second extraction information corresponding to the Nmth feature extraction, where m represents the number of self-supervision layers, m is a positive integer and m∈[1, N-1]; input the second extraction information and the self-supervision features into the pre-trained self-supervision branch to obtain a self-supervision result.
[0153] Further, optionally, the first training unit is also used to generate a target feature map of the third image according to a preset feature type; obtain a preset number of self-supervisory layers, and obtain a feature map size that matches the number of self-supervisory layers; resize the target feature map according to the feature map size to obtain the self-supervisory features of the third image.
[0154] Further, optionally, the capture unit is also used to capture a sub-image corresponding to a third detection box from the image sample; determine the sub-image corresponding to the third detection box as a third image, or perform data enhancement processing on the sub-image corresponding to the third detection box to obtain a third image; and capture a sub-image corresponding to a fourth detection box from the image sample; determine the sub-image corresponding to the fourth detection box as a fourth image, or perform data enhancement processing on the sub-image corresponding to the fourth detection box to obtain a fourth image.
[0155] In some optional implementations, the first extraction module 630 is further used to perform standardization processing on the first image to obtain a fifth image; the fifth image is input into the first preset neural network for feature extraction to obtain first feature information. The second extraction module 640 is further used to perform standardization processing on the second image to obtain a sixth image, wherein the first image size corresponding to the fifth image and the second image size corresponding to the sixth image satisfy a specified multiple, and the first image size is larger than the second image size; the sixth image is input into the second preset neural network for feature extraction to obtain second feature information.
[0156] In some optional implementations, the generation module 620 is specifically used to generate an initial detection frame in the target image, and the initial detection frame is used to locate the object to be identified; the initial detection frame is determined as the second detection frame, and the initial detection frame is expanded to obtain the first detection frame; or, the initial detection frame is expanded twice to obtain the first detection frame and the second detection frame, and the detection range of the first detection frame is larger than the detection range of the second detection frame.
[0157] In some optional implementations, the discrimination module 660 is specifically used to obtain a pre-trained liveness discrimination model, which includes a fusion unit and a classification unit; the first feature information and the second feature information are input into the fusion unit for feature fusion to obtain target feature information; the target feature information is input into the classification unit to obtain a liveness probability and a non-liveness probability, the liveness probability represents the probability that the object to be discriminated is alive, and the non-liveness probability represents the probability that the object to be discriminated is non-liveness; based on the liveness probability and the non-liveness probability, a liveness discrimination result is generated.
[0158] It should be noted that the specific implementation process of this embodiment can refer to the specific implementation process of the above method embodiment, and will not be repeated here.
[0159] An embodiment of the present application further provides an electronic device, which includes a memory and a processor. The memory stores a program, and when the program is executed by the processor, the above-mentioned living body identification method is implemented.
[0160] The embodiment of the present application also provides a storage medium for computer-readable storage, the storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the above-mentioned living body identification method.
[0161] Those skilled in the art will appreciate that all or some of the steps in the methods disclosed above, and the functional modules / units in the systems and devices may be implemented as software, firmware, hardware, or a suitable combination thereof.
[0162] In hardware implementation, the division between the functional modules / units mentioned in the above description does not necessarily correspond to the division of physical components; for example, a physical component may have multiple functions, or a function or step may be performed by several physical components in cooperation. Some physical components or all physical components may be implemented as software executed by a processor, such as a central processing unit, a digital signal processor or a microprocessor, or implemented as hardware, or implemented as an integrated circuit, such as an application-specific integrated circuit. Such software may be distributed on a computer-readable medium, which may include a computer storage medium (or non-transitory medium) and a communication medium (or temporary medium). As known to those of ordinary skill in the art, the term computer storage medium includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information (such as computer-readable instructions, data structures, program modules or other data). Computer storage media include, but are not limited to, RAM, ROM, EEPROM, flash memory or other memory technology, CD-ROM, digital versatile disk (DVD) or other optical disk storage, magnetic cassettes, magnetic tapes, disk storage or other magnetic storage devices, or any other medium that can be used to store desired information and can be accessed by a computer. Furthermore, it is well known to those skilled in the art that communication media typically embodies computer readable instructions, data structures, program modules, or other data in a modulated data signal such as a carrier wave or other transport mechanism, and may include any information delivery media.
[0163] The preferred embodiments of the present application are described above with reference to the accompanying drawings, but the scope of the present application is not limited thereby. Any modification, equivalent substitution and improvement made by a person skilled in the art without departing from the scope and essence of the present application shall be within the scope of the present application.
Claims
1. A method for identifying living bodies, It is characterized in that The method comprises: Acquire a target image, and generate a first detection frame and a second detection frame in the target image, wherein the first detection frame and the second detection frame are both used to locate the object to be identified, and a detection area of the first detection frame is larger than a detection area of the second detection frame; Using the first detection frame to intercept a first image from the target image, and inputting the first image into a first preset neural network for feature extraction to obtain first feature information, wherein the first preset neural network is obtained based on self-supervised pre-training; Using the second detection frame to intercept a second image from the target image, and inputting the second image into a second preset neural network for feature extraction to obtain second feature information; Identify a non-living feature according to the first feature information, and if the non-living feature is identified, determine the object to be identified as a non-living object; if the non-living feature is not identified, perform liveness identification according to the first feature information and the second feature information to obtain a liveness identification result; The training steps of the first preset neural network and the second preset neural network include: Acquire an image sample and a living body discrimination label of the image sample; generating a third detection frame and a fourth detection frame in the image sample, wherein a detection area of the third detection frame is larger than a detection area of the fourth detection frame; intercepting a third image from the image sample using the third detection frame, and intercepting a fourth image from the image sample using the fourth detection frame; generating a self-supervisory feature of the third image according to a preset feature type, wherein the preset feature type is a feature type that is different between a living body image and a non-living body image; Using the third image to train a first preset neural network to obtain a first training result, and using the self-supervisory feature to perform self-supervisory learning on the first preset neural network to obtain a self-supervisory result; Using the fourth image to train a second preset neural network to obtain a second training result; Performing liveness discrimination according to the first training result and the second training result to obtain a target discrimination result; The parameters of the first preset neural network and the second preset neural network are adjusted according to the self-supervision result, the target discrimination result and the living body discrimination label until a training end condition is reached.
2. The method according to claim 1, It is characterized in that The step of training the first preset neural network using the third image to obtain a first training result includes: Inputting the third image into a first preset neural network to perform feature extraction N times, and obtaining first extraction information corresponding to the Nth feature extraction, where N is a positive integer; Determining the first extracted information as a first training result; The using the self-supervisory feature to perform self-supervisory learning on the first preset neural network to obtain a self-supervisory result includes: Get the second extraction information corresponding to the Nm-th feature extraction, where m represents the number of self-supervision layers, m is a positive integer and m∈[1, N-1]; The second extracted information and the self-supervisory feature are input into a pre-trained self-supervisory branch to obtain a self-supervisory result.
3. The method according to claim 1, It is characterized in that The step of generating the self-supervisory feature of the third image according to the preset feature type includes: Generating a target feature map of the third image according to a preset feature type; Obtaining a preset number of self-supervisory layers, and obtaining a feature map size matching the number of self-supervisory layers; The target feature map is resized according to the feature map size to obtain the self-supervisory features of the third image.
4. The method according to claim 1, It is characterized in that The using the third detection frame to intercept a third image from the image sample comprises: Cutting out a sub-image corresponding to the third detection frame from the image sample; Determine the sub-image corresponding to the third detection frame as the third image, or perform data enhancement processing on the sub-image corresponding to the third detection frame to obtain the third image; The using the fourth detection frame to intercept a fourth image from the image sample comprises: Cutting out a sub-image corresponding to the fourth detection frame from the image sample; The sub-image corresponding to the fourth detection frame is determined as the fourth image, or the sub-image corresponding to the fourth detection frame is subjected to data enhancement processing to obtain the fourth image.
5. The method according to any one of claims 1 to 4, It is characterized in that The step of inputting the first image into a first preset neural network to extract features and obtain first feature information includes: performing standardization processing on the first image to obtain a fifth image; Inputting the fifth image into a first preset neural network to perform feature extraction to obtain first feature information; The step of inputting the second image into a second preset neural network for feature extraction to obtain second feature information includes: Performing standardization processing on the second image to obtain a sixth image, wherein a first image size corresponding to the fifth image and a second image size corresponding to the sixth image satisfy a specified multiple, and the first image size is larger than the second image size; The sixth image is input into a second preset neural network to perform feature extraction to obtain second feature information.
6. The method according to any one of claims 1 to 4, It is characterized in that The step of generating a first detection frame and a second detection frame in the target image comprises: Generating an initial detection frame in the target image, wherein the initial detection frame is used to locate the object to be identified; Determining the initial detection frame as a second detection frame, and performing an outward expansion process on the initial detection frame to obtain a first detection frame; Alternatively, the initial detection frame is expanded twice to obtain a first detection frame and a second detection frame, and the detection range of the first detection frame is larger than the detection range of the second detection frame.
7. The method according to any one of claims 1 to 4, It is characterized in that The performing liveness identification according to the first feature information and the second feature information to obtain a liveness identification result includes: Acquire a pre-trained liveness discrimination model, where the liveness discrimination model includes a fusion unit and a classification unit; Inputting the first feature information and the second feature information into the fusion unit to perform feature fusion to obtain target feature information; Inputting the target feature information into the classification unit to obtain a live probability and a non-live probability, wherein the live probability indicates the probability that the object to be identified is a live object, and the non-live probability indicates the probability that the object to be identified is a non-live object; A live body identification result is generated according to the live body probability and the non-live body probability.
8. An electronic device, It is characterized in that The electronic device includes a memory, a processor, a program stored in the memory and executable on the processor, and a data bus for realizing connection and communication between the processor and the memory. When the program is executed by the processor, the steps of the living body identification method as described in any one of claims 1 to 7 are realized.
9. A storage medium for computer-readable storage, It is characterized in that The storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the steps of the living body identification method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Living body recognition method and device, storage medium, and computer equipment
CN107818313A
Human face living body detection method
CN110598580A
Living body detection method, device and equipment
CN111178341A
Multi-person living body detection method and device, electronic equipment and storage medium
CN112149570A
Living body detection method and device
CN112215045A
