Anti-spoofing training image preprocessing method and device and electronic equipment

CN117133060BActive Publication Date: 2026-10-23CHINA ACADEMY OF INFORMATION & COMM
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202311146791.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-09-06
Publication Date
2026-10-23
Estimated Expiration
2043-09-06

AI Technical Summary

Technical Problem

[0003]现有的人脸鉴伪模型一般将虚假人脸检测问题形式化成一个真假二分类任务,然后基于真假标注信息训练二分类模型,然后这种朴素的训练方式在实际应用中常常存在过拟合风险,从而导致泛化性能不佳的问题

Benefits of technology

[0041]综上,本申请提供的一种鉴伪训练图像的预处理方法、装置和电子设备,包括:在待处理图像的人脸区域中确定目标区域,所述目标区域是人脸预设定义组成部分中的一个,人脸中按照五官的种类和皮肤划分为至少两个人脸预设定义组成部分;基于预设的处理方式对于所述目标区域中至少部分进行预设像素填充,得到鉴伪训练图像。本方案中,由于是对于待处理图像中人脸预设定义组成部分中的一个区域的部分或者全部进行预设像素填充得到的鉴伪训练图像,鉴伪模型基于该鉴伪训练图像训练,能够提高鉴伪的准确度。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117133060B_ABST
    Figure CN117133060B_ABST
Patent Text Reader

Abstract

The application provides a pre-processing method and device for a fake identification training image and electronic equipment, comprising: determining a target region in a face region of a to-be-processed image, the target region being one of face preset definition components, the face being divided into at least two face preset definition components according to the types of facial features and skin; and performing preset pixel filling on at least part of the target region based on a preset processing mode to obtain a fake identification training image.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of information processing technology, and more specifically, to a method, apparatus, and electronic device for preprocessing training images for anti-spoofing purposes. Background Technology

[0002] With the rapid development of deep generative models such as generative adversarial networks and diffusion models, the barrier to editing or generating highly realistic images and videos has become extremely low. The continuous development and widespread application of deepfake technology has brought many challenges and problems, the most worrying of which is the forgery of facial images and videos, posing significant potential risks to information dissemination and identity authentication. To address this challenge, researchers have proposed numerous facial forgery detection models designed to identify and distinguish between real and forged faces.

[0003] Existing face detection models typically formalize the fake face detection problem into a binary classification task of real and fake faces, and then train the binary classification model based on the real and fake face label information. However, this naive training method often has the risk of overfitting in practical applications, resulting in poor generalization performance.

[0004] On the one hand, bias information in deepfake face datasets, such as identity information, can be learned by binary classification models. While this bias enhances the difference between real and fake faces when evaluated on independent and identically distributed (ISD) datasets, it can mislead the model when evaluated on non-independent and identically distributed (ISD) datasets. On the other hand, the forgery traces left by existing face forgery techniques may be distributed in different regions and have varying degrees of forgery. Forgery detection models may quickly fit features with obvious forgery traces, but fail to learn features with less obvious traces, thus failing to learn more diverse and subtle forgery features. Therefore, a method to alleviate the overfitting problem of face forgery detection models is urgently needed. Summary of the Invention

[0005] In view of this, this application provides a preprocessing method, apparatus, and electronic device for anti-spoofing training images, as follows:

[0006] A method for preprocessing training images for fake detection, comprising:

[0007] In the face region of the image to be processed, a target region is determined. The target region is one of the predefined components of the face. The face is divided into at least two predefined components of the face according to the type of facial features and skin.

[0008] Based on a preset processing method, at least a portion of the target region is filled with preset pixels to obtain a fake detection training image.

[0009] Optionally, in the above method, determining the target region within the face region of the image to be processed includes:

[0010] Identify a preset number of key points contained in the face region of the image to be processed;

[0011] Based on the key points contained in each predefined component of a face, the first region range corresponding to each predefined component of a face is determined, wherein the key points are the positions that characterize the predefined components of a face;

[0012] Randomly select one of the predefined components of a face as the target component;

[0013] If the target component is skin, a portion of the first region corresponding to the target component is determined as the target region.

[0014] If the target component belongs to the five sense organs, the first region corresponding to the target component is determined to be the target region.

[0015] Optionally, in the above method, if the target component is skin, determining a portion of the first region corresponding to the target component as the target region includes:

[0016] If the target component is skin, select one pixel in the first region as the base pixel;

[0017] A selection area of ​​a preset shape is determined with the basic pixel as the center;

[0018] If the selected area only includes the first region of the skin, the mask of the target component in the image to be processed is determined to obtain a first mask image, wherein the mask value of the first region in the first mask image is different from the mask value outside the first region.

[0019] Based on the first mask image and the selected area, a target mask image is obtained. The mask value of the selected area in the target mask image is different from the mask value outside the selected area. The selected area is the target area within the range of the first area.

[0020] Optionally, the above methods also include:

[0021] If the selected area includes the first area of ​​the skin and the second area of ​​the first facial features, determine the mask of each preset facial component in the image to be processed to obtain at least two mask images, one of which corresponds to one preset facial component.

[0022] Based on the at least two mask images and the selected region, a target mask image is determined. The mask value of the target region in the target mask image is different from the mask value outside the target region. The target region is a region that belongs to the first region range and does not belong to the second region range.

[0023] Optionally, in the above method, if the target component belongs to the five sense organs, determining that the first region corresponding to the target component is the target region includes:

[0024] If the target component belongs to the facial features, the convex hull region is calculated based on the preset convex hull processing rules and the key points contained in the target component. The convex hull region corresponds to the first region range.

[0025] According to a preset random expansion rule, the convex hull region is processed to obtain a target mask image, wherein the mask value of the target region in the target mask image is different from the mask value outside the target region.

[0026] Optionally, in the above method, the step of filling at least a portion of the target region with preset pixels based on a preset processing method to obtain a fake detection training image includes:

[0027] Based on the target mask image and the image to be processed, a first image is obtained, wherein the pixel value of the target region in the first image is 0;

[0028] Random pixel values ​​are used to fill the pixels in the target region of the first image to obtain a fake detection training image.

[0029] Optionally, the above method, before determining the target region in the face region of the image to be processed, further includes:

[0030] Pre-processing probability of the preset image;

[0031] Generate random processing probabilities;

[0032] If the random processing probability is less than the preprocessing probability, the step of determining the target region in the face region of the image to be processed is triggered.

[0033] Optionally, the above methods also include:

[0034] The original model is trained based on the aforementioned anti-spoofing training images to obtain a trained face anti-spoofing model.

[0035] A preprocessing device for anti-spoofing training images, comprising:

[0036] The determination module is used to determine a target region in the face region of the image to be processed. The target region is one of the predefined components of the face. The face is divided into at least two predefined components of the face according to the type of facial features and skin.

[0037] The filling module is used to fill at least a portion of the target region with preset pixels based on a preset processing method to obtain a fake detection training image.

[0038] An electronic device includes: a memory and a processor;

[0039] The memory stores the processing program;

[0040] The processor is used to load and execute the processing program stored in the memory to implement the steps of the preprocessing method for the anti-spoofing training image as described in any of the preceding claims.

[0041] In summary, this application provides a preprocessing method, apparatus, and electronic device for anti-spoofing training images, comprising: determining a target region in a face region of an image to be processed, wherein the target region is one of the predefined components of a face, and the face is divided into at least two predefined components according to the types of facial features and skin; and filling at least a portion of the target region with predefined pixels based on a predefined processing method to obtain an anti-spoofing training image. In this solution, since the anti-spoofing training image is obtained by filling a portion or all of a region of a predefined component of a face in the image to be processed with predefined pixels, the anti-spoofing model can be trained based on this anti-spoofing training image, thereby improving the accuracy of anti-spoofing detection. Attached Figure Description

[0042] To more clearly illustrate the technical solutions of the embodiments of this application, the drawings used in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only embodiments of this application. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.

[0043] Figure 1 This is a flowchart of Embodiment 1 of a preprocessing method for anti-spoofing training images provided in this application;

[0044] Figure 2 This is a flowchart of Embodiment 2 of a preprocessing method for anti-spoofing training images provided in this application;

[0045] Figure 3 This is a schematic diagram of a target region in Embodiment 2 of the preprocessing method for anti-spoofing training images provided in this application;

[0046] Figure 4This is a schematic diagram of another target region in Embodiment 2 of the preprocessing method for anti-spoofing training images provided in this application;

[0047] Figure 5 This is a flowchart of Embodiment 3 of a preprocessing method for anti-spoofing training images provided in this application;

[0048] Figure 6 This is a flowchart of Embodiment 4 of a preprocessing method for anti-spoofing training images provided in this application;

[0049] Figure 7 This is a flowchart of Embodiment 5 of a preprocessing method for anti-spoofing training images provided in this application;

[0050] Figure 8 This is a flowchart of Embodiment 6 of a preprocessing method for anti-spoofing training images provided in this application;

[0051] Figure 9 This is a flowchart of Embodiment 7 of a preprocessing method for anti-spoofing training images provided in this application;

[0052] Figure 10 This is a flowchart of Embodiment 8 of a preprocessing method for anti-spoofing training images provided in this application;

[0053] Figure 11 This is a schematic diagram of an embodiment of a preprocessing device for anti-spoofing training images provided in this application. Detailed Implementation

[0054] 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.

[0055] like Figure 1 The flowchart shown is a sample of Embodiment 1 of a preprocessing method for anti-spoofing training images provided in this application. The method is applied to an electronic device and includes the following steps:

[0056] Step S101: Determine the target region in the face region of the image to be processed;

[0057] The target region is one of the components of a predefined face, and the face is divided into at least two predefined face components according to the type of facial features and skin.

[0058] The preset facial components are specifically human-defined facial components, such as the left eyebrow, right eyebrow, left eye, right eye, nose, mouth, and skin.

[0059] The preset definition of the face includes facial features and skin. The facial features include the left eyebrow, right eyebrow, left eye, right eye, nose, and mouth mentioned above.

[0060] It should be noted that the components of this preset face definition can be set according to the actual situation and are not limited to the facial features and skin included in the above explanation.

[0061] The image to be processed is the original image used for anti-spoofing training. In this application, the face region in the original image is processed so that information in some regions is hidden, providing anti-spoofing training images for subsequent anti-spoofing training.

[0062] Step S102: Based on a preset processing method, at least a portion of the target region is filled with preset pixels to obtain a fake detection training image.

[0063] In this process, after the target region is determined, a preset pixel filling method is used to fill all or part of the target region, so that at least part of the target region is missing feature information, thus obtaining a fake detection training image.

[0064] In this process, at least a portion of the target area is filled with preset pixels. The purpose is to erase the feature information contained in at least a portion of the target area using preset pixels, making it unrecognizable. The resulting anti-spoofing training image is an image with some information covered.

[0065] It should be noted that, in the image to be processed, a target region is identified and at least part of it is filled with preset pixels. This target region is one of the components of the preset definition of the face. The preset definition of the face contains many features. However, since feature loss processing is performed only on a part of a corresponding region in the preset definition of the face, the region to be erased is accurately determined, and it is ensured that all key regions of the image are not erased at the same time. This allows sufficient information to be retained to distinguish between real and fake. The fake detection training image obtained by erasing this region enables the fake detection model to be trained specifically on images missing a certain region, which can avoid the risk of overfitting of binary classification models and improve the learning accuracy of the face fake detection model.

[0066] It should be noted that by randomly erasing some predefined components of the face, the forgery detection model needs to learn and rely on other facial features to classify forged faces, rather than relying solely on identity features. This helps reduce the model's dependence on identity information and mitigates the risk of identity information leakage. It also prevents the forgery detection model from converging too quickly on some forgery traces with high forgery strength, thus stopping learning prematurely and leaving other forgery traces with low forgery strength unlearned. This allows the forgery detection model to capture more diverse forgery features, thereby improving the model's generalization ability. Randomly erasing some predefined components of the face simulates facial occlusion to some extent, such as partial occlusion by glasses, hats, or masks, which makes the forgery detection model more robust.

[0067] In summary, this embodiment provides a preprocessing method for anti-spoofing training images, comprising: determining a target region in the face region of the image to be processed, wherein the target region is one of the predefined components of a face, and the face is divided into at least two predefined components according to the types of facial features and skin; and filling at least a portion of the target region with predefined pixels based on a predefined processing method to obtain an anti-spoofing training image. In this embodiment, since the anti-spoofing training image is obtained by filling part or all of a region of a predefined component of a face in the image to be processed with predefined pixels, the anti-spoofing model can be trained based on this anti-spoofing training image, thereby improving the accuracy of anti-spoofing detection.

[0068] like Figure 2 The flowchart shown is a second embodiment of a preprocessing method for anti-spoofing training images provided in this application. The method includes the following steps:

[0069] Step S201: Identify a preset number of key points contained in the face region of the image to be processed;

[0070] In this process, key points contained in the face are pre-defined.

[0071] Specifically, when identifying an image to be processed, key points contained in the face region of the image are identified.

[0072] For example, the key points included in the face are set to 81.

[0073] Of course, the number of key points contained in the face and the number of key points contained in each preset component of the face can be set according to the actual situation, and this application does not limit the number.

[0074] In practice, a keypoint detector, such as the Dlib library, can be preset, which can identify key points of the face in the image.

[0075] In practice, when this preprocessing method is started, the key point detector Dlib and the face preset definition components are initialized.

[0076] Step S202: Based on the key points contained in each predefined component of a face, determine the range of the first region corresponding to each predefined component of a face;

[0077] The key point is the location of the components that characterize the preset definition of a face.

[0078] Among them, key points are predefined for the components of each face.

[0079] In practice, each key point is marked with a different identifier. The key points contained in each predefined component of a face can be divided by the identifier.

[0080] One of the components of a face preset definition includes multiple key points, each of which corresponds to multiple pixels in the image. These multiple key points constitute the components of the face preset definition.

[0081] Specifically, based on the location of each key point in the image to be processed and the key points contained in each preset facial component, the region of each preset facial component in the image to be processed can be determined.

[0082] For example, the left eye includes 10 key points, namely key points 1-10. When identifying key points in the image to be processed, the position of key points 1-10 in the image is determined, and the position range of key points 1-10 in the image is combined to obtain the area range corresponding to the left eye in the image.

[0083] Accordingly, the region range corresponding to each predefined component of the face in the image to be processed is determined in turn.

[0084] Step S203: Randomly select one of the preset facial components as the target component;

[0085] In this process, one of the multiple predefined facial components is randomly selected as the target component, and the information of the target component is erased to obtain the anti-spoofing training image.

[0086] It should be noted that the target component includes facial key points. Therefore, erasing part or all of the first region corresponding to the randomly selected target component can erase information in the effective region while avoiding the erasure of irrelevant regions, ensuring that sufficient information is retained in the final anti-spoofing training image for anti-spoofing training.

[0087] Step S204: If the target component is skin, a portion of the first region corresponding to the target component is determined as the target region;

[0088] If the randomly selected face is defined as a skin component, since the skin occupies a large area in the face, only the skin portion will have its information erased.

[0089] Specifically, a portion of the area corresponding to the first region of the target component skin is defined as the target area, and information is erased from that portion of the skin to avoid over-erasing.

[0090] like Figure 3 The diagram shows a target area, which is a portion of the skin. In the left image, target area 301 is the skin area between the nose and the eye, and in the right image, target area 302 is the skin area next to the left eye. Figure 3 The target area is indicated by a dashed line outline.

[0091] It should be noted that the specific implementation process of determining a portion of the first region range corresponding to the target group as the target region will be described in detail in subsequent embodiments, but will not be described in detail in this embodiment.

[0092] Step S205: If the target component belongs to the five senses, determine that the first region corresponding to the target component is the target region;

[0093] If the randomly selected facial features are defined as facial features, such as the left eye or nose, since any one of the facial features occupies a moderate area in the face and is not very large, the information of the entire range of the target feature can be erased.

[0094] The target component can be one or more of the five senses.

[0095] Generally, if the target component is multiple facial features, these multiple components are located in adjacent areas of the face, such as eyebrows and eyes, mouth and nose, etc.

[0096] Specifically, the entire first region corresponding to the facial features of the target component is designated as the target region, and information is erased from this target region.

[0097] like Figure 4The diagram shows another target area, which is one or more facial features. In the top left image, target area 401 is the right eyebrow; in the top middle image, target area 402 is the left eyebrow; in the top right image, target area 403 is the right eye; in the bottom left image, target area 404 is the left eye; in the bottom middle image, target area 405 is both the eyebrow and eye; and in the bottom right image, target area 406 is the mouth. Figure 4 The target area is indicated by a dashed line outline.

[0098] It should be noted that the specific implementation process of determining that the first region range corresponding to the target component is the target region will be described in detail in subsequent embodiments, and will not be described in detail in this embodiment.

[0099] Step S206: Based on a preset processing method, at least a portion of the target region is filled with preset pixels to obtain a fake detection training image.

[0100] Step S206 is the same as the corresponding step in Example 1, and will not be described again in this example.

[0101] In summary, this embodiment provides a preprocessing method for anti-spoofing training images, comprising: identifying a preset number of key points contained in a facial region of the image to be processed; determining a first region range corresponding to each preset facial component based on the key points contained in each preset facial component, wherein the key points represent the position of the preset facial component; randomly selecting one of the preset facial components as a target component; if the target component is skin, determining a portion of the first region range corresponding to the target component as a target region; if the target component belongs to facial features, determining the first region range corresponding to the target component as the target region. In this embodiment, multiple key points contained in a facial region of the image to be processed are identified; based on the key points contained in each preset facial component and the key points in the image to be processed, the first region range of each preset facial component in the image to be processed is determined; and a target component is randomly selected from the preset facial components. Different target regions are determined for the target components of skin and facial features to simulate real forgery situations and avoid excessive erasure and erasure of irrelevant areas.

[0102] like Figure 5 The flowchart shown is a third embodiment of a preprocessing method for anti-spoofing training images provided in this application. The method includes the following steps:

[0103] Step S501: Identify a preset number of key points contained in the face region of the image to be processed;

[0104] Step S502: Based on the key points contained in each preset facial component, determine the range of the first region corresponding to each preset facial component;

[0105] Step S503: Randomly select one of the preset facial components as the target component;

[0106] Steps S501-503 are the same as the corresponding steps in Example 2, and will not be repeated in this example.

[0107] Step S504: If the target component is skin, select a pixel in the first region as the basic pixel.

[0108] If the target component is skin, then a target region is defined within the first region range corresponding to the skin, and the target region is a part of the first region range.

[0109] Specifically, a pixel is selected as the base pixel within the first region corresponding to the skin in the image to be processed.

[0110] Specifically, a pixel is randomly selected from the first region as the base pixel to achieve random selection of the target region to be erased.

[0111] Step S505: Determine a selection area of ​​a preset shape centered on the basic pixel;

[0112] The preset shape can be either an irregular shape or a regular shape.

[0113] The irregular shape can be obtained by randomly combining several specific regular shapes, such as by randomly combining several circles.

[0114] The shape of the rule can be a rectangle, a circle, a square, or other symmetrical shapes.

[0115] Specifically, the preset shape can be a shape that matches the area range involved in the preset definition of a face.

[0116] In practice, when determining the selection area, the coordinate range of the selection area in the image to be processed can be determined, or the range of pixels in the image to be processed included in the selection area can be determined.

[0117] Step S506: If the selected area only includes the first region of the skin, determine the mask of the target component in the image to be processed to obtain the first mask image;

[0118] In this first mask image, the mask value within the first region is different from the mask value outside the first region.

[0119] If a pixel randomly selected within the first region is used as the center, and the selected region of the predetermined shape is within the skin's region (i.e., the selected region only includes the first region of the skin), then a target mask image will be generated based on the selected region. The mask value of the selected region in the target mask image is different from the mask values ​​of other regions, thus achieving the determination of the target region.

[0120] Specifically, the target component of the image to be processed is masked to obtain a first mask image. In the first mask image, the mask value of the first region corresponding to the target component is different from the mask values ​​of other regions.

[0121] For example, in the first mask image, the mask value for the first region is 1, and the mask value for the other regions is 0.

[0122] Step S507: Obtain the target mask image based on the first mask image and the selected area;

[0123] In the target mask image, the mask value of the selected area is different from the mask value outside the selected area, and the selected area is the target area within the range of the first area.

[0124] Wherein, based on the correspondence between the first mask image and the image to be processed, and the range of the selected area corresponding to the image to be processed has been determined, the mask value of the area in the first mask image where the target component does not correspond to the first area is adjusted according to the selected area.

[0125] For example, in the first mask image, the mask value corresponding to the first region range of the target component is 1, and the mask value of other regions range is 0. If the selected region is a part of the first region range, then the mask value of the selected region in the first mask image is kept as 1, and the remaining mask values ​​are adjusted to 0 to obtain the target mask image.

[0126] In this target mask image, the mask value of the target area is different from the mask values ​​of other areas.

[0127] Step S508: If the target component belongs to the five senses, determine that the first region corresponding to the target component is the target region;

[0128] Step S509: Based on a preset processing method, at least a portion of the target region is filled with preset pixels to obtain a fake detection training image.

[0129] Steps S508-509 are the same as the corresponding steps in Example 2, and will not be repeated in this example.

[0130] In summary, this embodiment provides a preprocessing method for anti-spoofing training images, comprising: if the target component is skin, selecting a pixel within a first region as a basic pixel; determining a selection region of a preset shape centered on the basic pixel; if the selection region only includes the first region of skin, determining a mask for the target component in the image to be processed, obtaining a first mask image, wherein the mask value of the first region in the first mask image is different from the mask value outside the first region; and obtaining a target mask image based on the first mask image and the selection region, wherein the mask value of the selected region in the target mask image is different from the mask value outside the selected region, and the selected region is the target region within the first region. In this embodiment, based on the target component being skin, a selection region of a preset shape is determined within the target component. If the selection region only includes the first region of skin, based on the first mask image corresponding to the target component in the image to be processed and the selection region, a target mask image is obtained where the mask value of the target region is different from the mask values ​​of other regions, thereby achieving the selection of the target region and providing a foundation for subsequent anti-spoofing training image generation.

[0131] like Figure 6 The flowchart shown is a sample of Embodiment 4 of a preprocessing method for anti-spoofing training images provided in this application. The method includes the following steps:

[0132] Step S601: Identify a preset number of key points contained in the face region of the image to be processed;

[0133] Step S602: Based on the key points contained in each preset facial component, determine the range of the first region corresponding to each preset facial component;

[0134] Step S603: Randomly select one of the preset facial components as the target component;

[0135] Step S604: If the target component is skin, select a pixel in the first region as the basic pixel.

[0136] Step S605: Determine a selection area of ​​a preset shape centered on the basic pixel;

[0137] Step S606: If the selected area only includes the first region of the skin, determine the mask of the target component in the image to be processed to obtain the first mask image;

[0138] Step S607: Obtain the target mask image based on the first mask image and the selected area;

[0139] Steps S601-607 are consistent with the corresponding steps in Example 3, and will not be repeated in this example.

[0140] Step S608: If the selected area includes the first area of ​​the skin and the second area of ​​the first facial features, determine the mask of each preset defined component of the face in the image to be processed, and obtain at least two mask images;

[0141] One of the mask images corresponds to a predefined component of a face.

[0142] The term "first facial feature" is used only to indicate the presence of facial features. The selected area may contain one or more first facial features.

[0143] As an example, the basic pixel is located on the skin at the center of the eyebrows, while the selection area of ​​the preset shape is relatively large. The final selected area includes the skin at the center of the eyebrows, the part of the left eyebrow near the center of the eyebrows, and the part of the right eyebrow near the center of the eyebrows.

[0144] If the selected area includes both the skin area and the facial features area, then in order to avoid erasing the facial features area, it is necessary to remove the facial features area from the selected area.

[0145] Specifically, the mask is first determined for each predefined component of the face in the image to be processed, and the mask image corresponding to each predefined component of the face is obtained.

[0146] For example, a face is predefined to consist of 5 parts: skin, eyes, nose, mouth, and eyebrows. Each part is represented by a mask image, resulting in a total of 5 mask images. For instance, in the mask image corresponding to the skin, the mask value of the first region corresponding to the skin is different from the mask values ​​of the other regions.

[0147] Step S609: Determine the target mask image based on the at least two mask images and the selected region;

[0148] In this target mask image, the mask value of the target area is different from the mask value outside the target area, and the target area is an area that belongs to the first area range but not to the second area range.

[0149] Among them, two or more mask images related to the selected area are first used in each mask image, including the mask image corresponding to the skin and the mask image corresponding to the first facial features.

[0150] Specifically, based on the selected area, the mask image corresponding to the first facial feature is compared with the mask image corresponding to the skin. The selected area is determined to belong to the mask image corresponding to the skin area but not to the mask image corresponding to the first facial feature, thus obtaining the target mask image. In the target mask image, only the mask values ​​of the selected area belonging to the skin area are different from the mask values ​​of other areas.

[0151] Step S610: If the target component belongs to the five senses, determine that the first region corresponding to the target component is the target region;

[0152] Step S611: Based on a preset processing method, fill at least a portion of the target region with preset pixels to obtain a fake detection training image.

[0153] Steps S610-611 are the same as the corresponding steps in Example 3, and will not be repeated in this example.

[0154] In summary, the preprocessing method for anti-spoofing training images provided in this embodiment further includes: if the selected region includes a first region of skin and a second region of the first facial features, determining the mask of each predefined facial component in the image to be processed to obtain at least two mask images, one mask image corresponding to one predefined facial component; based on the at least two mask images and the selected region, determining a target mask image, wherein the mask value of the target region in the target mask image is different from the mask value outside the target region, and the target region is a region belonging to the first region and not belonging to the second region. In this embodiment, based on the skin of the target component, and the selected region including the first region of skin and the second region of the first facial features, the mask of each predefined facial component in the image to be processed is determined to obtain multiple mask images. Based on the multiple mask images and the selected region, a target mask image is determined, resulting in a target mask image where the mask value of the target region is different from the mask values ​​of other regions, thus realizing the selection of the target region and providing a basis for subsequent anti-spoofing training image generation.

[0155] like Figure 7 The flowchart shown is a sample of embodiment 5 of a preprocessing method for anti-spoofing training images provided in this application. The method includes the following steps:

[0156] Step S701: Identify a preset number of key points contained in the face region of the image to be processed;

[0157] Step S702: Based on the key points contained in each preset facial component, determine the range of the first region corresponding to each preset facial component;

[0158] Step S703: Randomly select one of the preset facial components as the target component;

[0159] Step S704: If the target component is skin, a portion of the first region corresponding to the target component is determined as the target region;

[0160] Steps S701-704 are the same as the corresponding steps in Example 2, and will not be repeated in this example.

[0161] Step S705: If the target component belongs to the facial features, calculate the convex hull region according to the preset convex hull processing rules and the key points contained in the target component;

[0162] The convex hull region corresponds to the first region range.

[0163] If the target component is one of the five senses, such as the eyes, eyebrows, or nose, then proceed with steps S705-707.

[0164] The location of a key point in the image represents the region in the image to be processed corresponding to its predefined facial components.

[0165] In this embodiment, convex hull calculation is performed on each key point in the image to be processed that belongs to the same target component to obtain the convex hull region corresponding to each key point.

[0166] Specifically, the convex hull processing rules can adopt Graham scan method, Jarvis step method, etc., and this application does not restrict the specific algorithm of the convex hull processing rules.

[0167] Step S706: Process the convex hull region according to the preset random expansion rule to obtain the target mask image;

[0168] In the target mask image, the mask value of the target area is different from the mask value of the area outside the target area.

[0169] The system includes a preset random expansion rule, which can set the number of expansions and the conditions for determining the location of the expansion kernel. In practice, the specific content of the random expansion rule can be set according to the actual situation.

[0170] Specifically, an expansion kernel is set in the convex hull region, and random expansion is performed according to a set number of expansions. After processing, a target mask image corresponding to the target component is obtained.

[0171] The target mask image is obtained based on the key points of each component of the target, and each key point of the component of the target forms the target region corresponding to the component of the target. Accordingly, in the target mask image, the mask value of the target region corresponding to the component of the target is different from the mask value of other regions.

[0172] For example, in a target mask image, the mask value for the target area is 1, and the mask value for other areas is 0.

[0173] Step S707: Based on a preset processing method, at least a portion of the target region is filled with preset pixels to obtain a fake detection training image.

[0174] Step S707 is the same as the corresponding step in Example 2, and will not be described again in this example.

[0175] In summary, this embodiment provides a preprocessing method for anti-spoofing training images, comprising: if the target component belongs to facial features, calculating a convex hull region based on a preset convex hull processing rule and the key points contained in the target component, the convex hull region corresponding to a first region range; processing the convex hull region according to a preset random dilation rule to obtain a target mask image, wherein the mask value of the target region in the target mask image is different from the mask value outside the target region. In this embodiment, based on the target component belonging to facial features, a convex hull region is calculated for each key point contained in the target component according to a set convex hull processing rule, and then the icon region is dilated to obtain a target mask image. This target mask image, in which the mask value of the target region corresponding to the target component is different from the mask value of other regions, achieves the selection of the target region, providing a basis for subsequent anti-spoofing training image generation.

[0176] like Figure 8 The flowchart shown is a sample of Embodiment 6 of a preprocessing method for anti-spoofing training images provided in this application. The method includes the following steps:

[0177] Step S801: Identify a preset number of key points contained in the face region of the image to be processed;

[0178] Step S802: Based on the key points contained in each preset facial component, determine the range of the first region corresponding to each preset facial component;

[0179] Step S803: Randomly select one of the preset facial components as the target component;

[0180] Step S804: If the target component is skin, a portion of the first region corresponding to the target component is determined as the target region;

[0181] Step S805: If the target component belongs to the facial features, calculate the convex hull region according to the preset convex hull processing rules and the key points contained in the target component;

[0182] Step S806: Process the convex hull region according to the preset random expansion rule to obtain the target mask image;

[0183] Steps S801-806 are consistent with the corresponding steps in Example 5, and will not be repeated in this example.

[0184] Step S807: Based on the target mask image and the image to be processed, obtain the first image;

[0185] In the first image, the target region contains pixels with a pixel value of 0.

[0186] In this target mask image, the mask value of the target area is different from the mask values ​​of other areas.

[0187] In this target mask image, the mask value of the target area is 0, and the mask value of other areas is 1. The mask value of the target mask image can be directly multiplied with the image to be processed to obtain the first image.

[0188] In this target mask image, the mask value of the target area is 1, and the mask value of other areas is 0. The mask value of the target mask image is flipped so that the mask value of the target area is 0 and the mask value of other areas is 0. The mask value of the target mask image after the mask value is flipped is multiplied with the image to be processed to obtain the first image.

[0189] Specifically, in the first image, the pixel value of the target area is 0, while the pixel values ​​of other areas remain unchanged, thus erasing the information of the target area while retaining the information of other areas.

[0190] Step S808: Fill the pixels in the target region of the first image with random pixel values ​​to obtain the anti-spoofing training image.

[0191] In this first image, the pixel value of the target region is 0, and random pixel values ​​are used to fill the pixels of the target region.

[0192] The random pixel value is a value randomly selected from 0 to 255 and assigned to the pixel to fill the pixel.

[0193] In this process, random pixel values ​​are assigned to the pixels of the target region in the first image to fill the pixels. In the resulting anti-spoofing training image, the target region does not contain the information of the corresponding region in the image to be processed, while the information of other regions is preserved. This achieves the random erasure of some predefined components of the face in the image to be processed.

[0194] In summary, this embodiment provides a preprocessing method for a fake detection training image, comprising: obtaining a first image based on the target mask and the image to be processed, wherein the pixel value of the target region in the first image is 0; and filling the pixels of the target region in the first image with random pixel values ​​to obtain a fake detection training image. In this embodiment, the first image obtained based on the target mask and the image to be processed is an image with the target region content erased. Random pixel values ​​are used to fill the pixels of the target region in the first image to obtain a fake detection training image. The target region in the fake detection training image does not contain the information of the corresponding region in the image to be processed, while the information of other regions is retained. This achieves the random erasure of a portion of the face in the image to be processed, thus providing training samples for training a face fake detection model.

[0195] like Figure 9 The flowchart shown is a sample of embodiment 7 of a preprocessing method for anti-spoofing training images provided in this application. The method includes the following steps:

[0196] Step S901: Preset the image preprocessing probability;

[0197] In order to improve the randomness of the generation of fake detection training images, the processing probability of the images is preset to the preprocessing probability.

[0198] Specifically, the preprocessing refers to the process in subsequent steps S903-904 of processing the image to be processed to obtain the anti-spoofing training image.

[0199] The preprocessing probability can take the value (0,1), where 0 means no processing is performed and no information in any region of the image to be processed is erased, and 1 means processing is performed and the information in the target region is erased for any image to be processed.

[0200] For example, the preprocessing probability is set to 0.5.

[0201] In practice, the value of this preprocessing probability can be adjusted according to the actual usage.

[0202] In practice, when starting the process of generating fake detection training images, the preprocessing probability is initialized, and the value of the preprocessing probability is initialized.

[0203] Step S902: Generate random processing probabilities;

[0204] The random processing probability refers to the random processing probability for a single image to be processed. Different images to be processed may generate different or the same random processing probability.

[0205] In practice, when an image to be processed is obtained, a random processing probability can be generated for that image.

[0206] Specifically, the random processing probability is compared with the preprocessing probability. If the random processing probability is less than the preprocessing probability, it is determined that the image to be processed needs to be processed to obtain the anti-spoofing training image. Then, the subsequent steps S903-904 are executed.

[0207] If the random processing probability is not less than the preprocessing probability, then it is determined that the image to be processed will not be processed, and the image to be processed will be directly used as the training image for anti-spoofing.

[0208] Wherein, the preprocessing probability is p, the random processing probability is p1, the image to be processed is I, and the fake detection training image is I*. If p1≥p, I* is assigned the value I and I* is returned. If p1 is less than p, the subsequent steps S903-904 are executed.

[0209] Step S903: If the random processing probability is less than the preprocessing probability, determine the target region in the face region of the image to be processed;

[0210] Step S904: Based on a preset processing method, at least a portion of the target region is filled with preset pixels to obtain a fake detection training image.

[0211] Steps S903-904 are consistent with the corresponding steps in Example 1, and will not be repeated in this example.

[0212] In summary, the preprocessing method for anti-spoofing training images provided in this embodiment further includes: setting a preprocessing probability for the image; generating a random processing probability; and if the random processing probability is less than the preprocessing probability, triggering the step of determining the target region in the face region of the image to be processed. In this embodiment, the preprocessing probability is set, and a random processing probability is generated for each image to be processed. If the random processing probability of the image to be processed is less than the preprocessing probability, the image to be processed is processed to obtain the anti-spoofing training image, thereby improving the randomness of the generation of the anti-spoofing training image.

[0213] like Figure 10 The flowchart shown is an embodiment 8 of a preprocessing method for anti-spoofing training images provided in this application. The method includes the following steps:

[0214] Step S1001: Determine the target region in the face region of the image to be processed;

[0215] Step S1002: Based on a preset processing method, fill at least a portion of the target region with preset pixels to obtain a fake detection training image;

[0216] Steps S1001-1002 are the same as the corresponding steps in Example 1, and will not be repeated in this example.

[0217] Step S1003: Train the original model based on the fake detection training image to obtain the trained face fake detection model.

[0218] In this process, following the steps described above to obtain anti-spoofing training images, several anti-spoofing training images are obtained. Based on these anti-spoofing training images, the original model is trained to obtain a face anti-spoofing model, thereby enabling the anti-spoofing of faces in images.

[0219] It should be noted that, since the anti-spoofing training images obtained in the aforementioned steps involve erasing and filling pixels in areas related to the generation of fake faces to simulate real forgery, and random erasing is performed in conjunction with the structural information of the face set, there is an overfitting problem in the environment anti-spoofing model during the model training phase.

[0220] In summary, the preprocessing method for anti-spoofing training images provided in this embodiment further includes: training an original model based on the anti-spoofing training images to obtain a trained face anti-spoofing model. In this embodiment, the model is trained based on the anti-spoofing training images generated in the aforementioned steps to obtain a face anti-spoofing model, thus addressing the overfitting problem of the anti-spoofing model during the model training phase and improving the accuracy of the anti-spoofing model.

[0221] Corresponding to the above embodiment of the preprocessing method for anti-counterfeiting training images provided in this application, this application also provides an embodiment of an apparatus for applying the preprocessing method for anti-counterfeiting training images.

[0222] like Figure 11 The diagram shown is a structural schematic of an embodiment of a preprocessing device for anti-spoofing training images provided in this application. The device includes the following structure: a determination module 1101 and a filling module 1102.

[0223] The determining module 1101 is used to determine a target region in the face region of the image to be processed. The target region is one of the preset components of the face. The face is divided into at least two preset components of the face according to the type of facial features and skin.

[0224] The filling module 1102 is used to fill at least a portion of the target area with preset pixels based on a preset processing method to obtain a fake detection training image.

[0225] Optionally, the determining module includes:

[0226] The recognition unit is used to identify a preset number of key points contained in the face region of the image to be processed;

[0227] The first determining unit is used to determine the first region range corresponding to each preset facial component based on the key points contained in each preset facial component, wherein the key points are the positions that characterize the preset facial components.

[0228] The selection unit is used to randomly select one of the preset components of a face as the target component.

[0229] The second determining unit is configured to, if the target component is skin, determine a portion of the first region corresponding to the target component as the target region; and if the target component belongs to the five sense organs, determine the first region corresponding to the target component as the target region.

[0230] Optionally, the second determining unit is specifically used for:

[0231] If the target component is skin, select one pixel in the first region as the base pixel;

[0232] A selection area of ​​a preset shape is determined with the basic pixel as the center;

[0233] If the selected area only includes the first region of the skin, the mask of the target component in the image to be processed is determined to obtain a first mask image, wherein the mask value of the first region in the first mask image is different from the mask value outside the first region.

[0234] Based on the first mask image and the selected area, a target mask image is obtained. The mask value of the selected area in the target mask image is different from the mask value outside the selected area. The selected area is the target area within the range of the first area.

[0235] Optionally, the second determining unit is further configured to:

[0236] If the selected area includes the first area of ​​the skin and the second area of ​​the first facial features, determine the mask of each preset facial component in the image to be processed to obtain at least two mask images, one of which corresponds to one preset facial component.

[0237] Based on the at least two mask images and the selected region, a target mask image is determined. The mask value of the target region in the target mask image is different from the mask value outside the target region. The target region is a region that belongs to the first region range and does not belong to the second region range.

[0238] Optionally, the second determining unit is specifically used for:

[0239] Determining the first region range corresponding to the target component as the target region includes:

[0240] If the target component belongs to the facial features, the convex hull region is calculated based on the preset convex hull processing rules and the key points contained in the target component. The convex hull region corresponds to the first region range.

[0241] According to a preset random expansion rule, the convex hull region is processed to obtain a target mask image, wherein the mask value of the target region in the target mask image is different from the mask value outside the target region.

[0242] Optionally, the filling module is specifically used for:

[0243] Based on the target mask image and the image to be processed, a first image is obtained, wherein the pixel value of the target region in the first image is 0;

[0244] Random pixel values ​​are used to fill the pixels in the target region of the first image to obtain a fake detection training image.

[0245] Optional, also includes:

[0246] The preset module is used to preset the preprocessing probability of the image before determining the target region in the face region of the image to be processed;

[0247] The generation module is used to generate random processing probabilities;

[0248] The judgment module is used to determine whether the random processing probability is less than the preprocessing probability. If the random processing probability is less than the preprocessing probability, the determination module is triggered.

[0249] Optional, also includes:

[0250] The training module is used to train the original model based on the anti-spoofing training images to obtain the trained face anti-spoofing model.

[0251] It should be noted that the functional explanations of each component structure in the preprocessing device for anti-spoofing training images provided in this embodiment are as described in the foregoing method embodiments, and will not be repeated in this embodiment.

[0252] In summary, this embodiment provides a preprocessing device for anti-spoofing training images, comprising: a determination module, used to determine a target region in the face region of the image to be processed, wherein the target region is one of the predefined components of a face, and the face is divided into at least two predefined components according to the types of facial features and skin; and a filling module, used to fill at least a portion of the target region with predefined pixels based on a predefined processing method to obtain an anti-spoofing training image. In this embodiment, since the anti-spoofing training image is obtained by filling a portion or all of a region of the predefined components of a face in the image to be processed with predefined pixels, the anti-spoofing model can be trained based on this anti-spoofing training image, thereby improving the accuracy of anti-spoofing detection.

[0253] Corresponding to the above embodiment of the preprocessing method for anti-counterfeiting training images provided in this application, this application also provides an electronic device and a readable storage medium corresponding to the preprocessing method for anti-counterfeiting training images.

[0254] The electronic device includes: a memory and a processor;

[0255] The memory stores the processing program;

[0256] The processor is used to load and execute the processing program stored in the memory to implement the steps of the preprocessing method for the anti-spoofing training image as described in any of the preceding claims.

[0257] For the specific implementation of the preprocessing method for the anti-counterfeiting training images of this electronic device, please refer to the aforementioned embodiment of the anti-counterfeiting training image preprocessing method.

[0258] The readable storage medium stores a computer program that is invoked and executed by a processor to implement the steps of the preprocessing method for the anti-spoofing training image as described in any of the preceding claims.

[0259] Specifically, the computer program stored in the readable storage medium executes a preprocessing method for the anti-spoofing training images, as described in the aforementioned embodiment of the anti-spoofing training image preprocessing method.

[0260] The implementation of this invention is a legal use. The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. Regarding the apparatus provided in the embodiments, since it corresponds to the method provided in the embodiments, the description is relatively simple; relevant parts can be referred to in the method section.

[0261] The above description of the provided embodiments enables those skilled in the art to make or use this application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this application. Therefore, this application is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features provided herein.

Claims

1. A preprocessing method for anti-spoofing training images, characterized in that, include: Identify a preset number of key points contained in the face region of the image to be processed; Based on the key points contained in each predefined component of a face, the first region range corresponding to each predefined component of a face is determined, wherein the key points are the positions that characterize the predefined components of a face; Randomly select one of the predefined components of a face as the target component; If the target component is skin, select one pixel in the first region as the base pixel; A selection area of ​​a preset shape is determined with the basic pixel as the center; if the selection area only includes the first region of the skin, the mask of the target component in the image to be processed is determined to obtain a first mask image, wherein the mask value of the first region in the first mask image is different from the mask value outside the first region. Based on the first mask image and the selected area, a target mask image is obtained. The mask value of the selected area in the target mask image is different from the mask value outside the selected area. The selected area is the target area within the range of the first area. If the selected area includes the first area range of the skin and the second area range of the first facial features, the mask of each preset defined component of the face in the image to be processed is determined, and at least two mask images are obtained. One mask image corresponds to one preset defined component of the face. Based on the at least two mask images and the selected region, a target mask image is determined, wherein the mask value of the target region in the target mask image is different from the mask value outside the target region, and the target region is a region that belongs to the first region range and does not belong to the second region range. If the target component belongs to the facial features, a convex hull region is calculated based on the preset convex hull processing rules and the key points contained in the target component. The convex hull region corresponds to the first region range. An expansion kernel is set in the convex hull region, and random expansion processing is performed according to the set expansion number to obtain a target mask image corresponding to the target component. The mask value of the target region in the target mask image is different from the mask value outside the target region. A first image is obtained based on the target mask image and the image to be processed, wherein the pixel value of the target region in the first image is 0; Random pixel values ​​between 0 and 255 are used to fill the pixels in the target area of ​​the first image to obtain a fake detection training image.

2. The method according to claim 1, characterized in that, Before determining the target region in the face region of the image to be processed, the following steps are also included: Pre-processing probability of the preset image; Generate random processing probabilities; If the random processing probability is less than the preprocessing probability, the step of determining the target region in the face region of the image to be processed is triggered.

3. The method according to claim 1, characterized in that, Also includes: The original model is trained based on the aforementioned anti-spoofing training images to obtain a trained face anti-spoofing model.

4. A preprocessing device for anti-spoofing training images, characterized in that, include: The determination module is used to determine a target region in the face region of the image to be processed. The target region is one of the predefined components of the face. The face is divided into at least two predefined components of the face according to the type of facial features and skin. A filling module is used to obtain a first image based on a target mask image and the image to be processed, wherein the pixel value of the target region in the first image is 0; and to fill the pixels of the target region in the first image with random pixel values ​​between 0 and 255 to obtain a fake detection training image. The determining module includes: The recognition unit is used to identify a preset number of key points contained in the face region of the image to be processed; The first determining unit is used to determine the first region range corresponding to each preset facial component based on the key points contained in each preset facial component, wherein the key points are the positions that characterize the preset facial components. The selection unit is used to randomly select one of the preset components of a face as the target component. The second determining unit is configured to: if the target component is skin, select a pixel as a basic pixel within the first region; determine a selection region of a preset shape centered on the basic pixel; if the selection region only includes the first region of skin, determine a mask of the target component in the image to be processed to obtain a first mask image, wherein the mask value of the first region in the first mask image is different from the mask value outside the first region; based on the first mask image and the selection region, obtain a target mask image, wherein the mask value of the selected region in the target mask image is different from the mask value outside the selected region, and the selected region is the target region within the first region; if the selection region includes the first region of skin and the second region of the first facial features, determine each face in the image to be processed. A mask is defined for a predefined component, resulting in at least two mask images, one of which corresponds to a predefined component of a face. Based on the at least two mask images and the selected region, a target mask image is determined. The mask value of the target region in the target mask image is different from the mask value outside the target region. The target region belongs to a first region range but not to a second region range. If the target component is a facial feature, a convex hull region is calculated according to a predefined convex hull processing rule and the key points contained in the target component. The convex hull region corresponds to the first region range. An expansion kernel is set in the convex hull region, and random expansion processing is performed according to a set number of expansions to obtain a target mask image corresponding to the target component. The mask value of the target region in the target mask image is different from the mask value outside the target region.

5. An electronic device, characterized in that, include: Memory, processor; The memory stores the processing program; The processor is used to load and execute the processing program stored in the memory to implement the steps of the preprocessing method for anti-spoofing training images as described in any one of claims 1-3.

Citation Information

Patent Citations

  • Face recognition method and device, training method and device of face recognition network and storage medium

    CN111723612A