Image detection model training method and device, image detection method and device, equipment and medium

By using a combination of feature extraction network and classification network in the image detection model, the problem of poor performance of traditional image detection methods in identifying real and fake images is solved, and the accuracy and generalization of image detection are improved.

CN118657986APending Publication Date: 2024-09-17BEIJING BAIDU NETCOM SCI & TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410736821.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-07
Publication Date
2024-09-17

AI Technical Summary

Technical Problem

Existing Technology In image detection, especially in face image detection, with the development of AI technology, the face images obtained by AI are becoming more and more realistic. Traditional image detection methods are not effective and are difficult to effectively identify real images and fake ones. image.

Method used

An image detection model is adopted, including a feature extraction network, a first classification network, and a second classification network. Candidate image features at multiple scales are extracted through the feature extraction network, and a total loss function is constructed by combining the predicted values ​​of the first and second classification networks. , adjust model parameters to improve the accuracy and generalization of image detection.

Benefits of technology

It improves the accuracy and generalization of image detection, can more effectively identify real images and fake images, and enhances image authentication performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118657986A
    Figure CN118657986A
Patent Text Reader

Abstract

The invention provides an image detection model training and image detection method and device, equipment and a storage medium, relates to the technical field of artificial intelligence, in particular to the technical fields of computer vision, deep learning and the like, and can be applied to scenes of smart cities, smart industries and the like. The image detection model comprises a feature extraction network, a first classification network and a second classification network, the image detection model training method comprises the steps that the feature extraction network is adopted to obtain image features, and the image features comprise candidate image features used for representing at least one preset clue; obtaining a first category prediction value by adopting the first classification network; obtaining target image features based on the candidate image features; using the second classification network to obtain a second category prediction value; constructing a total loss function based on the first category prediction value and the second category prediction value; and adjusting model parameters by adopting the total loss function.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of artificial intelligence technology, specifically computer vision, deep learning and other technical fields, and can be applied to scenarios such as smart cities and smart industries. In particular, it relates to image detection model training and image detection methods, devices, equipment and media. Background Art

[0002] Image detection technology refers to identifying whether an image is real. With the development of artificial intelligence (AI) technology, the images obtained using AI technology are becoming more and more realistic, so it is necessary to improve the image detection effect. Summary of the invention

[0003] The present disclosure provides an image detection model training and image detection method, device, equipment and medium.

[0004] According to one aspect of the present disclosure, a training method for an image detection model is provided, wherein the image detection model includes: a feature extraction network, a first classification network, and a second classification network, wherein the method includes: using the feature extraction network to perform feature extraction processing on a sample image to obtain image features, wherein the image features include: candidate image features of at least one scale; the candidate image features of at least one scale are used to characterize at least one preset clue; using the first classification network to perform classification processing on the candidate image features of at least one scale to obtain a first category prediction value; based on the candidate image features of at least one scale, obtaining target image features; using the second classification network to perform classification processing on the target image features to obtain a second category prediction value; constructing a total loss function based on the first category prediction value and the second category prediction value; and using the total loss function to adjust the model parameters of the feature extraction network, the model parameters of the first classification network, and the model parameters of the second classification network.

[0005] According to another aspect of the present disclosure, an image detection method is provided, comprising: performing feature extraction processing on an image to be detected to obtain image features, the image features comprising: candidate image features of at least one scale; the candidate image features of at least one scale are used to characterize at least one preset clue; classifying the candidate image features of at least one scale to obtain a first category prediction value; acquiring fused image features based on the first category prediction value and the candidate image features of the at least one scale; classifying the fused image features to obtain a second category prediction value; and determining an authentication result of the image to be detected based on the second category prediction value.

[0006] According to another aspect of the present disclosure, a training device for an image detection model is provided, the image detection model comprising: a feature extraction network, a first classification network and a second classification network, the device comprising: an extraction module for using the feature extraction network to perform feature extraction processing on a sample image to obtain image features, the image features comprising: candidate image features of at least one scale; the candidate image features of at least one scale are used to characterize at least one preset clue; a first classification module for using the first classification network to perform classification processing on the candidate image features of at least one scale to obtain a first category prediction value; an acquisition module for acquiring target image features based on the candidate image features of at least one scale; a second classification module for using the second classification network to perform classification processing on the target image features to obtain a second category prediction value; a construction module for constructing a total loss function based on the first category prediction value and the second category prediction value; an adjustment module for using the total loss function to adjust the model parameters of the feature extraction network, the model parameters of the first classification network and the model parameters of the second classification network.

[0007] According to another aspect of the present disclosure, an image detection device is provided, comprising: an extraction module, configured to perform feature extraction processing on an image to be detected to obtain image features, wherein the image features include: candidate image features of at least one scale; the candidate image features of at least one scale are used to characterize at least one preset clue; a first classification module, configured to perform classification processing on the candidate image features of at least one scale to obtain a first category prediction value; a fusion module, configured to obtain fused image features based on the first category prediction value and the candidate image features of at least one scale; a second classification module, configured to perform classification processing on the fused image features to obtain a second category prediction value; and a determination module, configured to determine an authentication result of the image to be detected based on the second category prediction value.

[0008] According to another aspect of the present disclosure, an electronic device is provided, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute any method as described in any of the above aspects.

[0009] According to another aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to enable the computer to execute any one of the methods according to any one of the above aspects.

[0010] According to another aspect of the present disclosure, a computer program product is provided, including a computer program, wherein when the computer program is executed by a processor, the computer program implements any one of the methods described in any one of the above aspects.

[0011] According to the technical solution disclosed in the present invention, the image detection effect can be improved.

[0012] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0013] The accompanying drawings are used to better understand the present solution and do not constitute a limitation of the present disclosure.

[0014] Figure 1 is a schematic diagram according to a first embodiment of the present disclosure;

[0015] Figure 2 is a schematic diagram of an application scenario for implementing an embodiment of the present disclosure;

[0016] Figure 3 is a structural schematic diagram of an image detection model provided according to an embodiment of the present disclosure;

[0017] Figure 4 is a schematic diagram according to a second embodiment of the present disclosure;

[0018] Figure 5 is a schematic diagram according to a third embodiment of the present disclosure;

[0019] Figure 6 is a schematic diagram according to a fourth embodiment of the present disclosure;

[0020] Figure 7 is a schematic diagram according to a fifth embodiment of the present disclosure;

[0021] Figure 8 It is a schematic diagram of an electronic device used to implement the training method of the image detection model or the image detection method of the embodiment of the present disclosure. DETAILED DESCRIPTION

[0022] The following is a description of exemplary embodiments of the present disclosure in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, for the sake of clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.

[0023] Taking face image detection as an example, face image detection can identify whether a face image is a real person image or an image obtained by AI (such as synthesis or editing). It is an important component of the face recognition system and ensures the security of the face recognition system.

[0024] In related technologies, face image detection is usually performed based on traditional machine learning technology or deep learning technology. However, with the development of AI technology, face images obtained by AI are becoming more and more realistic, and traditional face image detection methods have the problem of poor results.

[0025] In order to improve the image detection effect, the present disclosure provides the following embodiments.

[0026] Figure 1 is a schematic diagram according to the first embodiment of the present disclosure. This embodiment provides a training method for an image detection model, the image detection model comprising: a feature extraction network, a first classification network and a second classification network, the method comprising:

[0027] 101. Using the feature extraction network, perform feature extraction processing on a sample image to obtain image features, wherein the image features include: candidate image features of at least one scale; the candidate image features of at least one scale are used to represent at least one preset clue.

[0028] 102. Use the first classification network to perform classification processing on the candidate image features of the at least one scale to obtain a first category prediction value.

[0029] 103. Obtain target image features based on the candidate image features of the at least one scale.

[0030] 104. Use the second classification network to classify the target image features to obtain a second category prediction value.

[0031] 105. Construct a total loss function based on the first category prediction value and the second category prediction value.

[0032] 106. Use the total loss function to adjust model parameters of the feature extraction network, model parameters of the first classification network, and model parameters of the second classification network.

[0033] The sample images refer to images used as training samples, which may come from existing data sets.

[0034] The sample image includes a target object, and the target object varies depending on the recognition scenario. For example, in a face recognition scenario, the target object is a face, and the corresponding sample image is a face image; or, in a person recognition scenario, the target object is a person, and the corresponding sample image is a person image; or, in a vehicle recognition scenario, the target object is a vehicle, and the corresponding sample image is a vehicle image.

[0035] Sample images include positive sample images and negative sample images. Positive sample images are real images, i.e., non-forged images. Negative sample images are non-real images, such as forged images obtained by artificial forgery or AI forgery (synthesis or editing). Taking facial images as an example, forged images can be obtained by forgery methods such as head replacement, face replacement, or facial feature editing.

[0036] Preset clues are used to characterize the image processing category, which can be set. In the forged image scenario, the preset clues are used to characterize the forgery category. The forgery can be artificial forgery or forgery through AI (synthesis or editing). Taking AI editing as an example, the preset clues include: head replacement, face replacement, and facial feature editing.

[0037] The feature extraction network refers to a deep neural network that extracts features from images. During the training phase, the input of the feature extraction network is the sample image, and the output is the image features.

[0038] In order to identify a wider range of forgeries, there are usually multiple preset clues, such as the three preset clues mentioned above: head replacement, face replacement, and facial feature editing.

[0039] In order to characterize a variety of preset clues, the image features adopt candidate image features of multiple scales, that is, candidate image features of multiple scales are adopted to characterize a variety of preset clues.

[0040] In order to obtain candidate image features of multiple scales, the feature extraction network can adopt a feature pyramid network (Feature Pyramid Network), and the specific network can be ResNet, MobileNet, etc.

[0041] Candidate image features at multiple scales correspond one-to-one to multiple preset clues.

[0042] Taking the above three preset clues as an example, the candidate image features of the three scales are represented by F1, F2, and F3 from high to shallow. Since the forgery category of facial feature editing is reflected in local features and belongs to low-level texture features, the shallow network can capture this feature, so F3 corresponds to the preset clue of facial feature editing; and the face-changing forgery is reflected in the global and local features and is classified as a medium-level scale feature, so F2 corresponds to the preset clue of face-changing; and the head-changing forgery is reflected in the contour features around the head, which requires global features to judge and is classified as a high-level scale feature, so F1 corresponds to the preset clue of head-changing.

[0043] Taking the candidate image features of multiple scales as an example, the input of the first classification network is the candidate image features of multiple scales, and the output is the first category prediction value; the input of the second classification network is the target image feature, and the output is the second category prediction value, and the target image feature is obtained based on the candidate image features of multiple scales. The classification network can be a fully connected network.

[0044] Specifically, if the sample image is a negative sample image (such as an image obtained by AI), the candidate image feature corresponding to the clue label is selected as the target image feature according to the clue label of the negative sample image. For example, if the negative sample image is obtained by head replacement, the target image feature is F1.

[0045] If the sample image is a positive sample image (real image), one of F1 to F3 can be randomly selected as the target image feature, or the mean of F1 to F3 can be calculated and the mean feature can be used as the target image feature.

[0046] The first category prediction value is used to characterize the occurrence probability of each preset clue. Taking the above three preset clues as an example, the first classification network is a three-classification network.

[0047] The second category prediction value is used to characterize the probability that the sample image is a positive sample and the probability that the sample image is a negative sample. The second classification network is a binary classification network.

[0048] After obtaining the first category prediction value and the second category prediction value, a first loss function can be constructed based on the first category prediction value and its corresponding true value (called the first category true value), and a second loss function can be constructed based on the second category prediction value and its corresponding true value (called the second category true value), and then a total loss function can be constructed based on the first loss function and the second loss function.

[0049] The above true value can be the sample image itself, or it can be annotated manually or by other means, and is usually represented by 1 or 0. Taking the three preset clues as an example, the first category prediction value and the first category true value are both vectors of dimension 3, and each element corresponds to a preset clue. For example, if the sample image is forged using the first forgery category, the first element of the first category true value is represented by 1, and the rest are 0, that is, [1,0,0]. Similarly, if the sample image is forged using the second forgery category, the first category true value = [0,1,0]. If the sample image is a real image, the first category true value = [0,0,0].

[0050] The second category prediction value can specifically be the probability that the sample image belongs to a positive sample. Correspondingly, the second category true value is the true value of whether the sample image is a positive sample. For example, if the sample image is a positive sample image, the second category true value = 1. If the sample image is a negative sample image (regardless of the forgery method), the second category true value = 0.

[0051] The first loss function and the second loss function are both functions used to characterize classification loss, and specifically may be cross entropy loss functions.

[0052] After obtaining the first loss function and the second loss function, a total loss function is constructed based on the first loss function and the second loss function.

[0053] After obtaining the total loss function, the total loss function is used to adjust the model parameters to obtain the final image detection model. In this embodiment, the adjusted model parameters include: model parameters of the feature extraction network and model parameters of the classification network.

[0054] The model training process includes multiple iterations, starting from the initial value, and continuously updating the model parameters until the preset end conditions are met (such as reaching a preset number of times or model convergence) to obtain the final image detection model.

[0055] The model is updated based on the total loss function, for example, by using the back propagation (BP) algorithm to adjust the model parameters.

[0056] In this embodiment, since the candidate image features of at least one scale are used to characterize at least one preset clue, the preset clue information can be introduced into the model. The preset clue information can reflect the fine-grained information of the image, so that more discriminative image features can be obtained, and then classification can be performed based on the image features, which can improve the accuracy of the classification results, improve the generalization of the model, and thus improve the image detection effect.

[0057] In order to better understand the embodiments of the present disclosure, application scenarios to which the embodiments of the present disclosure can be applied are described.

[0058] Figure 2 Schematic diagram of an application scenario for implementing the disclosed embodiment. This embodiment takes image detection based on a face image as an example, specifically detecting whether the face image is a real person image. Figure 2 As shown, the user can use a user terminal to upload the face image to be processed. The user terminal can be a terminal with an image acquisition module (such as a camera), such as a mobile phone, a tablet computer, a laptop computer, a smart wearable device, etc.

[0059] Taking a mobile phone as an example, an application (Application, APP) that needs to perform image detection can be installed on the mobile phone 201. When image detection is required, the APP can use the camera on the mobile phone 201 to collect the user's face image, and transmit the face image to the server. The server can be called an image detection system. The server can be deployed on the server 202, and the server can be a local server or a cloud server. After the server receives the face image, the face image is input into the image detection model and the output is the detection result. In this embodiment, the detection result is used to indicate whether the image to be detected is a real person image. The server can return the detection result to the APP, and the APP can pass or not pass face recognition based on the detection result. For example, if the detection result is a real person image, face recognition is passed, and if the detection result is not a real person image, face recognition is not passed. The above-mentioned server performs image detection based on the image detection model as an example. It can be understood that if the user terminal has the corresponding ability locally, image detection can also be performed locally on the user terminal based on the image detection model.

[0060] The image detection model is obtained through training. Figure 3 Schematic diagram of the structure of the image detection model provided according to the embodiment of the present disclosure. Figure 3 As shown, the image detection model includes: a feature extraction network, a first classification network and a second classification network. This embodiment takes the extraction of candidate image features of multiple scales as an example.

[0061] The image detection model can be specifically used for image authentication, that is, to identify whether an image is a real image or a forged image. Accordingly, the image detection model can be called an image authentication model, and the preset clues can be called forgery clues. Taking face image detection as an example, the detection result is a real image or a forged image.

[0062] Regarding the training process: the input of the image detection model is a sample image, which is input into the feature extraction network. The feature extraction network is a feature pyramid network, which can extract candidate image features of multiple scales. Each scale of candidate image features corresponds to a preset clue. Taking the above-mentioned three preset clues (head change, face change, and facial feature editing) as an example, candidate image features of three scales are obtained, which are represented as F1, F2, and F3 from high-level features to low-level features. The multiple candidate image features can be obtained by fusing (such as adding) the output features of different stages of the feature extraction network, wherein the high-level output features can be upsampled and pooled before fusion to ensure that the fused features are of the same dimension.

[0063] After the sample image is processed by the feature extraction network, candidate image features of multiple scales are obtained, such as F1 to F3. On the one hand, the candidate image features of multiple scales are input into the first classification network, which merges the candidate image features of multiple scales and then performs pooling processing, such as global average pooling (GAP) processing, and then inputs them into the multi-classifier to obtain the first category prediction value. The classification categories of the multi-classifier are the same as the number of candidate image features. For example, if there are three scales of candidate image features, the multi-classifier is a three-classifier. On the other hand, the candidate image features of multiple scales are input into the second classification network. The second classification network obtains a target image feature based on the candidate image features of multiple scales according to the forgery of the sample image. If the sample image is a forged image, the candidate image feature corresponding to the forged category of the forged image is selected as the target image feature; or, if the sample image is a real person image, a candidate image feature can be randomly selected as the target image feature, or the candidate image features of multiple scales are averaged, and the calculated average image feature is used as the target image feature. The target image features are processed by merging and pooling (such as GAP) and then input into the binary classifier to obtain the second category prediction value.

[0064] After obtaining the first category prediction value, the first loss function L is constructed according to the first category prediction value and its corresponding true value. s After obtaining the second category prediction value, the second loss function L is constructed according to the second category prediction value and its corresponding true value. b .

[0065] The first loss function and the second loss function mentioned above are used to characterize the classification losses of different dimensions. Therefore, by constructing the total loss function based on the first loss function and the second loss function, multi-dimensional classification information can be considered to improve the supervision performance and thus improve the model performance.

[0066] In addition, when constructing the total loss function, in addition to the classification loss, the loss of the regression graph dimension can also be considered.

[0067] Specifically, Figure 3 As shown in the figure, during the training phase, the regression image features output by the feature extraction network (such as the output features of the last stage) can be input into the generation network (such as a decoder). The output of the generation network is an image, which can be called a generated image. The size of the generated image is the same as that of the sample image.

[0068] The generative network is a deep learning network that generates images based on image features. It may specifically include modules such as deconvolution and upsampling. The generative network may be pre-trained before training the image detection model (offline training), or it may be trained together with the image detection model (online training).

[0069] In addition, a clue image may be obtained, and a third loss function may be constructed based on the clue image and the generated image.

[0070] The clue image is generated based on the sample image and is used to represent at least one preset clue.

[0071] The clue image can be generated offline, which can reduce the training time of the image detection model; or, the clue image can also be generated online based on the sample image.

[0072] The clue image can be generated as follows:

[0073] Performing difference processing on the sample image and a real image corresponding to the sample image to obtain an attack image;

[0074] Based on the contour position of the target object in the sample image, binarizing the sample image to obtain a contour image;

[0075] Performing conversion processing on the sample image to obtain a conversion image in a different domain from the sample image;

[0076] The clue image is generated based on at least one of the attack image, the contour image, and the transition image.

[0077] In this embodiment, since the attack image, contour image and conversion image can reflect preset clues of different dimensions, the clue image generated based on at least one of the above images can contain preset clue information of at least one dimension, and then the loss function is constructed based on the clue image, and the preset clue supervision information can be introduced to improve the image authentication performance.

[0078] Further, any one of the attack image, the contour image and the conversion image may be selected as the clue image; or at least two of the attack image, the contour image and the conversion image may be merged to obtain the clue image.

[0079] In this embodiment, by adopting a variety of methods to obtain clue images, clue images can be obtained flexibly and accurately, which is convenient for subsequent processing.

[0080] In addition, when obtaining the clue image, the attack image, the contour image, and the conversion image can be normalized to obtain a normalized image of at least one dimension, and then the clue image is obtained based on the normalized image of at least one dimension. Image normalization refers to the process of performing a series of standard processing transformations on an image to transform it into a fixed standard form. The standard image is called a normalized image.

[0081] like Figure 3 As shown, in this embodiment, the clue image is an attack image as an example. The attack image is a difference image obtained by performing difference calculation between the sample image and its corresponding real person image. The difference image is called the attack image. The difference calculation is obtained by subtracting the pixel values ​​at corresponding positions of the image and taking the absolute value.

[0082] After obtaining the attack image and the generated image, a third loss function is constructed based on the two images. The third loss function is a function used to reflect the regression loss between images, for example, it can be an L2 loss function.

[0083] After obtaining the first loss function, the second loss function and the third loss function, a total loss function is constructed based on these three loss functions. Since the first loss function and the second loss function are both classification loss functions, the first loss function and the second loss function can be weightedly added, and the classification loss function and the third loss function can be directly added.

[0084] The formula is:

[0085] L=α*L s +(1-α)*L b +L2

[0086] Among them, L is the total loss function, L s is the first loss function, L b is the second loss function, L2 is the third loss function, and α is the weight corresponding to the first loss function, which can be called the balance coefficient.

[0087] The above-mentioned balance coefficient may be a preset fixed value, or the initial value of the balance coefficient may be a preset value, such as α=0.9, and decreases to a preset minimum value as the number of iterations of the training process increases, the minimum value being, for example, α=0.5, and specifically may be reduced in a linear manner. Since the balance coefficient α is a relatively large value in the early stage of training, the classification of candidate image features can be emphasized in the early stage of training, the feature extraction capability can be improved, and the model performance can be improved.

[0088] After obtaining the above-mentioned total loss function, the total loss function is used to adjust the model parameters, specifically including the model parameters of the feature extraction network, the model parameters of the first classification network, and the model parameters of the second classification network, until the end condition of the model training is reached. The model that reaches the end condition is used as the final image detection model, and the final image detection model is used in the image detection stage.

[0089] For the image detection stage: the model input is the image to be detected, and the image to be detected is input into the pre-trained feature extraction network to obtain candidate image features of multiple scales, such as F1~F3. On the one hand, the candidate image features of multiple scales are input into the pre-trained first classification network, and the first classification network merges the candidate image features of multiple scales and then performs pooling processing, such as global average pooling (GAP) processing, and then inputs into the multi-classifier to obtain the first category prediction value. The first category prediction value is the same as the number of candidate image features. For example, if there are three scales of candidate image features, the first category prediction value is three, corresponding to one scale of candidate image features, which is used to characterize the probability of occurrence of the corresponding preset clue. After that, the first category prediction value is normalized to obtain the normalized probability, which is represented by p1~p3 respectively. The normalization processing, for example, uses the softmax function to process the three first category prediction values ​​output by the three classifiers.

[0090] After obtaining the above three normalized probabilities, the three normalized probabilities p1~p3 are used to perform weighted sum operation on the three candidate image features F1~F3 to obtain the fused image feature F, which is expressed as:

[0091] F=p1*F1+p2*F2+p3*F3.

[0092] The fused image features are input into a pre-trained second classification network, which performs pooling (such as GAP) on the fused image features and then inputs them into a binary classifier to output a second category prediction value. There are two second category prediction values, which are used to characterize the probability that the image to be detected is a real image and a forged image, respectively. Afterwards, the result corresponding to the larger probability is used as the image detection result. For example, if the probability of a real image is greater than the probability of a forged image, the image detection result is a real image. Otherwise, if the probability of a real image is less than the probability of a forged image, the image detection result is a forged image.

[0093] In combination with the above application scenarios, the present disclosure also provides the following embodiments.

[0094] Figure 4 is a schematic diagram according to the second embodiment of the present disclosure. This embodiment provides a training method for an image detection model, the image detection model comprising: a feature extraction network, a first classification network and a second classification network, the method comprising:

[0095] 401. Using the feature extraction network, perform feature extraction processing on the sample image to obtain image features, wherein the image features include: candidate image features and regression image features at multiple scales; the candidate image features at multiple scales correspond one-to-one to multiple preset clues.

[0096] The feature extraction network is a feature pyramid network, which can extract image features of multiple scales, including the candidate image features and regression image features mentioned above. Candidate image features are usually the features output by the intermediate stage, and regression image features are usually the features output by the last stage.

[0097] 402. Using the first classification network, classify the candidate image features of the multiple scales to obtain a first category prediction value; and construct a first loss function based on the first category prediction value and the first category true value corresponding to the sample image.

[0098] 403. Obtain target image features based on the candidate image features of the at least one scale.

[0099] Specifically, it may include: if the sample image is forged based on any one of the multiple preset clues, using the candidate image features corresponding to any one of the preset clues as the target image features; or, if the sample image is a real image, randomly selecting or averaging the candidate image features of the multiple scales to obtain the target image features.

[0100] In this embodiment, the target image features are obtained according to the actual forgery situation of the sample image, which can improve the accuracy of the target image features and further improve the model performance.

[0101] 404. Use the second classification network to classify the target image features to obtain a second category prediction value; and construct a second loss function based on the second category prediction value and the second category true value corresponding to the sample image.

[0102] 405. Perform generation processing on the regression image features to obtain a generated image.

[0103] 406. Perform difference processing on the sample image and a real image corresponding to the sample image to obtain an attack image.

[0104] Among them, taking face image recognition as an example, the sample image is a face image, which can be a real person image or a forged image; the real image corresponding to the sample image refers to a real person image. If the sample image is a real person image, then the corresponding real image is the real person image itself, or, if the sample image is a forged image, then the corresponding real image is a real person image without forgery.

[0105] 407. Construct a third loss function based on the generated image and the attack image.

[0106] 408. Construct a total loss function based on the first loss function, the second loss function, and the third loss function.

[0107] 409. Use the total loss function to adjust model parameters of the feature extraction network, model parameters of the first classification network, and model parameters of the second classification network.

[0108] In this embodiment, in addition to constructing the first loss function and the second loss function, a third loss function is constructed based on the generated image and the attack image, and a total loss function is constructed based on the first loss function, the second loss function and the third loss function. In this way, the total loss function not only reflects the classification loss, but also reflects the graph loss for preset clues. Therefore, the total loss function contains more information, thereby improving the model detection performance and the detection accuracy when the model is applied for image detection.

[0109] In some embodiments, constructing a total loss function based on the first loss function, the second loss function and the third loss function includes:

[0110] Performing weighted sum processing on the first loss function and the second loss function to obtain a weighted sum loss function;

[0111] The weighted-sum loss function and the third loss function are added to obtain a total loss function.

[0112] In this embodiment, by performing weighted sum processing on the first loss function and the second loss function, different emphases can be placed on the two classifications to improve model performance.

[0113] In some embodiments, during the weighted summation processing, the first loss function corresponds to a first weight, the second loss function corresponds to a second weight, and the sum of the first weight and the second weight is 1; the initial value of the first weight is a set value, and decreases with the increase in the number of training iterations.

[0114] In this way, more attention can be paid to the classification results corresponding to the preset clues in the early stage of training, which is helpful to extract more discriminative candidate image features, thereby improving the classification effect and generalization of the model.

[0115] Figure 5 is a schematic diagram according to a third embodiment of the present disclosure. This embodiment provides an image detection method, the method comprising:

[0116] 501. Perform feature extraction processing on an image to be detected to obtain image features, where the image features include: candidate image features of at least one scale; the candidate image features of at least one scale are used to represent at least one preset clue.

[0117] 502. Classify the candidate image features of the at least one scale to obtain a first category prediction value.

[0118] 503. Obtain a fused image feature based on the first category prediction value and the candidate image feature of the at least one scale.

[0119] 504. Classify the fused image features to obtain a second category prediction value.

[0120] 505. Determine an authentication result of the image to be detected based on the second category prediction value.

[0121] Among them, the image to be detected contains a target object, and the target object varies according to different recognition scenarios. For example, in a face recognition scenario, the target object is a face, and the corresponding sample image is a face image; or, in a person recognition scenario, the target object is a person, and the corresponding sample image is a person image; or, in a vehicle recognition scenario, the target object is a vehicle, and the corresponding sample image is a vehicle image.

[0122] Preset clues are used to represent image processing categories, which can be set. Taking AI editing as an example, preset clues include: head replacement, face replacement, and facial features editing.

[0123] Image features can be obtained through a feature extraction network. In the detection stage, the input of the feature extraction network is the image to be detected, and the output is the image features.

[0124] In order to identify a wider range of forgeries, there are usually multiple preset clues, such as the three preset clues mentioned above: head replacement, face replacement, and facial feature editing.

[0125] In order to characterize a variety of preset clues, the image features adopt candidate image features of multiple scales, that is, candidate image features of multiple scales are adopted to characterize a variety of preset clues.

[0126] In order to obtain candidate image features of multiple scales, the feature extraction network can adopt a feature pyramid network (Feature Pyramid Network), and the specific network can be ResNet, MobileNet, etc.

[0127] Candidate image features at multiple scales correspond one-to-one to multiple preset clues.

[0128] Taking the above three preset clues as an example, the candidate image features of the three scales are represented by F1, F2, and F3 from high to shallow. Since the forgery category of facial feature editing is reflected in local features and belongs to low-level texture features, the shallow network can capture this feature, so F3 corresponds to the preset clue of facial feature editing; and the face-changing forgery is reflected in the global and local features and is classified as a medium-level scale feature, so F2 corresponds to the preset clue of face-changing; and the head-changing forgery is reflected in the contour features around the head, which requires global features to judge and is classified as a high-level scale feature, so F1 corresponds to the preset clue of head-changing.

[0129] Taking candidate image features of multiple scales as an example, the input of the first classification network is the candidate image features of multiple scales, and the output is the first category prediction value; the input of the second classification network is the fused image features, and the output is the second category prediction value, and the fused image features are obtained based on the candidate image features of multiple scales and the first category prediction value.

[0130] The first category prediction value is used to characterize the occurrence probability of each preset clue.

[0131] The second category prediction value is used to characterize the probability that the sample image is a positive sample and the probability that the sample image is a negative sample.

[0132] After obtaining the second category prediction value, the result with a high probability can be used as the detection result. For example, the second category prediction value includes a first probability value and a second probability value, the first probability value corresponds to a real person image, and the second probability value corresponds to a forged image. If the first probability value is greater than the second probability value, the image detection result is true, such as the image to be detected is a real person image. On the contrary, if the first probability value is less than the second probability value, the image detection result is false, that is, the image to be detected is not a real person image.

[0133] In this embodiment, processing is performed based on candidate image features at at least one scale, and these candidate image features represent at least one preset clue. Therefore, preset clue information can be introduced in image detection. Since the preset clue information can reflect the fine-grained information of the image, more discriminative image features can be obtained, and then classification is performed based on the image features, which can improve the accuracy of the classification results, improve the generalization of the model, and thus improve the image detection effect.

[0134] In some embodiments, the candidate image features of the at least one scale are candidate image features of multiple scales, the first category prediction value is multiple, and the acquiring of the fused image features based on the first category prediction value and the candidate image features of the at least one scale includes:

[0135] Normalizing the multiple first category prediction values ​​to obtain multiple normalized values;

[0136] The multiple normalized values ​​are used to perform weighted sum processing on the candidate image features of the multiple scales to obtain the fused image feature.

[0137] For example, a softmax function may be used for normalization processing to obtain normalized values, which correspond one-to-one to the candidate image features. Then, a weighted sum operation is performed using the normalized values ​​corresponding to each candidate image feature to obtain a fused image feature.

[0138] In this embodiment, the normalized value corresponding to the prediction value of the first category is used to perform weighted sum processing on the candidate image features of multiple scales to obtain a fused image feature. The fused image feature can accurately include candidate image features of different scales, accurately reflect the preset clue information of different categories, improve the discriminability of the fused image feature, and improve the image detection performance.

[0139] In some embodiments, the step of performing feature extraction processing on the image to be detected to obtain image features includes:

[0140] Using the feature extraction network in the pre-trained image detection model, perform feature extraction processing on the image to be detected to obtain image features;

[0141] The classifying process of the candidate image features of the at least one scale to obtain a first category prediction value includes:

[0142] Using a first classification network in the image detection model, classify the candidate image features of the at least one scale to obtain a first category prediction value;

[0143] The classifying process of the fused image features to obtain a second category prediction value includes:

[0144] Using a second classification network in the image detection model, classify the fused image features to obtain a second category prediction value;

[0145] The image detection model is trained using any one of the above embodiments.

[0146] In this embodiment, since the image detection model refers to preset clue information during training, the image detection performance can be improved, and then image detection based on the image detection model with better performance can improve the image detection effect.

[0147] Figure 6 is a schematic diagram according to the fourth embodiment of the present disclosure. This embodiment provides a training device for an image detection model, wherein the image detection model comprises: a feature extraction network, a first classification network and a second classification network, such as Figure 6 As shown, the device 600 includes: an extraction module 601, a first classification module 602, an acquisition module 603, a second classification module 604, a construction module 605 and an adjustment module 606.

[0148] The extraction module 601 is used to use the feature extraction network to perform feature extraction processing on the sample image to obtain image features, and the image features include: candidate image features of at least one scale; the candidate image features of at least one scale are used to characterize at least one preset clue; the first classification module 602 is used to use the first classification network to classify the candidate image features of at least one scale to obtain a first category prediction value; the acquisition module 603 is used to obtain target image features based on the candidate image features of at least one scale; the second classification module 604 is used to use the second classification network to classify the target image features to obtain a second category prediction value; the construction module 605 is used to construct a total loss function based on the first category prediction value and the second category prediction value; the adjustment module 606 is used to use the total loss function to adjust the model parameters of the feature extraction network, the model parameters of the first classification network and the model parameters of the second classification network.

[0149] In this embodiment, since the candidate image features of at least one scale are used to characterize at least one preset clue, the preset clue information can be introduced into the model. The preset clue information can reflect the fine-grained information of the image, so that more discriminative image features can be obtained, and then classification can be performed based on the image features, which can improve the accuracy of the classification results, improve the generalization of the model, and thus improve the image detection effect.

[0150] In some embodiments, the at least one scale candidate image feature is a plurality of scale candidate image features, the at least one preset clue is a plurality of preset clues, and the plurality of scale candidate image features correspond one-to-one to the plurality of preset clues;

[0151] The acquisition module 603 is further used for:

[0152] If the sample image is forged based on any one of the multiple preset clues, the candidate image features corresponding to any one of the preset clues are used as the target image features; or, if the sample image is a real image, the candidate image features of the multiple scales are randomly selected or averaged to obtain the target image features.

[0153] In this embodiment, the target image features are obtained according to the actual forgery situation of the sample image, which can improve the accuracy of the target image features and further improve the model performance.

[0154] In some embodiments, the building module 605 is further used to:

[0155] Based on the first category prediction value and the first category true value corresponding to the sample image, a first loss function is constructed,

[0156] Constructing a second loss function based on the second category prediction value and the second category true value corresponding to the sample image;

[0157] Based on the first loss function and the second loss function, a total loss function is constructed.

[0158] The first loss function and the second loss function mentioned above are used to characterize the classification losses of different dimensions. Therefore, by constructing the total loss function based on the first loss function and the second loss function, multi-dimensional classification information can be considered to improve the supervision performance and thus improve the model performance.

[0159] In some embodiments, the image feature further comprises: a regression image feature; and the device further comprises:

[0160] A generating module, used for performing generating processing on the regression image features to obtain a generated image;

[0161] The building block 605 is further used for:

[0162] Based on the generated image and the clue image, constructing a third loss function; the clue image is generated based on the sample image;

[0163] A total loss function is constructed based on the first loss function, the second loss function and the third loss function.

[0164] In this embodiment, in addition to constructing the first loss function and the second loss function, a third loss function is constructed based on the generated image and the attack image, and a total loss function is constructed based on the first loss function, the second loss function and the third loss function. In this way, the total loss function not only reflects the classification loss, but also reflects the graph loss for preset clues. Therefore, the total loss function contains more information, thereby improving the model detection performance and the detection accuracy when the model is applied for image detection.

[0165] In some embodiments, the clue image is generated in the following manner:

[0166] Performing difference processing on the sample image and a real image corresponding to the sample image to obtain an attack image;

[0167] Based on the contour position of the target object in the sample image, binarizing the sample image to obtain a contour image;

[0168] Performing conversion processing on the sample image to obtain a conversion image in a different domain from the sample image;

[0169] The clue image is generated based on at least one of the attack image, the contour image, and the transition image.

[0170] In this embodiment, since the attack image, contour image and conversion image can reflect preset clues of different dimensions, the clue image generated based on at least one of the above images can contain preset clue information of at least one dimension, and then the loss function is constructed based on the clue image, and the preset clue supervision information can be introduced to improve the image authentication performance.

[0171] In some embodiments, the clue image is any one selected from the attack image, the contour image and the conversion image; or, the clue image is obtained by merging at least two of the attack image, the contour image and the conversion image.

[0172] In this embodiment, by adopting a variety of methods to obtain clue images, clue images can be obtained flexibly and accurately, which is convenient for subsequent processing.

[0173] In some embodiments, the building module 605 is further used to:

[0174] Performing weighted sum processing on the first loss function and the second loss function to obtain a weighted sum loss function;

[0175] The weighted-sum loss function and the third loss function are added to obtain a total loss function.

[0176] In this embodiment, by performing weighted sum processing on the first loss function and the second loss function, different emphases can be placed on the two classifications to improve model performance.

[0177] In some embodiments, during the weighted summation processing, the first loss function corresponds to a first weight, the second loss function corresponds to a second weight, and the sum of the first weight and the second weight is 1; the initial value of the first weight is a preset initial value, and decreases to a preset minimum value as the number of training iterations increases.

[0178] In this embodiment, more attention can be paid to the classification results corresponding to the preset clues in the early stage of training, which is helpful to extract more discriminative candidate image features, thereby improving the classification effect and generalization of the model.

[0179] Figure 7 is a schematic diagram according to the fifth embodiment of the present disclosure. This embodiment provides an image detection device, such as Figure 7 As shown, the device 700 includes: an extraction module 701, a first classification module 702, a fusion module 703, a second classification module 704 and a determination module 705.

[0180] The extraction module 701 is used to perform feature extraction processing on the image to be detected to obtain image features, and the image features include: candidate image features of at least one scale; the candidate image features of at least one scale are used to characterize at least one preset clue; the first classification module 702 is used to classify the candidate image features of at least one scale to obtain a first category prediction value; the fusion module 703 is used to obtain fused image features based on the first category prediction value and the candidate image features of at least one scale; the second classification module 704 is used to classify the fused image features to obtain a second category prediction value; the determination module 705 is used to determine the authentication result of the image to be detected based on the second category prediction value.

[0181] In this embodiment, processing is performed based on candidate image features at at least one scale, and these candidate image features represent at least one preset clue. Therefore, preset clue information can be introduced in image detection. Since the preset clue information can reflect the fine-grained information of the image, more discriminative image features can be obtained, and then classification is performed based on the image features, which can improve the accuracy of the classification results, improve the generalization of the model, and thus improve the image detection effect.

[0182] In some embodiments, the candidate image features of the at least one scale are candidate image features of multiple scales, the first category prediction value is multiple, and the fusion module 703 is further used to:

[0183] Normalizing the multiple first category prediction values ​​to obtain multiple normalized values;

[0184] The multiple normalized values ​​are used to perform weighted sum processing on the candidate image features of the multiple scales to obtain the fused image feature.

[0185] In this embodiment, the normalized value corresponding to the prediction value of the first category is used to perform weighted sum processing on the candidate image features of multiple scales to obtain a fused image feature. The fused image feature can accurately include candidate image features of different scales, accurately reflect the preset clue information of different categories, improve the discriminability of the fused image feature, and improve the image detection performance.

[0186] In some embodiments, the extraction module 701 is further used to: use a feature extraction network in a pre-trained image detection model to perform feature extraction processing on the image to be detected to obtain image features; the first classification module 702 is further used to: use the first classification network in the image detection model to classify the candidate image features of at least one scale to obtain a first category prediction value; the second classification module 704 is further used to: use the second classification network in the image detection model to classify the fused image features to obtain a second category prediction value; wherein the image detection model is trained using any of the above embodiments.

[0187] In this embodiment, since the image detection model refers to preset clue information during training, the image detection performance can be improved, and then image detection based on the image detection model with better performance can improve the image detection effect.

[0188] It can be understood that in the embodiments of the present disclosure, the same or similar contents in different embodiments can be referenced to each other.

[0189] It can be understood that the “first”, “second”, etc. in the embodiments of the present disclosure are only used for distinction and do not indicate the degree of importance, time sequence, etc.

[0190] In the technical solution of the present disclosure, the collection, storage, use, processing, transmission, provision and disclosure of user personal information involved are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals.

[0191] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium and a computer program product.

[0192] Figure 8 A schematic block diagram of an example electronic device 800 that can be used to implement an embodiment of the present disclosure is shown. The electronic device 800 is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, servers, blade servers, mainframe computers, and other suitable computers. The electronic device 800 can also represent various forms of mobile devices, such as personal digital assistants, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.

[0193] like Figure 8 As shown, the electronic device 800 includes a computing unit 801, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 802 or a computer program loaded from a storage unit 808 into a random access memory (RAM) 803. In the RAM 803, various programs and data required for the operation of the electronic device 800 can also be stored. The computing unit 801, the ROM 802, and the RAM 803 are connected to each other via a bus 804. An input / output (I / O) interface 805 is also connected to the bus 804.

[0194] Multiple components in the electronic device 800 are connected to the I / O interface 805, including: an input unit 806, such as a keyboard, a mouse, etc.; an output unit 807, such as various types of displays, speakers, etc.; a storage unit 808, such as a disk, an optical disk, etc.; and a communication unit 809, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 809 allows the electronic device 800 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.

[0195] The computing unit 801 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 801 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 801 performs the various methods and processes described above, such as the training method or image detection method of the image detection model. For example, in some embodiments, the training method or image detection method of the image detection model may be implemented as a computer software program, which is tangibly included in a machine-readable medium, such as a storage unit 808. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 800 via ROM 802 and / or communication unit 809. When the computer program is loaded into RAM 803 and executed by the computing unit 801, one or more steps of the training method or image detection method of the image detection model described above may be executed. Alternatively, in other embodiments, the computing unit 801 may be configured to execute the image detection model training method or the image detection method in any other appropriate manner (for example, by means of firmware).

[0196] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0197] The program code for implementing the method of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.

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

[0199] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).

[0200] The systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system may be interconnected by 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), and the Internet.

[0201] A computer system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship between the client and the server is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services ("Virtual Private Server", or "VPS" for short). The server may also be a server of a distributed system, or a server combined with a blockchain.

[0202] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and this document does not limit this.

[0203] The above specific implementations do not constitute a limitation on the protection scope of the present disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present disclosure shall be included in the protection scope of the present disclosure.

Claims

1. A training method for an image detection model, the image detection model comprising: A feature extraction network, a first classification network and a second classification network, the method comprising: Using the feature extraction network, performing feature extraction processing on the sample image to obtain image features, the image features including: candidate image features of at least one scale; the candidate image features of at least one scale are used to represent at least one preset clue; Using the first classification network, classify the candidate image features of the at least one scale to obtain a first category prediction value; Acquire a target image feature based on the candidate image feature of the at least one scale; Using the second classification network, classify the target image features to obtain a second category prediction value; Constructing a total loss function based on the first category prediction value and the second category prediction value; The total loss function is used to adjust the model parameters of the feature extraction network, the model parameters of the first classification network, and the model parameters of the second classification network.

2. The method according to claim 1, wherein: The at least one scale candidate image feature is a plurality of scale candidate image features, the at least one preset clue is a plurality of preset clues, and the plurality of scale candidate image features correspond one-to-one to the plurality of preset clues; The step of obtaining target image features based on the candidate image features of the at least one scale includes: If the sample image is obtained based on any one of the plurality of preset clues, taking the candidate image feature corresponding to any one of the preset clues as the target image feature; or, If the sample image is a real image, the candidate image features of the multiple scales are randomly selected or averaged to obtain the target image features.

3. The method according to claim 1, wherein: The constructing a total loss function based on the first category prediction value and the second category prediction value includes: Based on the first category prediction value and the first category true value corresponding to the sample image, a first loss function is constructed, Constructing a second loss function based on the second category prediction value and the second category true value corresponding to the sample image; Based on the first loss function and the second loss function, a total loss function is constructed.

4. The method according to claim 3, wherein: The image features further include: regression image features; the method further includes: Performing a generation process on the regression image features to obtain a generated image; The constructing a total loss function based on the first loss function and the second loss function includes: Based on the generated image and the clue image, constructing a third loss function; the clue image is generated based on the sample image; A total loss function is constructed based on the first loss function, the second loss function and the third loss function.

5. The method according to claim 4, wherein: The clue image is generated in the following manner: Performing difference processing on the sample image and a real image corresponding to the sample image to obtain an attack image; Based on the contour position of the target object in the sample image, binarizing the sample image to obtain a contour image; Performing conversion processing on the sample image to obtain a conversion image in a different domain from the sample image; The clue image is generated based on at least one of the attack image, the contour image, and the transition image.

6. The method according to claim 5, wherein: The step of generating the clue image based on at least one of the attack image, the contour image, and the conversion image comprises: Select any one of the attack image, the contour image and the conversion image as the clue image; or, At least two of the attack image, the contour image and the conversion image are merged to obtain the clue image.

7. The method according to claim 4, wherein: The constructing a total loss function based on the first loss function, the second loss function and the third loss function comprises: Performing weighted sum processing on the first loss function and the second loss function to obtain a weighted sum loss function; The weighted-sum loss function and the third loss function are added to obtain a total loss function.

8. The method according to claim 7, wherein: During the weighted summation processing, the first loss function corresponds to a first weight, the second loss function corresponds to a second weight, and the sum of the first weight and the second weight is 1; the initial value of the first weight is a preset initial value, and decreases to a preset minimum value as the number of training iterations increases.

9. An image detection method, comprising: Performing feature extraction processing on the image to be detected to obtain image features, wherein the image features include: candidate image features of at least one scale; the candidate image features of at least one scale are used to represent at least one preset clue; Classify the candidate image features of the at least one scale to obtain a first category prediction value; Acquire a fused image feature based on the first category prediction value and the candidate image feature of the at least one scale; Classifying the fused image features to obtain a second category prediction value; An authentication result of the image to be detected is determined based on the second category prediction value.

10. The method according to claim 9, wherein: The candidate image features of the at least one scale are candidate image features of multiple scales, the first category prediction values ​​are multiple, and the acquiring of fused image features based on the first category prediction values ​​and the candidate image features of the at least one scale includes: Normalizing the multiple first category prediction values ​​to obtain multiple normalized values; The multiple normalized values ​​are used to perform weighted sum processing on the candidate image features of the multiple scales to obtain the fused image feature.

11. The method according to claim 9, wherein: The performing feature extraction processing on the image to be detected to obtain image features includes: Using the feature extraction network in the pre-trained image detection model, perform feature extraction processing on the image to be detected to obtain image features; The classifying process of the candidate image features of the at least one scale to obtain a first category prediction value includes: Using a first classification network in the image detection model, classify the candidate image features of the at least one scale to obtain a first category prediction value; The classifying process of the fused image features to obtain a second category prediction value includes: Using a second classification network in the image detection model, classify the fused image features to obtain a second category prediction value; The image detection model is trained using the method described in any one of claims 1-8.

12. A training device for an image detection model, the image detection model comprising: A feature extraction network, a first classification network and a second classification network, the device comprising: An extraction module, used to use the feature extraction network to perform feature extraction processing on the sample image to obtain image features, wherein the image features include: candidate image features of at least one scale; the candidate image features of at least one scale are used to represent at least one preset clue; A first classification module, configured to classify the candidate image features of the at least one scale using the first classification network to obtain a first category prediction value; An acquisition module, configured to acquire target image features based on the candidate image features of the at least one scale; A second classification module, configured to classify the target image features using the second classification network to obtain a second category prediction value; A construction module, configured to construct a total loss function based on the first category prediction value and the second category prediction value; An adjustment module is used to use the total loss function to adjust the model parameters of the feature extraction network, the model parameters of the first classification network, and the model parameters of the second classification network.

13. The device according to claim 12, wherein: The at least one scale candidate image feature is a plurality of scale candidate image features, the at least one preset clue is a plurality of preset clues, and the plurality of scale candidate image features correspond one-to-one to the plurality of preset clues; The acquisition module is further used for: If the sample image is obtained based on any one of the plurality of preset clues, taking the candidate image feature corresponding to any one of the preset clues as the target image feature; or, If the sample image is a real image, the candidate image features of the multiple scales are randomly selected or averaged to obtain the target image features.

14. The device according to claim 12, wherein: The building blocks are further used to: Based on the first category prediction value and the first category true value corresponding to the sample image, a first loss function is constructed, Constructing a second loss function based on the second category prediction value and the second category true value corresponding to the sample image; Based on the first loss function and the second loss function, a total loss function is constructed.

15. The device according to claim 14, wherein: The image features further include: regression image features; the device further includes: A generating module, used for performing generating processing on the regression image features to obtain a generated image; The building blocks are further used to: Based on the generated image and the clue image, constructing a third loss function; the clue image is generated based on the sample image; A total loss function is constructed based on the first loss function, the second loss function and the third loss function.

16. The device according to claim 15, wherein: The clue image is generated in the following manner: Performing difference processing on the sample image and a real image corresponding to the sample image to obtain an attack image; Based on the contour position of the target object in the sample image, binarizing the sample image to obtain a contour image; Performing conversion processing on the sample image to obtain a conversion image in a different domain from the sample image; The clue image is generated based on at least one of the attack image, the contour image, and the transition image.

17. The device according to claim 16, wherein: The clue image is any one selected from the attack image, the contour image, and the conversion image; or, the clue image is obtained by merging at least two of the attack image, the contour image, and the conversion image.

18. The device according to claim 15, wherein: The building blocks are further used to: Performing weighted sum processing on the first loss function and the second loss function to obtain a weighted sum loss function; The weighted-sum loss function and the third loss function are added to obtain a total loss function.

19. The device according to claim 18, wherein During the weighted summation processing, the first loss function corresponds to a first weight, the second loss function corresponds to a second weight, and the sum of the first weight and the second weight is 1; the initial value of the first weight is a preset initial value, and decreases to a preset minimum value as the number of training iterations increases.

20. An image detection device, comprising: An extraction module is used to perform feature extraction processing on the image to be detected to obtain image features, wherein the image features include: candidate image features of at least one scale; the candidate image features of at least one scale are used to represent at least one preset clue; A first classification module, configured to classify the candidate image features of the at least one scale to obtain a first category prediction value; a fusion module, configured to obtain a fused image feature based on the first category prediction value and the candidate image feature of the at least one scale; A second classification module, used for classifying the fused image features to obtain a second category prediction value; A determination module is used to determine the authentication result of the image to be detected based on the second category prediction value.

21. The device according to claim 20, wherein: The candidate image features of the at least one scale are candidate image features of multiple scales, the first category prediction value is multiple, and the fusion module is further used for: Normalizing the multiple first category prediction values ​​to obtain multiple normalized values; The multiple normalized values ​​are used to perform weighted sum processing on the candidate image features of the multiple scales to obtain the fused image feature.

22. The device according to claim 20, wherein: The extraction module is further used to: use a feature extraction network in a pre-trained image detection model to perform feature extraction processing on the image to be detected to obtain image features; The first classification module is further used to: use the first classification network in the image detection model to classify the candidate image features of the at least one scale to obtain a first category prediction value; The second classification module is further used to: use the second classification network in the image detection model to classify the fused image features to obtain a second category prediction value; The image detection model is trained using the method described in any one of claims 1-8.

23. An electronic device, comprising: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 11.

24. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to cause the computer to execute the method according to any one of claims 1-11.

25. A computer program product comprising a computer program, which, when executed by a processor, implements the method according to any one of claims 1 to 11.