Living body detection method, training method of colorful detection model and related equipment

By using the colorful detection model and attention mechanism in the live detection, video features are extracted and light-color detection is performed, the problem of difficult injection attack detection in the existing technology is solved, and efficient and accurate live detection is achieved.

CN119453921APending Publication Date: 2025-02-18MASHANG CONSUMER FINANCE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310994479.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-08-08
Publication Date
2025-02-18

AI Technical Summary

Technical Problem

The prior art is difficult to effectively detect and prevent injection attacks, especially in the application of face generation technology and face swap technology, the accuracy and efficiency of live detection are low.

Method used

A living body detection method is adopted to determine the living body state of the object to be detected by obtaining the video to be detected and using the target color detection model, the video features are extracted based on the attention mechanism, and light color detection is performed.

Benefits of technology

The accuracy and efficiency of live detection are improved, and the live and non-living bodies can be accurately identified without the user cooperating with corresponding actions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119453921A_ABST
    Figure CN119453921A_ABST
Patent Text Reader

Abstract

The invention discloses a living body detection method, a training method of a colorful detection model and related equipment. The living body detection method comprises the steps of obtaining a to-be-detected video, wherein the to-be-detected video is obtained by shooting a to-be-detected object under light irradiation of a target light color sequence; extracting video features of the to-be-detected video based on the attention mechanism and a sequential relationship between video frames in the to-be-detected video through a target color detection model; performing light color detection based on the video features through the target dazzling color detection model to obtain a predicted light color sequence; and determining a living body detection result of the to-be-detected object based on the target light color sequence and the predicted light color sequence. By adopting the method, the living body detection efficiency and accuracy can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of image processing technology, and in particular to a living body detection method, a training method for a dazzle detection model, and related equipment. Background Art

[0002] As various face generation and face-changing technologies become more and more mature, security verification in commercial applications, such as face payment and identity verification, has become increasingly challenging. Among the many attack methods, injection attacks are currently more difficult to detect and prevent. Injection attacks refer to attackers illegally obtaining images or videos of the target person in advance, and using images or videos of the target person to pass the verification during identity verification.

[0003] It can be seen that in order to deal with injection attacks, determining whether the object used for verification is alive becomes a key issue. Therefore, how to perform liveness detection in the field of artificial intelligence has become one of the hot issues in research. Summary of the invention

[0004] The purpose of the embodiments of the present application is to provide a liveness detection method, a training method for a colorful detection model, and related equipment to improve the accuracy and efficiency of liveness detection.

[0005] In order to achieve the above objectives, the present application embodiment adopts the following technical solutions:

[0006] In a first aspect, an embodiment of the present application provides a living body detection method, comprising:

[0007] Acquire a video to be detected, wherein the video to be detected is obtained by shooting the object to be detected under the illumination of light of the target light color sequence;

[0008] Extracting video features of the video to be detected through the target dazzle detection model based on the attention mechanism and the temporal relationship between video frames in the video to be detected;

[0009] By using the target dazzle color detection model, light color detection is performed based on the video features to obtain a predicted light color sequence;

[0010] Based on the target light color sequence and the predicted light color sequence, a liveness detection result of the object to be detected is determined.

[0011] The liveness detection method provided in the embodiment of the present application utilizes the principle that living and non-living objects have different absorption characteristics and polarization effects on the same light, irradiates light to the object to be detected according to the target light color sequence, and collects a video of the object to be detected under the light irradiation; then, by comparing the target light color sequence with the light color sequence presented in the video, it can be determined whether the object to be detected is a living body. The whole process does not require the user to cooperate with the corresponding actions, and has high efficiency and accuracy. On this basis, considering that the duration of each light color in the light color sequence is extremely short, the change between adjacent light colors will cause certain interference to the imaging of the object to be detected, and in the light color detection In the process, the target dazzle detection model is used. The entire video to be detected is first taken as the feature extraction object. The target dazzle detection model performs feature extraction based on the attention mechanism and the temporal relationship between the video frames in the video to be detected. The extracted video features contain important information in the time domain and spatial domain, and then introduces the dynamic influence of the light color sequence change on the imaging of the object to be detected in the video, which can accurately reflect the dynamic change characteristics of the imaging of the object to be detected following the light color change; further, the target dazzle detection model performs light color detection based on the video features, which can provide light color detection accuracy, thereby improving the accuracy of living body detection.

[0012] In a second aspect, an embodiment of the present application provides a method for training a dazzle detection model, comprising:

[0013] Acquire a sample video, where the sample video is obtained by shooting a sample object under the illumination of a sample light color sequence;

[0014] Extracting video features of the sample video based on an attention mechanism and a temporal relationship between video frames in the sample video by using a dazzle detection model to be trained;

[0015] Using the dazzling color detection model, light color detection is performed based on the video features to obtain a predicted light color sequence;

[0016] Based on the sample light color sequence and the predicted light color sequence, the dazzle detection model is updated and trained to obtain a target dazzle detection model.

[0017] The training method of the dazzle detection model provided in the embodiment of the present application is used to train the above-mentioned target dazzle detection model. During the model training process, a sample video of the sample object under the illumination of the sample light color sequence and the sample light color sequence are used as training data, and a dazzle detection model including a feature extraction network and a decoding network is used as the basic model for training; then, considering that the duration of each light color in the light color sequence is extremely short, the changes between adjacent light colors will cause certain interference to the imaging of the detected object. For this reason, the entire sample video is used as the feature extraction object, and the dazzle detection model performs feature extraction based on the attention mechanism and the temporal relationship between the video frames of the sample video. The extracted video features contain important information in the time domain and the spatial domain, thereby introducing the light color sequence. The dynamic impact of changes on the imaging of sample objects in sample videos can accurately reflect the dynamic change characteristics of the imaging of sample objects following the changes in light color; then, the dazzle detection model performs light color detection based on the video features to obtain a predicted light color sequence, and based on the sample light color sequence and the predicted light color sequence, the dazzle detection model is updated and trained, so that the dazzle detection model can fully learn the optical characteristics of the sample objects under the illumination of the sample light color sequence during the training process, thereby having the ability to accurately detect light color; thus, the trained target detection model can quickly and accurately identify the light color presented in any video, providing reliable data support for subsequent liveness detection.

[0018] In a third aspect, an embodiment of the present application provides a living body detection device, including:

[0019] An acquisition unit, used for acquiring a video to be detected, wherein the video to be detected is obtained by shooting the object to be detected under the illumination of light of a target light color sequence;

[0020] An extraction unit, configured to extract video features of the video to be detected through a target dazzle detection model based on an attention mechanism and a temporal relationship between video frames in the video to be detected;

[0021] A detection unit, configured to perform light color detection based on the video features by using the target dazzle color detection model to obtain a predicted light color sequence;

[0022] The detection unit is further used to determine a liveness detection result of the object to be detected based on the target light color sequence and the predicted light color sequence.

[0023] In a fourth aspect, an embodiment of the present application provides a training device for a dazzle detection model, including:

[0024] An acquisition unit, used to acquire a sample video, wherein the sample video is obtained by shooting a sample object under the illumination of light of a sample light color sequence;

[0025] An extraction unit, configured to extract video features of the sample video through a dazzle detection model to be trained based on an attention mechanism and a temporal relationship between video frames in the sample video;

[0026] A detection unit, configured to perform light color detection based on the video features by using the dazzling color detection model to obtain a predicted light color sequence;

[0027] A training unit is used to update and train the dazzle detection model based on the sample light color sequence and the predicted light color sequence to obtain a target dazzle detection model.

[0028] In a fifth aspect, an embodiment of the present application provides an electronic device, comprising: a processor; a memory for storing instructions executable by the processor; wherein the processor is configured to execute the instructions to implement the liveness detection method as described in the first aspect; or, the processor is configured to execute the instructions to implement the training method of the dazzle detection model as described in the second aspect.

[0029] In a sixth aspect, an embodiment of the present application provides a computer-readable storage medium. When the instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the liveness detection method as described in the first aspect; or, when the instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the training method of the dazzle detection model as described in the second aspect. BRIEF DESCRIPTION OF THE DRAWINGS

[0030] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

[0031] Figure 1 A schematic diagram of a flow chart of a liveness detection method provided in an embodiment of the present application;

[0032] Figure 2 A schematic diagram of the structure of a target dazzle detection model provided in an embodiment of the present application;

[0033] Figure 3 A schematic diagram of the structure of an attention module provided in an embodiment of the present application;

[0034] Figure 4 A schematic diagram of another method for detecting a living body provided in an embodiment of the present application;

[0035] Figure 5 A flowchart of a method for training a dazzle detection model provided in an embodiment of the present application;

[0036] Figure 6A schematic diagram of the structure of a living body detection device provided in an embodiment of the present application;

[0037] Figure 7 A schematic diagram of the structure of a training device for a dazzle detection model provided in an embodiment of the present application;

[0038] Figure 8 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0039] In order to make the purpose, technical solution and advantages of the present application clearer, the technical solution of the present application will be clearly and completely described below in combination with the specific embodiments of the present application and the corresponding drawings. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present application.

[0040] The terms "first", "second", etc. in this specification and claims are used to distinguish similar objects, and are not used to describe a particular order or precedence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present application can be implemented in an order other than those illustrated or described herein. In addition, "and / or" in this specification and claims means at least one of the connected objects, and the character " / " generally means that the objects associated with each other are in an "or" relationship.

[0041] Related concept description:

[0042] Injection attack: The attacker illegally obtains the image or video data of the target face in advance and changes the data source of the verification backend during identity verification.

[0043] In order to deal with attacks including injection attacks, the conventional and mature approach is to use action liveness recognition, that is, the user performs simple facial movements, uses the action sequence as a key, and determines whether the user is alive based on the matching status between the action sequence and the key during the user's cooperation process. However, the disadvantages of this method are obvious. First, the types of actions are limited, and the random space formed is relatively small, which affects the accuracy of liveness detection; second, the action coordination takes a long time to complete, which affects the detection efficiency.

[0044] In view of this, the embodiment of the present application proposes a solution for liveness detection based on light of a light color sequence, which utilizes the principle that living and non-living objects have different absorption characteristics and polarization effects on the same light, irradiates light to the object to be detected according to the target light color sequence, and collects a video of the object to be detected under the light irradiation; then, by comparing the target light color sequence with the light color sequence presented in the video, it can be determined whether the object to be detected is a living body. The whole process does not require the user to cooperate with the corresponding actions, and has high efficiency and accuracy; on this basis, considering that the duration of each light color in the light color sequence is extremely short, the changes between adjacent light colors will cause certain effects on the imaging of the object to be detected. In order to avoid interference from the image processing, the target dazzle detection model is used in the process of light and color detection. The entire video to be detected is first taken as the feature extraction object. The target dazzle detection model performs feature extraction based on the attention mechanism and the temporal relationship between the video frames in the video to be detected. The extracted video features contain important information in the time domain and the spatial domain, and then the dynamic influence of the light and color sequence changes on the imaging of the object to be detected in the video is introduced, which can accurately reflect the dynamic change characteristics of the imaging of the object to be detected following the light and color changes. Furthermore, the target dazzle detection model performs light and color detection based on the video features, which can provide light and color detection accuracy, thereby improving the accuracy of living body detection.

[0045] The embodiment of the present application also provides a method for training a dazzle detection model, which is used to train the above-mentioned target dazzle detection model. During the model training process, a sample video of a sample object under the illumination of a sample light color sequence and a sample light color sequence are used as training data, and a dazzle detection model including a feature extraction network and a decoding network is used as the basic model for training; then, considering that the duration of each light color in the light color sequence is extremely short, the changes between adjacent light colors will cause certain interference to the imaging of the detected object. For this reason, the entire sample video is used as the feature extraction object, and the dazzle detection model performs feature extraction based on the attention mechanism and the temporal relationship between the video frames of the sample video. The extracted video features contain important information in the time domain and the spatial domain, thereby introducing the light color sequence. The dynamic impact of changes on the imaging of sample objects in sample videos can accurately reflect the dynamic change characteristics of the imaging of sample objects following the changes in light color; then, the dazzle detection model performs light color detection based on the video features to obtain a predicted light color sequence, and based on the sample light color sequence and the predicted light color sequence, the dazzle detection model is updated and trained, so that the dazzle detection model can fully learn the optical characteristics of the sample objects under the illumination of the sample light color sequence during the training process, thereby having the ability to accurately detect light color; thus, the trained target detection model can quickly and accurately identify the light color presented in any video, providing reliable data support for subsequent liveness detection.

[0046] It should be understood that the liveness detection method and the training method of the dazzling color detection model provided in the embodiments of the present application can be executed by an electronic device or software installed in the electronic device. The so-called electronic device here can include terminal devices, such as smart phones, tablet computers, laptops, desktop computers, intelligent voice interaction devices, smart home appliances, smart watches, vehicle terminals, aircraft, etc.; or, the electronic device can also include a server, such as an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides cloud computing services.

[0047] The technical solutions provided by various embodiments of the present application are described in detail below in conjunction with the accompanying drawings.

[0048] See also Figure 1 , is a flow chart of a liveness detection method provided in an embodiment of the present application, the method may include the following steps:

[0049] S102: Obtain a video to be detected.

[0050] The video to be detected is obtained by shooting the object to be detected under the illumination of the target light color sequence. The object to be detected refers to an object that needs to be detected as a living body, such as a face to be detected.

[0051] The target light color sequence includes a plurality of light colors arranged in order. Each light color in the target light color sequence is randomly selected from a preset light color set, and any two adjacent light colors in the target light color sequence are different. The preset light color set includes a plurality of light colors.

[0052] In actual applications, the number of light colors included in the target light color sequence (i.e., the length of the target light color sequence), the duration of each light color, and the light colors included in the preset light color set can all be designed according to actual business scenarios, and the embodiments of the present application are not limited to this.

[0053] For example, the target light color sequence includes light colors of 5 unit times, namely L original =(L1, L2, L3, L4, L5), where L1-L5 represent a light color respectively, and these light colors are randomly selected from the preset light color set, and L1 is different from L2, L2 is different from L3, L3 is different from L4, and L4 is different from L5. In addition, the duration of each of L1-L5 is equal, for example, they are all 200ms.

[0054] In the embodiment of the present application, the video to be detected can be obtained in a variety of ways. Optionally, considering that the liveness detection in most business scenarios is performed by video acquisition by the terminal device, for this reason, in the above S102, the screen of the terminal device can be used to emit light to the object to be detected according to the target light color sequence, and the front camera of the terminal device can be used to collect the video to be detected of the object to be detected under the light.

[0055] In specific implementation, the liveness detection method provided in the embodiment of the present application can be executed by a terminal device or by a server. In the case where the liveness detection method is executed by a terminal device, the terminal device can control its own screen brightness to be adjusted to the maximum brightness, and emit light according to the target light color sequence to irradiate light of multiple colors to the object to be detected; at the same time, the terminal device also controls the front camera to collect the video of the object to be detected under the light irradiation, and obtains the video to be detected. In actual applications, before controlling the front camera to collect video, the terminal device also controls the screen to display prompt information to prompt the object to be detected to be placed in the specified area of ​​the screen interface to ensure that the collected video to be detected contains a complete and unobstructed object to be detected.

[0056] In the case where the liveness detection method is executed by the server, the server may send a collection instruction to the terminal device to instruct the terminal device to collect the video to be detected of the object to be detected under the light of the target light color sequence in the above manner, and upload the video to be detected to the server. In this case, the target light color sequence may be generated by the server and carried in the collection instruction, or may be generated by the terminal device and sent to the server together with the video to be detected.

[0057] S104, extracting video features of the video to be detected through the target dazzle detection model based on the attention mechanism and the temporal relationship between video frames in the video to be detected.

[0058] The target dazzle detection model in the embodiment of the present application may have various appropriate structures, which may be specifically designed according to actual business requirements, and the embodiment of the present application does not limit this. Specifically, Figure 2 As shown, in order to introduce the dynamic influence of light color sequence changes on the imaging of the object to be detected in the video to improve the accuracy of light color detection, the target dazzle color detection model includes a feature extraction network. Accordingly, in the above S104, the video features of the video to be detected can be extracted through the feature extraction network based on the attention mechanism and the temporal relationship between the video frames in the video to be detected.

[0059] More specifically, considering that the imaging of the object to be detected follows the dynamic change characteristics of the light color change, which is reflected not only in time sequence but also in space, the above S104 may include: spatially mapping each video frame in the video to be detected to obtain a spatial feature image of each video frame; based on the attention mechanism and the temporal relationship between the video frames, extracting features from the spatial feature image of each video frame to obtain video features.

[0060] In the embodiment of the present application, the feature extraction network may have various appropriate structures, which may be specifically designed according to actual needs, and the embodiment of the present application does not limit this. Optionally, the feature extraction network is based on the Video Swin Transformer and its module combination is adjusted. Figure 2 As shown, the feature extraction network includes a mapping module and an N-level feature extraction module.

[0061] The mapping module is used to perform spatial mapping on each video frame in the video to be detected, and obtain the spatial feature image corresponding to each video frame. For example, the mapping module includes a 3D convolution layer and a normalization layer. The input channel of the 3D convolution layer is 3, the output channel is 128, the convolution kernel size is (2,4,4), and the convolution stride is (2,4,4), so that the input video frame can be mapped to a 128×32×56×56 spatial feature map; the spatial feature map is normalized by the normalization layer and used as the input of the first-level feature extraction module.

[0062] In the N-level feature extraction module, the first-level feature extraction module is used to perform feature extraction on the spatial feature map based on the attention mechanism and the temporal relationship between each video frame, so as to obtain the first-level intermediate feature; the i-th level feature extraction module is used to perform feature extraction on the i-1-th level intermediate feature based on the attention mechanism and the temporal relationship between each video frame, so as to obtain the i-th level intermediate feature, 1<i<N; the N-level feature extraction module is used to perform feature extraction on the N-1-th level intermediate feature based on the attention mechanism and the temporal relationship between each video frame, so as to obtain the video feature.

[0063] Combination Figure 2 , the first N-1 level feature extraction modules include an attention module and a fusion module, and the Nth level feature extraction module includes an attention module. Figure 3The attention modules include 3D W-MSA and 3D SW-MSA, where 3D W-MSA represents a window multi-head attention module without shift, and 3D SW-MSA represents a window multi-head attention module with shift. The difference between these two window multi-head attention modules is that when extracting features based on self-attention, 3D W-MSA does not need to mask the input, while 3D SW-MSA needs to mask the input. For each multi-head attention module, the input features are normalized by a normalization layer and then processed by the multi-head attention module. The input features and the processing results are added to form a residual, which is then processed by the normalization layer and the fully connected layer as the input of the fusion module.

[0064] The fusion module includes a normalization layer and a fully connected layer. The normalization layer is used to normalize the output of the attention module. After the processing result is processed by the fully connected layer, the size is halved and the number of channels is doubled to obtain the corresponding intermediate features. For example, the size of the processing result is 128×32×56×56, and after processing by the fully connected layer, the size is 256×32×28×28.

[0065] It can be understood that the spatial feature image obtained after spatial mapping can reflect the depth information of the corresponding video frame, and this depth information can accurately reflect the dynamic change characteristics of the object to be detected following the change of light color; the attention mechanism and the temporal relationship between video frames enable the feature extraction network to not only pay attention to the connection between different video frames in the time domain, but also pay attention to the important features in each video frame; therefore, on the basis of the spatial feature map, feature extraction is performed based on the attention mechanism and the temporal relationship between video frames, and the obtained video features integrate the depth information of each video frame and the important time domain features, and thus can more accurately reflect the dynamic change characteristics of the imaging of the object to be detected following the change of light color, which is beneficial to improving the accuracy of light color detection.

[0066] It is worth noting that the number of levels of the feature extraction module and the number of attention modules in each level of the feature extraction module can be set according to actual needs, and the embodiments of the present application do not limit this. For example, the feature extraction network can include 4 levels of feature extraction modules, and each level of the feature extraction module includes 2 attention modules.

[0067] S106, performing light color detection based on the video features through the target glare detection model to obtain a predicted light color sequence.

[0068] The predicted light color sequence is used to represent the light color presented by the object to be detected in each video frame of the video to be detected.

[0069] The target color detection model is trained based on sample videos and sample light color sequences, where the sample videos are obtained by shooting the sample objects under the illumination of the sample light color sequence. Therefore, the video to be detected has the ability to detect light color, and it can perform light color detection on any video, determine the light color presented by the object to be detected in each video frame of the video, and obtain the corresponding predicted light color sequence.

[0070] like Figure 2 As shown, the target glare detection model also includes a decoding network. Accordingly, in the above S106, the decoding network can be used to perform light color detection based on video features to obtain a predicted light color sequence.

[0071] In the embodiments of the present application, light color prediction can be performed in various appropriate ways, which are not limited in the embodiments of the present application.

[0072] Optionally, considering that each light color in the target light color sequence has a duration, the video features include image features of each video frame in the video to be detected, and the light color presented by the object to be detected in the image features of each video frame may be different. In order to improve the accuracy of light color detection, light color detection can be performed frame by frame on the video to be detected to obtain a predicted light color sequence. Specifically, the above S106 includes: based on the duration of each light color in the target light color sequence, determining the video frames corresponding to each light color from the video to be detected; then, based on the image features of the video frames corresponding to each light color, performing light color detection on the corresponding video frames to obtain the predicted light color of the corresponding video frames; further, based on the predicted light color corresponding to each video frame in the video to be detected, determining the predicted light color sequence.

[0073] For example, the light colors in the target light color sequence are L1 to L5. Taking light color L1 as an example, based on the duration of each light color, it is determined that light color L1 corresponds to video frames 1 to 3. Then, light color detection can be performed based on the image features of each of video frames 1 to 3 to obtain the predicted light colors of each of video frames 1 to 3; further, according to the time sequence relationship of each video frame in the video to be detected, the predicted light colors corresponding to each video frame are combined to obtain the predicted light color of the video to be detected.

[0074] In the embodiment of the present application, the decoding network may have various appropriate structures, which may be specifically designed according to actual needs, and the embodiment of the present application does not limit this. Figure 2 As shown, in order to balance the structural complexity of the decoding network and the accuracy of light color detection, the decoding network includes convolutional layers, pooling layers and fully connected layers.

[0075] The convolution layer is used to extract video features to obtain candidate features. For example, the convolution layer can be a 3D convolution layer, whose convolution kernel size is (5, 1, 1), the convolution step is (1, 1, 1), the feature map padding width is (2, 0, 0), and the output channel is 768.

[0076] The pooling layer is used to downsample the candidate features to obtain the target features. For example, the pooling layer may be a 3D adaptive pooling layer, which has a size of (5, 1, 1), where 5 represents the length of the predicted light color sequence, and may be designed according to actual needs.

[0077] The fully connected layer is used to detect light color based on the target features and obtain a predicted light color sequence. For example, the output size of the fully connected layer is 5×6, where 5 represents the length of the predicted light color sequence and 6 represents the number of light colors contained in the preset light color set, that is, the predicted light color sequence contains 5 light colors, each of which comes from the preset light color set.

[0078] S108, determining a liveness detection result of the object to be detected based on the target light color sequence and the predicted light color sequence.

[0079] Specifically, the predicted light color sequence and the target light color sequence may be compared for consistency. If the two are consistent, it can be determined that the object to be detected is a living body; otherwise, it can be determined that the object to be detected is a non-living body.

[0080] The liveness detection method provided in the embodiment of the present application utilizes the principle that living and non-living objects have different absorption characteristics and polarization effects on the same light, irradiates light to the object to be detected according to the target light color sequence, and collects a video of the object to be detected under the light irradiation; then, by comparing the target light color sequence with the light color sequence presented in the video, it can be determined whether the object to be detected is a living body. The whole process does not require the user to cooperate with the corresponding actions, and has high efficiency and accuracy. On this basis, considering that the duration of each light color in the light color sequence is extremely short, the change between adjacent light colors will cause certain interference to the imaging of the object to be detected, and in the light color detection In the process, the target dazzle detection model is used. The entire video to be detected is first taken as the feature extraction object. The target dazzle detection model performs feature extraction based on the attention mechanism and the temporal relationship between the video frames in the video to be detected. The extracted video features contain important information in the time domain and spatial domain, and then introduces the dynamic influence of the light color sequence change on the imaging of the object to be detected in the video, which can accurately reflect the dynamic change characteristics of the imaging of the object to be detected following the light color change; further, the target dazzle detection model performs light color detection based on the video features, which can provide light color detection accuracy, thereby improving the accuracy of living body detection.

[0081] The liveness detection method provided in the embodiment of the present application can be applied to various business scenarios that require liveness detection, such as access control, payment scenarios, financial business review scenarios, etc., and the embodiment of the present application does not limit this. For different scenarios, the above liveness detection method can be executed by different devices. The following takes the execution of the terminal device as an example, combined with Figure 4 The liveness detection method provided in the embodiments of the present application is described in detail.

[0082] First, the terminal device randomly generates a target light color sequence (L1, L2, L3, L4, L5) consisting of 5 unit times of light color, and the duration of each light color is equal.

[0083] Then, the terminal device controls the screen brightness to the maximum volume, and emits light according to the target light color sequence, so as to sequentially irradiate the five light colors to the object to be detected. At the same time, the terminal device also controls the front-end camera to collect the video of the object to be detected under the light.

[0084] Next, the terminal device inputs the video to be detected into the target color detection model, and the feature extraction network extracts video features from the video to be detected based on the attention mechanism and the temporal relationship between the video frames in the video to be detected; the video features are then predicted by the decoding network to obtain the predicted light color sequence of the video to be detected.

[0085] Further, the terminal device compares the target light color sequence with the predicted light color sequence. If the two are consistent, it is determined that the object to be detected is a living body; if the two are inconsistent, it is determined that the object to be detected is a non-living body.

[0086] The present application also provides a method for training a dazzle detection model, which is used to train the above-mentioned target dazzle detection model. Figure 5 , is a flow chart of a method for training a dazzle detection model provided in an embodiment of the present application, the method may include the following steps:

[0087] S502, obtaining a sample video.

[0088] The sample video is obtained by shooting the sample object under the illumination of the sample light color sequence. The sample light color sequence includes multiple light colors, each light color has a duration. Any two adjacent light colors in the sample light color sequence are different.

[0089] The specific implementation of the above S502 is similar to the specific implementation of the above S102, and will not be repeated here.

[0090] S504, extracting video features of the sample video through the dazzle detection model to be trained based on the attention mechanism and the temporal relationship between video frames in the sample video.

[0091] The dazzle detection model includes a feature extraction network, which is used to extract video features of the sample video based on the attention mechanism and the temporal relationship between video frames in the sample video.

[0092] The specific implementation of S504 is similar to that of S104, and will not be described in detail.

[0093] S506, performing light color detection based on the video features through a dazzling color detection model to obtain a predicted light color sequence.

[0094] The color detection model also includes a decoding network, which is used to detect light colors based on video features and obtain a predicted light color sequence.

[0095] Specifically, the predicted light color sequence is obtained by combining the predicted light colors corresponding to each video frame in the sample video, and the predicted light color corresponding to each video frame is obtained by the decoding network performing light color prediction based on the image features of the video frame.

[0096] The specific implementation method of S506 is similar to the specific implementation method of S106 described above, and will not be repeated here.

[0097] S508, based on the sample light color sequence and the predicted light color sequence, update and train the dazzle detection model to obtain a target dazzle detection model.

[0098] Specifically, the prediction loss of the dazzle detection model can be determined based on the sample light color sequence and the predicted light color sequence; then, based on the prediction loss, the model parameters of the dazzle detection model are updated. The prediction loss is used to represent the difference between the sample light color sequence and the predicted light color sequence. Optionally, in order to more accurately represent this difference to improve the training effect of the dazzle detection model, the above S506 may include: based on the light color value difference between the predicted light color sequence and the light color at the same position in the sample light color sequence, determining the prediction loss corresponding to each light color in the sample light color sequence; based on the sum of the prediction losses corresponding to each light color in the sample light color sequence, updating the dazzle detection model.

[0099] For example, assuming that the sample light color sequence is (L1, L2, L3, L4, L5), and the predicted light color sequence is (L1', L2', L3', L4', L5'), based on the light color value difference between L1 and L1' and the cross entropy loss function, the prediction sub-loss corresponding to L1 can be determined; similarly, the prediction sub-losses corresponding to L2 to L5 can be obtained; further, the sum of the prediction sub-losses corresponding to L1 to L5 is determined as the prediction loss of the dazzle detection model, and then the dazzle detection model is updated based on the prediction loss of the dazzle detection model.

[0100] In practical applications, the update of the dazzle detection model can be achieved through various update methods commonly used in the field, such as gradient descent algorithm, back propagation algorithm, etc., which is not limited in the embodiments of the present application.

[0101] The above process is only an update training process. In practical applications, the above S504-506 can be executed multiple times until the color detection model meets the preset training stop condition, and the target color detection model can be obtained. Among them, the preset training stop condition can be set according to actual needs, such as the number of update training reaches the preset number of iterations, or the prediction loss of the color detection model converges, etc., which is not limited in this embodiment of the present application. In practical applications, the above update training process can use warm up learning rate and cosine learning rate decay.

[0102] In order to avoid overfitting of the color detection model during the training process and to ensure that the trained target color detection model can be used for light and color detection in videos of various sizes, thereby meeting the needs of liveness detection in various business scenarios, sample videos of various sizes can be used to train the color detection model.

[0103] Specifically, the sample videos obtained through the above S502 include sample videos of N sizes, where N is an integer greater than 2. Further, the above S506 may include: based on the sample light color sequence and predicted light color sequence of the sample video of the first size, updating and training the color detection model to be trained to obtain the color detection model corresponding to the first size; based on the sample light color sequence and predicted light color sequence of the sample video of the i-th size, performing light color training on the color detection model corresponding to the i-1th size to obtain the color detection model corresponding to the i-th size, wherein 1<i≤N, the predicted light color sequence of the sample video of the i-th size is obtained by inputting the sample video of the i-th size into the color detection model corresponding to the i-1th size; if i is less than N, then performing an addition operation on i and assigning a value to i, and triggering the step of updating and training the color model corresponding to the i-1th size based on the sample light color sequence and predicted light color sequence of the sample video of the i-th size; if i is equal to N, then taking the color detection model corresponding to the i-th size as the target color detection model. That is to say, finally taking the color detection model corresponding to the Nth size as the target color detection model.

[0104] For example, assume that there are two sizes of sample videos. First, the sample video of size 1 and its corresponding sample light color sequence are used to update the detection model for training, specifically including: inputting the sample video of size 1 into the initial dazzle detection model to obtain the predicted light color sequence corresponding to the sample video of size 1; then, based on the predicted light color sequence and the sample light color sequence corresponding to the sample video of size 1, the dazzle detection model is updated, and the above process is repeated multiple times until the dazzle detection model meets the preset training stop condition, and the dazzle detection model 1 is obtained. Next, the sample video of size 2 and its corresponding sample light color sequence are used to update the dazzle detection model 1. The specific training process is similar to the above-mentioned process of updating and training the initial dazzle detection model, and the dazzle detection model 2 is obtained, and the dazzle detection model 2 can be used as the target dazzle detection model.

[0105] It can be understood that the dazzle detection model is trained by using sample videos of various sizes and corresponding sample light and color sequences, and the training process is carried out in a sequential manner. The dazzle detection model is first trained to a certain degree using sample videos of one size, and then the training is continued using sample videos of another size. In this way, the dazzle detection model can fully learn the light and color characteristics presented by sample objects in sample videos of different sizes during the training process, and has the ability to perform light and color detection on videos of different sizes, thereby avoiding overfitting of the target dazzle detection model obtained through training, and better meeting the needs of liveness detection in various business scenarios.

[0106] Furthermore, considering that in the process of training the dazzle detection model using sample videos of various sizes, in order to enable the dazzle detection model to pay attention to the characteristics of the sample objects in the sample videos, especially the characteristics of certain parts of the sample objects (such as eyes), so as to perform light and color detection more accurately, the area where the sample objects are located in each video frame of the sample video can be masked; in addition, considering that there are differences in the areas where the sample objects are located in sample videos of different sizes, if each video frame is masked according to the fixed mask technology in the relevant technology, the dazzle detection model will not be able to accurately locate the area where the sample objects are located.

[0107] Based on this, in the process of training the dazzle detection model using sample videos of various sizes, the video features of each size of the sample video are extracted in the following way: a template image with the same size as the sample video is generated, and the pixel value of each pixel in the template image is a first pixel value; based on the area where the sample object is located in each video frame of the sample video, the pixel value of the pixel in the target area of ​​the template image is modified to a second pixel value to obtain a mask image corresponding to each video frame, and the target area corresponds to the area where the sample object is located; each video frame and the mask image corresponding to each video frame are operated to obtain a masked video frame, and based on the attention mechanism and the temporal relationship between the video frames in the sample video, features of the masked video frame are extracted.

[0108] For example, the sample object is a sample face, and the target area can be the area where the eyes of the sample face in the corresponding video frame are located. If the size of the sample video is 224×224, then a 224×224 template image is generated, and the pixel values ​​of all pixels in the template image are 0. Then, for each video frame in the sample video, the area where the sample object is located in the video frame is determined, and the pixel values ​​of the pixels in the target area corresponding to the area in the template image are set to 1 to obtain the mask image corresponding to the video frame. Further, the video frame and its corresponding mask image are operated to realize the masking of the video frame, and based on the attention mechanism and the temporal relationship between the video frames in the sample video, the masked video frame is feature extracted to obtain the image features of the video frame.

[0109] The training method of the dazzle detection model provided in the embodiment of the present application is used to train the above-mentioned target dazzle detection model. During the model training process, a sample video of the sample object under the illumination of the sample light color sequence and the sample light color sequence are used as training data, and a dazzle detection model including a feature extraction network and a decoding network is used as the basic model for training; then, considering that the duration of each light color in the light color sequence is extremely short, the changes between adjacent light colors will cause certain interference to the imaging of the detected object. For this reason, the entire sample video is used as the feature extraction object, and the dazzle detection model performs feature extraction based on the attention mechanism and the temporal relationship between the video frames of the sample video. The extracted video features contain important information in the time domain and the spatial domain, thereby introducing the light color sequence. The dynamic impact of changes on the imaging of sample objects in sample videos can accurately reflect the dynamic change characteristics of the imaging of sample objects following the changes in light color; then, the dazzle detection model performs light color detection based on the video features to obtain a predicted light color sequence, and based on the sample light color sequence and the predicted light color sequence, the dazzle detection model is updated and trained, so that the dazzle detection model can fully learn the optical characteristics of the sample objects under the illumination of the sample light color sequence during the training process, thereby having the ability to accurately detect light color; thus, the trained target detection model can quickly and accurately identify the light color presented in any video, providing reliable data support for subsequent liveness detection.

[0110] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0111] The present application also provides a living body detection device. Figure 6 , is a schematic diagram of the structure of a living body detection device 600 provided in an embodiment of the present application, and the device 600 may include:

[0112] An acquisition unit 610 is used to acquire a video to be detected, where the video to be detected is obtained by shooting the object to be detected under the illumination of light of a target light color sequence;

[0113] An extraction unit 620 is used to extract video features of the video to be detected based on an attention mechanism and a temporal relationship between video frames in the video to be detected by using a target dazzle detection model;

[0114] A detection unit 630 is configured to perform light color detection based on the video features by using the target glare detection model to obtain a predicted light color sequence;

[0115] The detection unit 630 is further configured to determine a liveness detection result of the object to be detected based on the target light color sequence and the predicted light color sequence.

[0116] Optionally, the video features include image features of each video frame in the video to be detected, and each light color in the target light color sequence has a duration;

[0117] When the detection unit 630 performs light color detection based on the video features through the target glare detection model to obtain a predicted light color sequence, the detection unit 630 performs the following steps:

[0118] Based on the duration of each light color in the target light color sequence, determining the video frame corresponding to each light color from the video to be detected;

[0119] Based on the image features of the video frames corresponding to each light color, light color detection is performed on each video frame to obtain the predicted light color of each video frame;

[0120] The predicted light color sequence is determined based on the predicted light color of each video frame in the video to be detected.

[0121] Optionally, when the feature extraction unit 620 extracts the video features of the video to be detected through the target dazzle detection model based on the attention mechanism and the temporal relationship between video frames in the video to be detected, the feature extraction unit 620 performs the following steps:

[0122] Performing spatial mapping on each video frame in the video to be detected to obtain a spatial feature image of each video frame;

[0123] Based on the attention mechanism and the temporal relationship between each video frame, feature extraction is performed on the spatial feature image of each video frame to obtain the video feature.

[0124] Optionally, each light color in the target light color sequence is randomly selected from a preset light color set, and any two adjacent light colors in the target light color sequence are different.

[0125] Obviously, the living body detection device provided in the embodiment of the present application can be used as Figure 1 The execution subject of the living body detection method shown is, for example Figure 1 In the living body detection method shown in FIG. 1 , step S102 may be performed by Figure 6 The acquisition unit 610 in the living body detection device shown in FIG. 1 is executed, and step S104 can be performed by Figure 6 The feature extraction unit 620 in the living body detection device shown in FIG. 1 is executed, and step S106 can be performed by Figure 6 The detection unit 630 in the living body detection device shown in FIG. 1 is executed, and step 108 can be performed by Figure 6 The detection is performed by the detection unit 630 in the living body detection device shown.

[0126] According to another embodiment of the present application, Figure 6 The various units in the liveness detection device shown can be separately or completely combined into one or several other units to form, or one (some) of the units can be further divided into multiple functionally smaller units to form, which can achieve the same operation without affecting the realization of the technical effects of the embodiments of the present application. The above-mentioned units are divided based on logical functions. In practical applications, the functions of one unit can also be implemented by multiple units, or the functions of multiple units can be implemented by one unit. In other embodiments of the present application, the liveness detection device may also include other units. In practical applications, these functions can also be implemented with the assistance of other units, and can be implemented by the collaboration of multiple units.

[0127] According to another embodiment of the present application, the program can be executed on a general computing device such as a computer including a central processing unit (CPU), a random access memory (RAM), a read-only memory (ROM), and other processing elements and storage elements. Figure 1 A computer program (including program code) for each step involved in the corresponding method shown in FIG. Figure 6 The liveness detection device shown in the embodiment of the present application is used to implement the liveness detection method of the embodiment of the present application. The computer program can be recorded on a computer-readable storage medium, for example, and transferred to an electronic device through the computer-readable storage medium and run therein.

[0128] The present application also provides a training device for a dazzle detection model. Figure 7 , is a schematic diagram of the structure of a training device 700 for a dazzle detection model provided in an embodiment of the present application. The device 700 may include:

[0129] An acquisition unit 710 is used to acquire a sample video, where the sample video is obtained by shooting a sample object under the illumination of a sample light color sequence;

[0130] An extraction unit 720, configured to extract video features of the sample video through a dazzle detection model to be trained based on an attention mechanism and a temporal relationship between video frames in the sample video;

[0131] A detection unit 730, configured to perform light color detection based on the video features by using the dazzling color detection model to obtain a predicted light color sequence;

[0132] The training unit 740 is used to update and train the dazzle detection model based on the sample light color sequence and the predicted light color sequence to obtain a target dazzle detection model.

[0133] Optionally, the video features include image features of each video frame in the sample video, the predicted light color sequence is obtained by combining predicted light colors corresponding to each video frame in the sample video, and the predicted light color is obtained by the decoding network performing light color prediction based on the image features of the corresponding video frame;

[0134] When the training unit 740 performs update training on the dazzle detection model based on the sample light color sequence and the predicted light color sequence, the training unit 740 performs the following steps:

[0135] Determine the predicted sub-loss corresponding to each light color in the sample light color sequence based on the light color value difference between the predicted light color sequence and the light color with the same sequence number in the sample light color sequence;

[0136] The dazzle detection model is updated based on the sum of the prediction sub-losses corresponding to each light color in the sample light color sequence.

[0137] Optionally, the sample video includes sample videos of N sizes, where N is an integer greater than 2; and the sample light color sequence includes a sample light color sequence of a sample video of each size;

[0138] When the training unit 740 performs update training on the dazzle detection model based on the sample light color sequence and the predicted light color sequence, the training unit 740 performs the following steps:

[0139] Based on the sample light color sequence and the predicted light color sequence of the sample video of the first size, the dazzle detection model to be trained is updated and trained to obtain the dazzle detection model corresponding to the first size;

[0140] Based on the sample light color sequence and the predicted light color sequence of the sample video of the i-th size, the color detection model corresponding to the i-1th size is trained to obtain the color detection model corresponding to the i-th size, wherein 1<i≤N, and the predicted light color sequence of the sample video of the i-th size is obtained by inputting the sample video of the i-th size into the color detection model corresponding to the i-1th size;

[0141] If i is less than N, then i is incremented by 1 and assigned to i, triggering the step of updating and training the colorful model corresponding to the i-1th size based on the sample light color sequence and the predicted light color sequence of the sample video of the i-th size;

[0142] If i is equal to N, the dazzle detection model corresponding to the i-th size is used as the target dazzle detection model.

[0143] Optionally, the sample video includes sample videos of N sizes, and the extraction unit 720 performs the following steps when extracting the video features of the sample video through the dazzle detection model to be trained based on the attention mechanism and the temporal relationship between video frames in the sample video:

[0144] Generate a template image with the same size as the sample video, wherein the pixel value of each pixel in the template image is a first pixel value;

[0145] Based on the area where the sample object is located in each video frame of the sample video, modify the pixel values ​​of the pixels in the target area of ​​the template image to a second pixel value to obtain a mask image corresponding to each video frame, wherein the target area corresponds to the area where the sample object is located;

[0146] Each video frame and the mask image corresponding to each video frame are operated to obtain the masked video frame, and based on the attention mechanism and the temporal relationship between the video frames in the sample video, the features of the masked video frame are extracted.

[0147] Obviously, the training device of the dazzle detection model provided in the embodiment of the present application can be used as Figure 5 The execution body of the training method of the dazzle detection model shown, for example Figure 5 In the training method of the dazzle detection model shown in FIG. 1 , step S502 can be performed by Figure 7 The acquisition unit 710 in the training device of the dazzle detection model shown in FIG. 1 is executed, and step S504 can be performed by Figure 7 The feature extraction unit 720 in the training device of the dazzle detection model shown in FIG. 1 is executed, and step S506 can be performed by Figure 7 The detection unit 730 in the training device of the dazzle detection model shown in FIG. 1 is executed, and step 508 can be performed by Figure 7 The training unit 740 in the training device of the dazzle detection model shown is executed.

[0148] According to another embodiment of the present application, Figure 7The various units in the training device of the colorful detection model shown can be separately or completely combined into one or several other units to constitute, or one (some) of the units can be further divided into multiple functionally smaller units to constitute, which can achieve the same operation without affecting the realization of the technical effects of the embodiments of the present application. The above-mentioned units are divided based on logical functions. In practical applications, the function of one unit can also be implemented by multiple units, or the functions of multiple units can be implemented by one unit. In other embodiments of the present application, the training device of the colorful detection model may also include other units. In practical applications, these functions can also be implemented with the assistance of other units, and can be implemented by the collaboration of multiple units.

[0149] According to another embodiment of the present application, the program can be executed on a general computing device such as a computer including a central processing unit (CPU), a random access memory (RAM), a read-only memory (ROM), and other processing elements and storage elements. Figure 5 A computer program (including program code) for each step involved in the corresponding method shown in FIG. Figure 7 The computer program can be recorded on, for example, a computer-readable storage medium, and transferred to an electronic device through the computer-readable storage medium and run therein.

[0150] Figure 8 This is a schematic diagram of the structure of an electronic device according to an embodiment of the present application. Figure 8 At the hardware level, the electronic device includes a processor, and optionally also includes an internal bus, a network interface, and a memory. The memory may include a memory, such as a high-speed random access memory (RAM), and may also include a non-volatile memory (non-volatile memory), such as at least one disk storage. Of course, the electronic device may also include hardware required for other services.

[0151] The processor, network interface and memory can be interconnected through an internal bus, which can be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 8 Only one bidirectional arrow is used in the diagram, but this does not mean that there is only one bus or only one type of bus.

[0152] The memory is used to store the program. Specifically, the program may include a program code, and the program code includes a computer operation instruction. The memory may include a memory and a non-volatile memory, and provides instructions and data to the processor.

[0153] The processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it, forming a liveness detection device at the logical level. The processor executes the program stored in the memory and is specifically used to perform the following operations:

[0154] Acquire a video to be detected, wherein the video to be detected is obtained by shooting the object to be detected under the illumination of light of the target light color sequence;

[0155] Extracting video features of the video to be detected through the target dazzle detection model based on the attention mechanism and the temporal relationship between video frames in the video to be detected;

[0156] By using the target dazzle color detection model, light color detection is performed based on the video features to obtain a predicted light color sequence;

[0157] Based on the target light color sequence and the predicted light color sequence, a liveness detection result of the object to be detected is determined.

[0158] Alternatively, the processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it, forming a training device for the dazzle detection model at the logical level. The processor executes the program stored in the memory and is specifically used to perform the following operations:

[0159] Acquire a sample video, where the sample video is obtained by shooting a sample object under the illumination of a sample light color sequence;

[0160] Extracting video features of the sample video based on an attention mechanism and a temporal relationship between video frames in the sample video by using a dazzle detection model to be trained;

[0161] Using the dazzling color detection model, light color detection is performed based on the video features to obtain a predicted light color sequence;

[0162] Based on the sample light color sequence and the predicted light color sequence, the dazzle detection model is updated and trained to obtain a target dazzle detection model.

[0163] The above application Figure 1 The method performed by the living body detection device disclosed in the embodiment shown or the above-mentioned application Figure 5 The method performed by the training device of the dazzling detection model disclosed in the illustrated embodiment can be applied to a processor or implemented by a processor. The processor may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by an integrated logic circuit of hardware in the processor or an instruction in the form of software. The above processor may be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it may also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present application can be implemented or executed. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc. The steps of the method disclosed in conjunction with the embodiments of the present application can be directly embodied as being executed by a hardware decoding processor, or executed by a combination of hardware and software modules in a decoding processor. The software module can be located in a storage medium mature in the art such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory, and the processor reads the information in the memory and completes the steps of the above method in combination with its hardware.

[0164] The electronic device may also perform Figure 1 The method and the living body detection device are realized in Figure 1 Alternatively, the electronic device may also perform the functions of the embodiments shown. Figure 5 The method is used to implement the training device of the dazzle detection model. Figure 5 The functions of the illustrated embodiment will not be described in detail in the embodiments of the present application.

[0165] Of course, in addition to software implementation methods, the electronic device of the present application does not exclude other implementation methods, such as logic devices or a combination of software and hardware, etc. That is to say, the execution subject of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.

[0166] The embodiment of the present application also provides a computer-readable storage medium, which stores one or more programs, wherein the one or more programs include instructions, which, when executed by a portable electronic device including a plurality of application programs, enable the portable electronic device to execute Figure 1 The method of the embodiment shown is specifically used to perform the following operations:

[0167] Acquire a video to be detected, wherein the video to be detected is obtained by shooting the object to be detected under the illumination of light of the target light color sequence;

[0168] Extracting video features of the video to be detected through the target dazzle detection model based on the attention mechanism and the temporal relationship between video frames in the video to be detected;

[0169] By using the target dazzle color detection model, light color detection is performed based on the video features to obtain a predicted light color sequence;

[0170] Based on the target light color sequence and the predicted light color sequence, a liveness detection result of the object to be detected is determined.

[0171] Alternatively, when the instruction is executed by a portable electronic device including a plurality of application programs, the portable electronic device can execute Figure 5 The method of the embodiment shown is specifically used to perform the following operations:

[0172] Acquire a sample video, where the sample video is obtained by shooting a sample object under the illumination of a sample light color sequence;

[0173] Extracting video features of the sample video based on an attention mechanism and a temporal relationship between video frames in the sample video by using a dazzle detection model to be trained;

[0174] Using the dazzling color detection model, light color detection is performed based on the video features to obtain a predicted light color sequence;

[0175] Based on the sample light color sequence and the predicted light color sequence, the dazzle detection model is updated and trained to obtain a target dazzle detection model.

[0176] In short, the above description is only a preferred embodiment of the present application and is not intended to limit the protection scope of the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.

[0177] The systems, devices, modules or units described in the above embodiments may be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, the computer may be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.

[0178] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.

[0179] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.

[0180] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

Claims

1. A method for detecting a living body, characterized in that: include: Acquire a video to be detected, wherein the video to be detected is obtained by shooting the object to be detected under the illumination of light of the target light color sequence; Extracting video features of the video to be detected through the target dazzle detection model based on the attention mechanism and the temporal relationship between video frames in the video to be detected; By using the target dazzle color detection model, light color detection is performed based on the video features to obtain a predicted light color sequence; Based on the target light color sequence and the predicted light color sequence, a liveness detection result of the object to be detected is determined.

2. The method according to claim 1, characterized in that The video features include image features of each video frame in the video to be detected, and each light color in the target light color sequence has a duration; The method of performing light color detection based on the video features by using the target glare detection model to obtain a predicted light color sequence includes: Based on the duration of each light color in the target light color sequence, determining the video frame corresponding to each light color from the video to be detected; Based on the image features of the video frames corresponding to each light color, light color detection is performed on each video frame to obtain the predicted light color of each video frame; The predicted light color sequence is determined based on the predicted light color of each video frame in the video to be detected.

3. The method according to claim 1, characterized in that The target dazzle detection model is used to extract video features of the video to be detected based on the attention mechanism and the temporal relationship between video frames in the video to be detected, including: Performing spatial mapping on each video frame in the video to be detected to obtain a spatial feature image of each video frame; Based on the attention mechanism and the temporal relationship between each video frame, feature extraction is performed on the spatial feature image of each video frame to obtain the video feature.

4. The method according to any one of claims 1 to 3, characterized in that Each light color in the target light color sequence is randomly selected from a preset light color set, and any two adjacent light colors in the target light color sequence are different.

5. A method for training a dazzle detection model, characterized in that: include: Acquire a sample video, where the sample video is obtained by shooting a sample object under the illumination of a sample light color sequence; Extracting video features of the sample video based on an attention mechanism and a temporal relationship between video frames in the sample video by using a dazzle detection model to be trained; Using the dazzling color detection model, light color detection is performed based on the video features to obtain a predicted light color sequence; Based on the sample light color sequence and the predicted light color sequence, the dazzle detection model is updated and trained to obtain a target dazzle detection model.

6. The method according to claim 5, characterized in that The video features include image features of each video frame in the sample video, the predicted light color sequence is obtained by combining the predicted light colors of each video frame in the sample video, and the predicted light color of each video frame is obtained by predicting the light color based on the image features of each video frame; The updating and training of the dazzle detection model based on the sample light color sequence and the predicted light color sequence includes: Determine the predicted sub-loss corresponding to each light color in the sample light color sequence based on the light color value difference between the predicted light color sequence and the light color with the same sequence number in the sample light color sequence; The dazzle detection model is updated based on the sum of the prediction sub-losses corresponding to each light color in the sample light color sequence.

7. The method according to claim 5, characterized in that The sample video includes sample videos of N sizes, where N is an integer greater than 2; the sample light color sequence includes a sample light color sequence of a sample video of each size; The updating and training of the dazzle detection model based on the sample light color sequence and the predicted light color sequence to obtain a target dazzle detection model includes: Based on the sample light color sequence and the predicted light color sequence of the sample video of the first size, the dazzle detection model to be trained is updated and trained to obtain the dazzle detection model corresponding to the first size; Based on the sample light color sequence and the predicted light color sequence of the sample video of the i-th size, the color detection model corresponding to the i-1th size is trained to obtain the color detection model corresponding to the i-th size, wherein 1<i≤N, and the predicted light color sequence of the sample video of the i-th size is obtained by inputting the sample video of the i-th size into the color detection model corresponding to the i-1th size; If i is less than N, then i is incremented by 1 and assigned to i, triggering the step of updating and training the colorful model corresponding to the i-1th size based on the sample light color sequence and the predicted light color sequence of the sample video of the i-th size; If i is equal to N, the dazzle detection model corresponding to the i-th size is used as the target dazzle detection model.

8. The method according to claim 5, characterized in that The sample videos include sample videos of N sizes, and the video features of the sample videos are extracted based on the attention mechanism and the temporal relationship between video frames in the sample videos by the dazzle detection model to be trained, including: Generate a template image with the same size as the sample video, wherein the pixel value of each pixel in the template image is a first pixel value; Based on the area where the sample object is located in each video frame of the sample video, modify the pixel values ​​of the pixels in the target area of ​​the template image to a second pixel value to obtain a mask image corresponding to each video frame, wherein the target area corresponds to the area where the sample object is located; Each video frame and the mask image corresponding to each video frame are operated to obtain the masked video frame, and based on the attention mechanism and the temporal relationship between the video frames in the sample video, the features of the masked video frame are extracted.

9. A living body detection device, characterized in that: include: An acquisition unit, used for acquiring a video to be detected, wherein the video to be detected is obtained by shooting the object to be detected under the illumination of light of a target light color sequence; An extraction unit, configured to extract video features of the video to be detected through a target dazzle detection model based on an attention mechanism and a temporal relationship between video frames in the video to be detected; A detection unit, configured to perform light color detection based on the video features by using the target dazzle color detection model to obtain a predicted light color sequence; The detection unit is further used to determine a liveness detection result of the object to be detected based on the target light color sequence and the predicted light color sequence.

10. A training device for a dazzle detection model, characterized in that: include: An acquisition unit, used to acquire a sample video, wherein the sample video is obtained by shooting a sample object under the illumination of light of a sample light color sequence; An extraction unit, configured to extract video features of the sample video through a dazzle detection model to be trained based on an attention mechanism and a temporal relationship between video frames in the sample video; A detection unit, configured to perform light color detection based on the video features by using the dazzling color detection model to obtain a predicted light color sequence; A training unit is used to update and train the dazzle detection model based on the sample light color sequence and the predicted light color sequence to obtain a target dazzle detection model.

11. An electronic device, characterized in that: include: processor; a memory for storing instructions executable by the processor; The processor is configured to execute the instructions to implement the liveness detection method as described in any one of claims 1 to 4; or, the processor is configured to execute the instructions to implement the training method of the dazzle detection model as described in any one of claims 5 to 8.

12. A computer-readable storage medium, characterized in that: When the instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the liveness detection method as described in any one of claims 1 to 4; or, when the instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the training method of a dazzle detection model as described in any one of claims 5 to 8.