Liveness detection method and system
By compressing and differentially processing the target user image to generate a differential user image and extracting fusion features, the problem of efficiency and accuracy of liveness detection under high-definition screen attacks is solved, and efficient liveness detection is achieved.
Patent Information
- Application Number
- CN202310284432.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-17
- Publication Date
- 2026-01-09
- Estimated Expiration
- 2043-03-17
AI Technical Summary
Existing liveness detection methods require the introduction of additional information, such as motion or glare, when facing attacks on high-definition screens, resulting in reduced detection efficiency, a degraded user experience, and poor detection performance.
By compressing the target user image, multiple differential user images are generated. These images are then fused and feature extracted. Attention weights and feature encoding networks are used for liveness classification to improve detection accuracy.
It can effectively amplify abnormal clues of high-definition screen attacks without requiring additional information, thereby improving the detection performance and accuracy of liveness detection.
Smart Images

Figure CN116311551B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present specification relates to the field of living body detection, and in particular, to a living body detection method and system. BACKGROUND
[0002] In recent years, with the rapid development of Internet technology, living body detection has become an indispensable part in face recognition systems. Through living body detection, non-living body type attack samples can be effectively intercepted. The continuous evolution of living body detection methods can efficiently detect general types of living body attacks, but there are still some attack types that cannot be solved, such as high-definition screen attacks. In high-definition screen attacks, it is difficult to collect attack clues presented by high-definition screens. For this type of attack, existing living body detection methods often use multi-action interaction or introduce random glare for living body detection.
[0003] In the process of research and practice of the prior art, the inventors of the present application found that the methods based on multi-action interaction and the introduction of random glare both require the introduction of additional information (actions or glare light, etc.) in the living body detection process, which not only reduces the detection efficiency of living body detection, but also increases the disturbance rate to users. Therefore, under the premise of ensuring user experience, the detection performance of living body detection is reduced. SUMMARY
[0004] The present specification provides a living body detection method and system with higher detection performance.
[0005] In a first aspect, the present specification provides a living body detection method, comprising: obtaining a target user image of a target user, and compressing the target user image based on K compression rates to obtain K compressed user images, the K being an integer greater than 0; generating K difference user images based on the target user image and the K compressed user images; and performing living body detection on the target user based on the K difference user images to obtain a living body detection result of the target user, and outputting the living body detection result.
[0006] In some embodiments, the K compression rates have the same difference between adjacent compression rates after sorting.
[0007] In some embodiments, the generating K difference user images based on the target user image and the K compressed user images comprises: sorting the target user image and the K compressed user images based on the K compression rates to obtain a user image sequence; and performing difference on adjacent images in the user image sequence to obtain the K difference user images.
[0008] In some embodiments, the liveness detection on the target user to obtain the liveness detection result of the target user comprises: fusing the K difference user images to obtain a fused user image; performing feature extraction on the fused user image to obtain an image liveness feature of the target user; and performing liveness classification on the target user based on the image liveness feature to obtain the liveness detection result of the target user.
[0009] In some embodiments, the fusing the K difference user images to obtain a fused user image comprises: determining attention weights corresponding to the K difference user images; and fusing the K difference user images based on the attention weights to obtain the fused user image.
[0010] In some embodiments, the performing liveness classification on the target user to obtain the liveness detection result of the target user comprises: determining a target attack probability of the target user based on the image liveness feature; and performing a target operation based on the target attack probability, the target operation comprising a first operation or a second operation, wherein: the first operation comprises determining that the target attack probability is greater than a preset probability threshold, determining that the liveness detection result of the target user is an attack user, and the second operation comprises determining that the target attack probability is less than the preset probability threshold, determining that the liveness detection result of the target user is a liveness user.
[0011] In some embodiments, the liveness detection on the target user to obtain the liveness detection result of the target user comprises: inputting the K difference user images into a target liveness detection model to obtain a plurality of attack probabilities; determining a mean value of the plurality of attack probabilities to obtain a target attack probability of the target user; and determining the liveness detection result of the target user based on the target attack probability.
[0012] In some embodiments, the plurality of attack probabilities comprise an attack probability corresponding to each pixel in a fused user image, and the fused user image comprises a user image fused from the K difference user images.
[0013] In some embodiments, a training process of the target liveness detection model comprises the following steps: obtaining a first difference user image sample group; training a preset liveness detection model based on the first difference user image sample group to obtain a trained liveness detection model; and compressing the liveness detection model to obtain the target liveness detection model.
[0014] In some embodiments, the training of the preset living body detection model to obtain the trained living body detection model comprises: inputting the first differential user image sample set into the preset living body detection model to obtain a first predicted living body category; determining a first living body classification loss corresponding to the first differential user image sample set based on the first predicted living body category; and converging the preset living body detection model based on the first living body classification loss to obtain the living body detection model.
[0015] In some embodiments, the first differential user image sample set comprises K first differential user image samples, the preset living body detection model comprises an image fusion network, a feature encoding network and a living body classification network, and the inputting of the first differential user image sample set into the preset living body detection model to obtain a first predicted living body category comprises: inputting the K first differential user image samples into the image fusion network to obtain a first fused user image sample, inputting the first fused user image sample into the feature encoding network to obtain a first sample image living body feature, and inputting the first sample image living body feature into the living body classification network to obtain a first predicted living body category corresponding to each pixel in the first fused user image sample.
[0016] In some embodiments, the determination of the first living body classification loss corresponding to the first differential user image sample set comprises: obtaining a first labeled living body category corresponding to the first differential user image sample set; comparing the first labeled living body category with the first predicted living body category to obtain an initial living body classification loss corresponding to each pixel in the first fused user image sample; and accumulating the initial living body classification loss to obtain the first living body classification loss.
[0017] In some embodiments, the determination of the first living body classification loss corresponding to the first differential user image sample set comprises: obtaining a first labeled living body category corresponding to the first differential user image sample set, and comparing the first labeled living body category with the first predicted living body category to obtain an initial living body classification loss corresponding to each pixel; comparing the first predicted living body category corresponding to each pixel to obtain a predicted consistency loss; and fusing the predicted consistency loss and the initial living body classification loss to obtain the first living body classification loss.
[0018] In some embodiments, the compressing the living body detection model to obtain the target living body detection model comprises: taking the living body detection model as a teacher model, performing knowledge distillation on the living body detection model based on the teacher model and a preset meta network configured to balance a relationship between model performance and model volume in a model compression process, and performing channel pruning on the distilled living body detection model to obtain the target living body detection model.
[0019] In some embodiments, the performing knowledge distillation on the living body detection model comprises: performing preset first number of times of knowledge distillation on the living body detection model based on the teacher model and the preset meta network to obtain a distilled candidate living body detection model; updating the living body detection model to the candidate living body detection model, performing preset second number of times of training on the preset meta network based on the candidate living body detection model and the teacher model to obtain a current meta network; and updating the preset meta network to the current meta network and returning to perform the preset first number of times of knowledge distillation on the living body detection model until the living body detection model converges to obtain the distilled living body detection model.
[0020] In some embodiments, the preset first number of times is greater than the preset second number of times, and a ratio between the preset first number of times and the preset second number of times is a preset ratio.
[0021] In some embodiments, the performing preset first number of times of knowledge distillation on the living body detection model to obtain a distilled candidate living body detection model comprises: obtaining a second differential user image sample group and inputting the second differential user image sample group into the teacher model to obtain a second predicted living body category; inputting the second differential user image sample group into the living body detection model to obtain a second sample image living body feature and a third predicted living body category, the second sample image living body feature comprising a feature element corresponding to at least one feature channel; inputting the third predicted living body category into the preset meta network to obtain a model compression weight, and updating a network parameter of the living body detection model based on the model compression weight, the feature element, the second predicted living body category and the third predicted living body category to obtain an updated living body detection model; and updating the living body detection model to the updated living body detection model and returning to perform the obtaining of the second differential user image sample group until an updating number of times of the network parameter reaches the preset first number of times to obtain the candidate living body detection model.
[0022] In some embodiments, the model compression weight includes a model performance weight and a model volume weight; and the updating of the network parameters of the living body detection model to obtain an updated living body detection model includes: obtaining a second labeled living body class of the second difference user image sample group, and comparing the second labeled living body class with the second predicted living body class and the third predicted living body class respectively to obtain a second living body classification loss; comparing the second predicted living body class with the third predicted living body class to obtain a distillation loss, and weighting the distillation loss based on the model performance weight to obtain a target distillation loss; determining a sparse loss corresponding to the at least one feature channel based on the feature element, weighting the sparse loss based on the model volume weight to obtain a target sparse loss, and fusing the second living body classification loss, the target distillation loss and the target sparse loss, and updating the network parameters of the living body detection model based on the fused target compression loss to obtain the updated living body detection model.
[0023] In some embodiments, the determining of the sparse loss corresponding to the at least one feature channel based on the feature element includes: determining a channel importance value of each feature channel in the at least one feature channel based on the feature element; selecting a candidate feature channel from the at least one feature channel based on the channel importance value, the candidate feature channel including a feature channel with a channel importance value less than a preset importance threshold; and determining the sparse loss based on the number of candidate feature channels, the sparse loss constraining the number of candidate feature channels to be greater than a preset number threshold during training.
[0024] In some embodiments, the channel pruning of the distilled living body detection model to obtain the target living body detection model includes: obtaining a target channel importance value of each feature channel in the distilled living body detection model; determining a target feature channel to be pruned based on the target channel importance value, and selecting a target convolution kernel corresponding to the target feature channel from the distilled living body detection model; and pruning the target feature channel and the target convolution kernel in the distilled living body detection model to obtain the target living body detection model.
[0025] In a second aspect, the present specification also provides a living body detection system, including: at least one storage medium storing at least one instruction set for living body detection; and at least one processor in communication connection with the at least one storage medium, wherein when the living body detection system is running, the at least one processor reads the at least one instruction set and executes the living body detection method according to the indication of the at least one instruction set.
[0026] According to the technical solution, the method and system for living body detection provided by the present specification can obtain a target user image of a target user, compress the target user image based on K compression rates to obtain K compressed user images, generate K difference user images based on the target user image and the K compressed user images, perform living body detection on the target user based on the K difference user images, obtain a living body detection result of the target user, and output the result. Since the solution is directed against attacks by high-definition screens, no additional information needs to be introduced, and the solution can effectively amplify abnormal attack search by performing compression difference processing on the user image of the target user, and can extract as many abnormal attack clues as possible through different compression rates, thereby improving the detection accuracy of living body detection. Therefore, the detection performance of living body detection can be improved.
[0027] Other functions of the method and system for living body detection provided by the present specification will be partially listed in the following description. According to the description, the following numbers and examples will be apparent to those of ordinary skill in the art. The creative aspects of the method and system for living body detection provided by the present specification can be fully explained by practicing or using the methods, devices and combinations described in the following detailed examples. BRIEF DESCRIPTION OF DRAWINGS
[0028] In order to more clearly illustrate the technical solutions in the embodiments of the present specification, the following will briefly introduce the drawings needed to be used in the embodiment description. Obviously, the drawings in the following description are only some embodiments of the present specification, and those of ordinary skill in the art can also obtain other drawings according to these drawings without creative labor.
[0029] Figure 1 An application scenario schematic diagram of a living body detection system according to an embodiment of the present specification is shown;
[0030] Figure 2 A hardware structure diagram of a computing device according to an embodiment of the present specification is shown;
[0031] Figure 3 A flowchart of a living body detection method according to an embodiment of the present specification is shown;
[0032] Figure 4 A whole flowchart of a living body detection method in a face recognition scenario according to an embodiment of the present specification is shown; and
[0033] Figure 5 A flowchart of living body detection on a target user according to an embodiment of the present specification is shown. DETAILED DESCRIPTION
[0034] The following description provides specific examples and requirements for the application of the present specification, in order to enable a person skilled in the art to make and use the content of the present specification. Various local modifications to the disclosed embodiments will be apparent to those skilled in the art, and the general principles defined herein can be applied to other embodiments and applications without departing from the spirit and scope of the present specification. Therefore, the present specification is not limited to the embodiments shown, but is consistent with the widest scope of the claims.
[0035] The terms used herein are only for the purpose of describing specific example embodiments, and are not limiting. For example, unless the context clearly indicates otherwise, as used herein, the singular forms "a", "an", and "the" can also include the plural forms. When used in the present specification, the terms "comprise", "include" and / or "contain" mean that the associated whole, step, operation, element and / or component exists, but do not exclude the presence of one or more other features, whole, step, operation, element, component and / or group.
[0036] In view of the following description, these features of the present specification and other features, as well as the operation and function of the related elements of the structure, and the economy of the combination and manufacture of components can be significantly improved. With reference to the drawings, all of which form part of the present specification. However, it should be clearly understood that the drawings are for illustrative and descriptive purposes only and are not intended to limit the scope of the present specification. It should also be understood that the drawings are not drawn to scale.
[0037] The flowchart used in the present specification shows the operation of the system implementation according to some embodiments of the present specification. It should be clearly understood that the operations of the flowchart can not be implemented in sequence. On the contrary, the operations can be implemented in reverse order or simultaneously. In addition, one or more other operations can be added to the flowchart. One or more operations can be removed from the flowchart.
[0038] For the convenience of description, the present specification will explain the terms that will appear in the following description as follows:
[0039] Image compression: different degrees of compression of images using image compression techniques (such as JPEG techniques or other compression techniques), resulting in different compression results;
[0040] Compression difference: refers to the difference image between images of different compression rates;
[0041] Live detection (live attack prevention): refers to the technology of detecting and intercepting live attacks using artificial intelligence models, such as, for example, mobile phone screens, printed paper, masks or headsets, etc.
[0042] Before the embodiments of the present specification are described, the application scenarios of the present specification are introduced as follows:
[0043] The living body detection method provided by the present specification can be applied in any living body detection scenario. For example, in a face payment scenario, the face image of a user to be paid can be detected by the living body detection method of the present specification; in an identity verification scenario, the identity image of a user can be detected by the living body detection method of the present specification; and the living body detection method can also be applied in any face recognition scenario, which will not be described here.
[0044] Those skilled in the art should understand that the living body detection method and system described in the present specification can also be applied to other use scenarios within the protection scope of the present specification.
[0045] Figure 1 An application scenario schematic diagram of a living body detection system 001 according to an embodiment of the present specification is shown. The living body detection system 001 (hereinafter referred to as system 001) can be applied to living body detection in any scenario, such as living body detection in a face payment scenario, living body detection in an identity verification scenario, living body detection in a face recognition scenario, etc. Figure 1 As shown in FIG. 1, the system 001 can include a user 100, a client 200, a server 300, and a network 400.
[0046] The user 100 can be a user triggering living body detection on a target user. The user 100 can perform a living body detection operation on the client 200. The user 100 can be the target user or another user.
[0047] The client 200 can be a device for performing living body detection on a target user in response to a living body detection operation of the user 100. In some embodiments, the living body detection method can be executed on the client 200. At this time, the client 200 can store data or instructions for executing the living body detection method described in the present specification, and can execute or be used to execute the data or instructions. In some embodiments, the client 200 can include a hardware device with data information processing function and necessary programs for driving the hardware device to work. As shown in FIG. 2, the client 200 can include a processor 201, a memory 202, a communication interface 203, and a communication bus 204. Figure 1As shown, the client 200 can be communicatively connected with the server 300. In some embodiments, the server 300 can be communicatively connected with a plurality of clients 200. In some embodiments, the client 200 can interact with the server 300 through the network 400 to receive or send messages, etc., such as receiving or sending a target user image of a target user, etc. In some embodiments, the client 200 can include a mobile device, a tablet, a notebook, a built-in device of a motor vehicle, or the like, or any combination thereof. In some embodiments, the mobile device can include a smart home device, a smart mobile device, a virtual reality device, an augmented reality device, or the like, or any combination thereof. In some embodiments, the smart home device can include a smart television, a desktop computer, or the like, or any combination thereof. In some embodiments, the smart mobile device can include a smartphone, a personal digital assistant, a gaming device, a navigation device, or the like, or any combination thereof. In some embodiments, the virtual reality device or the augmented reality device can include a virtual reality headset, a virtual reality glasses, a virtual reality handle, an augmented reality headset, an augmented reality glasses, an augmented reality handle, or the like, or any combination thereof. For example, the virtual reality device or the augmented reality device can include Google glasses, a head-mounted display, a VR, or the like. In some embodiments, the built-in device in the motor vehicle can include an on-board computer, an on-board television, or the like. In some embodiments, the client 200 can include an image acquisition device for acquiring at least one user image of a target user to obtain a target user image. In some embodiments, the image acquisition device can be a two-dimensional image acquisition device (such as an RGB camera), or a two-dimensional image acquisition device (such as an RGB camera) and a depth image acquisition device (such as a 3D structured light camera, a laser detector, or the like). In some embodiments, the client 200 can be a device with positioning technology for positioning the location of the client 200.
[0048] In some embodiments, the client 200 can be installed with one or more applications (APPs). The APPs can provide the user 100 with the ability and interface to interact with the outside world through the network 400. The APPs include, but are not limited to, web browser type APPs, search type APPs, chat type APPs, shopping type APPs, video type APPs, financial type APPs, instant messaging tools, email clients, social platform software, and the like. In some embodiments, the client 200 can be installed with a target APP. The target APP can enable the client 200 to collect at least one user image of a target user, thereby obtaining a target user image. In some embodiments, the user 100 can also trigger a live body detection request through the target APP. The target APP can respond to the live body detection request by performing the live body detection method described in the present specification. The live body detection method will be described in detail in the following content.
[0049] The server 300 can be a server that provides various services, such as a background server that provides support for live body detection of a target user image collected on the client 200. In some embodiments, the live body detection method can be performed on the server 300. At this time, the server 300 can store data or instructions for performing the live body detection method described in the present specification, and can execute or be used to execute the data or instructions. In some embodiments, the server 300 can include a hardware device with data information processing function and necessary programs for driving the hardware device to work. The server 300 can be in communication connection with a plurality of clients 200, and can receive data sent by the client 200.
[0050] The network 400 is a medium for providing communication connection between the client 200 and the server 300. The network 400 can facilitate exchange of information or data. As Figure 1 shown, the client 200 and the server 300 can be connected to the network 400, and transmit information or data to each other through the network 400. In some embodiments, the network 400 can be any type of wired or wireless network, or a combination thereof. For example, the network 400 can include a cable network, a wired network, a fiber optic network, a telecommunication network, an intranet, the Internet, a local area network (LAN), a wide area network (WAN), a wireless local area network (WLAN), a metropolitan area network (MAN), a wide area network (WAN), a public switched telephone network (PSTN), a Bluetooth network, a ZigBee network, a near-field communication (NFC) network, a radio frequency (RF) network, a near field magnetic induction network, a satellite network, an Internet Protocol (IP) network, and the like. TM TM network, a near field communication (NFC) network, or a similar network. In some embodiments, the network 400 can include one or more network access points. For example, the network 400 can include a wired or wireless network access point, such as a base station or an Internet exchange point, through which one or more components of the client 200 and the server 300 can connect to the network 400 to exchange data or information.
[0051] It should be understood that Figure 1 The number of the client 200, the server 300, and the network 400 in the system 100 is merely illustrative. Depending on implementation needs, there can be any number of the client 200, the server 300, and the network 400.
[0052] It should be noted that the live detection method can be executed completely on the client 200, completely on the server 300, partially on the client 200, and partially on the server 300.
[0053] Figure 2 A hardware structure diagram of a computing device 600 is shown, which is provided according to an embodiment of the present specification. The computing device 600 can execute the live detection method described in the present specification. The live detection method is introduced in other parts of the present specification. When the live detection method is executed on the client 200, the computing device 600 can be the client 200. When the live detection method is executed on the server 300, the computing device 600 can be the server 300. When the live detection method can be executed partially on the client 200 and partially on the server 300, the computing device 600 can be the client 200 and the server 300.
[0054] As shown in Figure 2 The computing device 600 can include at least one storage medium 630 and at least one processor 620. In some embodiments, the computing device 600 can further include a communication port 650 and an internal communication bus 610. Meanwhile, the computing device 600 can further include an I / O component 660.
[0055] The internal communication bus 610 can connect different system components, including the storage medium 630, the processor 620, and the communication port 650.
[0056] The I / O component 660 supports input / output between the computing device 600 and other components.
[0057] The communication port 650 is used for data communication between the computing device 600 and the outside world. For example, the communication port 650 can be used for data communication between the computing device 600 and the network 400. The communication port 650 can be a wired communication port or a wireless communication port.
[0058] The storage medium 630 can include a data storage device. The data storage device can be a non-transitory storage medium or a transitory storage medium. For example, the data storage device can include one or more of a disk 632, a read-only memory (ROM) 634, or a random access memory (RAM) 636. The storage medium 630 also includes at least one set of instructions stored in the data storage device. The instructions are computer program code that can include programs, routines, objects, components, data structures, procedures, modules, and the like that perform the live detection methods provided in the present specification.
[0059] The at least one processor 620 can be communicatively connected to the at least one storage medium 630 and the communication port 650 through the internal communication bus 610. The at least one processor 620 is configured to execute the at least one set of instructions. When the computing device 600 is running, the at least one processor 620 reads the at least one set of instructions and performs the live detection methods provided in the present specification according to the instructions of the at least one set of instructions. The processor 620 can perform all the steps included in the live detection methods. The processor 620 can be in the form of one or more processors, and in some embodiments, the processor 620 can include one or more hardware processors, such as a microcontroller, a microprocessor, a reduced instruction set computer (RISC), an application-specific integrated circuit (ASIC), an application-specific instruction set processor (ASIP), a central processing unit (CPU), a graphics processing unit (GPU), a physics processing unit (PPU), a microcontroller unit, a digital signal processor (DSP), a field programmable gate array (FPGA), an advanced RISC machine (ARM), a programmable logic device (PLD), any circuit or processor capable of executing one or more functions, or the like, or any combination thereof. For the sake of illustration only, only one processor 620 is described in the computing device 600 in the present specification. However, it should be noted that the computing device 600 in the present specification can also include multiple processors, and thus, the operations and / or method steps disclosed in the present specification can be performed by one processor as described in the present specification, or jointly performed by multiple processors. For example, if the processor 620 of the computing device 600 in the present specification performs step A and step B, it should be understood that step A and step B can also be performed jointly or separately by two different processors 620 (e.g., a first processor performs step A, a second processor performs step B, or the first and second processors jointly perform steps A and B).
[0060] Figure 3A flowchart of a living body detection method P100 according to an embodiment of the present specification is shown. As before, the computing device 600 can perform the living body detection method P100 of the present specification. Specifically, the processor 620 can read the instruction set stored in its local storage medium, and then perform the living body detection method P100 of the present specification according to the provisions of the instruction set. As shown, the method P100 can include: Figure 3
[0061] S110: obtaining a target user image of a target user, and compressing the target user image based on K compression rates to obtain K compressed user images.
[0062] The target user image can be at least one user image containing biological features of the target user. The biological features can include at least one of a face, a body, an iris, a sclera, a fingerprint, a palm print, a voiceprint, or a skeletal projection.
[0063] K is an integer greater than 0. The compression rate can represent the compression degree or the quality after compression of a file or content. It is usually the ratio of the size of the file or content after compression to the size before compression, which is an important compression parameter in the compression algorithm. The higher the compression rate, the smaller the file or content after compression, and accordingly, the smaller the quality. After sorting, the difference between adjacent compression rates is the same, for example, if K is 4, then the four compression rates are sorted by size, and the difference between adjacent compression rates is the same, that is, the four compression rates can form an arithmetic sequence, for example, the four compression rates can be [20, 40, 60, 80].
[0064] The compressed user image can be a user image obtained by compressing the target user image. The K compression rates correspond to the K compressed user images one-to-one, that is, one compression rate corresponds to one compressed user image.
[0065] The way of obtaining a target user image of a target user, and compressing the target user image based on K compression rates to obtain K compressed user images can be as follows:
[0066] S111: obtaining a target user image of a target user.
[0067] For example, the processor 620 can directly receive at least one user image of the target user uploaded by the user 100 or the target user through a client, a terminal or a server, so as to obtain the target user image, or can obtain an image containing the biological feature of the target user from a network or an image database, so as to obtain the target user image, or can collect at least one user image containing the biological feature of the target user through an image collection device, so as to obtain the target user image, or when the number of target user images is large or the memory is large, the living body detection request including the storage address of the target user image of the target user can also be received, and based on the storage address, the target user image of the target user is obtained, and the like.
[0068] S112: compressing the target user image based on the K compression rates to obtain K compressed user images.
[0069] For example, the processor 620 can determine a compression rate interval and uniformly sample K compression rates in the compression rate interval, and then compress the target user image based on the K compression rates to obtain K compressed user images, or the K compression rates can be directly obtained, the K compression rates can form an arithmetic sequence, and then the target user image is compressed based on the K compression rates, and the like.
[0070] The compression rate interval can be a value range of the compression rate that can be compressed based on the image quality, for example, if the image quality interval after compression is [0, 100], the compression rate interval can also be [0, 100], the compression rate of 0 means that the target user image is not compressed, and the compression rate of 100 means that the target user image is compressed to the maximum extent by the image compression algorithm. In addition, it should be noted that the compression rate interval also needs to depend on the compression performance of the compression algorithm, and the maximum compression rate corresponds to the maximum compression performance of the compression algorithm. The compression method based on the K compression rates can be various, for example, the processor 620 can use the JPEG compression algorithm to compress the target user image according to the K compression rates, so as to obtain K compressed images, and the K compressed images are used as the K compressed user images, or other image compression algorithms can also be used to compress the target user image according to the K compression rates to obtain the K compressed user images, and the like.
[0071] It should be noted that, in the compression of the target user image, different compression rates are adopted, which can also be understood as a lossy compression, that is, some unnecessary information is deleted, and it is not a simple format conversion (such as converting RAW format to JPEG format, color space conversion or other types of format conversion) or other lossless compression not involving data change, etc. Due to screen imaging (especially high-definition screen imaging) and real human face images, there are often some differences after compression. The types of these differences can be various, such as can include moire, abnormal light spots or slight distortion, etc. Different differences often have different magnification effects under different compression rates, so the target user image can be compressed to magnify these differences, and the differences can be extracted in the form of attack clues. In addition, through multiple (K) compression rates, the maximum magnification can be covered as much as possible, so that more abnormal clues can be extracted as much as possible. The abnormal clues here can be the clue information containing these differences.
[0072] S120: generating K difference user images based on the target user image and the K compressed user images.
[0073] The difference user image can be a user image obtained by differencing the target user image and the compressed user image. The difference types can include the difference between the K compressed user images and the difference between the K compressed user images and the target user image.
[0074] The manner of generating K difference user images based on the target user image and the K compressed user images can be various, and can be as follows:
[0075] For example, the processor 620 can sort the target user image and the K compressed user images based on the K compression rates to obtain a user image sequence, and difference adjacent images in the user image sequence to obtain the K difference user images.
[0076] The compression rate corresponding to the target user image can be 0. The manner of sorting the target user image and the K compressed user images can be various, for example, the processor 620 can determine that the compression rate corresponding to the target user image is 0, and then sort the target user image and the K compressed user images according to the size of the compression rate, so as to obtain the user image sequence. At this time, the user image sequence can include (K+1) images. The (K+1) images in the user image sequence can constitute an image compression pyramid.
[0077] After obtaining the user image sequence, the processor 620 can perform difference between adjacent images in the user image sequence to obtain K difference user images. The difference between adjacent images in the user image sequence can be performed in various ways. For example, the processor 620 can determine a pair of directly adjacent images in the user image sequence to obtain K adjacent image pairs, then determine a difference image corresponding to each adjacent image pair to obtain K difference user images, or can determine a pair of directly adjacent or indirectly adjacent images in the user image sequence, randomly or according to a preset rule, select K adjacent image pairs from the image pairs, then determine a difference image corresponding to each adjacent image pair to obtain K difference user images, and the like.
[0078] The difference image corresponding to each adjacent image pair can be determined in various ways. For example, the processor 620 can determine a pixel difference value of a corresponding pixel position in the two images in the adjacent image pair to obtain a difference image corresponding to each adjacent image pair, or can perform difference processing on the images in each adjacent image pair based on other difference algorithms to obtain K difference user images.
[0079] It should be noted that the format and size of the difference user image can be the same as or different from the format and size of the images in the adjacent image pair.
[0080] For example, the images in the adjacent image pair are directly adjacent, that is, the images in the adjacent image pair are directly adjacent in the user image sequence, which means that the compression rates of the two images are also directly adjacent. By performing difference between images in adjacent compression rates, the main purpose is to suppress noise. If the compression rates are too different, some normal images will also cause some differences, thereby affecting the accuracy of the liveness detection. In addition, by compressing and performing difference between images, the signal of the tiny abnormality corresponding to the attack clue in the high-definition screen attack can be effectively amplified, thereby improving the accuracy of the liveness detection.
[0081] S130: performing liveness detection on the target user based on the K difference user images to obtain a liveness detection result of the target user, and outputting the liveness detection result.
[0082] The liveness detection result can include one of the target user being an attack user or a liveness user. The attack user can be a user with attack behavior, and the attack can be in various forms, such as paper, screen / high-definition screen, mask or headgear, and the like. The liveness user can be a real user, or a user with real biological characteristics, which can also be referred to as a normal user.
[0083] Wherein, based on the K difference user images, the target user is subjected to live body detection to obtain a live body detection result of the target user, and the live body detection result is outputted. The manner can be various, and can be as follows:
[0084] S131: Based on the K difference user images, the target user is subjected to live body detection to obtain a live body detection result of the target user.
[0085] For example, the processor 620 can fuse the K difference user images to obtain a fused user image, extract features from the fused user image to obtain image live body features of the target user, and classify the target user based on the image live body features to obtain a live body detection result of the target user.
[0086] Wherein, the fused user image can be an image obtained by fusing the K difference user images. The manner of fusing the K difference user images can be various, for example, the processor 620 can determine attention weights corresponding to the K difference user images, and fuse the K difference user images based on the attention weights to obtain the fused user image, or other image fusion algorithms can be used to fuse the K difference user images to obtain the fused user image, etc.
[0087] Wherein, the attention weight can be a weight representing the importance of different images or different regions in the K difference user images in live body detection. The processor 620 can determine the attention weight corresponding to the K difference user images through an attention mechanism, an attention network or a transformer network, and then fuse the K difference user images based on the attention weight to obtain the fused user image. At this time, the number of fused user images can be one.
[0088] After fusing the K difference user images, the processor 620 can extract features from the fused user image to obtain image live body features of the target user. The image live body features can be feature information related to live body classification contained in the fused user image, such as image moire, abnormal light spot or tiny distortion, etc. The manner of extracting features from the fused user image can be various, for example, the processor 620 can encode the fused user image through a feature encoding network to obtain image features of the fused user image, extract feature information related to live body from the image features to obtain image live body features of the target user, or the feature encoding network can be used to change the feature of the fused user image to obtain the image live body features of the target user, etc.
[0089] The image living body feature can be a living body feature corresponding to the global fusion user image, and can also include a local living body feature corresponding to each pixel in the fusion user image.
[0090] After the processor 620 extracts the image living body feature from the fusion user image, the processor 620 can perform living body classification on the target user based on the image living body feature, thereby obtaining a living body detection result of the target user. The processor 620 can determine a target attack probability of the target user based on the image living body feature, and perform a target operation based on the target attack probability. The target operation can include a first operation or a second operation.
[0091] The target attack probability can be a probability that the target user is an attack user. The processor 620 can input the image living body feature into a classifier or a classification network to obtain a probability that the target user is an attack user, and take the probability as the target attack probability. Alternatively, the processor 620 can extract a target image living body feature corresponding to each pixel in the fusion user image from the image living body feature, input the target image living body feature into the classifier or the classification network to obtain a probability that each pixel is an attack user, take the probability as an attack probability, and then determine a mean value of all attack probabilities to obtain the target attack probability of the target user.
[0092] The classifier or the classification network can be of various types, such as a softmax network (a type of classification network), a fully connected network (FC), or other classification networks.
[0093] The first operation includes determining that the target attack probability is greater than a preset probability threshold, and determining that the living body detection result of the target user is an attack user. The second operation includes determining that the target attack probability is less than the preset probability threshold, and determining that the living body detection result of the target user is a living body user.
[0094] In some embodiments, the processor 620 can directly input the K difference user images into the target living body detection model to perform living body detection, thereby obtaining a plurality of attack probabilities, determining a mean value of the plurality of attack probabilities to obtain the target attack probability of the target user, and determining the living body detection result of the target user based on the target attack probability.
[0095] The plurality of attack probabilities include an attack probability corresponding to each pixel in the fused user image. That is, when the target living body detection model is used to classify the living body, the K difference user images can be fused to obtain a fused user image, and then the fused user image is classified to obtain the living body detection result of the target user. In addition, it should be noted that the process of classifying the living body of the target user by the processor 620 through the target living body detection model can be the same as or different from the living body classification process described above.
[0096] The target living body detection model can be a model for detecting (classifying) the living body of the target user. The processor 620 can train the preset living body detection model to obtain a trained target living body detection model, and then use the target living body detection model to detect the living body of the target user. The training process of the target living body detection model can include the following steps: the processor 620 can obtain a first difference user image sample group, train the preset living body detection model based on the first difference user image sample group to obtain a trained living body detection model, and compress the living body detection model to obtain the target living body detection model.
[0097] The first difference user image sample group can include K first difference user image samples corresponding to one user sample, or K first difference user image samples corresponding to each of N user samples, where N is an integer greater than 0. The K first difference user image samples can be K compressed user image samples generated based on a user image sample and K compression rates. The processor 620 can obtain the K first difference user image samples of each user sample in at least one user sample uploaded by the user 100 through the client 200 or the terminal to obtain the first difference user image sample group, or obtain a user image sample and compress the user image sample based on K compression rates to obtain K compressed user image samples, generate K difference user image samples based on the user image sample and the K compressed user image samples, and use the K difference user image samples as the first difference user image sample group.
[0098] After obtaining the first set of differential user image samples, the processor 620 can train the preset living body detection model based on the first set of differential user image samples, thereby obtaining the trained living body detection model. The process of training the preset living body detection model can be various. For example, the processor 620 can input the first set of differential user image samples into the preset living body detection model to obtain a first predicted living body category, determine a first living body classification loss corresponding to the first set of differential user image samples based on the first predicted living body category, and converge the preset living body detection model based on the first living body classification loss to obtain the living body detection model.
[0099] The preset living body detection model can include an image fusion network, a feature encoding network, and a living body classification network. The image fusion network is configured to fuse K first differential user image samples into a first fused user image sample, the feature encoding network is configured to perform feature encoding on the first fused user image sample, and the living body classification network is configured to perform living body classification on the first sample image living body feature. The manner of inputting the first set of differential user image samples into the preset living body detection model to obtain the first predicted living body category can be various. For example, the processor 620 can input K first differential user image samples into the image fusion network to obtain a first fused user image sample, input the first fused user image sample into the feature encoding network to obtain a first sample image living body feature, and input the first sample living body feature into the living body classification network to obtain a first predicted living body category corresponding to each pixel in the first fused user image sample.
[0100] The processor 620 can determine a first live body classification loss corresponding to the first differential user image sample set based on the first predicted live body class after obtaining the first predicted live body class. The first live body classification loss can be a loss generated when the first fused user image sample is classified as a live body. The first live body classification loss can include an initial live body classification loss corresponding to each pixel in the first fused user image sample, and can also include a prediction consistency loss. The classification loss constrains the difference between the first predicted live body class and the first labeled live body class corresponding to the first differential user image sample set to be less than a preset first difference threshold (or within a first preset difference range) during the training process. The prediction consistency loss information constrains the difference between the first predicted live body classes corresponding to different pixels to be less than a second difference threshold (or within a second prediction difference range) during the training process. There can be various ways to determine the first live body classification loss, for example, the processor 620 can obtain the first labeled live body class corresponding to the first differential user image sample set, compare the first labeled live body class with the first predicted live body class to obtain the initial live body classification loss corresponding to each pixel in the first fused user image sample, and accumulate the initial live body classification loss to obtain the first live body classification loss; or the processor 620 can also obtain the first labeled live body class corresponding to the first differential user image sample set, compare the first labeled live body class with the first predicted live body class to obtain the initial live body classification loss corresponding to each pixel in the first fused user image sample, compare the first predicted live body class corresponding to each pixel to obtain the prediction consistency loss, and fuse the prediction consistency loss and the initial live body classification loss to obtain the first live body classification loss, and the like.
[0101] The first labeled class and the first predicted live body class can be compared to obtain the initial live body classification loss corresponding to each pixel in the first fused user image sample in various ways, for example, the processor 620 can use a cross-entropy loss function to compare the first labeled class and the first predicted live body class to obtain the initial live body classification loss corresponding to each pixel in the first fused user image sample, or other types of loss functions can also be used to compare the first labeled class and the first predicted live body class to obtain the initial live body classification loss corresponding to each pixel in the first fused user image sample, and the like.
[0102] The manner in which the first predicted living body category corresponding to each pixel is compared to obtain the prediction consistency loss can be various. For example, the processor 620 can compare the first predicted living body category corresponding to each pixel to obtain an initial prediction consistency loss corresponding to each pixel, and accumulate the initial prediction consistency losses to obtain the prediction consistency loss. The manner in which the initial prediction consistency loss is determined is similar to the manner in which the initial living body classification loss is determined, and details are described above, which will not be repeated here.
[0103] After the initial living body classification loss or the prediction consistency loss is determined, the processor 620 can take the initial living body classification loss as the first living body classification loss, or can also fuse the initial living body classification loss and the prediction consistency loss to obtain the first living body classification loss.
[0104] After the living body classification loss is obtained, the processor 620 can take the first living body classification loss to converge the preset living body detection model to obtain a living body detection model. The manner in which the preset living body detection model is converged can be various. For example, the processor 620 can update the network parameters of the preset living body detection model based on the first living body classification loss by using a gradient descent algorithm to obtain an updated current living body detection model, update the preset living body detection model to the current living body detection model, return to execute the step of obtaining the first differential user image sample set, and stop until the preset living body detection model converges, thereby obtaining a trained living body detection model. Alternatively, the network parameters of the preset living body detection model can be updated based on the first living body classification loss by using other network parameter updating algorithms to obtain an updated current living body detection model, update the preset living body detection model to the current living body detection model, return to execute the step of obtaining the first differential user image sample set, and stop until the preset living body detection model converges, thereby obtaining a trained living body detection model, and the like.
[0105] After the preset living body detection model is trained, the processor 620 can compress the trained living body detection model to obtain a target living body detection model. The manner in which the living body detection model is compressed can be various. For example, the processor 620 can take the living body detection model as a teacher model, perform knowledge distillation on the living body detection model based on the teacher model and a preset meta network, and perform channel pruning on the distilled living body detection model to obtain the target living body detection model.
[0106] The preset meta-network is configured to balance the relationship between model performance and model volume in the model compression process. The input of the preset meta-network is the output of the living body detection model (student model), and the output can be model compression weights, which can include model performance weights and model volume weights. The model performance weights are used to control the performance of the living body detection model corresponding to the knowledge distillation, and the model volume weights are used to control the model volume corresponding to the channel pruning (pruning). By outputting the model performance weights and the model volume weights, the balance between the model performance and the model volume is achieved.
[0107] The teacher model and the living body detection model (student model) can be the same network or model in the initialization process, and the teacher model remains unchanged in the knowledge distillation process. This is self-distillation. It should be noted that the teacher model can also have a different initialized network structure from the student model, i.e., the student model is a lightweight model. Based on the teacher model and the preset meta-network, there are multiple ways to perform knowledge distillation on the living body detection model. For example, the processor 620 can perform preset first number of times of knowledge distillation on the current living body detection model based on the teacher model and the preset meta-network, obtain a distilled candidate living body detection model, update the living body detection model to the candidate living body detection model, perform preset second number of times of training on the preset meta-network based on the candidate living body detection model and the teacher model, obtain a current meta-network, update the preset meta-network to the current meta-network, and return to perform the preset first number of times of knowledge distillation on the living body detection model until the living body detection model converges, and obtain a distilled living body detection model.
[0108] The preset first number of times is greater than the preset second number of times, and the ratio between the preset first number of times and the preset second number of times is a preset ratio, that is, the number of times of training the living body detection model is greater than the number of times of training the preset meta-network in the process of performing knowledge distillation on the living body detection model. Taking the preset ratio of 10:1 as an example, in the knowledge distillation process of the living body detection model, the living body detection model (student model) is trained for 10 rounds, and the preset meta-network is trained for one round. It should be noted that the preset ratio can be set according to actual application and can be any ratio.
[0109] The manner of performing the preset first number of times of knowledge distillation on the current living body detection model based on the teacher model and the preset meta network can be various. For example, the processor 620 can obtain a second differential user image sample set, input the second differential user image sample set into the teacher model to obtain a second predicted living body category, input the second differential user image set into the living body detection model to obtain a second sample image living body feature and a third predicted living body category, the second sample living body image feature includes a feature element corresponding to at least one feature channel, input the third predicted living body category into the preset meta network to obtain a model compression weight, and update the network parameters of the living body detection model based on the model compression weight, the feature element, the second predicted living body category and the third predicted living body category to obtain an updated living body detection model. The living body detection model is updated to the updated living body detection model, and the step of obtaining the second differential user image sample set is returned to be executed until the number of times of updating the network parameters reaches the preset first number of times, and a candidate living body detection model is obtained.
[0110] The manner of obtaining the second differential user image sample set is similar to the manner of obtaining the first differential user image sample set, which is described above and will not be repeated here. In addition, it should be noted that the first differential user image sample set and the second differential user image sample set can be the same or different.
[0111] The feature element can be at least one feature value or other feature information contained or output in the feature channel. The manner of updating the network parameters of the living body detection model based on the model compression weight, the feature element, the second predicted living body category and the third predicted living body category can be various. For example, the processor 620 can obtain a second labeled living body category of the second differential user image sample set, compare the second labeled living body category with the second predicted living body category and the third predicted living body category to obtain a second living body classification loss, compare the second predicted living body category with the third predicted living body category to obtain a distillation loss, weight the distillation loss based on a model performance weight to obtain a target distillation loss, determine a sparse loss corresponding to at least one feature channel based on the feature element, weight the sparse loss based on a model volume weight to obtain a target sparse loss, and fuse the second living body classification loss, the target distillation loss and the target sparse loss, and update the network parameters of the living body detection model based on the fused target compression loss to obtain an updated living body detection model.
[0112] The second living body classification loss can be a loss generated when the second difference user image sample group is classified. The second living body classification loss can include at least one of the first initial classification loss, the second initial classification loss, and a classification loss including the first initial classification loss and the second initial classification loss. The first initial classification loss constrains the difference between the second predicted living body class and the second labeled living body class to be less than a third preset difference threshold (or within a third preset difference range) during the training process. The second initial classification loss constrains the difference between the third predicted living body class and the second labeled living body class to be less than a fourth preset difference threshold (or within a fourth preset difference range) during the training process. The process of determining the first initial classification loss can include the processor 620 comparing the second labeled living body class with the predicted second living body class to obtain the first initial classification loss. The process of determining the second initial classification loss can include the processor 620 comparing the second labeled living body class with the predicted third living body class to obtain the second initial classification loss. The manner of determining the first initial classification loss and the second initial classification loss is similar to the manner of determining the initial living body classification loss, which is described in detail above and will not be repeated here.
[0113] The distillation loss can be a loss generated when the living body detection model is distilled by the teacher model, and can also be understood as a loss corresponding to the difference between the output of the teacher model and the output of the living body detection model (student model). The distillation loss constrains the difference between the second predicted living body class and the third predicted living body class to be less than a fifth preset difference threshold (or within a fifth preset difference range) during the training process (knowledge distillation). The manner of determining the distillation loss is similar to the manner of determining the initial living body classification loss, which is described in detail above and will not be repeated here. After the processor 620 determines the distillation loss, the distillation loss can be weighted based on the model performance weight to obtain the target distillation loss.
[0114] It should be noted that the first preset difference threshold, the second preset difference threshold, the third preset difference threshold, the fourth preset difference threshold, and the fifth difference threshold can be the same or different. The first preset difference range, the second preset difference range, the third preset difference range, the fourth preset difference range, and the fifth preset difference range can be the same or different. The manner of determining the distillation loss is similar to the manner of determining the initial living body classification loss, which is described in detail above and will not be repeated here.
[0115] The sparse loss is a loss corresponding to the sparsity of the feature channels in the living body detection model. The sparse loss can also be regarded as a channel pruning loss. The sparse loss restricts the number of feature channels of which the channel importance value is less than the preset importance threshold to be greater than the preset number threshold in the training process (knowledge distillation). In other words, the greater the number of unimportant feature channels, the better the sparsity of the feature channels in the entire model, and the greater the number of channels that can be pruned, and the smaller the volume of the model. There are various ways to determine the sparse loss corresponding to the at least one feature channel based on the feature elements. For example, the processor 620 can determine the channel importance value of each feature channel in the at least one feature channel based on the feature elements, select a candidate feature channel from the at least one feature channel based on the channel importance value, and determine the sparse loss based on the number of candidate feature channels.
[0116] The candidate feature channel includes a feature channel whose channel importance value is less than the preset importance threshold, and can also be understood as a feature channel that can be pruned or pruned. The sparse loss can restrict the number of candidate feature channels to be greater than the preset number threshold in the training process. There are various ways to determine the channel importance value in the at least one feature channel based on the feature elements. For example, the processor 620 can select a target feature element of each feature channel in the at least one feature channel from the feature elements, determine the L1 norm of the target feature element, and thereby obtain the channel importance value corresponding to the feature channel.
[0117] After determining the channel importance value of each feature channel in the at least one feature channel, the processor 620 can select a candidate feature channel from the at least one feature channel based on the channel importance value. There are various ways to select the candidate feature channel. For example, the processor 620 can select a feature channel whose channel importance value is less than a preset channel importance threshold from the at least one feature channel, and thereby obtain the candidate feature channel.
[0118] After selecting the candidate feature channel, the processor 620 can determine the sparse loss based on the number of candidate feature channels. There are various ways to determine the sparse loss. For example, the processor 620 can determine the number difference between the number of candidate feature channels and the preset number threshold to obtain the sparse loss, or can use other functions to compare the number of candidate feature channels with the preset number threshold to obtain the sparse loss, and the like. After determining the sparse loss, the processor 620 can weight the sparse loss based on the model volume weight to obtain a target sparse loss.
[0119] After determining the second living body classification loss, the target distillation loss and the target sparsity loss, the processor 620 can fuse the second living body classification loss, the target distillation loss and the target sparsity loss to obtain a fused target compression loss. The fusion manner can be various, for example, the processor 620 can directly add the second living body classification loss, the target distillation loss and the target sparsity loss to obtain the target compression loss, which can be shown as formula (1):
[0120] Loss total =Loss pix-cls +a*Loss KD +b*Loss pruning (1)
[0121] wherein, Loss total is the target compression loss, a is a model performance weight, Loss KD is the distillation loss, b is a model volume weight, and Loss pruning is the sparsity loss.
[0122] After fusing the second living body classification loss, the target distillation loss and the target sparsity loss, the processor 620 can update the network parameters of the living body detection model based on the fused target compression model to obtain an updated living body detection model. The network parameter updating manner of the living body detection model can be various, for example, the processor 620 can use a gradient descent algorithm to update the network parameters of the living body detection model based on the target compression loss to obtain the updated living body detection model, or other network parameter updating algorithms can also be used to update the network parameters of the living body detection model based on the target compression loss to obtain the updated living body detection model, etc.
[0123] After updating the network parameters of the living body detection model, the processor 620 can update the living body detection model to the updated living body detection model, and return to execute the step of obtaining the second difference user image sample set until the number of network parameter updates reaches a preset first number, so that the candidate living body detection model can be obtained.
[0124] After obtaining the candidate living body detection model, the processor 620 can update the living body detection model to the candidate living body detection model, and train the preset meta network based on the candidate living body detection model and the teacher model for a preset second number of times to obtain a current meta network. The training method of the preset meta network is similar to the knowledge distillation of the living body detection model, which is described above, that is, in the knowledge distillation process, the network of the living body detection model (student model) remains unchanged, and the network parameters of the preset meta network are updated until the preset meta network converges, so that the trained current meta network is obtained.
[0125] After the preset meta-network is trained, the processor 620 updates the preset meta-network to the current meta-network, and returns to perform the step of knowledge distillation on the living body detection model for a preset first number of times until the living body detection model converges, to obtain a distilled living body detection model.
[0126] For example, when the preset first number is 10 and the preset second number is 1, the processor 620 performs knowledge distillation on the living body detection model (student model) (during training), trains the student network for 10 rounds each time, trains the preset meta-network for one round, and sequentially cycles until the living body detection model converges, so as to obtain the distilled living body detection model.
[0127] After the knowledge distillation on the living body detection model, the processor 620 can perform channel pruning on the distilled living body detection model, to obtain a target living body detection model. There are various ways of channel pruning. For example, the processor 620 can obtain a target importance value of each feature channel in the distilled living body detection model, determine a target feature channel that needs to be pruned based on the target channel importance value, select a target convolution kernel corresponding to the target feature channel in the distilled living body detection model, and prune the target feature channel and the target convolution kernel in the distilled living body detection model to obtain the target living body detection model.
[0128] The target importance value can be a value representing the importance of each feature channel in the distilled living body detection model. There are various ways to obtain the target channel importance value. For example, the processor 620 can input the second differential user image sample group into the distilled living body detection model to obtain a feature element set of each feature channel in the distilled living body detection model, determine the L1 norm of the feature element set, and thus obtain the target importance value of each feature channel. Alternatively, other differential user image sample groups can be input into the distilled living body detection model to obtain a feature element set of each feature channel in the distilled living body detection model, determine the L1 norm of the feature element set, and thus obtain the target importance value of each feature channel.
[0129] The target convolution kernel can be a convolution kernel corresponding to the target feature channel in the distilled live body detection model. The convolution kernel can also be understood as a filter in a network layer of the model. After determining the target feature channel and the target convolution kernel, the processor 620 can prune the target feature channel and the target convolution kernel, which can be pruning. The distilled live body detection model no longer contains the target feature channel and the target convolution kernel, thereby reducing the volume of the distilled live body detection model. The distilled live body detection model after pruning the target feature channel and the target convolution kernel is used as the target live body detection model.
[0130] After obtaining the trained target live body detection model, the processor 620 can input the K difference user images into the target live body detection model to determine the live body detection result of the target user. The process of determining the live body detection result is described above and will not be repeated here.
[0131] S132: Output the live body detection result.
[0132] For example, the processor 620 can directly send the live body detection result to the user 100 or the client 200, the terminal or the server corresponding to the target user, so that the client 200, the terminal or the server responds to the request of the target user or the target user based on the live body detection result, or the live body detection result can be directly visualized and displayed, etc.
[0133] The live body detection result can be visualized and displayed in various ways. For example, the processor 620 can directly display the live body detection result, or can display the live body detection result through sound and light (for example, the live body detection result can be announced through voice, or different types of live body detection results can be displayed through different colors of light, or the live body detection result can be displayed through sound and light linkage), or the live body detection result of a specific type can be displayed (for example, only the live body detection result of an attack user or only the live body detection result of a normal user is displayed, etc.), etc.
[0134] In some embodiments, after determining the live body detection result of the target user or outputting the live body detection result, the processor 620 can respond to the request of the target user or the target user based on the live body detection result. The response can be in various ways, such as directly intercepting the request of the target user or the target user, or the processor 620 can directly perform secondary verification on the target user, and based on the secondary verification result, the request of the target user or the target user is finally responded, etc.
[0135] In the face recognition scene, the scheme can perform liveness detection on the high-definition screen based on the compression difference. The overall detection process can include four parts: compression pyramid, liveness detection model training based on difference, intelligent model compression, and model deployment and liveness detection, as shown in Figure 4 , which can be as follows:
[0136] (1) Compression pyramid: using user face images, obtain uncompressed user images, uniformly generate K compression rates (for example, [20, 40, 60, 80]) between quality 0-100, use the JPEG compression algorithm to generate K compressed images according to the corresponding compression rate; plus the uncompressed image, a total of K+1 image compression pyramids.
[0137] (2) Liveness detection model training based on difference: using the K+1 image pyramid, using the image with low compression rate and the image with high compression rate (adjacent images in the image compression pyramid) to calculate the difference image, obtaining K difference images, inputting the K difference images as input, training the liveness detection model, for the specific training process, please refer to the description above, here will not be repeated.
[0138] (3) Model compression: since the liveness detection model obtained through steps (1) and (2) has a large volume, in order to be deployed to the terminal device, the liveness detection model can also be compressed by using knowledge distillation and channel pruning, thereby obtaining the target liveness detection model, for the specific compression process, please refer to the description above. Combining channel pruning and knowledge distillation can balance the model lightweight and performance improvement, so that the target liveness detection model can maintain the balance between model lightweight and performance.
[0139] (4) Model deployment and liveness detection: the target liveness detection model can be deployed on the terminal device, the user's face image is collected by the terminal device, and the user's face image is compressed based on K compression rates to obtain a compressed image group, the compressed image group is input into the target liveness detection model, and the pixel-level attack probability is obtained., after averaging, the attack probability p is obtained, for the threshold T of the terminal device, if p is greater than T, it is determined that the user is attacked, otherwise it is determined that it is a liveness, which can be as shown in Figure 5 .
[0140] The traditional liveness detection method for high-definition screen attack often needs to introduce additional information, which inevitably reduces the user experience and affects the detection performance of liveness detection under the premise of ensuring the user experience. In the present scheme, the compressed difference graph is used for high-definition screen attack detection, which not only greatly improves the user experience without introducing additional information, but also uses the difference between screen imaging and face imaging after compression, constructs multiple compression rates to strengthen the difference, and then enlarges the tiny signal corresponding to the difference in a differential manner, thereby greatly improving the detection accuracy of liveness detection, so as to improve the liveness detection performance.
[0141] In summary, the liveness detection method P100 and system 001 provided by the present specification obtain the target user image of the target user, compress the target user image based on K compression rates to obtain K compressed user images, generate K difference user images based on the target user image and the K compressed user images, and perform liveness detection on the target user based on the K difference user images to obtain and output the liveness detection result of the target user. Since the present scheme is aimed at high-definition screen attacks, it does not need to introduce additional information, and can effectively enlarge the abnormal attack search by performing compression difference processing on the user image of the target user, and can extract as many abnormal attack clues as possible through different compression rates, thereby improving the detection accuracy of liveness detection, so as to improve the detection performance of liveness detection.
[0142] In another aspect of the present specification, there is provided a non-transitory storage medium storing at least one set of executable instructions for performing the living body detection. When the executable instructions are executed by a processor, the executable instructions direct the processor to implement the steps of the living body detection method P100 described in the present specification. In some possible implementations, various aspects of the present specification can also be implemented as a program product in the form of a program code. When the program product is run on the computing device 600, the program code is used to cause the computing device 600 to perform the steps of the living body detection method P100 described in the present specification. The program product for implementing the above method can include the program code in a portable compact disc read-only memory (CD-ROM) and can be run on the computing device 600. However, the program product of the present specification is not limited to this, and in the present specification, the 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. The program product can adopt any combination of one or more readable media. The readable medium can be a readable signal medium or a readable storage medium. The readable storage medium may, for example, be but is not limited to an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or apparatus, or any suitable combination of the above. More specific examples of the readable storage medium include an electrical connection having one or more wires, a portable disc, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or a flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. The computer readable storage medium can include a data signal carried in a baseband or as part of a carrier wave, in which readable program code is borne. Such a propagated data signal can take on many forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. The readable storage medium can also be any readable medium that is not a storage medium that can send, propagate, or transmit the program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained in the readable storage medium can be transmitted using any suitable medium, including but not limited to wireless, wired, optical fiber, RF, and the like, or any suitable combination of the above. The program code for performing the operations of the present specification can be written in any combination of one or more programming languages, including an object-oriented programming language, such as Java, C++, and the like, and a conventional procedural programming language, such as the "C" programming language or similar programming languages. The program code can be executed entirely on the computing device 600, partially on the computing device 600, as an independent software package, partially on the computing device 600 and partially on a remote computing device, or entirely on a remote computing device.
[0143] The foregoing description of specific embodiments of the disclosure has been presented for the purposes of illustration and description. Other embodiments are within the scope of the following claims. In some instances, the actions or steps recited in the claims can occur in a different order and still accomplish the desired results. Additionally, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order to achieve the desired results. In certain instances, multitasking and parallel processing can be advantageous.
[0144] In light of the above, those skilled in the art will appreciate that the foregoing detailed description of the present disclosure is susceptible to various modifications and / or revisions without departing from the spirit and scope of the present disclosure. Although specific embodiments have been described in detail, those skilled in the art will appreciate that various modifications and equivalents can be used without departing from the spirit and scope of the present disclosure. Accordingly, the disclosure is intended to embrace all such alterations, modifications, and variations that fall within the scope of the exemplary embodiments of the present disclosure.
[0145] In addition, certain terminology has been used to describe embodiments of the disclosure. For example, the terms "one embodiment" or "an embodiment" or "some embodiments" and / or "one specific embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment is included in at least one embodiment of the disclosure. The appearances of the phrase "in one embodiment" or "an embodiment" or "in some embodiments" or "some embodiments" in various places in the specification are not necessarily all referring to the same embodiment. Furthermore, the particular features, structures, or characteristics can be combined in any suitable manner on one or more embodiments without necessarily being included in all embodiments.
[0146] It should be understood that in the foregoing description of embodiments of the disclosure, various features can be combined in a single embodiment or in multiple embodiments of the disclosure. It is therefore contemplated to this disclosure that the features of the following claims can be combined with the features of the preceding embodiments in any suitable manner without necessarily being limited to the specific embodiments as described. In addition, it is intended that features of one embodiment can be used in other embodiments of the disclosure. It is therefore contemplated to this disclosure that the features of the following claims can be combined with the features of the preceding embodiments in any suitable manner without necessarily being limited to the specific embodiments as described.
[0147] Each patent, patent application, publication of a patent application, and other material, for example articles, books, specifications, publications, documents, things, or the like which can be cited in the present document can be accorded with the scope of their respective copyrights. The contents of all such cited patents, patent applications, publications of patent applications, and other material are hereby incorporated by reference herein, except that for any and all that can be dependent on the history of prosecution of any application incorporated herein by reference, to the extent that such history can be inconsistent with the term of this document now or hereafter associated with it. In the event of any such inconsistency, the term of this document controls. For example, if there is any discrepancy between what can be expressed herein as to the description, definition and / or use of terms associated with any incorporated material and what is expressed in the incorporated material, the term in this document controls.
[0148] Finally, it should be understood that the embodiments of the application disclosed herein are illustrative of the principles of the present specification. Other modifications that can be substituted to the embodiments of the present specification are also within the scope of the present specification. Accordingly, the embodiments disclosed in the present specification are merely for example and not limiting. One skilled in the art can take alternative arrangements to the embodiments in the present specification according to the embodiments in the present specification. Therefore, the embodiments of the present specification are not limited to the embodiments precisely described in the application.
Claims
1. A method for live detection, comprising: obtaining a target user image of a target user, and compressing the target user image based on K compression rates to obtain K compressed user images, wherein K is an integer greater than 0; sorting the target user image and the K compressed user images based on the K compression rates to obtain a user image sequence; differencing adjacent images in the user image sequence to obtain K difference user images; fusing the K difference user images to obtain a fused user image; extracting features from the fused user image to obtain an image live feature of the target user; and based on the image live feature, classifying the target user as live to obtain a live detection result of the target user, and outputting the live detection result. The difference between adjacent compression rates after sorting is the same.
2. The living body detection method according to claim 1, wherein The fusing of the K difference user images to obtain a fused user image comprises:
3. The living body detection method according to claim 1, wherein determining attention weights corresponding to the K difference user images; and based on the attention weights, fusing the K difference user images to obtain the fused user image. The classifying of the target user as live to obtain a live detection result of the target user comprises:
4. The living body detecting method according to claim 1, wherein based on the image live feature, determining a target attack probability of the target user; and based on the target attack probability, performing a target operation, wherein the target operation comprises a first operation or a second operation, and wherein: the first operation comprises determining that the target attack probability is greater than a preset probability threshold, determining that the live detection result of the target user is an attack user, and the second operation comprises determining that the target attack probability is less than a preset probability threshold, determining that the live detection result of the target user is a live user.
5. The method for live detection according to claim 1, comprising: inputting the K difference user images into a target live detection model to obtain a plurality of attack probabilities; determining a mean value of the plurality of attack probabilities to obtain a target attack probability of the target user; and based on the target attack probability, determining the live detection result of the target user. The plurality of attack probabilities comprise an attack probability corresponding to each pixel in the fused user image, and the fused user image comprises a user image fused from the K difference user images. The training process of the target live detection model comprises the following steps:
6. The living body detecting method according to claim 5, wherein obtaining a first difference user image sample group; 7. The living body detecting method according to claim 5, wherein based on the first difference user image sample group, training a preset live detection model to obtain a trained live detection model; and compressing the live detection model to obtain the target live detection model. The training of the preset live detection model to obtain a trained live detection model comprises: inputting the first difference user image sample group into the preset live detection model to obtain a first predicted live class; 8. The living body detecting method according to claim 7, wherein based on the first predicted live class, determining a first live classification loss corresponding to the first difference user image sample group; and based on the first live classification loss, training the preset live detection model to obtain the trained live detection model. Converge the preset living body detection model based on the first living body classification loss to obtain the living body detection model.
9. The living body detecting method according to claim 8, wherein The first difference user image sample set includes K first difference user image samples, and the preset living body detection model includes an image fusion network, a feature encoding network, and a living body classification network. And The inputting of the first difference user image sample set into the preset living body detection model to obtain a first predicted living body category includes: inputting the K first difference user image samples into the image fusion network to obtain a first fused user image sample, inputting the first fused user image sample into the feature encoding network to obtain a first sample image living body feature, and inputting the first sample image living body feature into the living body classification network to obtain a first predicted living body category corresponding to each pixel in the first fused user image sample.
10. The living body detecting method according to claim 9, wherein The determination of the first living body classification loss corresponding to the first difference user image sample set includes: obtaining a first labeled living body category corresponding to the first difference user image sample set; comparing the first labeled living body category with the first predicted living body category to obtain an initial living body classification loss corresponding to each pixel in the first fused user image sample; and accumulating the initial living body classification loss to obtain the first living body classification loss.
11. The living body detecting method according to claim 9, wherein The determination of the first living body classification loss corresponding to the first difference user image sample set includes: obtaining a first labeled living body category corresponding to the first difference user image sample set, and comparing the first labeled living body category with the first predicted living body category to obtain an initial living body classification loss corresponding to each pixel in the first fused user image sample; comparing the first predicted living body category corresponding to each pixel to obtain a prediction consistency loss; and fusing the prediction consistency loss and the initial living body classification loss to obtain the first living body classification loss.
12. The living detection method according to claim 7, wherein, The compression of the living body detection model to obtain the target living body detection model includes: taking the living body detection model as a teacher model, and performing knowledge distillation on the living body detection model based on the teacher model and a preset meta network configured to balance the relationship between model performance and model volume in the model compression process; and performing channel pruning on the distilled living body detection model to obtain the target living body detection model.
13. The living body detecting method according to claim 12, wherein The knowledge distillation of the living body detection model includes: performing preset first number of times of knowledge distillation on the living body detection model based on the teacher model and the preset meta network to obtain a distilled candidate living body detection model; updating the living body detection model to the candidate living body detection model, and performing preset second number of times of training on the preset meta network based on the candidate living body detection model and the teacher model to obtain a current meta network; and update the preset meta-network to the current meta-network, and return to performing the step of performing knowledge distillation on the living body detection model for a preset first number of times until the living body detection model converges, to obtain the distilled living body detection model.
14. The living body detecting method according to claim 13, wherein The preset first number of times is greater than the preset second number of times, and a ratio between the preset first number of times and the preset second number of times is a preset ratio.
15. The living body detecting method according to claim 13, wherein The performing knowledge distillation on the living body detection model for a preset first number of times to obtain a distilled candidate living body detection model comprises: obtaining a second differential user image sample group and inputting the second differential user image sample group into the teacher model to obtain a second predicted living body category; inputting the second differential user image sample group into the living body detection model to obtain a second sample image living body feature and a third predicted living body category, the second sample image living body feature comprising a feature element corresponding to at least one feature channel; inputting the third predicted living body category into the preset meta-network to obtain a model compression weight, and updating a network parameter of the living body detection model based on the model compression weight, the feature element, the second predicted living body category and the third predicted living body category to obtain an updated living body detection model; and updating the living body detection model to the updated living body detection model and returning to performing the step of obtaining a second differential user image sample group until the number of times of updating the network parameter reaches the preset first number of times, to obtain the candidate living body detection model.
16. The living body detecting method according to claim 15, wherein The model compression weight comprises a model performance weight and a model volume weight. And The updating the network parameter of the living body detection model to obtain an updated living body detection model comprises: obtaining a second labeled living body category of the second differential user image sample group and comparing the second labeled living body category with the second predicted living body category and the third predicted living body category respectively to obtain a second living body classification loss; comparing the second predicted living body category with the third predicted living body category to obtain a distillation loss, and weighting the distillation loss based on the model performance weight to obtain a target distillation loss; based on the feature element, determining a sparsity loss corresponding to the at least one feature channel, and weighting the sparsity loss based on the model volume weight to obtain a target sparsity loss, and fusing the second living body classification loss, the target distillation loss and the target sparsity loss, and updating the network parameter of the living body detection model based on the fused target compression loss to obtain an updated living body detection model.
17. The living detection method according to claim 16, wherein, The determining the sparsity loss corresponding to the at least one feature channel based on the feature element comprises: based on the feature element, determining a channel importance value of each feature channel in the at least one feature channel; based on the channel importance value, selecting a candidate feature channel from the at least one feature channel, the candidate feature channel comprising a feature channel with a channel importance value less than a preset importance threshold; and Determine the sparse loss based on the number of candidate feature channels, which constrains the number of candidate feature channels to be greater than a preset number threshold during the training process.
18. The living detection method according to claim 12, wherein, The channel pruning of the distilled live body detection model to obtain the target live body detection model comprises: Obtaining a target channel importance value of each feature channel in the distilled live body detection model; Based on the target channel importance value, determining a target feature channel that needs to be pruned, and selecting a target convolution kernel corresponding to the target feature channel in the distilled live body detection model; and Pruning the target feature channel and the target convolution kernel in the distilled live body detection model to obtain the target live body detection model.
19. A live body detection system, comprising: at least one storage medium storing at least one instruction set for live body detection; and at least one processor in communication connection with the at least one storage medium, wherein when the live body detection system is running, the at least one processor reads the at least one instruction set and executes the live body detection method according to the instruction of the at least one instruction set as claimed in any one of claims 1-18.
Citation Information
Patent Citations
Tampering detection method and system for digital image
CN112614116A
Face living body detection method and device, electronic equipment and storage medium
CN113469085A