A model compression method, device, storage medium, product and electronic equipment
By deploying a compressed detection model in the terminal device and combining it with performance degradation prediction and adaptive adjustment, the problems of low efficiency and large storage space consumption in liveness detection are solved, achieving efficient and secure face recognition liveness detection.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-24
- Publication Date
- 2026-03-10
AI Technical Summary
Existing technologies for facial recognition have low efficiency in detecting liveness attacks and pose risks to user privacy and security. Furthermore, installing the model directly on mobile terminal devices consumes a large amount of storage space.
A compressed detection model is used for liveness detection. The initial detection model is trained using a multimodal pre-trained model to obtain a basic detection model. The compressed detection model is then deployed on the terminal device. Combined with performance degradation prediction and adaptive adjustment processing, the model performance is ensured.
It improves the safety and convenience of liveness detection, reduces storage space usage, and ensures the detection performance of the model through performance prediction and adjustment.
Smart Images

Figure CN116824310B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a model compression method, apparatus, storage medium, product, and electronic device. Background Technology
[0002] Facial recognition is increasingly used in information security, becoming a crucial means of identity verification in daily life. Current technologies can distinguish between genuine facial recognition and malicious liveness detection by capturing facial images. These technologies typically utilize mobile devices or cameras to acquire facial images, then send them to cloud servers for unified liveness detection. However, this transmission process poses privacy risks and reduces detection efficiency due to the double data transmission. Directly installing liveness detection models on users' mobile devices consumes significant storage and RAM. Therefore, a lightweight liveness detection method is needed. Summary of the Invention
[0003] This application provides a model compression method, apparatus, storage medium, and electronic device. By using the compressed model for liveness detection, the safety and convenience of liveness detection can be improved. Furthermore, the performance degradation of the compressed detection model can be predicted, thereby enabling adjustments to the compressed detection model and further ensuring its performance. The technical solution is as follows:
[0004] In a first aspect, embodiments of this application provide a model compression method, the method comprising:
[0005] A compressed detection model is used to perform liveness detection on the acquired face images to obtain a preset number of detection results;
[0006] Based on the preset number of detection results, performance degradation prediction processing is performed to obtain the difference value of each detection result in the preset number of detection results;
[0007] The average value of the difference in detection results corresponding to each detection result is calculated to obtain the performance difference value of the compressed detection model.
[0008] If the performance difference value does not meet the performance degradation threshold, an adaptive method is used to obtain the scaling parameter, and the scaling parameter is used to adjust the compression detection model.
[0009] Secondly, embodiments of this application provide a model compression apparatus, the apparatus comprising:
[0010] The detection result acquisition module is used to perform liveness detection processing on the acquired face images using a compressed detection model and obtain a preset number of detection results;
[0011] The performance degradation prediction module is used to perform performance degradation prediction processing based on the preset number of detection results, and to obtain the detection result difference value corresponding to each detection result in the preset number of detection results;
[0012] The difference value acquisition module is used to calculate the average value of the difference value of each detection result to obtain the performance difference value of the compressed detection model.
[0013] The adjustment processing module is used to obtain a proportional parameter in an adaptive manner if the performance difference value does not meet the performance decay threshold, and then adjust the compression detection model using the proportional parameter.
[0014] Thirdly, embodiments of this application provide a computer storage medium storing a plurality of instructions adapted for loading by a processor and executing the above-described method steps.
[0015] Fourthly, embodiments of this application provide a computer program product that stores multiple instructions adapted for loading by a processor and executing the above-described method steps.
[0016] Fifthly, embodiments of this application provide an electronic device that may include: a processor and a memory; wherein the memory stores a computer program adapted to be loaded by the processor and to execute the above-described method steps.
[0017] In one or more embodiments of this application, a compressed detection model is used to perform liveness detection on the acquired face images, obtaining a preset number of detection results. Based on these preset number of detection results, performance degradation prediction processing is performed to obtain the difference value of each detection result among the preset number of results. The average value of these difference values is calculated to obtain the performance difference value of the compressed detection model. If the performance difference value does not meet the performance degradation threshold, an adaptive scaling parameter is obtained, and the compressed detection model is adjusted using this scaling parameter. Using a compressed model for liveness detection improves the security and convenience of liveness detection, and predicting the performance degradation of the compressed detection model allows for adjustment, further ensuring the performance of the compressed detection model. Attached Figure Description
[0018] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0019] Figure 1 This is a schematic diagram illustrating an example of basic detection model training processing provided in an embodiment of this application;
[0020] Figure 2 This is a schematic flowchart of a model compression method provided in an embodiment of this application;
[0021] Figure 3 This is a schematic flowchart of a model compression method provided in an embodiment of this application;
[0022] Figure 4 This is an example diagram illustrating a compression process provided in an embodiment of this application;
[0023] Figure 5 This is an example diagram illustrating the training of a performance degradation prediction model provided in an embodiment of this application;
[0024] Figure 6 This is a schematic diagram of a process for adjusting a compression detection model using proportional parameters, provided in an embodiment of this application.
[0025] Figure 7 This is a schematic diagram of the structure of a model compression device provided in an embodiment of this application;
[0026] Figure 8 This is a schematic diagram of the structure of a model compression device provided in an embodiment of this application;
[0027] Figure 9 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0028] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0029] Users can use terminal devices for facial recognition processing. Facial recognition processing can be used to obtain user identity information. The terminal device can capture facial images containing the user's face through its camera function, and then perform facial recognition processing based on the facial images. However, before this, the terminal device needs to perform liveness detection processing on the facial images to determine whether the captured facial images are the user's real facial images or liveness attack operations. The terminal device can be a mobile phone, tablet, wearable device, or access control device with camera function, etc.
[0030] The model compression device can obtain a basic detection model for liveness detection through training. This basic detection model can perform liveness detection on face images. When a face image is input into the basic detection model, it outputs a detection result indicating whether the face image is a real face or a liveness attack. If the face image is a real face, the model compression device can continue to instruct the terminal device to perform face recognition processing. If the face image is a liveness attack, the model compression device can refuse to perform face recognition processing and send a liveness attack warning message to the terminal device. This warning message alerts relevant personnel or users to the presence of a liveness attack on the face recognition process, prompting them to take appropriate action. It can be understood that the detection result represents the probability of a liveness attack. If the attack probability is greater than or equal to an attack probability threshold, the face image is considered a liveness attack; if the attack probability is less than the threshold, the face image is considered a real face. The attack probability threshold can be an initial setting of the model compression device or can be set by the user or relevant personnel, for example, it could be 50%.
[0031] Deploying the basic detection model directly on the terminal device would consume excessive storage space and RAM. Therefore, a model compression device can compress the basic detection model to obtain a compressed detection model. This compressed model, essentially the compressed version of the basic detection model, possesses the same functionality and can perform liveness detection on face images. The model compression device allows the compressed detection model to be deployed on the terminal device for liveness detection on face images, achieving this without consuming excessive storage space or RAM, thus ensuring both efficiency and privacy during the liveness detection process.
[0032] The model compression device can train an initial detection model based on a multimodal pre-trained model to obtain a basic detection model. When a face image is input into the initial detection model, it outputs the image features and detection results corresponding to the face image. The image features are the feature vectors of the face image, and the detection results are the liveness detection results for the face image. The multimodal pre-trained model can generate text features based on text. Text refers to text data describing the image. For example, "A person is holding a mobile phone, and the phone screen shows a face image" can be considered text describing a liveness attack image, while "A person with pigtails" can be considered text describing a real face image. The multimodal pre-trained model can simulate the corresponding simulated image based on the text and then obtain the image features corresponding to the simulated image. These simulated image features are the text features of the text. It can be understood that the text can describe a liveness attack image or a real face image. Training the initial detection model based on the multimodal pre-trained model can improve the basic detection model's ability to distinguish liveness attack images. Please refer to [link to relevant documentation]. Figure 1 This document provides an example of a basic detection model training process. The model compression device can acquire at least one sample face image, along with sample image features and detection results corresponding to each sample face image. The sample face image is used as the input to the initial detection model, and the sample image features and detection results corresponding to each sample face image are used as the output. It can also acquire at least one sample text, along with sample text features corresponding to each sample text. The sample text is used as the input to a cross-modal pre-trained model, and the sample text features are used as the output. The model is trained using a cross-entropy loss function and cross-modal consistency between sample image features and sample text features as loss functions until the initial detection model converges, thus obtaining the basic detection model. Cross-modal consistency can be the Euclidean distance between sample image features and sample text features. During model training, the cross-modal consistency needs to decrease, and the sample image features and sample text features need to be as similar as possible.
[0033] The model compression method provided in this application will be described in detail below with reference to specific embodiments.
[0034] Please see Figure 2 The diagram below illustrates a model compression method provided in this application. Figure 2 As shown, the method described in this application embodiment may include the following steps S102-S108.
[0035] S102, a compressed detection model is used to perform liveness detection processing on the acquired face images to obtain a preset number of detection results.
[0036] Specifically, the model compression device can compress the basic detection model to obtain a compressed detection model, and then deploy the compressed detection model in the terminal device. When the terminal device needs to perform face recognition processing, it can capture a face image containing the user's face through the camera function. The model compression device can use the compressed detection model deployed in the terminal device to perform liveness detection processing on the face image. If the detection result output by the compressed detection model shows that the face image is a real face image, then face recognition processing continues. If the detection result output by the compressed detection model shows that the face image is a liveness attack, then face recognition processing is not performed. The model compression device can also send a liveness attack warning message to the terminal device.
[0037] The model compression device can acquire liveness detection results during the liveness detection process of acquired face images using a compressed detection model on a terminal device, until a preset number of detection results are obtained. This indicates that the compressed detection model has undergone liveness detection processing for a long time and multiple times, and the model compression device needs to test the performance of the compressed detection model. The preset number can be the initial setting of the model compression device, or it can be set by the user or relevant personnel. For example, the preset number can be 5000.
[0038] S104, based on a preset number of test results, perform performance degradation prediction processing to obtain the test result difference value corresponding to each test result in the preset number of test results.
[0039] Specifically, after the model compression device obtains a preset number of detection results, it can perform performance degradation prediction processing on the compressed detection model based on these preset number of detection results, thereby obtaining the difference value of each detection result among the preset number of detection results. Performance degradation prediction processing is used to detect the difference between the performance of the compressed detection model and the basic detection model. Because the compressed detection model is obtained by compressing the basic detection model, its performance has a certain degree of degradation. Furthermore, the performance of the compressed detection model will also degrade over a long period of time and with repeated use. The model compression device needs to perform performance degradation prediction processing on the compressed detection model to obtain the degree of performance degradation of the compressed detection model, i.e., the performance difference between the compressed detection model and the basic detection model.
[0040] Performance degradation processing can predict the detection results of the base detection model for the same face image based on the detection results, and obtain the difference between the detection results of the compressed detection model and the predicted detection results of the base detection model. For example, after the target face image is processed by the compressed detection model for liveness detection, a target detection result can be obtained. The target detection result is any one of a preset number of detection results. The model compression device can perform performance degradation prediction processing based on the target detection result to predict the base detection result of the base detection model for the target face image, thereby obtaining the difference between the target detection result and the base detection result.
[0041] S106, calculate the average value of the difference values of the detection results corresponding to each detection result to obtain the performance difference value of the compressed detection model.
[0042] Specifically, the model compression device can calculate the average of the difference values corresponding to each detection result. The device can obtain the sum of the absolute values of the difference values for each detection result, and then divide this sum by a preset number to obtain the performance difference value of the compressed detection model. In essence, the performance difference value represents the performance difference between the compressed detection model and the base detection model, that is, the degree of performance degradation of the compressed detection model. Therefore, the larger the performance difference value, the greater the difference between the compressed detection model and the base detection model, and the greater the performance degradation of the compressed detection model. Conversely, the smaller the performance difference value, the smaller the difference between the compressed detection model and the base detection model, and the smaller the performance degradation of the compressed detection model.
[0043] S108 If the performance difference value does not meet the performance degradation threshold, the proportional parameter is obtained in an adaptive manner, and the proportional parameter is used to adjust the compression detection model.
[0044] Specifically, the model compression device can determine whether the performance difference value meets the performance degradation threshold. If it does not, it means that the model compression device needs to be adjusted. The model compression device can then use an adaptive method to obtain the proportional parameter and adjust the compressed detection model accordingly. The adaptive method means that the model compression device can obtain the proportional parameter based on the performance difference value, that is, based on the current performance degradation level of the compressed detection model. The proportional parameter can be the compression ratio of the compressed detection model relative to the basic detection model. Adjusting the compressed detection model means adjusting the compression ratio of the compressed detection model relative to the basic detection model.
[0045] The performance degradation threshold can be a first threshold and a second threshold, where the first threshold is less than the second threshold. This threshold is used to determine the degree of performance degradation of the compressed detection model and to determine what adjustments are needed. Understandably, if the performance difference value is greater than the second threshold, it indicates that the difference between the compressed detection model and the basic detection model is too large, leading to excessive performance degradation. Therefore, the compressed detection model needs to be expanded to increase its compression ratio relative to the basic detection model, thus ensuring its performance in liveness detection. Conversely, if the performance difference value is less than the first threshold, it indicates that the difference between the compressed detection model and the basic detection model is small, meaning the compressed detection model still has room for further compression. The model compression device can then compress the compressed detection model, reducing its compression ratio relative to the basic detection model, thereby reducing its size.
[0046] In this embodiment, a compressed detection model is used to perform liveness detection on the acquired face images, obtaining a preset number of detection results. Based on the preset number of detection results, performance degradation prediction processing is performed to obtain the difference value of each detection result among the preset number of detection results. The average value of the difference values of each detection result is calculated to obtain the performance difference value of the compressed detection model. If the performance difference value does not meet the performance degradation threshold, an adaptive method is used to obtain a scaling parameter, and the compressed detection model is adjusted using the scaling parameter. By using a compressed model for liveness detection, the security and convenience of liveness detection are improved, and the performance degradation of the compressed detection model is predicted, thereby enabling adjustment processing of the compressed detection model and further ensuring the performance of the compressed detection model.
[0047] Please see Figure 3 The diagram below illustrates a model compression method provided in this application. Figure 3 As shown, the method described in this application embodiment may include the following steps S202-S214.
[0048] S202, compress the basic detection model based on a preset compression ratio to obtain a compressed detection model.
[0049] Specifically, the model compression device can compress the basic detection model based on a preset compression ratio to obtain a compressed detection model, and then deploy the compressed detection model on the terminal device for liveness detection. The preset compression ratio can be an initial setting of the model compression device or can be set by the user or relevant personnel; for example, it can be 60%. If the preset compression ratio is 60%, it means that the compressed detection model is compressed by 60% relative to the basic detection model.
[0050] Optionally, compression can reduce the absolute values of the parameter weights in the basic detection model. The sum of the absolute values of all parameter weights in the compressed model will decrease. The preset compression ratio is the compression ratio of the compressed detection model relative to the basic detection model. This compression ratio can be the ratio of the sum of the absolute values of all parameter weights in the compressed detection model to the sum of the absolute values of all parameter weights in the basic detection model. It is understandable that when the model compression device deploys the compressed detection model on a terminal device, parameters with zero weights in the compressed detection model can be deleted.
[0051] Optionally, the model compression device does not compress the basic detection model to the preset compression ratio all at once. Instead, it performs multiple compression processes on the basic detection model until the preset compression ratio is met. The compression ratio for each process can be the same or different. The compression ratio for each process can be obtained from the compression ratio allocation module. The current compression ratio of the basic detection model being compressed is input into the compression ratio allocation module, which then outputs the target compression ratio to be used in the next compression process. For example, if the compression ratio of the basic detection model is 90% (i.e., the current compression ratio is 90%), this current compression ratio is input into the compression ratio allocation module, which outputs the target compression ratio. The target compression ratio indicates the compression ratio for the next compression process of the basic detection model. For instance, if the target compression ratio is 80%, the model compression device will compress the basic detection model, which is already compressed to 90%, down to 80%, until the model compression device compresses the basic detection model to the preset compression ratio, resulting in a compressed detection model.
[0052] Please see also Figure 4This document provides an example of compression processing in an embodiment of this application. The model compression device trains the basic detection model under compression based on a compression ratio allocation module and a basic detection model until the basic detection model is compressed to a preset compression ratio, thus obtaining a compressed detection model. The model compression device inputs the current compression ratio of the basic detection model under compression into the compression ratio allocation module, which outputs a target compression ratio. The model compression device then compresses the basic detection model to meet the target compression ratio. The model compression device can acquire at least one compressed face image and input it into the basic detection model under compression. The basic detection model under compression can output the compressed image features and compression detection results of each compressed face image in the at least one compressed face image. It can also input at least one compressed face image into the basic detection model, which can output the comparison image features and comparison detection results corresponding to each compressed face image in the at least one compressed face image. The loss function corresponding to the compression process can be the cross-entropy function, the liveness feature consistency between compressed image features and contrast image features, and the coherence constraint between the current compression ratio and the target compression ratio. The model is trained using the loss function corresponding to the compression process until it converges, resulting in a compressed detection model compressed to the preset compression ratio.
[0053] Among them, the liveness feature consistency, which is the difference between the compressed image features and the contrast image features, can be the Euclidean distance between the compressed image features and the contrast image features. The model compression device can make the compressed image features and the contrast image features as similar as possible and the differences as small as possible during the compression process, thereby ensuring the functionality of the obtained compressed detection model.
[0054] S204. If a liveness detection command is received, a compressed detection model is used to perform liveness detection processing on the acquired face image.
[0055] Specifically, when a terminal device needs to perform facial recognition processing, it can capture a facial image containing the user's face through its camera function. The model compression device can use a compression detection model deployed in the terminal device to perform liveness detection processing on the facial image. If the detection result output by the compression detection model shows that the facial image is a real facial image, then facial recognition processing continues. If the detection result output by the compression detection model shows that the facial image is a liveness attack, then facial recognition processing is not performed. The model compression device can also send a liveness attack warning message to the terminal device.
[0056] S206, obtain the detection results of the liveness detection results with a preset probability, until a preset number of detection results are obtained.
[0057] Specifically, the model compression device can acquire liveness detection results during the liveness detection processing of the acquired face images using a compressed detection model on the terminal device, until a preset number of detection results are obtained. This indicates that the compressed detection model has undergone liveness detection processing for a long time and multiple times, and the model compression device needs to test the performance of the compressed detection model. The preset number can be the initial setting of the model compression device, or it can be set by the user or relevant personnel. For example, the preset number can be 5000.
[0058] When the terminal device performs liveness detection using the compressed detection model each time, the model compression device can obtain the detection result of this liveness detection process with a preset probability. The preset probability can be the initial setting of the model compression device, or it can be set by the user or relevant personnel, for example, it can be 50%.
[0059] S208, based on a preset number of test results, performs performance degradation prediction processing to obtain the difference value of each test result among the preset number of test results.
[0060] Specifically, after the model compression device obtains a preset number of detection results, it can perform performance degradation prediction processing on the compressed detection model based on these results to obtain the difference value of each detection result among the preset number of results. Performance degradation prediction processing is used to detect the difference between the performance of the compressed detection model and the basic detection model. Because the compressed detection model is obtained by compressing the basic detection model, its performance is inevitably attenuated. Furthermore, the performance of the compressed detection model will also degrade over a long period and with repeated use. The model compression device needs to perform performance degradation prediction processing on the compressed detection model to obtain the degree of performance degradation, i.e., the performance difference between the compressed detection model and the basic detection model. Performance degradation processing can predict the detection results of the basic detection model for the same face image based on the detection results, and obtain the difference value between the detection results of the compressed detection model and the predicted detection results of the basic detection model.
[0061] Optionally, the model compression device can acquire target detection results from a preset number of detection results. The target detection result is any one of the preset number of detection results. The model compression device can perform performance degradation prediction processing based on the target detection result to predict the basic detection result corresponding to the basic detection model. For example, if the target detection result is the liveness detection result of the compressed detection model for the target face image, the model compression device can predict the basic detection result of the basic detection model for the target face image, and then obtain the detection result difference value based on the target detection result and the basic detection result.
[0062] Optionally, the model compression device can employ a performance degradation prediction model for performance degradation prediction processing. The detection results are input into the performance degradation prediction model, which then outputs the corresponding result difference values. The model compression device can train an initial degradation prediction model based on a basic detection model and a compressed detection model to obtain the performance degradation prediction model. Please refer to [link / reference]. Figure 5 This document provides an example of training a performance degradation prediction model. The model compression device can acquire at least one degradation training face image, input it into a compressed detection model, and obtain degradation compressed image features and degradation compressed detection results corresponding to each degradation training face image. It can also input at least one degradation training face image into a basic detection model, obtaining degradation basic image features and degradation basic detection results corresponding to each degradation training face image. The model compression device can use the degradation compressed image features and degradation compressed detection results as input and the degradation basic image features and degradation basic detection results as output to train the initial degradation prediction model. The loss function in the training process of the initial degradation prediction model can be a differential regression loss function. The model compression device can train the initial degradation prediction model based on this loss function until the model converges, thereby obtaining the performance degradation prediction model. It is understood that by inputting the target image features and target detection results obtained by the compressed detection model based on the target face image into the performance degradation prediction model, the performance degradation prediction model can predict the basic image features and basic detection results of the basic detection model for the target face image.
[0063] S210: Calculate the average value of the difference values of the detection results corresponding to each detection result to obtain the performance difference value of the compressed detection model.
[0064] Specifically, the model compression device can calculate the average of the difference values corresponding to each detection result. The device can obtain the sum of the absolute values of the difference values for each detection result, and then divide this sum by a preset number to obtain the performance difference value of the compressed detection model. In essence, the performance difference value represents the performance difference between the compressed detection model and the base detection model, that is, the degree of performance degradation of the compressed detection model. Therefore, the larger the performance difference value, the greater the difference between the compressed detection model and the base detection model, and the greater the performance degradation of the compressed detection model. Conversely, the smaller the performance difference value, the smaller the difference between the compressed detection model and the base detection model, and the smaller the performance degradation of the compressed detection model.
[0065] Optionally, since the performance degradation prediction image can predict not only the basic detection results of the basic detection model but also the basic image features of the basic detection model, the model compression device can obtain the performance difference value not only based on the difference value of the detection results but also by combining the difference value of the detection results and the difference value of the feature vector. The feature vector difference value is the difference between the target feature vector and the basic feature vector. The model compression device can calculate a first average value by averaging the difference values of the detection results corresponding to each detection result, and it can also calculate a second average value by averaging the difference values of the feature vectors corresponding to each detection result. Then, it calculates the average of the first average value and the second average value to obtain the performance difference value of the compressed detection model.
[0066] S212, if the performance difference value does not meet the performance degradation threshold, the proportional parameter is obtained in an adaptive manner, and the proportional parameter is used to adjust the compression detection model.
[0067] Specifically, the model compression device can determine whether the performance difference value meets the performance degradation threshold. If it does not, it means that the model compression device needs to be adjusted. The model compression device can then use an adaptive method to obtain the proportional parameter and adjust the compressed detection model accordingly. The adaptive method means that the model compression device can obtain the proportional parameter based on the performance difference value, that is, based on the current performance degradation level of the compressed detection model. The proportional parameter can be the compression ratio of the compressed detection model relative to the basic detection model. Adjusting the compressed detection model means adjusting the compression ratio of the compressed detection model relative to the basic detection model.
[0068] Optionally, the performance degradation threshold can be a first threshold and a second threshold, where the first threshold is less than the second threshold. The performance degradation threshold is used to determine the degree of performance degradation of the compressed detection model and to determine what adjustments are needed. Understandably, if the performance difference value is greater than the second threshold, it indicates that the difference between the compressed detection model and the basic detection model is too large, leading to excessive performance degradation. Therefore, the compressed detection model needs to be expanded to increase the compression ratio relative to the basic detection model, thereby ensuring the performance of the compressed detection model in liveness detection. The model compression device can then obtain initial expansion parameters and adjust the compressed detection model based on these parameters. Conversely, if the performance difference value is less than the first threshold, it indicates that the difference between the compressed detection model and the basic detection model is small, meaning the compressed detection model still has room for further compression. The model compression device can then compress the compressed detection model, obtain initial compression parameters, and adjust the compressed detection model based on these parameters, reducing the compression ratio relative to the basic detection model, thereby reducing the size of the compressed detection model.
[0069] Optionally, the model compression device may adjust the compressed detection model once according to the initial expansion parameters or the initial basic compression parameters. However, this may not be enough to make the adjusted compressed detection model achieve a suitable compression ratio or performance. Therefore, the model compression device can perform a gradual adjustment of the compressed detection model, that is, perform multiple adjustments to the compressed detection model to gradually adjust the compression ratio and performance of the compressed detection model relative to the basic detection model.
[0070] Please see Figure 6 This application provides a schematic diagram illustrating the process of adjusting a compression detection model using proportional parameters, as described in an embodiment of the present application. Figure 6 As shown, the adjustment processing method of this application embodiment may include the following steps S302-S314.
[0071] S302, if the performance difference value does not meet the performance degradation threshold, then obtain the initial proportional parameter, and use the initial proportional parameter to adjust the compression detection model to obtain the first adjusted model.
[0072] Specifically, if the performance difference value does not meet the performance degradation threshold, the model compression device can obtain the initial scaling parameters and adjust the compression detection model based on the initial scaling parameters to obtain the first adjusted model.
[0073] Optionally, the performance degradation threshold can be a first threshold and a second threshold, where the first threshold is less than the second threshold. The initial scaling parameters can include initial compression parameters and initial expansion parameters. If the performance difference is less than the first threshold, the initial compression parameters are obtained, and the compression detection model is adjusted based on the initial compression parameters. If the performance difference is greater than the second threshold, the initial expansion parameters are obtained, and the compression detection model is adjusted based on the initial expansion parameters. The initial compression parameters and initial expansion parameters can be the initial settings of the model compression device, or they can be set by the user or relevant personnel. The values of the initial compression parameters and initial expansion parameters can be the same or different. For example, both the initial compression parameters and initial expansion parameters can be 10%, indicating that the current compression detection model is compressed or expanded by 10% relative to the basic detection model.
[0074] S304, determine whether the difference value of the result of the first adjustment model meets the performance degradation threshold.
[0075] Specifically, the model compression device can obtain the result difference value of the first adjusted model, determine whether the result difference value of the first adjusted model meets the performance decay threshold, and if the result difference value of the first adjusted model meets the performance decay threshold, then execute S306; if the result difference value of the first adjusted model does not meet the performance decay threshold, then execute S308.
[0076] Optionally, the model compression device can perform performance degradation prediction processing on the first adjusted model to obtain the result difference value of the first adjusted model. The model compression device can acquire a test face image, input the test face image into the first adjusted model for liveness detection processing, obtain the test detection result corresponding to the test face image, and then perform performance degradation prediction processing based on the test detection result to obtain the result difference value corresponding to the first adjusted model. It can be understood that the model compression device can input the test detection result into the performance degradation prediction model, and the performance degradation prediction model can output the result difference value corresponding to the test detection result, which is the result difference value corresponding to the first adjusted model.
[0077] S306, the first adjusted model is confirmed as the adjusted compression detection model.
[0078] Specifically, if the difference value of the result of the first adjusted model meets the performance decay threshold, it means that the liveness detection capability of the first adjusted model is good and no further adjustment is required. The model compression device can use the first adjusted model as the compressed detection model after adjustment and can continue to execute S214.
[0079] S308 uses an adaptive method to obtain the adjustment ratio parameter.
[0080] Specifically, if the difference value of the result of the first adjusted model does not meet the performance decay threshold, it means that the liveness detection capability of the first adjusted model is insufficient or that the first adjusted model still has room for further compression and needs to be adjusted again. The model compression device can use an adaptive method to obtain the adjustment ratio parameter of the first adjusted model, that is, it can obtain the adjustment ratio parameter based on the difference value of the result of the first adjusted model.
[0081] Optionally, the model compression device can use an adaptive scaling module to obtain the scaling parameters. The adaptive scaling module can determine the appropriate scaling parameters for the next adjustment of the first adjusted model based on the difference value of the results of the first adjusted model. The model compression device can input the difference value of the results of the first adjusted model into the adaptive scaling module, and the adaptive scaling module can output the scaling parameters.
[0082] S310, the first adjustment model is adjusted using the adjustment ratio parameter to obtain the second adjustment model.
[0083] Specifically, the model compression device can adjust the first adjusted model using an adjustment ratio parameter to obtain the second adjusted model. For example, if the compression ratio of the first adjusted model relative to the basic adjusted model is 60%, and the adjustment ratio parameter is a compression parameter of 10%, the model compression device can compress the first adjusted model to a compression ratio of 50% relative to the basic adjusted model, thus obtaining the second adjusted model. If the adjustment ratio parameter is an expansion parameter of 10%, the model compression device can expand the first adjusted model to a compression ratio of 70% relative to the basic adjusted model, thus obtaining the second adjusted model. It is understood that the adjustment ratio parameter can be either a compression parameter or an expansion parameter.
[0084] S312, determine whether the difference value of the result of the second adjustment model meets the performance degradation threshold.
[0085] Specifically, the model compression device can obtain the result difference value of the second adjusted model and determine whether the result difference value of the second adjusted model meets the performance degradation threshold. If the result difference value of the second adjusted model does not meet the performance degradation threshold, then S314 is executed; if the result difference value of the second adjusted model meets the performance degradation threshold, then S316 is executed.
[0086] Optionally, the method by which the model compression device obtains the result difference value of the second adjusted model is the same as the method by which it obtains the result difference value of the first adjusted model; please refer to S304.
[0087] S314, the second adjustment model is confirmed as the first adjustment model.
[0088] Specifically, if the difference value of the result of the second adjustment model does not meet the performance decay threshold, it means that the liveness detection capability of the second adjustment model is insufficient or that the second adjustment model still has room for further compression and needs to be adjusted again. In this case, the model compression device can identify the second adjustment model as the first adjustment model and continue to execute step S308, using an adaptive method to obtain the adjustment ratio parameter, and then using the adjustment ratio parameter to perform the adjustment process again.
[0089] S316, The second adjusted model is confirmed as the adjusted compression detection model.
[0090] Specifically, if the difference value of the result of the second adjusted model meets the performance degradation threshold, it means that the liveness detection capability of the second adjusted model is good and no further adjustment is required. The model compression device can use the second adjusted model as the compressed detection model after adjustment and can continue to execute S214.
[0091] It is understandable that S302-S316 can be the training process of the compressed detection model by the model compression device, thereby obtaining the adjusted compressed detection model. The model compression device can train the compressed detection model based on the adaptive scaling module and the performance degradation prediction model to obtain the adjusted compressed detection model. The model compression device can acquire a test face image, input the test face image into the compressed detection model to obtain the test detection result corresponding to the test face image, then input the test detection result into the performance degradation prediction model to obtain the result difference value corresponding to the test detection result, then input the result difference value corresponding to the test detection result into the adaptive scaling module to obtain the scaling parameter, and then use the scaling parameter to adjust the compressed detection model. The loss function in the training process can be the cross-entropy function, the smoothing loss between each scaling parameter, and the result difference value. During the training process, the loss function is minimized until the result difference value meets the performance degradation threshold, thereby obtaining the adjusted compressed detection model.
[0092] S214, The compressed detection model is replaced with the adjusted compressed detection model, and the liveness detection process is performed on the acquired face image using the adjusted compressed detection model.
[0093] Specifically, the model compression device can replace the compressed detection model with an adjusted compressed detection model. That is, the adjusted compressed detection model is deployed in the terminal device, the compressed detection model in the terminal device is deleted, and then the adjusted compressed detection model is used to perform liveness detection processing on the acquired face images.
[0094] Optionally, the adjusted compression detection model can be confirmed as the compression detection model, and step S202 can be executed.
[0095] In this embodiment, a basic detection model is compressed based on a preset compression ratio to obtain a compressed detection model. This compression process can be repeated multiple times until the preset compression ratio is met, averaging the compression ratios across multiple compression processes and ensuring the performance of the compressed detection model during the compression process. If a liveness detection command is received, the compressed detection model is used to perform liveness detection processing on the acquired face image. Liveness detection results are obtained with a preset probability until a preset number of results are obtained. This allows the compressed detection model to be tested and adjusted after prolonged and repeated use, ensuring the accuracy of liveness detection processing on the terminal device. Performance degradation prediction processing is performed based on the preset number of detection results. The difference values corresponding to each detection result within the preset number of results are obtained, and the average value of these difference values is calculated to obtain the performance difference value of the compressed detection model. A performance degradation prediction model can then be used to predict performance degradation, ensuring the accuracy of the performance degradation prediction. If the performance difference does not meet the performance degradation threshold, an adaptive approach is used to obtain the scaling parameter. This scaling parameter is then used to adjust the compressed detection model, which is then used to replace the original compressed detection model. The adjusted compressed detection model is then used to perform liveness detection on the acquired face images. Using the compressed model for liveness detection improves the security and convenience of liveness detection and predicts the performance degradation of the compressed detection model, thus enabling adjustments and further ensuring its performance. Furthermore, the compressed detection model can be progressively adjusted multiple times, gradually adjusting its compression ratio and performance relative to the base detection model.
[0096] The following will be combined with the appendix Figure 7 - Appendix Figure 8 This paper provides a detailed description of the model compression apparatus provided in the embodiments of this application. It should be noted that the appendix... Figure 7 - Appendix Figure 8 The model compression device in the present application is used to perform the model compression device in this application. Figures 2-6 The methods shown in the embodiments are for illustrative purposes only, illustrating the parts relevant to the embodiments of this application. For specific technical details not disclosed, please refer to this application. Figures 2-6 The example shown.
[0097] Please see Figure 7 This illustration shows a schematic diagram of a model compression apparatus provided in an exemplary embodiment of this application. The model compression apparatus can be implemented as all or part of a device through software, hardware, or a combination of both. The device 1 includes a detection result acquisition module 11, a performance degradation prediction module 12, a difference value acquisition module 13, and an adjustment processing module 14.
[0098] The detection result acquisition module 11 is used to perform liveness detection processing on the acquired face images using a compressed detection model, and obtain a preset number of detection results;
[0099] The performance degradation prediction module 12 is used to perform performance degradation prediction processing based on the preset number of detection results, and obtain the detection result difference value corresponding to each detection result in the preset number of detection results;
[0100] The difference value acquisition module 13 is used to calculate the average value of the difference value of each detection result to obtain the performance difference value of the compressed detection model.
[0101] The adjustment processing module 14 is used to obtain a proportional parameter in an adaptive manner if the performance difference value does not meet the performance decay threshold, and to adjust the compression detection model using the proportional parameter.
[0102] In this embodiment, a compressed detection model is used to perform liveness detection on the acquired face images, obtaining a preset number of detection results. Based on these preset number of detection results, performance degradation prediction is performed to obtain the difference value of each detection result among the preset number of results. The average value of the difference values is calculated to obtain the performance difference value of the compressed detection model. If the performance difference value does not meet the performance degradation threshold, an adaptive scaling parameter is obtained, and the compressed detection model is adjusted using the scaling parameter. By using a compressed model for liveness detection, the security and convenience of liveness detection are improved, and the performance degradation of the compressed detection model is predicted, thereby enabling adjustment of the compressed detection model and further ensuring its performance.
[0103] Please see Figure 8 This illustration shows a schematic diagram of a model compression apparatus provided in an exemplary embodiment of this application. The model compression apparatus can be implemented as all or part of the apparatus through software, hardware, or a combination of both. The apparatus includes a model compression module 15, a detection result acquisition module 11, a performance degradation prediction module 12, a difference value acquisition module 13, an adjustment processing module 14, and a model replacement module 16.
[0104] The model compression module 15 is used to compress the basic detection model based on a preset compression ratio to obtain a compressed detection model.
[0105] The detection result acquisition module 11 is used to perform liveness detection processing on the acquired face images using a compressed detection model, and obtain a preset number of detection results;
[0106] Optionally, the detection result acquisition module 11 is specifically used to perform liveness detection processing on the acquired face image using a compressed detection model if a liveness detection instruction is received.
[0107] The detection results of liveness detection are obtained at a preset probability until a preset number of detection results are obtained.
[0108] The performance degradation prediction module 12 is used to perform performance degradation prediction processing based on the preset number of detection results, and obtain the detection result difference value corresponding to each detection result in the preset number of detection results;
[0109] Optionally, the performance degradation prediction module 12 is specifically used to obtain the target detection result from the preset number of detection results;
[0110] Based on the target detection results, a performance degradation prediction process is performed to predict the basic detection results corresponding to the basic detection model.
[0111] Based on the target detection result and the basic detection result, the difference value of the detection result is obtained.
[0112] The difference value acquisition module 13 is used to calculate the average value of the difference value of each detection result to obtain the performance difference value of the compressed detection model.
[0113] The adjustment processing module 14 is used to obtain the proportional parameter in an adaptive manner if the performance difference value does not meet the performance decay threshold, and to adjust the compression detection model using the proportional parameter.
[0114] Optionally, the difference value acquisition module 13 is specifically used to acquire initial compression parameters if the performance difference value is less than a first threshold, and adjust the compression detection model based on the initial compression parameters;
[0115] If the performance difference value is greater than the second threshold, then the initial expansion parameters are obtained, and the compression detection model is adjusted based on the initial expansion parameters, wherein the first threshold is less than the second threshold.
[0116] Optionally, the difference value acquisition module 13 is specifically used to acquire an initial ratio parameter, and use the initial ratio parameter to adjust the compression detection model to obtain a first adjusted model;
[0117] If the difference value of the result of the first adjustment model does not meet the performance degradation threshold, then the adjustment ratio parameter is obtained in an adaptive manner.
[0118] The first adjustment model is adjusted using the aforementioned adjustment ratio parameter to obtain the second adjustment model;
[0119] If the difference value of the result of the second adjustment model does not meet the performance degradation threshold, then the second adjustment model is confirmed as the first adjustment model, and the step of obtaining the adjustment ratio parameter in an adaptive manner is executed.
[0120] If the difference value of the result of the second adjustment model meets the performance degradation threshold, then the second adjustment model is confirmed as the adjusted compression detection model.
[0121] Optionally, the difference value acquisition module 13 is specifically used to perform liveness detection processing on the test face image using the first adjustment model to obtain the test detection result;
[0122] The test results are subjected to performance degradation prediction processing to obtain the result difference value corresponding to the first adjustment model;
[0123] If the result parameters corresponding to the first adjustment model do not meet the performance degradation threshold, then the adjustment ratio parameter is obtained based on the result difference value corresponding to the first adjustment model.
[0124] Model replacement module 16 is used to replace the compressed detection model with the adjusted compressed detection model;
[0125] The adjusted compression detection model is used to perform liveness detection on the acquired face images.
[0126] In this embodiment, a basic detection model is compressed based on a preset compression ratio to obtain a compressed detection model. This compression process can be repeated multiple times until the preset compression ratio is met, averaging the compression ratios across multiple compression processes and ensuring the performance of the compressed detection model during the compression process. If a liveness detection command is received, the compressed detection model is used to perform liveness detection processing on the acquired face image. Liveness detection results are obtained with a preset probability until a preset number of results are obtained. This allows the compressed detection model to be tested and adjusted after long-term, multiple uses, ensuring the accuracy of liveness detection processing on the terminal device. Performance degradation prediction processing is performed based on the preset number of detection results. The difference values corresponding to each detection result within the preset number of results are obtained, and the average value of these difference values is calculated to obtain the performance difference value of the compressed detection model. A performance degradation prediction model can then be used to predict performance degradation, ensuring the accuracy of the performance degradation prediction. If the performance difference does not meet the performance degradation threshold, an adaptive approach is used to obtain the scaling parameter. This scaling parameter is then used to adjust the compressed detection model, which is then used to replace the original compressed detection model. The adjusted compressed detection model is then used to perform liveness detection on the acquired face images. Using the compressed model for liveness detection improves the security and convenience of liveness detection and predicts the performance degradation of the compressed detection model, thus enabling adjustments and further ensuring its performance. Furthermore, the compressed detection model can be progressively adjusted multiple times, gradually adjusting its compression ratio and performance relative to the base detection model.
[0127] It should be noted that the model compression device provided in the above embodiments is only illustrated by the division of the above functional modules when executing the model compression method. In practical applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. In addition, the model compression device and the model compression method embodiments provided in the above embodiments belong to the same concept, and the implementation process is detailed in the method embodiments, which will not be repeated here.
[0128] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0129] This application also provides a computer storage medium that can store multiple instructions, which are adapted to be loaded and executed by a processor as described above. Figures 1-6 The model compression method described in the illustrated embodiment can be found in the following documentation for its specific execution process. Figures 1-6 The specific details of the illustrated embodiments will not be elaborated here.
[0130] This application also provides a computer program product storing at least one instruction, which is loaded and executed by the processor as described above. Figures 1-6 The model compression method described in the illustrated embodiment can be found in the following documentation for its specific execution process. Figures 1-6 The specific details of the illustrated embodiments will not be elaborated here.
[0131] Please refer to Figure 9 This diagram illustrates a structural block diagram of an electronic device provided in an exemplary embodiment of this application. The electronic device in this application may include one or more components such as a processor 110, a memory 120, an input device 130, an output device 140, and a bus 150. The processor 110, memory 120, input device 130, and output device 140 may be connected via the bus 150.
[0132] Processor 110 may include one or more processing cores. Processor 110 connects to various parts of the electronic device using various interfaces and lines, and executes various functions of terminal 100 and processes data by running or executing instructions, programs, code sets, or instruction sets stored in memory 120, and by calling data stored in memory 120. Optionally, processor 110 may be implemented using at least one hardware form of Digital Signal Processing (DSP), Field-Programmable Gate Array (FPGA), or Programmable Logic Array (PLA). Processor 110 may integrate one or more of the following: Central Processing Unit (CPU), Graphics Processing Unit (GPU), and modem. The CPU primarily handles the operating system, user page, and applications; the GPU is responsible for rendering and drawing the displayed content; and the modem handles wireless communication. It is understood that the modem may also not be integrated into processor 110 and may be implemented separately using a communication chip.
[0133] The memory 120 may include random access memory (RAM) or read-only memory (ROM). Optionally, the memory 120 may include non-transitory computer-readable storage medium. The memory 120 may be used to store instructions, programs, code, code sets, or instruction sets. The memory 120 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for implementing at least one function (such as touch function, sound playback function, image playback function, etc.), instructions for implementing the various method embodiments described above, etc. The operating system may be the Android system, including systems deeply developed based on the Android system, the iOS system developed by Apple Inc., including systems deeply developed based on the iOS system, or other systems.
[0134] The memory 120 can be divided into operating system space and user space. The operating system runs in the operating system space, while native and third-party applications run in user space. To ensure that different third-party applications can achieve good running performance, the operating system allocates corresponding system resources for each application. However, different application scenarios within the same third-party application have different requirements for system resources. For example, in local resource loading scenarios, third-party applications have high requirements for disk read speed; in animation rendering scenarios, third-party applications have high requirements for GPU performance. Since the operating system and third-party applications are independent of each other, the operating system often cannot promptly perceive the current application scenario of a third-party application, resulting in the operating system's inability to adapt system resources accordingly.
[0135] In order for the operating system to distinguish the specific application scenarios of third-party applications, it is necessary to establish data communication between the third-party applications and the operating system. This would allow the operating system to obtain the current scenario information of the third-party applications at any time, and then perform targeted system resource adaptation based on the current scenario.
[0136] The input device 130 is used to receive input instructions or data, and includes, but is not limited to, a keyboard, mouse, camera, microphone, or touch device. The output device 140 is used to output instructions or data, and includes, but is not limited to, a display device and a speaker. In one example, the input device 130 and the output device 140 can be combined, and the input device 130 and the output device 140 can be a touch display screen.
[0137] The touch display screen can be designed as a full-screen, curved screen, or irregularly shaped screen. It can also be designed as a combination of a full-screen and a curved screen, or a combination of an irregularly shaped screen and a curved screen; however, this application does not limit the specific design in this regard.
[0138] In addition, those skilled in the art will understand that the structure of the electronic device shown in the above figures does not constitute a limitation on the electronic device. The electronic device may include more or fewer components than shown, or combine certain components, or have different component arrangements. For example, the electronic device may also include radio frequency circuits, input units, sensors, audio circuits, Wireless Fidelity (WiFi) modules, power supplies, Bluetooth modules, etc., which will not be described in detail here.
[0139] exist Figure 9 In the illustrated electronic device, the processor 110 can be used to call the model compression application stored in the memory 120 and specifically perform the following operations:
[0140] A compressed detection model is used to perform liveness detection on the acquired face images to obtain a preset number of detection results;
[0141] Based on the preset number of detection results, performance degradation prediction processing is performed to obtain the difference value of each detection result in the preset number of detection results;
[0142] The average value of the difference in detection results corresponding to each detection result is calculated to obtain the performance difference value of the compressed detection model.
[0143] If the performance difference value does not meet the performance degradation threshold, an adaptive method is used to obtain the scaling parameter, and the scaling parameter is used to adjust the compression detection model.
[0144] In one embodiment, before performing liveness detection processing on the acquired face image using a compressed detection model and obtaining a preset number of detection results, the processor 110 also performs the following operations:
[0145] The basic detection model is compressed based on a preset compression ratio to obtain a compressed detection model.
[0146] In one embodiment, when the processor 110 performs liveness detection processing on the acquired face image using a compressed detection model and obtains a preset number of detection results, it specifically performs the following operations:
[0147] If a liveness detection command is received, a compressed detection model is used to perform liveness detection processing on the acquired face image;
[0148] The detection results of liveness detection are obtained at a preset probability until a preset number of detection results are obtained.
[0149] In one embodiment, when the processor 110 performs performance degradation prediction processing based on the preset number of detection results and obtains the difference value of each detection result among the preset number of detection results, it specifically performs the following operations:
[0150] Obtain the target detection result from the preset number of detection results;
[0151] Based on the target detection results, a performance degradation prediction process is performed to predict the basic detection results corresponding to the basic detection model.
[0152] Based on the target detection result and the basic detection result, the difference value of the detection result is obtained.
[0153] In one embodiment, when the processor 110 performs the process of adaptively obtaining a scaling parameter if the performance difference value does not meet the performance degradation threshold, and then adjusting the compression detection model using the scaling parameter, it specifically performs the following operations:
[0154] If the performance difference value is less than the first threshold, then the initial compression parameters are obtained, and the compression detection model is adjusted based on the initial compression parameters;
[0155] If the performance difference value is greater than the second threshold, then the initial expansion parameters are obtained, and the compression detection model is adjusted based on the initial expansion parameters, wherein the first threshold is less than the second threshold.
[0156] In one embodiment, when the processor 110 performs the process of adaptively acquiring scaling parameters and adjusting the compression detection model using the scaling parameters, it specifically performs the following operations:
[0157] Obtain initial scaling parameters, and use the initial scaling parameters to adjust the compression detection model to obtain a first adjusted model;
[0158] If the difference value of the result of the first adjustment model does not meet the performance degradation threshold, then the adjustment ratio parameter is obtained in an adaptive manner.
[0159] The first adjustment model is adjusted using the aforementioned adjustment ratio parameter to obtain the second adjustment model;
[0160] If the difference value of the result of the second adjustment model does not meet the performance degradation threshold, then the second adjustment model is confirmed as the first adjustment model, and the step of obtaining the adjustment ratio parameter in an adaptive manner is executed.
[0161] If the difference value of the result of the second adjustment model meets the performance degradation threshold, then the second adjustment model is confirmed as the adjusted compression detection model.
[0162] In one embodiment, when the processor 110 executes the operation of adaptively obtaining the adjustment ratio parameter if the result difference value of the first adjustment model does not meet the performance degradation threshold, it specifically performs the following operations:
[0163] The first adjustment model is used to perform liveness detection processing on the test face image to obtain the test detection results;
[0164] The test results are subjected to performance degradation prediction processing to obtain the result difference value corresponding to the first adjustment model;
[0165] If the result parameters corresponding to the first adjustment model do not meet the performance degradation threshold, then the adjustment ratio parameter is obtained based on the result difference value corresponding to the first adjustment model.
[0166] In one embodiment, after the processor 110 performs the operation of adaptively obtaining a scaling parameter if the performance difference value does not meet the performance degradation threshold, and then adjusting the compression detection model using the scaling parameter, it further performs the following operations:
[0167] The adjusted compression detection model is used to replace the original compression detection model.
[0168] The adjusted compression detection model is used to perform liveness detection on the acquired face images.
[0169] In this embodiment, a basic detection model is compressed based on a preset compression ratio to obtain a compressed detection model. This compression process can be repeated multiple times until the preset compression ratio is met, averaging the compression ratios across multiple compression processes and ensuring the performance of the compressed detection model during the compression process. If a liveness detection command is received, the compressed detection model is used to perform liveness detection processing on the acquired face image. Liveness detection results are obtained with a preset probability until a preset number of results are obtained. This allows the compressed detection model to be tested and adjusted after long-term, multiple uses, ensuring the accuracy of liveness detection processing on the terminal device. Performance degradation prediction processing is performed based on the preset number of detection results. The difference values corresponding to each detection result within the preset number of results are obtained, and the average value of these difference values is calculated to obtain the performance difference value of the compressed detection model. A performance degradation prediction model can then be used to predict performance degradation, ensuring the accuracy of the performance degradation prediction. If the performance difference does not meet the performance degradation threshold, an adaptive approach is used to obtain the scaling parameter. This scaling parameter is then used to adjust the compressed detection model, which is then used to replace the original compressed detection model. The adjusted compressed detection model is then used to perform liveness detection on the acquired face images. Using the compressed model for liveness detection improves the security and convenience of liveness detection and predicts the performance degradation of the compressed detection model, thus enabling adjustments and further ensuring its performance. Furthermore, the compressed detection model can be progressively adjusted multiple times, gradually adjusting its compression ratio and performance relative to the base detection model.
[0170] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The program can be stored in a computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. The storage medium can be a magnetic disk, optical disk, read-only memory, or random access memory, etc.
[0171] The above-disclosed embodiments are merely preferred embodiments of this application and should not be construed as limiting the scope of this application. Therefore, any equivalent variations made in accordance with the claims of this application shall still fall within the scope of this application.
[0172] It should be noted that the information (including but not limited to user device information, user personal information, etc.), data (including but not limited to data used for analysis, stored data, displayed data, etc.), and signals involved in the embodiments of this specification are all authorized by the user or fully authorized by all parties, and the collection, use, and processing of related data must comply with the relevant laws, regulations, and standards of the relevant countries and regions. For example, the facial images and detection results of liveness detection processing involved in this specification were obtained under full authorization.
Claims
1. A model compression method, the method comprising: performing liveness detection processing on a collected face image using a compressed detection model to obtain a preset number of detection results; performing performance degradation prediction processing based on the preset number of detection results to obtain a detection result difference value corresponding to each detection result in the preset number of detection results; performing average value calculation on the detection result difference values corresponding to the detection results to obtain a performance difference value of the compressed detection model; if the performance difference value does not satisfy a performance degradation threshold, obtaining a proportion parameter in an adaptive manner, and adjusting the compressed detection model using the proportion parameter; the performance degradation prediction processing based on the preset number of detection results to obtain a detection result difference value corresponding to each detection result in the preset number of detection results comprises: obtaining a target detection result in the preset number of detection results; inputting a target feature vector obtained by the compressed detection model based on a target face image and the target detection result into a performance degradation prediction model, and the performance degradation prediction model predicts a base feature vector and a base detection result of a base detection model for the target face image; the average value calculation on the detection result difference values corresponding to the detection results to obtain the performance difference value of the compressed detection model comprises: performing average value calculation on the detection result difference values corresponding to the detection results to obtain a first average value, the detection result difference value being a difference value between the target detection result and the base detection result; performing average value calculation on feature vector difference values corresponding to the detection results to obtain a second average value, the feature vector difference value being a difference value between the target feature vector and the base feature vector; calculating an average value of the first average value and the second average value to obtain the performance difference value of the compressed detection model.
2. The method of claim 1, before the performing liveness detection processing on a collected face image using a compressed detection model to obtain a preset number of detection results, further comprising: performing compression processing on a base detection model based on a preset compression proportion to obtain a compressed detection model.
3. The method of claim 1, the performing liveness detection processing on a collected face image using a compressed detection model to obtain a preset number of detection results comprises: if a liveness detection instruction is received, performing liveness detection processing on the collected face image using a compressed detection model; obtaining a detection result of a liveness detection result with a preset probability until a preset number of detection results are obtained.
4. The method of claim 2, the performance degradation prediction processing based on the preset number of detection results to obtain a detection result difference value corresponding to each detection result in the preset number of detection results comprises: obtaining a target detection result in the preset number of detection results; performing performance degradation prediction processing based on the target detection result to predict a base detection result corresponding to the base detection model; obtaining a detection result difference value based on the target detection result and the base detection result.
5. The method of claim 1, wherein if the performance difference value does not satisfy the performance degradation threshold, a scaling parameter is obtained in an adaptive manner, and the scaling parameter is used to adjust the compression detection model, including: if the performance difference value is less than a first threshold, an initial compression parameter is obtained, and the compression detection model is adjusted based on the initial compression parameter; and if the performance difference value is greater than a second threshold, an initial expansion parameter is obtained, and the compression detection model is adjusted based on the initial expansion parameter, wherein the first threshold is less than the second threshold.
6. The method of claim 1, wherein the scaling parameter is obtained in an adaptive manner, and the scaling parameter is used to adjust the compression detection model, including: an initial scaling parameter is obtained, and the initial scaling parameter is used to adjust the compression detection model to obtain a first adjusted model; if a result difference value of the first adjusted model does not satisfy the performance degradation threshold, an adjusted scaling parameter is obtained in an adaptive manner; the first adjusted model is adjusted using the adjusted scaling parameter to obtain a second adjusted model; if a result difference value of the second adjusted model does not satisfy the performance degradation threshold, the second adjusted model is confirmed as the first adjusted model, and the step of obtaining the adjusted scaling parameter in an adaptive manner is performed; and if the result difference value of the second adjusted model satisfies the performance degradation threshold, the second adjusted model is confirmed as the compression detection model after adjustment.
7. The method of claim 6, wherein if the result difference value of the first adjusted model does not satisfy the performance degradation threshold, the adjusted scaling parameter is obtained in an adaptive manner, including: a test face image is subjected to live detection processing using the first adjusted model to obtain a test detection result; the test detection result is subjected to performance degradation prediction processing to obtain a result difference value corresponding to the first adjusted model; and based on the result difference value corresponding to the first adjusted model, the adjusted scaling parameter is obtained if the result difference value corresponding to the first adjusted model does not satisfy the performance degradation threshold.
8. The method of claim 1, wherein after the scaling parameter is obtained in an adaptive manner, and the scaling parameter is used to adjust the compression detection model, the method further includes: the compression detection model after adjustment is used to replace the compression detection model; and the face image collected is subjected to live detection processing using the compression detection model after adjustment.
9. A model compression device, comprising: a detection result obtaining module configured to perform live detection processing on a collected face image using a compression detection model to obtain a preset number of detection results; and a performance degradation prediction module configured to perform performance degradation prediction processing based on the preset number of detection results to obtain a detection result difference value corresponding to each detection result in the preset number of detection results. The difference value acquisition module is configured to calculate an average value of the detection result difference values corresponding to the detection results to obtain a performance difference value of the compressed detection model. The adjustment processing module is configured to, if the performance difference value does not satisfy a performance attenuation threshold, acquire a proportion parameter in an adaptive manner, and adjust the compressed detection model by using the proportion parameter. The performance attenuation prediction module is specifically configured to acquire a target detection result in the preset number of detection results. The performance attenuation prediction model is used to input a target feature vector obtained by the compressed detection model based on a target human face image and the target detection result, and to predict a basic feature vector and a basic detection result of a basic detection model for the target human face image. The difference value acquisition module is specifically configured to calculate an average value of the detection result difference values corresponding to the detection results to obtain a first average value, and the detection result difference value is a difference value between the target detection result and the basic detection result. The difference value acquisition module is specifically configured to calculate an average value of the detection result difference values corresponding to the detection results to obtain a first average value, and the detection result difference value is a difference value between the target detection result and the basic detection result. The difference value acquisition module is specifically configured to calculate an average value of the detection result difference values corresponding to the detection results to obtain a first average value, and the detection result difference value is a difference value between the target detection result and the basic detection result.
10. A computer storage medium, the computer storage medium storing a plurality of instructions, the instructions being adapted to be loaded and executed by a processor to perform the method steps of any one of claims 1-8.
11. A computer program product, the computer program product storing a plurality of instructions, the instructions being adapted to be loaded and executed by a processor to perform the method steps of any one of claims 1-8.
12. An electronic device comprising: A processor and a memory; wherein the memory stores a computer program, and the computer program is adapted to be loaded and executed by the processor to perform the method steps of any one of claims 1-8.
Citation Information
Patent Citations
Data processing method and device, electronic equipment and computer readable storage medium
CN113673694A
Living body detection method and system
CN116110134A