Facial image detection method and device, electronic equipment and storage medium
By performing facial object detection, preset filling processing and feature extraction on the image to be detected, it is determined whether it is an abnormal image and the features are stored in the preset library. This solves the problem of slow identification of new attacks in the existing technology and achieves rapid Responsive and efficient identification.
Patent Information
- Application Number
- CN202310212458.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-27
- Publication Date
- 2024-08-27
AI Technical Summary
When existing living body detection models face new attacks, the iterative process spans a long time and cannot quickly identify new attacks, resulting in higher system security risks and possible greater resource losses.
By performing facial object detection, preset filling processing and feature extraction on the image to be detected, it is determined whether it is an abnormal image, and the features are stored in the preset database to achieve rapid response to new background attacks based on preset database retrieval.
It achieves timely response to new attacks, reduces resource losses, and improves identification efficiency and accuracy through feature matching algorithms, with a low false detection rate.
Smart Images

Figure CN118552992A
Abstract
Description
Technical Field
[0001] The embodiments of the present disclosure relate to the field of data processing technology, and in particular to a facial image detection method, device, electronic device, and storage medium. Background Art
[0002] Liveness detection can be considered as a detection technology to determine whether the user in front of the camera is a real person. Liveness detection is often achieved through data-driven machine learning models.
[0003] In the prior art, when a model encounters a new type of attack, the algorithm iteration process (e.g., including the design / collection and processing of attack data, model training based on attack data, model update, etc.) takes a long time. Existing methods cannot quickly identify new attacks, which leads to a high security risk in the system to which the algorithm belongs, and may cause great losses when facing new attacks. Summary of the invention
[0004] The embodiments of the present disclosure provide a facial image detection method, device, electronic device, and storage medium, which can respond to new attacks in a timely manner and reduce resource losses.
[0005] In a first aspect, an embodiment of the present disclosure provides a facial image detection method, comprising:
[0006] Performing facial object detection on the image to be detected, and determining a first area to be filled based on the detection result of the facial object;
[0007] Performing a preset filling process on the first to-be-filled area in the to-be-detected image to obtain a first filled image;
[0008] Performing feature extraction on the first filled image to obtain first image features;
[0009] When there is a second image feature matching the first image feature in a preset library, it is determined that the image to be detected is an abnormal image; wherein the second image feature is obtained based on feature extraction of a sample image, and the sample image includes the abnormal image synthesized by the background with preset attributes and the facial object.
[0010] In a second aspect, the present disclosure also provides a facial image detection device, including:
[0011] A detection module, configured to detect facial objects in the image to be detected, and determine a first area to be filled based on the detection result of the facial objects;
[0012] A filling module, used for performing a preset filling process on the first to-be-filled area in the to-be-detected image to obtain a first filled image;
[0013] A feature extraction module, used for performing feature extraction on the first filled image to obtain a first image feature;
[0014] A recognition module is used to determine that the image to be detected is an abnormal image when there is a second image feature matching the first image feature in a preset library; wherein the second image feature is obtained based on feature extraction of a sample image, and the sample image includes the abnormal image synthesized by the background with preset attributes and the facial object.
[0015] In a third aspect, an embodiment of the present disclosure further provides an electronic device, the electronic device comprising:
[0016] one or more processors;
[0017] a storage device for storing one or more programs,
[0018] When the one or more programs are executed by the one or more processors, the one or more processors implement the facial image detection method as described in any one of the embodiments of the present disclosure.
[0019] In a fourth aspect, the embodiments of the present disclosure further provide a storage medium comprising computer executable instructions, which, when executed by a computer processor, are used to execute the facial image detection method as described in any one of the embodiments of the present disclosure.
[0020] The technical solution of the disclosed embodiment is to detect facial objects in the image to be detected, and determine the first area to be filled based on the detection result of the facial objects; perform preset filling processing on the first area to be filled in the image to be detected to obtain a first filled image; extract features from the first filled image to obtain first image features; and determine that the image to be detected is an abnormal image when there is a second image feature matching the first image feature in the preset library; wherein the second image feature is obtained based on feature extraction of a sample image, and the sample image includes an abnormal image synthesized by a background and a facial object using preset attributes. When encountering a new type of attack, by extracting its features and storing them in the preset library, it is possible to respond to attacks with new backgrounds in a timely manner based on preset library retrieval, thereby reducing resource losses. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] The above and other features, advantages and aspects of the embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the accompanying drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic and the originals and elements are not necessarily drawn to scale.
[0022] Figure 1 A schematic diagram of a facial image detection method provided by an embodiment of the present disclosure;
[0023] Figure 2 A flowchart of feature map storage / feature map matching in a facial image detection method provided by an embodiment of the present disclosure;
[0024] Figure 3 A flowchart of serial execution of abnormal image detection and liveness detection in a facial image detection method provided by an embodiment of the present disclosure;
[0025] Figure 4 A flowchart of serial execution of abnormal image detection and living body detection in another facial image detection method provided by an embodiment of the present disclosure;
[0026] Figure 5 A schematic diagram of the structure of a facial image detection device provided by an embodiment of the present disclosure;
[0027] Figure 6 A schematic diagram of the structure of an electronic device provided by an embodiment of the present disclosure. DETAILED DESCRIPTION
[0028] Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as being limited to the embodiments described herein, which are instead provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are only for exemplary purposes and are not intended to limit the scope of protection of the present disclosure.
[0029] It should be understood that the various steps described in the method embodiments of the present disclosure may be performed in different orders and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this respect.
[0030] The term "including" and its variations used herein are open inclusions, i.e., "including but not limited to". The term "based on" means "based at least in part on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". The relevant definitions of other terms will be given in the following description.
[0031] It should be noted that the concepts such as "first" and "second" mentioned in the present disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.
[0032] It should be noted that the modifications of "one" and "plurality" mentioned in the present disclosure are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, it should be understood as "one or more".
[0033] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are only used for illustrative purposes and are not used to limit the scope of these messages or information.
[0034] It is understandable that before using the technical solutions disclosed in the embodiments of the present disclosure, the types, scope of use, usage scenarios, etc. of the personal information involved in the present disclosure should be informed to the user and the user's authorization should be obtained in an appropriate manner in accordance with relevant laws and regulations.
[0035] It is understandable that the data involved in this technical solution (including but not limited to the data itself, the acquisition or use of the data) shall comply with the requirements of relevant laws, regulations and relevant provisions.
[0036] The study found that there are cases where abnormal images synthesized with strange backgrounds (such as non-realistic scene backgrounds) and faces are used to attack liveness detection models. Abnormal images with new backgrounds are easy to distinguish for the human eye, but for the model, they are out-of-range samples (OOD). Since real samples are generally used for training during model training, the model trained with OOD samples tends to believe that they are real samples, so the ability to resist them is relatively limited. In order to enable the model to have the ability to defend against abnormal images with new backgrounds, in related technologies, it is necessary to collect / construct a considerable amount of abnormal images for model training and update the model online, which has high maintenance costs and takes a long time, and is likely to cause users to suffer large resource losses. In addition, since such abnormal images have low production costs and short cycles, when the model iteration is completed, other abnormal images with new backgrounds are often generated. At this time, the iteration process needs to continue, resulting in frequent model iterations.
[0037] Figure 1 A flow chart of a facial image detection method provided by an embodiment of the present disclosure. The present disclosure embodiment is applicable to the case where the image to be detected is an abnormal image synthesized by a background with preset attributes and a facial object. The method can be executed by a facial image detection device, which can be implemented in the form of software and / or hardware, and the device can be configured in an electronic device, such as a mobile phone, a computer, or other electronic device.
[0038] like Figure 1 As shown, the facial image detection method provided in this embodiment may include:
[0039] S110 , performing facial object detection on the image to be detected, and determining a first area to be filled based on the facial object detection result.
[0040] In the embodiment of the present disclosure, the image to be detected can be considered as an image that currently needs to be judged whether it is an abnormal image. Among them, the abnormal image can be considered as an image synthesized by a background and a facial object using preset attributes. Among them, the preset attributes can be set in advance according to specific application scenarios. For example, in a liveness detection scenario, the preset attributes may include attributes such as non-realistic scenes.
[0041] The facial object in the image to be detected can be detected based on an existing facial detection algorithm, and the first area to be filled can be determined according to the detection result. The existing facial detection algorithm may include but is not limited to a convolutional neural network (CNN) algorithm and its derivative model algorithm, a single shot multibox detector (SSD) algorithm, etc. The first area to be filled may include the entire facial object.
[0042] In some optional implementations, performing facial object detection on the image to be detected and determining the first area to be filled based on the facial object detection result may include: performing facial object detection on the image to be detected to obtain a facial detection frame; and expanding the facial detection frame to obtain the first area to be filled. In these optional implementations, by expanding the facial detection frame to a certain extent (e.g., 1.5 times, etc.), it can be ensured that the first area to be filled can contain all head objects including facial objects and hair objects, so as to avoid interfering with the feature extraction of the background of the preset attribute.
[0043] S120 , performing a preset filling process on a first to-be-filled area in the image to be detected to obtain a first filled image.
[0044] In the embodiment of the present disclosure, the first area to be filled in the image to be detected is subjected to a preset filling process, which can be considered as changing the pixel values of the pixels in the first area to be filled according to a preset rule. By performing the preset filling process on the area within the first area to be filled, the facial object can be removed from the image to be detected to better extract the characteristics of the background with the preset attribute.
[0045] In some optional implementations, the preset filling processing is performed on the first area to be filled in the image to be detected, which may include at least one of the following: filling the first area to be filled with a preset pixel value; filling the first area to be filled with the texture of the background area other than the first area to be filled in the image to be detected.
[0046] Wherein, using the preset pixel value to fill the area within the first area to be filled may include setting the pixels of the first area to be filled to the preset pixel value. Wherein, the preset pixel value may be set according to an empirical value or an experimental value to ensure the feature extraction effect of the background of the preset attribute. Wherein, using the background area texture to fill the first area to be filled may include: according to the pixel value arrangement rule of the pixels in the background area texture, updating the pixel value from the outer edge to the center of the first area to be filled, so as to achieve the effect of texture expansion and completion of the first detection area from the outside to the inside.
[0047] In addition, other methods may be used to perform preset filling processing on the first area to be filled, such as using the most distributed pixel values in the background area texture to perform preset filling processing on the first area to be filled, etc., which are not listed here exhaustively.
[0048] Among these optional implementations, at least one of the above methods can be used to perform preset filling processing on the first area to be filled to obtain at least one first filled image; or a method that is beneficial to the feature extraction effect of the background can be selected based on the specific application scenario to perform preset filling processing to obtain a better first filled image.
[0049] S130: Perform feature extraction on the first filled image to obtain first image features.
[0050] In the disclosed embodiment, at least one representation of the first filled image can be extracted based on an existing image feature extraction algorithm to obtain at least one first image feature. The existing image feature extraction algorithm may include a traditional algorithm and a neural network algorithm, wherein the neural network algorithm may include but is not limited to a Momentum Contrast (MOCO) algorithm, a Visual Geometry Group (VGG) algorithm, and a Residual Network (ResNet) algorithm.
[0051] S140: When there is a second image feature matching the first image feature in the preset library, determine that the image to be detected is an abnormal image.
[0052] In the disclosed embodiment, the second image feature is obtained based on feature extraction of a sample image, and the sample image includes an abnormal image synthesized by a background and a facial object using a preset attribute. The sample image may include a historical abnormal image or an abnormal image with a new background.
[0053] In the disclosed embodiment, the R&D personnel can extract features from historical abnormal images to obtain second image features, and use the adding tool to add them to the preset library; and when the business personnel find abnormal images with new backgrounds online, they can also extract features of the new backgrounds through the platform-based feature extraction tool to obtain second image features, and use the adding tool to add them to the preset library. That is, the preset library can contain second image features corresponding to abnormal images with multiple different backgrounds.
[0054] For example, Figure 2 This is a flowchart of a feature map storage / feature map matching process in a facial image detection method provided by an embodiment of the present disclosure. Figure 2 In some optional implementations, the step of building the preset library may include: performing facial object ( Figure 2 The method further comprises the following steps: detecting the facial object (represented by an ellipse in the figure), and determining a second area to be filled based on the detection result of the facial object; performing a preset filling process on the second area to be filled in the sample image to obtain a second filled image; performing feature extraction on the second filled image to obtain second image features, and storing the second image features in a preset library.
[0055] In these optional implementations, the step of detecting facial objects on the sample image may be consistent with the step of detecting facial objects on the image to be detected; the step of performing preset filling processing on the second area to be filled may be consistent with the step of performing preset filling processing on the first area to be filled; the step of extracting features from the second filled image may be consistent with the step of extracting features from the first filled image.
[0056] If at least one preset filling processing method is used to fill the same sample image, at least one second filled image and at least one corresponding image feature can be obtained. Figure 2 , Figure 2 The preset filling processing method in may include two types, each image to be detected may correspond to two first filling images, and each abnormal image may also correspond to two second filling images; accordingly, each image to be detected may correspond to two first image features ( Figure 2 Not shown), each abnormal image may also correspond to two second image features ( Figure 2 not shown).
[0057] After obtaining each second image feature image corresponding to the abnormal image, it can be stored in the preset library ( Figure 2 The preset library may contain at least one second image feature corresponding to the same abnormal image. Accordingly, after extracting at least one first image feature, it may be determined based on an existing feature map matching algorithm whether the at least one first image feature matches each second image feature in the preset library ( Figure 2 When there is a second image feature matching any first image feature in the preset library, it can be determined that the image to be detected is an abnormal image; when there is no second image feature matching each first image feature in the preset library, it can be determined that the image to be detected is not an abnormal image. By comparing at least one first image feature with all second image features in the preset library, and determining whether it is an abnormal image based on the comparison result, the reliability of the comparison can be improved.
[0058] In addition, in some implementations, when the same abnormal image corresponds to at least two second image features, the weighted fusion image features of the at least two image features can also be used as the second image features corresponding to the abnormal image and stored in a preset library; correspondingly, when at least two first image features of the image to be detected are obtained, the same weighted fusion method can also be used to fuse the at least two first image features, and the fused first image features are matched with the second image features in the preset library to determine whether the image to be detected is an abnormal image. By comparing the weighted fused first image features with the second image features in the preset library and determining whether it is an abnormal image based on the comparison results, reliability can be improved while also improving comparison efficiency to a certain extent.
[0059] In some optional implementations, after obtaining the first image feature, it can also include: determining the similarity between the first image feature and each second image feature in a preset library; based on each similarity, determining whether there is a second image feature in the preset library that matches the first image feature.
[0060] In these optional implementations, for each first image feature, the similarity can be calculated with each second image feature in the preset library (for example, the cosine similarity can be calculated), and whether the image to be detected is an abnormal image can be determined based on each similarity. For example, if there is a similarity greater than or equal to a preset threshold, that is, there is a second image feature in the preset library that matches the first image feature, then it can be considered that the image to be detected hits the abnormal image in the preset library; if there is no similarity greater than or equal to the preset threshold, that is, there is no second image feature in the preset library that matches the first image feature, then it can be considered that the image to be detected does not hit the abnormal image in the preset library. Among them, the preset threshold can be preset according to an empirical value or an experimental value. In addition, when the image to be detected hits an abnormal image in the preset library, the image to be detected can also be intercepted.
[0061] The facial image detection method provided by the disclosed embodiment can realize the recognition of the image to be detected as an abnormal image by simply searching from a preset library whether there is a matching second image feature after determining the first image feature of the image to be detected. It can be achieved that each time a new background attack is discovered, it can be intercepted immediately, without the need to frequently iterate the facial image detection model, thereby reducing the model maintenance cost and avoiding the situation where large asset losses are caused by long model iterations.
[0062] Moreover, experiments have proved that because the existing algorithm has powerful feature extraction capabilities, abnormal image recognition is performed by matching the first image features of the image to be detected with the second image features of the sample image in the preset library, and its detection rate can reach more than 90%, and the false detection rate can be less than one thousandth, which is a highly practical solution.
[0063] The technical solution of the disclosed embodiment is to detect facial objects in the image to be detected, and determine the first area to be filled based on the detection result of the facial objects; perform preset filling processing on the first area to be filled in the image to be detected to obtain a first filled image; extract features from the first filled image to obtain first image features; and determine that the image to be detected is an abnormal image when there is a second image feature matching the first image feature in the preset library; wherein the second image feature is obtained based on feature extraction of a sample image, and the sample image includes an abnormal image synthesized by a background and a facial object using preset attributes. When encountering a new type of attack, by extracting its features and storing them in the preset library, it is possible to respond to attacks with new backgrounds in a timely manner based on preset library retrieval, thereby reducing resource losses.
[0064] The various optional schemes in the facial image detection method provided in the embodiment of the present disclosure and the above embodiment can be combined. The facial image detection method provided in this embodiment describes the application scenario in detail, wherein the step of performing abnormal image detection on the image to be detected can be performed in series with the step of performing liveness detection on the image to be detected. Moreover, the target service can be triggered to execute when the detection result of the liveness detection is a real face and there is no second image feature matching the first image feature in the preset library.
[0065] For example, Figure 3 This is a flowchart of the serial execution of abnormal image detection and liveness detection in a facial image detection method provided by an embodiment of the present disclosure. Figure 3 As shown, the process of serially executing abnormal image detection and living body detection provided by this embodiment may include:
[0066] S301, obtaining an image to be detected.
[0067] After the process is started, an image to be detected can be obtained. Acquiring the image to be detected may include at least one of the following: capturing an instantaneous image containing the user's face; capturing a video containing the user's face and capturing a video frame image therein; reading the captured instantaneous image containing the user's face; reading the video frame image in the captured video containing the user's face.
[0068] S302, performing liveness detection on the image to be detected, and determining whether the detection result of the liveness detection is a real face; if so, jumping to S303; if not, the process can be terminated.
[0069] If the result of the liveness detection is a real face, the image to be detected can continue to be detected for abnormal images. If the result of the liveness detection is not a real face, that is, a false face, the process can be terminated directly.
[0070] S303: Perform facial object detection on the image to be detected, and determine a first area to be filled based on the facial object detection result.
[0071] S304 , performing a preset filling process on the first to-be-filled area in the image to be detected to obtain a first filled image.
[0072] S305 : Extract features of the first filled image to obtain first image features.
[0073] S306: Determine the similarity between the first image feature and each second image feature in the preset library.
[0074] The second image feature is obtained based on feature extraction of a sample image, and the sample image includes an abnormal image synthesized by a background with preset attributes and a facial object.
[0075] S307 , judging whether the maximum similarity among the similarities is greater than or equal to a preset threshold; if so, jumping to S308 ; otherwise, jumping to S309 .
[0076] Among them, if the maximum similarity is greater than or equal to the preset threshold, it can be considered that there is a second image feature matching the first image feature in the preset library; if the maximum similarity is less than the preset threshold, it can be considered that there is no second image feature matching the first image feature in the preset library.
[0077] S308: Determine whether the image to be detected is an abnormal image.
[0078] After determining that the image to be detected is an abnormal image, the process can be ended.
[0079] S309: Trigger execution of the target business.
[0080] Among them, if there is no second image feature matching the first image feature in the preset library, then it can be considered that the image to be detected is not an abnormal image. When the detection result of the liveness detection is a real face, and there is no second image feature matching the first image feature in the preset library, the corresponding module can be triggered to execute the target business. Among them, the target business is, for example, face recognition business, login business, payment business, information display business, etc., which are not exhaustive here. Among them, after the execution of the target business is completed, the process can be ended.
[0081] For example, Figure 4 This is a flowchart of the serial execution of abnormal image detection and liveness detection in another facial image detection method provided by the embodiment of the present disclosure. Figure 4 As shown, the process of serially executing abnormal image detection and living body detection provided by this embodiment may include:
[0082] S401, obtaining an image to be detected.
[0083] S402: Perform facial object detection on the image to be detected, and determine a first area to be filled based on the facial object detection result.
[0084] S403 , performing a preset filling process on the first to-be-filled area in the image to be detected to obtain a first filled image.
[0085] S404: Extract features from the first filled image to obtain first image features.
[0086] S405: Determine the similarity between the first image feature and each second image feature in the preset library.
[0087] The second image feature is obtained based on feature extraction of a sample image, and the sample image includes an abnormal image synthesized by a background with preset attributes and a facial object.
[0088] S406, judging whether the maximum similarity among the similarities is greater than or equal to a preset threshold; if so, jumping to S407; if not, jumping to S408.
[0089] Among them, if the maximum similarity is greater than or equal to the preset threshold, it can be considered that there is a second image feature matching the first image feature in the preset library; if the maximum similarity is less than the preset threshold, it can be considered that there is no second image feature matching the first image feature in the preset library.
[0090] S407: Determine whether the image to be detected is an abnormal image.
[0091] After determining that the image to be detected is an abnormal image, the process can be ended.
[0092] S408, performing liveness detection on the image to be detected, and determining whether the liveness detection result is a real face; if so, jumping to S409; if not, the process can be terminated.
[0093] If there is no second image feature matching the first image feature in the preset library, it can be considered that the image to be detected is not an abnormal image, and the liveness detection step can be continued. Liveness detection can be performed on the image to be detected based on the trained liveness detection model.
[0094] S409: Trigger execution of the target service.
[0095] When the liveness detection result is a real face and there is no second image feature matching the first image feature in the preset library, the corresponding module can be triggered to execute the target service. The target service is, for example, face recognition service, login service, payment service, information display service, etc., which are not exhaustive here. After the target service is executed, the process can be ended.
[0096] It can be understood that abnormal image detection based on preset library retrieval is equivalent to adding a new link on the basis of the liveness detection method. The two are executed in series and the strict execution order is not limited. In addition, the subsequent business process can be executed when the image to be detected is not an abnormal image and the facial object in the image to be detected is a real face; when the image to be detected is first determined to be an abnormal image, or the facial object in the image to be detected is first determined to be a false face, the image to be detected can be intercepted and the process can be ended to ensure the security of the business system.
[0097] The technical solution of the disclosed embodiment describes the application scenario in detail, wherein the step of performing abnormal image detection on the image to be detected can be executed in series with the step of performing liveness detection on the image to be detected. Moreover, the target business can be triggered to execute when the detection result of the liveness detection is a real face and there is no second image feature matching the first image feature in the preset library. By using the search and identification of abnormal images based on the preset library as a patch strategy and executing it in series with the step of performing liveness detection based on the liveness detection model, frequent iterations of the liveness detection model can be avoided when encountering abnormal image attacks with new backgrounds, which can reduce the model maintenance cost, and can also respond to attacks with new backgrounds in a timely manner, reducing resource losses.
[0098] In addition, the facial image detection method provided in the embodiment of the present disclosure and the facial image detection method provided in the above embodiment belong to the same public concept. The technical details not fully described in this embodiment can be referred to the above embodiment, and the same technical features have the same beneficial effects in this embodiment and the above embodiment.
[0099] Figure 5 The structure diagram of a facial image detection device provided by the embodiment of the present disclosure is as follows. The facial image detection device provided by the embodiment is suitable for detecting whether the image to be detected is an abnormal image composed of a background with preset attributes and a facial object.
[0100] like Figure 5 As shown, the facial image detection device provided by the embodiment of the present disclosure may include:
[0101] A detection module 510 is used to detect facial objects in the image to be detected, and determine a first area to be filled based on the detection result of the facial objects;
[0102] A filling module 520, configured to perform a preset filling process on a first to-be-filled area in the image to be detected to obtain a first filled image;
[0103] A feature extraction module 530 is used to extract features from the first filled image to obtain first image features;
[0104] The identification module 540 is used to determine that the image to be detected is an abnormal image when there is a second image feature matching the first image feature in the preset library; wherein the second image feature is obtained based on feature extraction of a sample image, and the sample image includes an abnormal image synthesized by a background and a facial object with preset attributes.
[0105] In some optional implementations, the facial image detection device may include:
[0106] A preset library building module, which is used to build a preset library based on the following steps:
[0107] Performing facial object detection on the sample image, and determining a second area to be filled based on the facial object detection result;
[0108] Performing a preset filling process on the second area to be filled in the sample image to obtain a second filled image;
[0109] Feature extraction is performed on the second filled image to obtain second image features, and the second image features are stored in a preset library.
[0110] In some optional implementations, the detection module may be used to:
[0111] Detect facial objects on the image to be detected and obtain a facial detection frame;
[0112] The face detection frame is expanded to obtain a first area to be filled.
[0113] In some optional implementations, the filling module may be used to perform a preset filling process on the first to-be-filled area in the image to be detected based on at least one of the following:
[0114] Filling the first area to be filled using a preset pixel value;
[0115] The first area to be filled is filled using the texture of the background area in the image to be detected except the first area to be filled.
[0116] In some optional implementations, the facial image detection device may further include:
[0117] A feature map matching module is used to determine the similarity between the first image feature and each second image feature in the preset library after obtaining the first image feature;
[0118] Based on each similarity, it is determined whether there is a second image feature matching the first image feature in the preset library.
[0119] In some optional implementations, the facial image detection apparatus further includes:
[0120] A liveness detection module, used for performing liveness detection on the image to be detected before performing facial object detection on the image to be detected;
[0121] Correspondingly, the detection module can be used to: when the detection result of the liveness detection is a real face, perform facial object detection on the image to be detected.
[0122] In some optional implementations, the recognition module is also used to determine that the image to be detected is not an abnormal image when there is no second image feature matching the first image feature in the preset library; accordingly, the liveness detection module can also perform liveness detection on the image to be detected in response to the image to be detected not being an abnormal image.
[0123] In some optional implementations, the facial image detection device may further include:
[0124] The trigger device is used to trigger the execution of the target service when the detection result of the liveness detection is a real face and there is no second image feature matching the first image feature in the preset library.
[0125] The facial image detection device provided in the embodiments of the present disclosure can execute the facial image detection method provided in any embodiment of the present disclosure, and has the functional modules and beneficial effects corresponding to the execution method.
[0126] It is worth noting that the various units and modules included in the above-mentioned device are only divided according to functional logic, but are not limited to the above-mentioned division, as long as the corresponding functions can be achieved; in addition, the specific names of the functional units are only for the convenience of distinguishing each other, and are not used to limit the protection scope of the embodiments of the present disclosure.
[0127] Reference below Figure 6 , which shows an electronic device (eg, Figure 6 The terminal device in the embodiment of the present disclosure may include but is not limited to mobile terminals such as mobile phones, notebook computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 6 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0128] like Figure 6 As shown, the electronic device 600 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage device 608 to a random access memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the electronic device 600 are also stored. The processing device 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.
[0129] Typically, the following devices may be connected to the I / O interface 605: an input device 606 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 607 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 608 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 609. The communication device 609 may allow the electronic device 600 to communicate with other devices wirelessly or by wire to exchange data. Although Figure 6 The electronic device 600 is shown with various devices, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.
[0130] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication device 609, or installed from the storage device 608, or installed from the ROM 602. When the computer program is executed by the processing device 601, the above functions defined in the facial image detection method of the embodiment of the present disclosure are executed.
[0131] The electronic device provided in the embodiment of the present disclosure and the facial image detection method provided in the above embodiment belong to the same disclosed concept. The technical details not fully described in this embodiment can be referred to the above embodiment, and this embodiment has the same beneficial effects as the above embodiment.
[0132] The embodiment of the present disclosure provides a computer storage medium on which a computer program is stored. When the program is executed by a processor, the facial image detection method provided by the above embodiment is implemented.
[0133] It should be noted that the computer-readable medium disclosed above may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM) or a flash memory (FLASH), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, device or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer readable signal media may also be any computer readable medium other than computer readable storage media, which may send, propagate, or transmit programs for use by or in conjunction with an instruction execution system, apparatus, or device. The program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
[0134] In some embodiments, the client and the server may communicate using any currently known or future developed network protocol such as HTTP (Hyper Text Transfer Protocol), and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or future developed network.
[0135] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.
[0136] The computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device:
[0137] The image to be detected is subjected to facial object detection, and a first area to be filled is determined based on the detection result of the facial object; the first area to be filled in the image to be detected is subjected to preset filling processing to obtain a first filled image; the first filled image is subjected to feature extraction to obtain a first image feature; when a second image feature matching the first image feature exists in a preset library, it is determined that the image to be detected is an abnormal image; wherein the second image feature is obtained based on feature extraction of a sample image, and the sample image includes an abnormal image synthesized by a background and a facial object using preset attributes.
[0138] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages or a combination thereof, including, but not limited to, object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).
[0139] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0140] The units involved in the embodiments described in the present disclosure may be implemented by software or hardware, wherein the names of the units and modules do not, in some cases, limit the units and modules themselves.
[0141] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: Field Programmable Gate Array (FPGA), Application Specific Integrated Circuit (ASIC), Application Specific Standard Parts (ASSP), System on Chip (SOC), Complex Programmable Logic Device (CPLD), etc.
[0142] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0143] According to one or more embodiments of the present disclosure, a facial image detection method is provided, the method comprising:
[0144] Performing facial object detection on the image to be detected, and determining a first area to be filled based on the detection result of the facial object;
[0145] Performing a preset filling process on the first to-be-filled area in the to-be-detected image to obtain a first filled image;
[0146] Performing feature extraction on the first filled image to obtain first image features;
[0147] When there is a second image feature matching the first image feature in a preset library, it is determined that the image to be detected is an abnormal image; wherein the second image feature is obtained based on feature extraction of a sample image, and the sample image includes the abnormal image synthesized by the background with preset attributes and the facial object.
[0148] According to one or more embodiments of the present disclosure, a facial image detection method is provided, further comprising:
[0149] In some optional implementations, the step of constructing the preset library includes:
[0150] Performing facial object detection on the sample image, and determining a second area to be filled based on the facial object detection result;
[0151] Performing a preset filling process on the second to-be-filled area in the sample image to obtain a second filled image;
[0152] Perform feature extraction on the second filled image to obtain the second image features, and store the second image features in the preset library.
[0153] According to one or more embodiments of the present disclosure, a facial image detection method is provided, further comprising:
[0154] In some optional implementations, the detecting of facial objects on the image to be detected and determining the first area to be filled based on the detection result of the facial objects includes:
[0155] Performing facial object detection on the image to be detected to obtain a facial detection frame;
[0156] The face detection frame is expanded to obtain the first area to be filled.
[0157] According to one or more embodiments of the present disclosure, a facial image detection method is provided, further comprising:
[0158] In some optional implementations, the performing a preset filling process on the first to-be-filled area in the to-be-detected image includes at least one of the following:
[0159] Filling the first area to be filled using a preset pixel value;
[0160] The first area to be filled is filled using the texture of the background area in the image to be detected except the first area to be filled.
[0161] According to one or more embodiments of the present disclosure, a facial image detection method is provided, further comprising:
[0162] In some optional implementations, after obtaining the first image feature, the method further includes:
[0163] Determining the similarity between the first image feature and each second image feature in the preset library;
[0164] Based on each of the similarities, it is determined whether there is a second image feature matching the first image feature in the preset library.
[0165] According to one or more embodiments of the present disclosure, a facial image detection method is provided, further comprising:
[0166] In some optional implementations, before performing facial object detection on the image to be detected, the method further includes:
[0167] Performing liveness detection on the image to be detected;
[0168] When the detection result of the living body detection is a real face, facial object detection is performed on the image to be detected.
[0169] According to one or more embodiments of the present disclosure, a facial image detection method is provided, further comprising:
[0170] In some optional implementations, when there is no second image feature matching the first image feature in the preset library, it is determined that the image to be detected is not an abnormal image, and liveness detection is performed on the image to be detected.
[0171] According to one or more embodiments of the present disclosure, a facial image detection method is provided, further comprising:
[0172] In some optional implementations, when the detection result of the liveness detection is a real face and there is no second image feature matching the first image feature in the preset library, execution of the target service is triggered.
[0173] According to one or more embodiments of the present disclosure, a facial image detection device is provided, comprising:
[0174] A detection module, configured to detect facial objects in the image to be detected, and determine a first area to be filled based on the detection result of the facial objects;
[0175] A filling module, used for performing a preset filling process on the first to-be-filled area in the to-be-detected image to obtain a first filled image;
[0176] A feature extraction module, used for performing feature extraction on the first filled image to obtain a first image feature;
[0177] A recognition module is used to determine that the image to be detected is an abnormal image when there is a second image feature matching the first image feature in a preset library; wherein the second image feature is obtained based on feature extraction of a sample image, and the sample image includes the abnormal image synthesized by the background with preset attributes and the facial object.
[0178] The above description is only a preferred embodiment of the present disclosure and an explanation of the technical principles used. Those skilled in the art should understand that the scope of disclosure involved in the present disclosure is not limited to the technical solutions formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosed concept. For example, the above features are replaced with the technical features with similar functions disclosed in the present disclosure (but not limited to) by each other to form a technical solution.
[0179] In addition, although each operation is described in a specific order, this should not be understood as requiring these operations to be performed in the specific order shown or in a sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although some specific implementation details are included in the above discussion, these should not be interpreted as limiting the scope of the present disclosure. Some features described in the context of a separate embodiment can also be implemented in a single embodiment in combination. On the contrary, the various features described in the context of a single embodiment can also be implemented in multiple embodiments individually or in any suitable sub-combination mode.
[0180] Although the subject matter has been described in language specific to structural features and / or methodological logical actions, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. On the contrary, the specific features and actions described above are merely example forms of implementing the claims.
Claims
1. A facial image detection method, characterized in that: include: Performing facial object detection on the image to be detected, and determining a first area to be filled based on the detection result of the facial object; Performing a preset filling process on the first to-be-filled area in the to-be-detected image to obtain a first filled image; Performing feature extraction on the first filled image to obtain first image features; When there is a second image feature matching the first image feature in a preset library, it is determined that the image to be detected is an abnormal image; wherein the second image feature is obtained based on feature extraction of a sample image, and the sample image includes the abnormal image synthesized by the background with preset attributes and the facial object.
2. The method according to claim 1, characterized in that The steps of constructing the preset library include: Performing facial object detection on the sample image, and determining a second area to be filled based on the facial object detection result; Performing a preset filling process on the second to-be-filled area in the sample image to obtain a second filled image; Perform feature extraction on the second filled image to obtain the second image features, and store the second image features in the preset library.
3. The method according to claim 1, characterized in that The step of detecting a facial object on the image to be detected and determining a first area to be filled based on the detection result of the facial object includes: Performing facial object detection on the image to be detected to obtain a facial detection frame; The face detection frame is expanded to obtain the first area to be filled.
4. The method according to claim 1, characterized in that: The performing a preset filling process on the first to-be-filled area in the to-be-detected image includes at least one of the following: Filling the first area to be filled using a preset pixel value; The first area to be filled is filled using the texture of the background area in the image to be detected except the first area to be filled.
5. The method according to claim 1, characterized in that After obtaining the first image feature, the method further includes: Determining the similarity between the first image feature and each second image feature in the preset library; Based on each of the similarities, it is determined whether there is a second image feature matching the first image feature in the preset library.
6. The method according to claim 1, characterized in that Before the facial object detection is performed on the image to be detected, the method further includes: Performing liveness detection on the image to be detected; When the detection result of the living body detection is a real face, facial object detection is performed on the image to be detected.
7. The method according to claim 1, characterized in that Also includes: When there is no second image feature matching the first image feature in the preset library, it is determined that the image to be detected is not an abnormal image, and living body detection is performed on the image to be detected.
8. The method according to claim 6 or 7, characterized in that: Also includes: When the detection result of the liveness detection is a real face and there is no second image feature matching the first image feature in the preset library, execution of the target service is triggered.
9. A facial image detection device, characterized in that: include: A detection module, configured to detect facial objects in the image to be detected, and determine a first area to be filled based on the detection result of the facial objects; A filling module, used for performing a preset filling process on the first to-be-filled area in the to-be-detected image to obtain a first filled image; A feature extraction module, used for performing feature extraction on the first filled image to obtain a first image feature; A recognition module is used to determine that the image to be detected is an abnormal image when there is a second image feature matching the first image feature in a preset library; wherein the second image feature is obtained based on feature extraction of a sample image, and the sample image includes the abnormal image synthesized by the background with preset attributes and the facial object.
10. An electronic device, characterized in that: The electronic device comprises: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the facial image detection method as described in any one of claims 1-8.
11. A storage medium comprising computer executable instructions, wherein the computer executable instructions are used to perform the facial image detection method according to any one of claims 1 to 8 when executed by a computer processor.
