Lightweight living body detection method and device, electronic equipment and computer storage medium
This paper proposes a deep learning model with a lightweight network structure for face image liveness detection, which solves the problem of face liveness detection in scenarios with limited computing resources. It enables efficient deployment and accurate recognition on embedded devices and is suitable for scenarios such as ATMs and banking applications.
Patent Information
- Application Number
- CN202511724262.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-23
- Publication Date
- 2026-02-17
AI Technical Summary
Existing face image liveness detection methods are highly dependent on hardware devices and computing performance, making them difficult to deploy effectively in scenarios with limited computing resources, especially in ATMs and banking applications, and unable to meet the usage needs of various scenarios.
A lightweight deep learning model with a network structure is used for face image liveness detection, including a face detection model and a liveness detection model. By using channel partitioning and identity connection in the lightweight network structure, the computational load and number of parameters are reduced. Combined with the squeeze-excitation attention mechanism, fast face detection and liveness recognition are achieved.
This invention achieves efficient face liveness detection on embedded devices with limited computing resources, reducing the demand for computing resources, improving model inference speed, and ensuring the accuracy of liveness detection, making it suitable for deployment in more scenarios.
Smart Images

Figure CN121545231A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of artificial intelligence technology, and in particular to a lightweight liveness detection method, apparatus, electronic device, and computer storage medium. Background Technology
[0002] Liveness detection of facial images is an important technology for defending against liveness attacks, which can analyze whether the person performing the facial recognition is the user himself / herself.
[0003] Existing face image liveness detection methods are highly dependent on hardware devices and their performance. They typically rely on high-definition bullet screen cameras for image acquisition, and also require the use of flashlights and sound collectors for auxiliary information acquisition. Alternatively, multiple images may need to be acquired for judgment, and further depth maps of the face images are required. This process consumes a lot of resources and places certain demands on the performance of computing devices.
[0004] Currently, banks use facial image liveness detection primarily in two scenarios: Automated Teller Machines (ATMs) and bank applications (Apps). These scenarios have limited computing performance, and existing technologies are somewhat dependent on computing resources, making it difficult to meet the needs of various scenarios. Summary of the Invention
[0005] In view of this, the present invention provides a lightweight liveness detection method, device, electronic device and computer storage medium, which uses a lightweight network structure model to perform liveness detection on face images, in order to solve the deployment problem in embedded and other scenarios with limited computing resources, while ensuring the accuracy of face liveness detection results.
[0006] The first aspect of this invention provides a lightweight liveness detection method, comprising:
[0007] Acquire the image to be recognized;
[0008] The image to be identified is input into a face detection model to obtain a face detection result; wherein, the face detection result includes: the detection box range and key point coordinates; the face detection model is trained by a first deep learning model; the first deep learning model adopts a lightweight network structure; the channels in the lightweight network structure are divided according to a preset ratio to obtain a first channel and a second channel, the first channel is subjected to convolution calculation, and the convolution of the second channel adopts an identity connection method;
[0009] The image to be identified is cropped based on the detection box range to obtain the face region image;
[0010] The face region image and the key point coordinates are input into the liveness detection model to obtain the liveness detection result; wherein, the liveness detection result is that the face region image is a live face or a non-live face; the liveness detection model is trained by a second deep learning model; the second deep learning model adopts the lightweight network structure.
[0011] Optionally, the lightweight network structure employs a squeeze-excitement attention mechanism.
[0012] Optionally, the face detection result also includes the number of face images. After inputting the image to be recognized into the face detection model to obtain the face detection result, the method further includes:
[0013] If the number of facial images is not 1, then a transaction risk is identified.
[0014] If the number of face images is 1, then the step of cropping the image to be identified based on the detection box range to obtain the face region image is started.
[0015] Optionally, after cropping the image to be recognized based on the detection box range to obtain the face region image, the method further includes:
[0016] Based on the face region and the required image size for liveness detection, the face region image and the key point coordinates are adjusted to obtain the target face region image and the target key point coordinates.
[0017] The step of inputting the face region image and the key point coordinates into the liveness detection model to obtain the liveness detection result includes:
[0018] The target face region image and the coordinates of the target key points are input into the liveness detection model to obtain the liveness detection result.
[0019] Optionally, after inputting the face region image and the key point coordinates into the liveness detection model to obtain the liveness detection result, the method further includes:
[0020] If the liveness detection result indicates that the face region image is not a live face, then a security check is performed; wherein, the security check includes one or more of blink detection, mouth opening detection, and head posture detection.
[0021] A second aspect of the present invention provides a lightweight liveness detection device, comprising:
[0022] The acquisition unit is used to acquire the image to be recognized;
[0023] A face detection unit is used to input the image to be recognized into a face detection model to obtain a face detection result; wherein, the face detection result includes: the detection box range and key point coordinates; the face detection model is trained by a first deep learning model; the first deep learning model adopts a lightweight network structure; the channels in the lightweight network structure are divided according to a preset ratio to obtain a first channel and a second channel, the first channel performs convolution calculation, and the convolution of the second channel adopts an identity connection method;
[0024] The cropping unit is used to crop the image to be recognized based on the detection box range to obtain a face region image;
[0025] A liveness detection unit is used to input the face region image and the key point coordinates into a liveness detection model to obtain a liveness detection result; wherein, the liveness detection result is that the face region image is a live face or a non-live face; the liveness detection model is trained by a second deep learning model; the second deep learning model adopts the lightweight network structure.
[0026] Optionally, the lightweight network structure employs a squeeze-excitement attention mechanism.
[0027] Optionally, the lightweight liveness detection device further includes:
[0028] A transaction risk determination unit is used to determine that a transaction risk exists if the number of face images is not 1.
[0029] The cropping unit is further configured to, if the number of face images is 1, start cropping the image to be identified based on the detection box range to obtain a face region image.
[0030] Optionally, the lightweight liveness detection device further includes:
[0031] The adjustment unit is used to adjust the face region image and the key point coordinates based on the face region and the image size required for liveness detection, so as to obtain the target face region image and the target key point coordinates.
[0032] The liveness detection unit is used for:
[0033] The target face region image and the coordinates of the target key points are input into the liveness detection model to obtain the liveness detection result.
[0034] Optionally, the lightweight liveness detection device further includes:
[0035] A security verification unit is used to perform security verification if the liveness detection result indicates that the face region image is not a live face; wherein the security verification includes one or more of blink detection, mouth opening detection, and head posture detection.
[0036] A third aspect of the present invention provides an electronic device, comprising:
[0037] One or more processors;
[0038] A storage device on which one or more programs are stored;
[0039] When the one or more programs are executed by the one or more processors, the one or more processors implement the lightweight liveness detection method as described in any one of the first aspects.
[0040] A fourth aspect of the present invention provides a computer storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the lightweight liveness detection method as described in any one of the first aspects.
[0041] As can be seen from the above solutions, the present invention provides a lightweight liveness detection method, device, electronic device, and computer storage medium. By deploying a face detection model and a liveness detection model with a lightweight network structure, face detection and liveness detection are performed on the image to be recognized, realizing deployment in scenarios with limited computing resources such as embedded systems, while ensuring the accuracy of the liveness detection results. Attached Figure Description
[0042] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.
[0043] Figure 1 A detailed flowchart of a lightweight liveness detection method provided in an embodiment of the present invention;
[0044] Figure 2 A schematic diagram illustrating a conventional convolution calculation method according to another embodiment of the present invention;
[0045] Figure 3 A schematic diagram illustrating a partial convolution calculation method according to another embodiment of the present invention;
[0046] Figure 4 A schematic diagram of a convolutional layer structure of a network provided in another embodiment of the present invention;
[0047] Figure 5 A schematic diagram of a key point provided for another embodiment of the present invention;
[0048] Figure 6 A schematic diagram of a neural network for face detection provided in another embodiment of the present invention;
[0049] Figure 7 A schematic diagram of a neural network for liveness detection provided in another embodiment of the present invention;
[0050] Figure 8 A schematic diagram of a head posture provided for another embodiment of the present invention;
[0051] Figure 9 A schematic diagram of a lightweight liveness detection device provided in another embodiment of the present invention;
[0052] Figure 10 This is a schematic diagram of an electronic device for implementing a lightweight liveness detection method, provided as another embodiment of the present invention. Detailed Implementation
[0053] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0054] The term "comprising" and its variations as used herein are open-ended inclusions, meaning "including but not limited to". The term "based on" means "at least partially based on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". Definitions of other terms will be given in the description below.
[0055] It should be noted that the information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this invention are all information and data authorized by the user or fully authorized by all parties.
[0056] It should be noted that the concepts of "first" and "second" mentioned in this invention are only used to distinguish different devices, modules or units, and are not used to limit the order of functions performed by these devices, modules or units or their interdependencies.
[0057] It should be noted that the terms "a" and "a plurality of" used in this invention are illustrative rather than restrictive. Those skilled in the art should understand that, unless otherwise expressly indicated in the context, they should be understood as "one or more".
[0058] This invention provides a lightweight liveness detection method, such as... Figure 1 As shown, the specific steps include:
[0059] S101. Obtain the image to be recognized.
[0060] In practical applications of this invention, the image to be recognized can be obtained through, but is not limited to, cameras installed on ATMs or cameras built into mobile phones; no limitation is made here. For example, when a user deposits or transfers money using an ATM, the image to be recognized can be obtained through a camera installed on the ATM. Similarly, when a user uses a mobile banking app, the image to be recognized can be obtained through the mobile phone.
[0061] S102. Input the image to be recognized into the face detection model to obtain the face detection result.
[0062] The face detection results include: the detection box range and key point coordinates; the face detection model is trained by the first deep learning model; the first deep learning model adopts a lightweight network structure; the channels in the lightweight network structure are divided according to a preset ratio to obtain the first channel and the second channel, the first channel is convolutionally calculated, and the convolution of the second channel adopts the identity connection method.
[0063] Understandably, existing traditional convolutional neural network models are large, computationally intensive, and have a huge number of parameters, which makes their inference speed slow and difficult to deploy in practical applications. These models are more suitable for server deployment, while embedded devices (such as ATMs) have insufficient computing power. In order to achieve deployment in embedded environments, this invention provides a lightweight network structure that aims to reduce model size and computational load, and improve the model's inference speed.
[0064] The lightweight network structure provided by this invention can be shown in Table 1:
[0065] Table 1
[0066] Convolutional layer Output size convolution kernel Number of channels Step length Number of repetitions Large convolutional layers 112X112 7X7 64 2 1 Partial Convolution 1 56X56 3X3 256 2 3 Partial Convolution 2 28X28 3X3 512 2 4 Partial Convolution 3 14X14 3X3 1024 2 6 Partial convolution 4 7X7 3X3 2048 2 3 Average pooling 1X1 - 2048 - - Fully connected layer 1X1 - 1000 - -
[0067] The lightweight network structure takes a three-channel RGB image with dimensions of 224x224x3 as input. After a 7x7 convolution, the image size is adjusted to 112x112, and the number of channels is reduced to 64. Then, multiple 3x3 convolutions adjust the output size of the feature map. The convolutional parts with 1x1 kernels used to adjust the number of channels in each stage are omitted. In the multiple repeated convolutional layers, the first convolution adjusts the feature map size, so the stride is 2; subsequent convolutions maintain the same size, so the stride is 1. This invention divides the 3x3 convolutional channels according to a preset ratio to obtain a first channel and a second channel. The first channel undergoes convolution calculation, while the second channel uses an identity connection method for convolution.
[0068] Identity connection refers to directly passing the input data (or the output of the previous layer) to the subsequent layer without any transformation, and adding it to the output after convolution, activation and other operations.
[0069] For example, when training a model, only half of the convolutional layers are convolved, and the rest are directly passed to the next layer. Figure 2 This is a regular convolution, and as you can see, the calculation is performed by crossing channels to obtain the result. Figure 3 This is a partial convolution with a partition factor of 2 (first channel convolution), such as... Figure 3 As shown, only the first half of the channels participate in the convolution calculation, while the second half is an identity connection. Replacing regular convolution with partial convolution can effectively reduce the amount of computation and parameters.
[0070] Optionally, in another embodiment of the present invention, a Squeeze-and-Excitation Networks (SENet) mechanism can be further introduced into the lightweight network structure. This mechanism does not modify the input or output; therefore, it can be achieved by simply adding a shortcut connection to the 3x3 convolution and incorporating the SE attention mechanism. The shortcut directly adds the input features to the convolutional output through a skip connection across layers, effectively mitigating the gradient vanishing problem in deep networks and enabling the network to be trained to greater depths.
[0071] From this, we can obtain the convolutional layer structure of the network as follows: Figure 4 As shown in the diagram, taking partial convolutional layer 1 as an example, the input is 112*112*64. First, the size of the output feature map is adjusted using the first partial convolution, resulting in 56*56*64. Partial convolutional layer 1 is repeated 3 times; the first repetition is for size adjustment, so it is repeated 2 times thereafter. During the repetition phase, the stride of the partial convolution is set to 1, requiring padding to avoid modifying the feature map size. Simultaneously, an SE attention mechanism is added to the shortcut branch.
[0072] In the specific implementation of this invention, the detection box range can be represented by only two points, such as the coordinates of the upper left and lower right corners of the detection box. The position of the rectangular box can be obtained using only these two coordinates. Since the coordinates include x and y coordinates, a total of 4 data points are sufficient to represent the detection box.
[0073] In the specific implementation of this invention, the number of key point coordinates in the face detection result may be, but is not limited to, 68. Taking 68 key points as an example, a schematic diagram of the key points can be referred to. Figure 5 .
[0074] In the practical application of this invention, if a user is in a risky scenario such as transferring money or making a payment, other people are usually not allowed to be nearby to avoid the risk of being coerced or spied on. Therefore, in another embodiment of this invention, the face detection model outputs the face detection result, which also includes the number of face images. If the number of face images is not 1, it is determined that there is a transaction risk, and subsequent operations will not be performed, and the user will be prompted; if the number of face images is 1, then step 103 will be executed.
[0075] In the process of training the network, this invention, such as Figure 6 As shown, three fully connected layers can be used to obtain the face detection classification result, the bounding box regression result, and the keypoint regression result, respectively. No limitation is made here. The face detection result corresponds to the number of face images, the bounding box regression result corresponds to the bounding box range, and the keypoint regression result corresponds to the keypoint coordinates. Taking the aforementioned risk scenario as an example, there are only two possible face classifications, represented by two numbers; the face bounding box can be represented by only two points: the coordinates of the top-left and bottom-right corners of the bounding box. These two coordinates are sufficient to determine the position of the bounding box. Since the coordinates include x and y coordinates, a total of four data points are needed to represent the bounding box; there are a total of 68 coordinate points, therefore 116 keypoints are required. Therefore, the total output is 122. For the final 1000 classifications trained by the network, three fully connected layers are used to obtain the face detection classification result, the bounding box regression result, and the keypoint regression result, respectively.
[0076] S103. Based on the detection box range, crop the image to be recognized to obtain the face region image.
[0077] Continuing with the above example, by obtaining the coordinates of the upper left and lower right corners of the detection box, the range of the detection box can be determined based on these two coordinates. Based on the range of the detection box, the face position in the image to be recognized is cropped to obtain the face region image.
[0078] Optionally, in another embodiment of the present invention, since the required size for liveness detection may not be consistent with the detection box range, it is necessary to adjust the size of the face region image to the required size for liveness detection. This can be done by, but is not limited to, calculating a scaling ratio according to the ratio between the required size for liveness detection and the detection box range, and adjusting the face region image according to the scaling ratio to obtain the target face region image, thus avoiding deformation or partial loss of the face due to stretching or compression. This is not limited here. Of course, it is understood that the key point coordinates also need to be adjusted simultaneously according to the scaling ratio to obtain the target key point coordinates.
[0079] S104. Input the face region image and key point coordinates into the liveness detection model to obtain the liveness detection results.
[0080] Among them, the liveness detection result is whether the face region image is a live face or a non-live face; the liveness detection model is trained by the second deep learning model; the second deep learning model adopts a lightweight network structure.
[0081] In the actual application of this invention, non-living faces may be obtained by forging non-living face information (such as photos, videos, 3D models, etc.) to deceive the face recognition system, causing it to mistakenly identify the forged information as "real people," synthesizing realistic face images or videos through AI technologies such as generative adversarial networks, tampering with real face data, or creating face replicas without life characteristics through artificial means, etc., without limitation here.
[0082] In the specific implementation of this invention, the image data used in the training set of the liveness detection model during training includes, but is not limited to, 2D face attack images, 3D face attack images, and AI face attack images. Specifically, a face image data photo can be photographed using an image acquisition device as a 2D face attack image; for 3D images, a face photo needs to be printed out, and some relatively fitting 3D face masks need to be made, and a frontal photo needs to be acquired as a 3D face attack image; and some fake AI face images are generated through an AI model.
[0083] The second deep learning model can also be implemented using the same method as the first deep learning model. However, since the dataset includes 2D images, 3D images, and AI-generated images, the final part of the model needs to be modified, such as... Figure 7 As shown, the number of categories was changed to 4, and then the model was trained.
[0084] It should be noted that the model trained on the server is of type PTH, which is not compatible with all devices and is typically only well-suited for servers. Therefore, it is not suitable for embedded devices or Android devices. To facilitate use on embedded devices, format conversion is required. This invention is not specific to any particular device; taking Android devices as an example, the format needs to be converted to an ONNX model structure. Therefore, further format conversion is necessary. Both the liveness detection model and the face detection model of this invention need to be converted to ONNX format.
[0085] When the liveness detection result is that the face region image is not a live face, directly rejecting the user's related transactions will cause a bad user experience. Therefore, enhanced security verification is required. Considering that image frames are easy to forge, video can be used for verification. In another embodiment of the present invention, security verification includes, but is not limited to, one or more of blink detection, mouth opening detection, and head posture detection, which are not limited here.
[0086] The blink detection method can be, but is not limited to, requiring the user to blink, identifying whether the user blinks based on different eye angles, and specifically, determining whether the user blinks by calculating the aspect ratio of the eye.
[0087] Now Figure 5 Taking key points as an example, by setting {p1:36, p2:37, p3:38, p4:39, p5:40, p6:41} respectively, we can obtain the calculation method for the eye's aspect ratio. By calculating the common angles of open and closed eyes and setting an appropriate threshold, we can calculate the current user's eye-opening status. The calculation method for the right eye is the same as that for the left eye.
[0088] Aspect ratio = ((p37y+p38y)-(p40y+p41y)) / 2 / (p39x-p36x);
[0089] This involves calculating the distance between the upper and lower parts of the left corner of the eye and dividing it by the distance between the left and right corners of the eye. The aspect ratio is used to represent the angle at which the eye is open, and the change in angle is used to determine whether the user is blinking.
[0090] The mouth opening detection method can be, but is not limited to, requiring the user to open their mouth. Specifically, it is only necessary to set the following relationship, and the length and width calculation formula of the open and closed eyes can be used to calculate the mouth opening and closing status.
[0091] The association relationships are {p1:48, p2:50, p3:52, p4:64, p5:56, p6:58}.
[0092] The head pose detection method can be, but is not limited to, detecting whether the user is turning left or right. User pose detection typically uses a rotation matrix for calculation. Specifically, it can use, but is not limited to, three angles—Yaw, Pitch, and Roll—to represent the rotation of the 3D graphic along the x, y, and z coordinate axes. An illustration of head pose is shown below. Figure 8 As shown. Obtaining the YAW angle is primarily for controlling the horizontal rotation of the head; therefore, it requires calculating the YAW angle of the head using a single image. Existing technologies typically use multiple cameras to acquire the angle, but this invention can roughly estimate the head's posture based on two-dimensional key points and a three-dimensional head model.
[0093] The mapping between two-dimensional and three-dimensional images requires the coordinates of key points in the two-dimensional image and the coordinates of the three-dimensional model. This invention uses the solvePnP function of OpenCV for calculation, specifically requiring the two-dimensional coordinates of the left corner of the eye, right corner of the eye, tip of the nose, left corner of the mouth, right corner of the mouth, and chin of the face image, as well as the coordinates of the three-dimensional model.
[0094] The coordinates of points in a 3D model can generally be represented using the following coordinates: tip of the nose (0,0,0), chin (0,-330,-65), left corner of the eye (-225,170,-135), right corner of the eye (225,170,135), left corner of the mouth (-150,-150,-125), and right corner of the mouth (150,-150,-125). Two-dimensional coordinates are represented using... Figure 5 The coordinates of points 36, 45, 33, 48, 54, and 8 are obtained. This invention uses OpenCV's `solvePnP` function to obtain the corresponding Yaw, Pitch, and Roll angles, thus determining whether the user has correctly executed the left or right turn command.
[0095] In the specific implementation of this invention, when it is determined that the currently identified face region image is a non-live face, the face region image can be stored to facilitate subsequent learning and review of the attack scenario and optimization of the model.
[0096] It is important to emphasize that the solution of this invention can determine whether a face image is live using only a single image, without the need for a depth map. Therefore, deployment can be completed using only a monocular camera. Furthermore, by deploying a lightweight network structure face detection model and a liveness detection model, face detection and liveness detection are performed on the image to be identified. This reduces the requirements for equipment, makes it applicable to more scenarios, and allows for local deployment of the model. This reduces server computation, image uploading, and queuing processes, effectively reducing the time required for liveness detection and improving the user experience.
[0097] As can be seen from the above solutions, the present invention provides a lightweight liveness detection method. By deploying a face detection model and a liveness detection model with a lightweight network structure, face detection and liveness detection are performed on the image to be recognized, realizing deployment in scenarios with limited computing resources such as embedded systems, while ensuring the accuracy of liveness detection results.
[0098] Another embodiment of the present invention provides a lightweight liveness detection device, such as... Figure 9 As shown, it specifically includes:
[0099] The acquisition unit 901 is used to acquire the image to be recognized.
[0100] The face detection unit 902 is used to input the image to be recognized into the face detection model to obtain the face detection result.
[0101] The face detection results include: the detection box range and key point coordinates; the face detection model is trained by the first deep learning model; the first deep learning model adopts a lightweight network structure; the channels in the lightweight network structure are divided according to a preset ratio to obtain the first channel and the second channel, the first channel is convolutionally calculated, and the convolution of the second channel adopts the identity connection method.
[0102] Optionally, in another embodiment of the invention, the lightweight network structure employs a squeeze-excitement attention mechanism.
[0103] The specific working process of the units disclosed in the above embodiments of the present invention can be found in the corresponding method embodiments, and will not be repeated here.
[0104] The cropping unit 903 is used to crop the image to be recognized based on the detection box range to obtain a face region image.
[0105] The liveness detection unit 904 is used to input the face region image and key point coordinates into the liveness detection model to obtain the liveness detection result.
[0106] Among them, the liveness detection result is whether the face region image is a live face or a non-live face; the liveness detection model is trained by the second deep learning model; the second deep learning model adopts a lightweight network structure.
[0107] For details on the specific operation of the units disclosed in the above embodiments of the present invention, please refer to the corresponding method embodiments, such as... Figure 1 As shown, it will not be elaborated further here.
[0108] Optionally, in another embodiment of the present invention, one implementation of the lightweight liveness detection device further includes:
[0109] The transaction risk determination unit is used to determine that a transaction risk exists if the number of face images is not 1.
[0110] The cropping unit is also used to crop the image to be recognized based on the detection box range if the number of face images is 1, so as to obtain the face region image.
[0111] The specific working process of the units disclosed in the above embodiments of the present invention can be found in the corresponding method embodiments, and will not be repeated here.
[0112] Optionally, in another embodiment of the present invention, one implementation of the lightweight liveness detection device further includes:
[0113] The adjustment unit is used to adjust the face region image and key point coordinates based on the face region and the image size required for liveness detection, so as to obtain the target face region image and target key point coordinates.
[0114] The liveness detection unit is used for:
[0115] The target face region image and the coordinates of the target key points are input into the liveness detection model to obtain the liveness detection results.
[0116] The specific working process of the units disclosed in the above embodiments of the present invention can be found in the corresponding method embodiments, and will not be repeated here.
[0117] Optionally, in another embodiment of the present invention, one implementation of the lightweight liveness detection device further includes:
[0118] The security verification unit is used to perform security verification if the liveness detection result is that the face region image is not a live face.
[0119] The security verification includes one or more of the following: blink detection, mouth opening detection, and head posture detection.
[0120] The specific working process of the units disclosed in the above embodiments of the present invention can be found in the corresponding method embodiments, and will not be repeated here.
[0121] As can be seen from the above solutions, the present invention provides a lightweight liveness detection device. By deploying a face detection model and a liveness detection model with a lightweight network structure, face detection and liveness detection are performed on the image to be recognized, realizing deployment in scenarios with limited computing resources such as embedded systems, while ensuring the accuracy of the liveness detection results.
[0122] The functions described above in this document can be performed at least in part by one or more hardware logic components. For example, exemplary types of hardware logic components that can be used, without limitation, include: field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), system-on-a-chip (SoCs), complex programmable logic devices (CPLDs), and so on.
[0123] Another embodiment of the present invention provides an electronic device, such as... Figure 10 As shown, it includes:
[0124] One or more processors 1001.
[0125] Storage device 1002, on which one or more programs are stored.
[0126] When the one or more programs are executed by the one or more processors 1001, the one or more processors 1001 implement the lightweight liveness detection method as described in the above embodiments.
[0127] Another embodiment of the present invention provides a computer storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the lightweight liveness detection method as described in the above embodiments.
[0128] In the context of this invention, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. Machine-readable media can include, but are not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0129] It should be noted that the computer-readable medium described above in this invention can be a computer-readable signal medium, a computer-readable storage medium, or any combination thereof. A computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this invention, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In this invention, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium can be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wires, optical fibers, RF (radio frequency), etc., or any suitable combination thereof.
[0130] The aforementioned computer-readable medium may be included in the aforementioned electronic device; or it may exist independently and not assembled into the electronic device.
[0131] Another embodiment of the present invention provides a computer program product, which, when executed, is used to perform the above-described lightweight liveness detection method.
[0132] In particular, according to embodiments of the present invention, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of the present invention include a computer program product comprising a computer program carried on a non-transitory computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device, or installed from a storage device, or installed from a ROM. When the computer program is executed by a processing device, it performs the functions defined in the methods of the embodiments of the present invention.
[0133] Although the subject matter has been described using language specific to structural features and / or methodological logic, it should be understood that the subject matter defined in this invention is not necessarily limited to the specific features or actions described above. Rather, the specific features and actions described above are merely exemplary forms for implementing the invention.
[0134] While several specific implementation details are included in the foregoing discussion, these should not be construed as limiting the scope of the invention. Certain features described in the context of individual embodiments may also be implemented in combination in a single embodiment. Conversely, various features described in the context of a single embodiment may also be implemented individually or in any suitable sub-combination in multiple embodiments.
[0135] The above description is merely a preferred embodiment of the present invention and an explanation of the technical principles employed. Those skilled in the art should understand that the scope of the invention is not limited to the specific combination of the above-described technical features, but also includes other technical solutions formed by arbitrary combinations of the above-described technical features or their equivalents without departing from the inventive concept. For example, technical solutions formed by substituting the above-described features with technical features of the present invention (but not limited to) that have similar functions.
Claims
1. A lightweight liveness detection method, characterized in that, The method comprises the following steps: obtaining an image to be identified; inputting the image to be identified into a face detection model to obtain a face detection result; wherein the face detection result comprises a detection frame range and key point coordinates; the face detection model is obtained by training a first deep learning model; the first deep learning model adopts a lightweight network structure; the channels in the lightweight network structure are divided into a first channel and a second channel according to a preset ratio; the first channel performs convolution calculation; and the convolution of the second channel adopts an identity connection mode; cropping the image to be identified based on the detection frame range to obtain a face region image; inputting the face region image and the key point coordinates into a living body detection model to obtain a living body detection result; wherein the living body detection result is that the face region image is a living body face or a non-living body face; the living body detection model is obtained by training a second deep learning model; and the second deep learning model adopts the lightweight network structure.
2. The lightweight liveness detection method of claim 1, wherein, The lightweight network structure adopts a squeeze-excitation attention mechanism.
3. The lightweight liveness detection method of claim 1, wherein, The face detection result further comprises a face image quantity; after the step of inputting the image to be identified into the face detection model to obtain the face detection result, the following steps are further included: if the face image quantity is not 1, it is determined that there is a current transaction risk; if the face image quantity is 1, the step of cropping the image to be identified based on the detection frame range to obtain the face region image is started to be executed.
4. The lightweight liveness detection method of claim 1, wherein, After the step of cropping the image to be identified based on the detection frame range to obtain the face region image, the following steps are further included: adjusting the face region image and the key point coordinates based on the face region and the image size required by living body detection to obtain a target face region image and target key point coordinates; wherein the step of inputting the face region image and the key point coordinates into the living body detection model to obtain the living body detection result comprises: inputting the target face region image and the target key point coordinates into the living body detection model to obtain the living body detection result.
5. The lightweight liveness detection method of claim 1, wherein, After the step of inputting the face region image and the key point coordinates into the living body detection model to obtain the living body detection result, the following steps are further included: if the living body detection result is that the face region image is a non-living body face, safety verification is performed; wherein the safety verification comprises one or more of blink detection, mouth opening detection, and head posture detection.
6. A lightweight liveness detection apparatus, characterized by, The method comprises the following steps: an obtaining unit, configured to obtain an image to be identified; a face detection unit, configured to input the image to be identified into a face detection model to obtain a face detection result; wherein the face detection result comprises a detection frame range and key point coordinates; the face detection model is obtained by training a first deep learning model; the first deep learning model adopts a lightweight network structure; the channels in the lightweight network structure are divided into a first channel and a second channel according to a preset ratio; the first channel performs convolution calculation; and the convolution of the second channel adopts an identity connection mode; a cropping unit, configured to crop the image to be identified based on the detection frame range to obtain a face region image; The living body detection unit is configured to input the face region image and the key point coordinates into a living body detection model to obtain a living body detection result, wherein the living body detection result indicates whether the face region image is a living face or a non-living face, the living body detection model is trained by a second deep learning model, and the second deep learning model adopts the lightweight network structure.
7. The lightweight liveness detection apparatus according to claim 6, wherein Also comprising: The transaction risk determination unit is configured to determine that there is a transaction risk if the number of face images is not 1. The cropping unit is further configured to perform the cropping of the to-be-identified image based on the range of the detection frame to obtain a face region image if the number of face images is 1.
8. The lightweight liveness detection apparatus according to claim 6, wherein Also comprising: The security verification unit is configured to perform security verification if the living body detection result indicates that the face region image is a non-living face, and the security verification includes one or more of blink detection, mouth opening detection, and head posture detection.
9. An electronic device, comprising: Comprising: One or more processors; A storage device having one or more programs stored thereon; When the one or more programs are executed by the one or more processors, the one or more processors implement the lightweight living body detection method according to any one of claims 1 to 5.
10. A computer storage medium, characterized in that A computer program is stored thereon, and the computer program is executed by a processor to implement the lightweight living body detection method according to any one of claims 1 to 5.