Image security detection method

By combining the image detection model and the object detection model, the target image is detected, and the problem of low image safety detection accuracy in the prior art is solved, and a more efficient image safety detection effect is achieved.

CN119888302APending Publication Date: 2025-04-25JINAN UNIVERSITY
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411718099.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-27
Publication Date
2025-04-25

AI Technical Summary

Technical Problem

The prior art has low accuracy when performing security detection of images, making it difficult to effectively distinguish between generated images and non-generated images.

Method used

The target image is detected by combining the image detection model and the object detection model. The image detection model is used to obtain the probability that the target image belongs to a generative image, and the object detection model is used to obtain the probability that the object in the target image belongs to a generative object, and determine the type of the image based on the combination of the two.

Benefits of technology

The accuracy of safe detection of images is improved, and the generated objects in the image can be detected more precisely and targetedly, and the ability to judge whether the target image is a generated image is an ability to determine.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119888302A_ABST
    Figure CN119888302A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides an image security detection method. The method comprises the steps of obtaining a target image; inputting the target image into the image detection model to obtain a first probability which is the probability that the target image belongs to the generative image; the image detection model is obtained by training according to the first sample image and the first label; inputting the target image into a target detection model to obtain a second probability corresponding to at least one object, the at least one object being an object in the target image, and the second probability being a probability that the corresponding object belongs to a generative object; the target detection model is obtained by training according to the second sample image and the second label; and determining the type of the target image according to the first probability and a second probability corresponding to the at least one object, the type of the target image being a generative image or a non-generative image. According to the scheme, the accuracy of safety detection on the target image is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of artificial intelligence, and in particular to an image security detection method. Background Art

[0002] With the development of artificial intelligence (AI), some AI products can generate generative images that are difficult to distinguish with the naked eye. In some scenarios, in order to ensure the security and authenticity of the image, it is necessary to distinguish whether the image is a generative image.

[0003] In the related art, a large-scale generative image is used as a training data set to train a neural network model to obtain a trained neural network model, and the trained neural network model is used to detect an image to determine whether the image is a generative image. However, the accuracy of security detection of images using the above method is low. Summary of the invention

[0004] The embodiment of the present application provides an image security detection method to improve the accuracy of image security detection.

[0005] In a first aspect, an embodiment of the present application provides an image security detection method, comprising:

[0006] Get the target image;

[0007] Input the target image into the image detection model to obtain a first probability, where the first probability is the probability that the target image belongs to the generated image; the image detection model is trained based on the first sample image and the first label, and the first label is used to indicate whether the first sample image belongs to the generated image;

[0008] Input the target image into the target detection model to obtain a second probability corresponding to at least one object, wherein the at least one object is an object in the target image, and the second probability is a probability that the corresponding object belongs to a generative object; the target detection model is trained based on the second sample image and the second label, and the second label is used to indicate the first sample object in the second sample image, and whether the first sample object belongs to the generative object;

[0009] The type of the target image is determined according to the first probability and the second probability corresponding to each of the at least one object, and the type of the target image is a generative image or a non-generative image.

[0010] In a possible implementation, inputting the target image into the target detection model to obtain a second probability corresponding to at least one object includes:

[0011] Perform feature extraction processing on the target image to obtain the semantic features of the target image;

[0012] Determine at least one object and at least one category of each object in the target image based on the semantic features;

[0013] Detection processing is performed on at least one object according to the respective category of the at least one object to obtain a second probability corresponding to each of the at least one object.

[0014] In a possible implementation, performing feature extraction processing on the target image to obtain semantic features of the target image includes:

[0015] Perform convolution processing on the target image to obtain the first sample feature map;

[0016] Perform convolution and downsampling processing on the i-th sample feature map to obtain the i+1-th sample feature map, where i is 1, 2, ..., M-1, and M is a positive integer greater than or equal to 2;

[0017] Perform feature fusion processing on M sample feature maps to obtain semantic features.

[0018] In a possible implementation, determining at least one object and a category of at least one object in a target image according to semantic features includes:

[0019] Detecting the target image according to the semantic features, determining at least one object detection frame and a candidate category of each of the at least one object detection frame in the target image;

[0020] At least one object and a category of the at least one object are determined in the target image according to the at least one object detection box and the candidate category of the at least one object detection box.

[0021] In a possible implementation, for any object detection frame in at least one object detection frame, determining at least one object and a category of the at least one object in the target image according to the at least one object detection frame and the candidate category of the at least one object detection frame includes:

[0022] Determine a sub-image corresponding to the object detection frame in the target image according to the position information and size information of the object detection frame;

[0023] Determine the target object corresponding to the object detection box in the sub-image;

[0024] Determine the category of the target object among the candidate categories of the object detection box according to the sub-image;

[0025] The at least one object includes a target object corresponding to each of the at least one object detection boxes.

[0026] In a possible implementation, determining the type of the target image according to the first probability and the second probability corresponding to each of the at least one object includes:

[0027] Generate a probability vector according to the first probability and the second probability corresponding to each of the at least one object;

[0028] The probability vector is input into the prediction model to obtain the prediction result output by the prediction model, and the prediction result is used to indicate the type of the target image;

[0029] The prediction model is obtained by training according to the sample probability vector and the third label, and the sample probability vector is generated according to the first sample probability corresponding to the third sample image and the second sample probability corresponding to each of the at least one second sample object;

[0030] The first sample probability is the probability that the third sample image belongs to the generative image, the second sample probability is the probability that at least one second sample object belongs to the generative object, and the third label is used to indicate whether the third sample image is a generative image.

[0031] In a possible implementation, determining the type of the target image according to the first probability and the second probability corresponding to each of the at least one object includes:

[0032] Obtaining a weight of the first probability;

[0033] Determining a weight of a second probability corresponding to each of the at least one object according to the respective category of the at least one object;

[0034] The type of the target image is determined according to the first probability, the weight of the first probability, the second probability corresponding to each of the at least one object, and the weight of the second probability corresponding to each of the at least one object.

[0035] In a second aspect, an embodiment of the present application provides an image safety detection device, the device comprising: an acquisition module, a first detection module, a second detection module and a determination module, wherein:

[0036] An acquisition module, used for acquiring a target image;

[0037] A first detection module is used to input the target image into the image detection model to obtain a first probability, where the first probability is the probability that the target image belongs to the generative image; the image detection model is trained based on the first sample image and the first label, and the first label is used to indicate whether the first sample image belongs to the generative image;

[0038] A second detection module is used to input the target image into the target detection model to obtain a second probability corresponding to at least one object, wherein the at least one object is an object in the target image, and the second probability is a probability that the corresponding object belongs to a generative object; the target detection model is trained based on the second sample image and the second label, and the second label is used to indicate the first sample object in the second sample image, and whether the first sample object belongs to the generative object;

[0039] The determination module is used to determine the type of the target image according to the first probability and the second probability corresponding to each of the at least one object, where the type of the target image is a generative image or a non-generative image.

[0040] In a possible implementation manner, the second detection module is specifically used to:

[0041] Perform feature extraction processing on the target image to obtain the semantic features of the target image;

[0042] Determine at least one object and at least one category of each object in the target image based on the semantic features;

[0043] Detection processing is performed on at least one object according to the respective category of the at least one object to obtain a second probability corresponding to each of the at least one object.

[0044] In a possible implementation manner, the second detection module is specifically used to:

[0045] Perform convolution processing on the target image to obtain the first sample feature map;

[0046] Perform convolution and downsampling processing on the i-th sample feature map to obtain the i+1-th sample feature map, where i is 1, 2, ..., M-1, and M is a positive integer greater than or equal to 2;

[0047] Perform feature fusion processing on M sample feature maps to obtain semantic features.

[0048] In a possible implementation manner, the second detection module is specifically used to:

[0049] Detecting the target image according to the semantic features, determining at least one object detection frame and a candidate category of each of the at least one object detection frame in the target image;

[0050] At least one object and a category of the at least one object are determined in the target image according to the at least one object detection box and the candidate category of the at least one object detection box.

[0051] In a possible implementation manner, the second detection module is specifically used to:

[0052] Determine a sub-image corresponding to the object detection frame in the target image according to the position information and size information of the object detection frame;

[0053] Determine the target object corresponding to the object detection box in the sub-image;

[0054] Determine the category of the target object among the candidate categories of the object detection box according to the sub-image;

[0055] The at least one object includes a target object corresponding to each of the at least one object detection boxes.

[0056] In a possible implementation manner, the determination module is specifically configured to:

[0057] Generate a probability vector according to the first probability and the second probability corresponding to each of the at least one object;

[0058] The probability vector is input into the prediction model to obtain the prediction result output by the prediction model, and the prediction result is used to indicate the type of the target image;

[0059] The prediction model is obtained by training according to the sample probability vector and the third label, and the sample probability vector is generated according to the first sample probability corresponding to the third sample image and the second sample probability corresponding to each of the at least one second sample object;

[0060] The first sample probability is the probability that the third sample image belongs to the generative image, the second sample probability is the probability that at least one second sample object belongs to the generative object, and the third label is used to indicate whether the third sample image is a generative image.

[0061] In a possible implementation manner, the determination module is specifically configured to:

[0062] Obtaining a weight of the first probability;

[0063] Determining a weight of a second probability corresponding to each of the at least one object according to the respective category of the at least one object;

[0064] The type of the target image is determined according to the first probability, the weight of the first probability, the second probability corresponding to each of the at least one object, and the weight of the second probability corresponding to each of the at least one object.

[0065] In a third aspect, an embodiment of the present application provides an image safety detection device, including:

[0066] at least one processor; and

[0067] a memory communicatively connected to at least one processor; wherein,

[0068] The memory stores instructions that can be executed by at least one processor, and the instructions are executed by at least one processor so that the at least one processor executes the image safety detection method involved in the first aspect and any possible implementation manner.

[0069] In a fourth aspect, an embodiment of the present application provides a non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to enable a computer to execute the image safety detection method involved in the first aspect and any possible implementation manner.

[0070] In a fifth aspect, the present application provides a computer program product, including a computer program, which, when executed by a processor, implements the image safety detection method involved in the first aspect and any possible implementation manner.

[0071] An image security detection method provided by an embodiment of the present application, in view of the fact that a generative image includes a generative object that may have abnormal features, uses a target detection model to detect at least one object in the target image, obtains a second probability corresponding to each of the at least one object, and the second probability is used to indicate the probability that at least one object in the target image belongs to a generative object, and at the same time uses an image detection model to detect the target image to obtain a first probability, and the first probability is used to indicate the probability that the target image belongs to a generative image. Finally, according to the first probability and the second probability corresponding to each of the at least one object, it is determined whether the type of the target image is a generative image or a non-generative image. The above method uses a target detection model to detect the probability that each object in the target image belongs to a generative object, which can perform more precise and targeted detection on the target image, thereby improving the accuracy of security detection on the target image. At the same time, the detection results of the target image by both the image detection model and the target detection model are combined to determine whether the target image is a generative image, further improving the accuracy of security detection on the target image. BRIEF DESCRIPTION OF THE DRAWINGS

[0072] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.

[0073] Figure 1 A schematic diagram of applicable scenarios provided for embodiments of the present application;

[0074] Figure 2 A schematic diagram of a process flow of an image security detection method provided in an embodiment of the present application;

[0075] Figure 3 A schematic diagram of a model structure of an image detection model provided in an embodiment of the present application;

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

[0077] Figure 5 A schematic diagram of the structure of a Darkenet network provided in an embodiment of the present application;

[0078] Figure 6 A schematic diagram of a process of detecting a target image using a target detection model provided in an embodiment of the present application;

[0079] Figure 7 A schematic diagram of a process flow of another image security detection method provided in an embodiment of the present application;

[0080] Figure 8 A schematic diagram of the structure of a prediction model provided in an embodiment of the present application;

[0081] Fig. 9 A schematic diagram of the structure of an image safety detection device provided in an embodiment of the present application;

[0082] Fig.10 A schematic diagram of the structure of an image safety detection device provided in an embodiment of the present application.

[0083] The above drawings have shown clear embodiments of the present application, which will be described in more detail later. These drawings and text descriptions are not intended to limit the scope of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION

[0084] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.

[0085] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in one or more embodiments of the present application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards, and corresponding operation entrances are provided for users to choose to authorize or refuse.

[0086] For ease of understanding, the following Figure 1 , briefly describe the application scenarios to which the embodiments of the present application are applicable.

[0087] Figure 1 A schematic diagram of an applicable scenario provided for an embodiment of the present application, such as Figure 1 As shown, it includes a client 11 and a server 12, and the client 11 and the server 12 are connected via wired or wireless communication.

[0088] The client 11 may send a target image 13 to the server 12. After receiving the target image 13, the server 12 performs image security detection on the target image 13. The target image 13 may be a sample image for model training. In this case, the server 12 performs the training process of the model (including the image detection model and / or the target detection model). The target image 13 may also be an image to be detected. In this case, the server 12 performs the image security detection process.

[0089] It should be noted that the client 11 and the server 12 may be two independent devices or two different components integrated into the same device. Figure 1 In the example, the client 11 and the server 21 are taken as two independent devices.

[0090] Despite Figure 1 In the example, the execution subject is the server 12, but the execution subject in the embodiment of the present application can be a server, a processor, a microprocessor, a chip or other device with data processing function, for example, the execution subject can also be the client 11. The specific execution subject of each embodiment in the present application is not limited, and it can be selected and set according to actual needs. As long as it is a device with data processing function, it can be used as the execution subject of each embodiment in the present application.

[0091] It should be noted that Figure 1 It is only an example to illustrate an application scenario, and is not intended to limit the application scenarios to which the embodiments of the present application are applicable.

[0092] In the related art, the image detection model is trained using a training data set. During the training process, the image detection model learns the feature information of each image in the training data set, as well as the correlation between the feature information and the generated image. When the target image is detected by the image detection model, the image detection model obtains the feature information of the target image, and determines whether the target image is a generated image based on the correlation between the feature information and the generated image. However, the image detection model trained by the above method has poor generalization ability, which results in low accuracy of the image detection model when performing security detection on the target image.

[0093] The image security detection method provided by the embodiment of the present application, in view of the fact that the generated image includes a generated object with abnormal features, therefore, for any object in the target image, the probability that the object belongs to the generated object is detected by the target detection model, and the second probability corresponding to at least one object is obtained. At the same time, the target image is detected by the image detection model to obtain the first probability. Finally, the type of the target image is determined by combining the first probability and the second probability corresponding to at least one object, thereby improving the accuracy of security detection of the target image.

[0094] The technical solution of the present application and how the technical solution of the present application solves the above-mentioned technical problems are described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.

[0095] Figure 2 A schematic diagram of a process flow of an image security detection method provided in an embodiment of the present application is shown as follows: Figure 2 As shown, the method includes:

[0096] S21. Acquire a target image.

[0097] The target image is the image to be detected. In some scenarios, it is necessary to perform security detection on the target image to determine whether the target image is a generated image.

[0098] The types of images can be divided into non-generative images and generative images, wherein non-generative images mainly refer to images captured by a camera device, or images captured by a camera device and processed by simple stitching, etc. The camera device may include, for example, a mobile phone, a tablet, a camera, etc., which is not limited in the embodiments of the present application. Generative images can be images generated by AI products. Unlike non-generative images, generative images are not images directly captured by a camera device, but are images generated by algorithms or other methods.

[0099] Optionally, the target image may also be an image after image preprocessing is performed on the image to be detected. The image preprocessing may be converting the image to be detected into an image with a fixed resolution and format, and performing image processing operations on the obtained image with a fixed resolution and format. The image processing operations may include normalization processing, data enhancement processing, or denoising processing.

[0100] For example, assuming that the fixed resolution is 320*320, the fixed format is JPG, the resolution of the image to be detected is 640*640, and the format of the image to be detected is PNG. The resolution of the image to be detected is converted to 320*320, the format is converted to JPG, and the image with a resolution of 320*320 and a format of JPG is normalized and denoised to obtain the target image.

[0101] S22. Input the target image into the image detection model to obtain a first probability, where the first probability is the probability that the target image belongs to the generative image; the image detection model is trained based on the first sample image and the first label, and the first label is used to indicate whether the first sample image belongs to the generative image.

[0102] Exemplarily, the model structure of the image detection model can be as follows Figure 3 As shown, Figure 3 For a schematic diagram of the model structure of an image detection model provided in an embodiment of the present application, see Figure 3 The image detection model includes an input layer, a convolution layer, a convolution block, a maximum pooling layer, an average pooling layer, a fully connected layer, and an output layer. The convolution block is composed of multiple convolution layers, and each convolution layer corresponds to a convolution kernel. The sizes of the convolution kernels corresponding to different convolution layers can be the same or different. Figure 3 Taking the image detection model shown in FIG. 1 as an example, the image detection model includes 3 convolution blocks A, 3 convolution blocks B, 6 convolution blocks C and 3 convolution blocks D, wherein convolution block A includes convolution layer 1, convolution layer 2 and convolution layer 3, and the convolution kernel size corresponding to convolution layer 1 is (641 1), the convolution kernel size corresponding to convolution layer 2 is (64 3 3), and the convolution kernel size corresponding to convolution layer 3 is (256 1 1); convolution block B includes convolution layer 4, convolution layer 5 and convolution layer 6, and the convolution kernel size corresponding to convolution layer 4 is (128 1 1), the convolution kernel size corresponding to convolution layer 5 is (128 3 3), and the convolution kernel size corresponding to convolution layer 6 is (512 1 1); convolution block C includes convolution layer 7, convolution layer 8 and convolution layer 9, and the convolution kernel size corresponding to convolution layer 7 is (256 1 1), the convolution kernel size corresponding to convolution layer 8 is (256 3 3), and the convolution kernel size corresponding to convolution layer 9 is (1024 1 1); the convolution block D includes convolution layer 10, convolution layer 11 and convolution layer 12, and the convolution kernel size corresponding to convolution layer 10 is (5121 1), the convolution kernel size corresponding to convolution layer 11 is (512 3 3), and the convolution kernel size corresponding to convolution layer 12 is (2048 1 1).

[0103] The first sample image is a sample image used for training the image detection model, and the first sample image includes a positive sample image and a negative sample image, wherein the positive sample image can be a generative image generated by an AI product (such as a generative model), wherein the generative model can be an open source image generation model such as VQDM, Stable Diffusion, BigGAN, Midjourney, GLIDE, Wukong, etc., and the negative sample image is a non-generative image. Using the sample images in the above-mentioned multiple training data sets to train the image detection model can improve the performance of the image detection model, and at the same time, can make the generalization ability of the image detection model stronger.

[0104] The first sample image is annotated with a corresponding first label, and the first label is used to indicate whether the first sample image is a positive sample image or a negative sample image. In some embodiments, the first label can be represented by a specific numerical value, for example, the number 0 or 1 can be used as the first label, where the number 0 indicates that the corresponding first sample image is a positive sample image, and the number 1 indicates that the corresponding first sample image is a negative sample image, or the number 0 indicates that the corresponding first sample image is a negative sample image, and the number 1 indicates that the corresponding first sample image is a positive sample image.

[0105] In a process of training the image detection model, the server can input the first sample image into the image detection model, process the first sample image through the image detection model, and obtain the first probability output by the image detection model, where the first probability is the probability that the first sample image predicted by the image detection model belongs to the generative image. Then, the server calculates the loss value based on the first probability and the first label, and adjusts the model parameters of the image detection model based on the calculated loss value, thereby completing a round of training process.

[0106] The server can perform one or more rounds of training on the image detection model until the training termination condition of the image detection model is reached, and the training process is stopped to obtain a trained image detection model. The training termination condition can be set according to actual needs, for example, the training termination condition can be set to a loss value less than or equal to a preset loss value, for example, the training termination condition can be set to a training number of times reaching a preset number, and so on. The trained image detection model has the ability to perform security detection on images to determine whether the image is a generative image.

[0107] The performance indicators of the image detection model include inference time and accuracy. The more complex the model structure of the image detection model, that is, the more convolutional layers included in the image detection model, the higher the accuracy of the image detection model in detecting the target image. At the same time, the image detection model takes a longer inference time to detect the target image. In this way, the image detection model has lower computational efficiency when detecting the target image and requires more computing resources.

[0108] Therefore, during the training process of the image detection model, the model structure of the image detection model can be adjusted according to the inference time and accuracy of the image detection model, so that the trained image detection model is more suitable for image detection tasks.

[0109] For example, assuming that the image detection model includes an input layer, 30 convolutional layers, two pooling layers, a fully connected layer and an output layer, in the process of training the image detection model through the first sample image and the first label, the model structure of the image detection model is adjusted according to the inference time and accuracy of the image detection model, and the trained image detection model includes an input layer, 50 convolutional layers, two pooling layers, a fully connected layer and an output layer. The obtained image detection model includes more convolutional layers. At this time, the image detection model is more suitable for the current image security detection task, and more convolutional layers can obtain more subtle feature information in the target image, thereby further improving the accuracy of security detection of the target image.

[0110] The method of detecting the target image according to the image detection model obtained after training is as follows: the target image is input into the image detection model, and the convolution layer, maximum pooling layer, average pooling layer and full connection layer of the image detection model process the target image to obtain a one-dimensional vector that can be predicted. For example, the one-dimensional vector can be [x 1 、x 2 、x 3 、x 4 …x n ]. The one-dimensional vector is input to the output layer of the image detection model. The output layer of the image detection model includes a Softmax function. The formula of the Softmax function can be shown as formula (1):

[0111]

[0112] Among them, x i is the i-th element in a one-dimensional vector, and the value of i ranges from 1 to n.

[0113] After processing the one-dimensional vector based on the Softmax function, a first probability is obtained. The value range of the first probability can be 0-1, and can be expressed in the form of percentage, decimal, etc. The larger the first probability, the greater the possibility that the target image belongs to the generative image; the smaller the first probability, the smaller the possibility that the target image belongs to the generative image.

[0114] S23. Input the target image into the target detection model to obtain a second probability corresponding to at least one object, at least one object is an object in the target image, and the second probability is the probability that the corresponding object belongs to the generative object; the target detection model is trained based on the second sample image and the second label, and the second label is used to indicate the first sample object in the second sample image, and whether the first sample object belongs to the generative object.

[0115] For example, the model structure of the target detection model can be as follows Figure 4 As shown, Figure 4 For a schematic diagram of the model structure of a target detection model provided in an embodiment of the present application, see Figure 4 The backbone network of the target detection model is the Darkenet network, and the target detection model also includes an input layer, multiple convolutional layers, multiple convolutional blocks, an upsampling layer, a connection layer, and an output layer. Figure 4 In the example, the Darkenet network is the backbone network of the target detection model, and the structure of the Darkenet network can be as follows Figure 5 As shown, Figure 5 For a schematic diagram of the structure of a Darkenet network provided in the embodiment of the present application, see Figure 5 The Darkenet network includes multiple convolutional layers and residual modules. There are multiple convolutional layers in the Darkenet network with smaller convolution kernels. For example, the convolution kernel size of the convolutional layer is (32 3 3), (64 3 3), etc. These convolutional layers with small convolution kernel sizes can extract more detailed features in the target image, making the target detection model have higher performance.

[0116] The second sample image is a sample image used for training the target detection model, and the second sample image includes a positive sample image and a negative sample image. The second sample image may be consistent with the first sample image or may be different from the first sample image.

[0117] Each second sample image includes at least one first sample object, and the first sample object may be a characteristic part in the second sample image. For example, assuming that the second sample image is a face image, the first sample object may be eyes, mouth, ears, etc. in the face image.

[0118] For a generative image, the generative image includes at least one generative object, and the generative object is an object with abnormal features. For example, assuming that the hand in the generative image has abnormal features such as blurred gaps between fingers or the number of fingers is greater than 5, the teeth have abnormal features such as blurred gaps between teeth or abnormal teeth, and the hair has abnormal features such as blurred hair boundaries, then the generative objects can be hands, teeth, and hair. Therefore, by determining whether there are abnormal features in the first sample object, it can be determined whether the first sample object belongs to a generative object or a non-generative object. If there are abnormal features in the first sample object, it means that the first sample object belongs to a generative object. If there are abnormal features in the first sample object, it means that the first sample object belongs to a generative object. If there are no abnormal features in the first sample object, it means that the first sample object belongs to a non-generative object.

[0119] Each second sample image corresponds to a second label, and for any second sample image, the corresponding second label is used to indicate at least one first sample object included in the second sample image, and whether at least one first sample object belongs to a generative object. In some embodiments, the second label can indicate whether the first sample object belongs to a generative object by a specific numerical value, for example, the number 0 or 1 can be used to indicate whether the first sample object belongs to a generative object, wherein the number 0 indicates that the first sample object belongs to a generative object, and the number 1 indicates that the first sample object belongs to a non-generative object, or the number 0 indicates that the first sample object belongs to a non-generative object, and the number 1 indicates that the first sample object belongs to a generative object.

[0120] Taking the example that the number 0 indicates that the first sample object belongs to a non-generative object and the number 1 indicates that the first sample object belongs to a generative object, assuming that the first sample objects included in the second sample image C are mouth, teeth, and hands, and the mouth has no abnormal features, the gaps between the teeth are blurred, and the gaps between the fingers are blurred, then the second label of the second sample image C is shown in Table 1:

[0121] Table 1

[0122] First sample object Whether the first sample object belongs to the generative object mouth 0 teeth 1 hand 1

[0123] In a process of training the target detection model, the server can input the second sample image into the target detection model, process the second sample image through the target detection model, and obtain the second probability output by the target detection model, where the second probability is the probability that at least one first sample object in the second sample image predicted by the target detection model belongs to the generative object. Then, the server calculates the loss value according to the second probability and the second label, and adjusts the model parameters of the target detection model according to the calculated loss value, thereby completing a round of training process.

[0124] The server can perform one or more rounds of training on the target detection model until the training termination condition of the target detection model is reached, and the training process is stopped to obtain a trained target detection model. The training termination condition can be set according to actual needs, for example, the training termination condition can be set to a loss value less than or equal to a preset loss value, for example, the training termination condition can be set to a training number of times reaching a preset number of times, and so on. The trained target detection model has the ability to perform security detection on at least one object in the image to determine whether each of the at least one object in the image belongs to a generative object.

[0125] The performance indicators of the target detection model include inference time and accuracy. The more complex the model structure of the target detection model, that is, the more convolutional layers included in the target detection model, the higher the accuracy of the target detection model in detecting the target image. At the same time, the longer the inference time used by the target detection model to detect the target image, the lower the computational efficiency of the target detection model when detecting the target image and the more computing resources are required.

[0126] Therefore, during the training process of the target detection model, the model structure of the target detection model can be adjusted according to the inference time and accuracy of the target detection model, so that the trained target detection model is more suitable for image security detection tasks.

[0127] For example, assuming that the target detection model includes an input layer, 40 convolution layers, multiple upsampling layers, a connection layer and an output layer, and in the process of training the target detection model using a second sample image and a second label, the model structure of the target detection model is adjusted according to the inference time and accuracy of the target detection model. The trained target detection model includes an input layer, 55 convolution layers, multiple upsampling layers, a connection layer and an output layer, and the obtained target detection model includes more convolution layers. At this time, the target detection model is more suitable for the current image security detection task, and more convolution layers can obtain more subtle feature information in the target image, thereby making the security detection of the target image and at least one object in the target image more accurate.

[0128] The target image includes at least one object, and each object may be a characteristic part in the target image. For example, assuming that the target image is a face image, the object in the target image may be a characteristic part such as eyes, mouth, nose, ears, teeth, etc.

[0129] The method of detecting the target image according to the trained target detection model is as follows: the target image is input into the target detection model, the target detection model determines at least one object in the target image, and detects at least one object in the target image respectively to obtain a one-dimensional vector corresponding to at least one object.

[0130] For example, suppose the target detection model determines that the objects in the target image are eyes and mouths, and detects the eyes, and obtains the one-dimensional vector corresponding to the eyes as [x 1 、x 2 、x 3 、x 4 …x n ], detect the mouth, and get the one-dimensional vector corresponding to the mouth as [y 1 ,y 2 ,y 3 ,y 4 …y n ].

[0131] A one-dimensional vector corresponding to at least one object is input into an output layer of an image detection model, wherein the output layer of the image detection model includes a Softmax function. After processing the one-dimensional vector corresponding to at least one object based on the Softmax function, a second probability corresponding to at least one object is obtained. The value range of the second probability can be 0-1, and can be expressed in the form of percentage, decimal, etc., and the larger the second probability is, the possibility that the first sample object corresponding to the second probability belongs to the generative object is represented; the smaller the second probability is, the smaller the possibility that the first sample object corresponding to the second probability belongs to the generative object is represented.

[0132] S24. Determine a type of a target image according to the first probability and a second probability corresponding to at least one object, where the type of the target image is a generative image or a non-generative image.

[0133] The target image is detected by an image detection model to obtain a first probability, which is used to indicate the probability that the target image belongs to a generative image; the target image is detected by an object detection model to obtain a second probability corresponding to at least one object, which is used to indicate the probability that at least one object in the target image belongs to a generative object, and based on the first probability and the second probability corresponding to at least one object, it is further determined whether the target image is a generative image or a non-generative image.

[0134] The type of the target image may be further determined according to the first probability and the second probability corresponding to the at least one object in the following manner:

[0135] In some embodiments, when the first probability and the second probability corresponding to at least one object are both greater than or equal to a preset probability threshold, the type of the target image is determined to be a generative image; when any probability value among the first probability and the second probability corresponding to at least one object is less than a preset probability threshold, the type of the target image is determined to be a non-generative image.

[0136] In some embodiments, the probability that the target image is a generative image can be calculated based on the first probability and the second probability corresponding to at least one object, and finally the probability that the target image is a generative image is compared with a preset probability threshold to determine the type of the target image.

[0137] The image security detection method provided by the embodiment of the present application, considering that the generated image includes a generated object with abnormal features, uses a target detection model to detect at least one object in the target image, obtains a second probability corresponding to each of the at least one object, and the second probability is used to indicate the probability that at least one object in the target image belongs to the generated object, and at the same time uses the image detection model to detect the target image to obtain a first probability, and the first probability is used to indicate the probability that the target image belongs to the generated image. Finally, according to the first probability and the second probability corresponding to each of the at least one object, it is determined whether the type of the target image is a generated image or a non-generated image. The above method uses the target detection model to detect the probability that each object belongs to the generated object for at least one object in the target image, and can perform more precise and targeted detection on the target image, thereby improving the accuracy of security detection on the target image. At the same time, the detection results of the target image by both the image detection model and the target detection model are combined to determine whether the target image is a generated image, further improving the accuracy of security detection on the target image.

[0138] Based on the above embodiments, Figure 6 The shown embodiment illustrates the process of detecting a target image through a target detection model provided in an embodiment of the present application.

[0139] Figure 6 For a flow chart of a target detection model provided in an embodiment of the present application for detecting a target image, see Figure 6 , the method may include the following steps:

[0140] S61, performing feature extraction processing on the target image to obtain semantic features of the target image.

[0141] Among them, the semantic features are used to represent the features in the target image that can express high-level information such as the attributes, categories, and relationships of the target object. For example, assuming that the target image is a portrait image, the semantic features of the target image can represent that the target image is a portrait image, and when the target image includes eyes, ears, and a mouth, the semantic features of the target image can also represent the parts of the target image that belong to the eyes, the parts that belong to the ears, and the parts that belong to the mouth.

[0142] The method of performing feature extraction processing on the target image to obtain the semantic features of the target image is as follows: performing convolution processing on the target image to obtain the first sample feature map; performing convolution processing and downsampling processing on the i-th sample feature map to obtain the i+1-th sample feature map, where i is 1, 2, ..., M-1, and M is a positive integer greater than or equal to 2; performing feature fusion processing on the M sample feature maps to obtain semantic features.

[0143] by Figure 4 Taking the model structure of the target detection model shown as an example, the target detection model includes a convolution block, a convolution layer, an upsampling layer and a connection layer, wherein the convolution block can perform convolution processing and downsampling processing on the i-th sample feature map respectively to obtain the i+1-th sample feature map. The upsampling layer, the convolution layer and the connection layer constitute a feature fusion layer, which performs feature fusion processing on the M sample feature maps to obtain feature information after feature fusion, and inputs the feature information after feature fusion into the feature processing layer, which can be a convolution layer or a network layer specially used for feature processing, and the feature processing layer performs feature processing on the feature information after feature fusion to obtain the semantic features of the target image.

[0144] S62: Determine at least one object and a category of at least one object in the target image according to the semantic features.

[0145] The category of each object is used to indicate the characteristic part corresponding to the object. For example, assuming that the target image is a face image, object X in the target image corresponds to the eye part of the target image, object Y corresponds to the mouth part of the target image, and object Z corresponds to the ear part of the target image. Then the category of object X is "eye", the category of object Y is "mouth", and the category of object Z is "ear".

[0146] The method for determining at least one object and the respective category of at least one object in a target image is as follows: detecting the target image according to semantic features, determining at least one object detection frame and the respective candidate category of at least one object detection frame in the target image; determining at least one object and the respective category of at least one object in the target image according to the at least one object detection frame and the respective candidate category of at least one object detection frame.

[0147] Each object corresponds to an object detection box. For any object in the target image, the object detection box can be a bounding box of the object at the corresponding feature part in the target image. The object detection box can be represented in the target image in the form of a geometric figure. For example, in the target image, the object detection box can be a rectangle, a square, etc.

[0148] For example, assuming that the target image is a face image, and object X corresponds to the eye portion in the target image, then the object detection box of object X is the bounding box at the eye portion in the target image.

[0149] The candidate categories of the object detection box may be possible categories of the object detection box. For example, assuming that the target image is a face image, the candidate categories of any object detection box may be eyes, ears, mouth, nose, etc.

[0150] Optionally, the target detection model also includes an object detection frame prediction layer, and the semantic information of the target image is input into the object detection frame prediction layer, and the object detection frame prediction layer detects the semantic features and determines at least one object detection frame. It should be noted that the object detection frame prediction layer includes multiple convolution layers and activation functions with small convolution kernel sizes, which can detect semantic features more accurately, making the determined object detection frame and object more accurate, thereby indirectly improving the accuracy of detecting at least one object in the target image.

[0151] The method of determining at least one object and the respective category of at least one object in a target image based on at least one object detection frame and the respective candidate category of at least one object detection frame is as follows: determining a sub-image corresponding to the object detection frame in the target image based on position information and size information of the object detection frame; determining a target object corresponding to the object detection frame in the sub-image; determining the category of the target object in the candidate categories of the object detection frame based on the sub-image; wherein the at least one object includes a target object corresponding to each of the at least one object detection frames.

[0152] The position information of the object detection frame is used to indicate the position coordinates of the object detection frame on the target image, and the size information of the object detection frame is used to indicate the size of the object detection frame on the target image. Assuming that the object detection frame is represented in the form of a rectangle in the target image, the position information of the object detection frame is used to indicate the corner coordinates of the rectangle, and the size information of the object detection frame is used to indicate the length and width of the rectangle. The sub-image is a feature image in the target image with the object detection frame as the boundary frame; the target object corresponding to the object detection frame can be a feature part in the sub-image corresponding to the object detection frame.

[0153] Optionally, the target detection model also includes a category prediction layer, which includes a fully connected layer and a convolutional layer classifier. The category prediction layer processes at least one sub-image of an object detection box through the classifiers of the fully connected layer and the convolutional layer, and determines the category of the target object from the candidate categories of the object detection box corresponding to the sub-image.

[0154] For example, assuming that the target image is a face image, the target image includes an object detection frame U and an object detection frame I. The candidate categories of the object detection frame U are eyes, nose, and ears, and the candidate categories of the object detection frame I are mouth, eyes, and hair. The sub-image corresponding to the object detection frame U is processed by the category prediction layer, and the category of the target object is determined to be nose in the candidate categories of the object detection frame U; the sub-image corresponding to the object detection frame I is processed by the category prediction layer, and the category of the target object is determined to be eyes in the candidate categories of the object detection frame I.

[0155] S63: Perform detection processing on at least one object according to the category of the at least one object to obtain a second probability corresponding to the at least one object.

[0156] For any object, determine the abnormal features that may exist in the generated image for the category of the object, and when detecting the object, specifically detect whether the corresponding abnormal features exist in the object, so as to obtain a second probability corresponding to the object.

[0157] For example, assuming that the target image is a portrait image, and the target objects include hands, ears, and teeth. Since the abnormal features of the hands in the generated image may include blurred gaps between fingers and the number of fingers is greater than 5; the abnormal features of the ears in the generated image may include abnormal or blurred auricle boundaries; the abnormal features of the teeth in the generated image may include abnormal teeth and blurred gaps between teeth. When detecting the hands in the target image, it is possible to specifically detect whether the hands in the target image have the abnormal features of blurred gaps between fingers and the number of fingers is greater than 5; when detecting the ears in the target image, it is possible to specifically detect whether the ears in the target image have the abnormal or blurred auricle boundaries; when detecting the teeth in the target image, it is possible to specifically detect whether the teeth in the target image have the abnormal features of abnormal teeth and blurred gaps between teeth.

[0158] exist Figure 6 In the embodiment shown, feature extraction processing is performed on the target image to obtain semantic features of the target image, and at least one object and the respective category of at least one object are determined in the target image based on the semantic features of the target image, and based on the respective category of at least one object, whether there are abnormal features in the generative image that may exist at the corresponding category in the at least one object is detected respectively, thereby obtaining the second probability corresponding to the at least one object. In the process of detecting the target image by the above method, at least one object and the respective category of at least one object are determined in the target image, and the probability of at least one object belonging to the generative object is detected respectively, that is, targeted detection is performed on specific feature parts in the target image, thereby improving the accuracy of security detection of the target image.

[0159] Based on the above embodiments, Figure 7 The illustrated embodiment takes determining whether the type of the target image is a generative image or a non-generative image based on the probability and threshold that the type of the target image is a generative image in S24 as an example to further illustrate the image security detection method provided in the embodiment of the present application.

[0160] Figure 7 For a flow chart of another image security detection method provided in the embodiment of the present application, please refer to Figure 7 , the method may include the following steps:

[0161] S71. Acquire a target image.

[0162] For details on obtaining the target image, see Figure 2 In the illustrated embodiment, S21 will not be described in detail here.

[0163] S72. Detect the target image using an image detection model to obtain a first probability.

[0164] For more information about how the image detection model detects the target image, see Figure 2 S22 in the illustrated embodiment will not be described in detail here.

[0165] S73. Detect at least one object in the target image using the target detection model to obtain a second probability corresponding to each of the at least one object.

[0166] For more information about how the target detection model detects target images, see Figure 6 The illustrated embodiments will not be described in detail here.

[0167] S74: Obtain a weight of the first probability, and determine a weight of a second probability corresponding to each of the at least one object according to a category of each of the at least one object.

[0168] The weight of the first probability may be a weight ratio of the first probability to the first probability and the second probability corresponding to the at least one object, and the value range of the weight of the first probability may be 0-1.

[0169] For the second probability corresponding to any one of the second probabilities corresponding to at least one object, the weight of the second probability can be the weight ratio of the second probability to the first probability and the second probability corresponding to at least one object. The value range of the weight of the second probability can be 0-1. It should be noted that the sum of the weights of the first probability and the second probability corresponding to at least one object is 1.

[0170] For example, assuming that the weight of the first probability is x, the objects included in the target image are eyes, mouth, and nose, and the weight of the second probability corresponding to the eyes is y, the weight of the second probability corresponding to the mouth is z, and the weight of the second probability corresponding to the nose is r, then the value ranges of x, y, z, and r are all 0-1, and x+y+z+r=1.

[0171] According to the respective categories of at least one object, the weight of the second probability corresponding to each of the at least one object is determined in the following manner: according to the degree to which abnormal features are likely to appear in the category of each object in the generative image, the weight of the second probability corresponding to the object is determined. For example, assuming that the objects included in the target image are eyes and noses, since under normal circumstances, the eyes in the generative image are more likely to have abnormal features, the weight of the second probability corresponding to the eyes can be determined to be 60%; the nose in the generative image is less likely to have abnormal features, and the weight of the second probability corresponding to the nose can be determined to be 20%.

[0172] S75. Determine a probability that the type of the target image is a generative image according to the first probability, the weight of the first probability, the second probability corresponding to each of the at least one object, and the weight of the second probability corresponding to each of the at least one object.

[0173] The probability that the type of the target image is a generative image can be determined in the following manner: the first probability is multiplied by the weight of the first probability, the second probability corresponding to each object is multiplied by the weight of the second probability corresponding to the object, and the multiplication results are added to obtain the probability that the type of the target image is a generative image.

[0174] For example, assuming that the objects included in the target image are eyes, mouth, and nose, and the second probability corresponding to the eyes is 80%, and the weight of the second probability corresponding to the eyes is 0.3; the second probability corresponding to the mouth is 60%, and the weight of the second probability corresponding to the mouth is 0.2; the second probability corresponding to the nose is 50%, and the weight of the second probability corresponding to the nose is 0.2; the first probability is 50%, and the weight of the first probability is 0.3. Then, according to the first probability, the weight of the first probability, the second probability corresponding to at least one object, and the weight of the second probability corresponding to at least one object, the probability that the type of the target image is a generative image can be: 0.3*80%+0.2*60%+0.2*50%+0.3*50%=61%.

[0175] S76: Determine whether the probability that the target image type is a generative image is greater than or equal to a preset probability threshold.

[0176] If yes, execute S77;

[0177] If not, execute S78.

[0178] S77: Determine that the type of the target image is a generative image.

[0179] For example, assuming that the preset probability threshold is 55%, the probability that the target image type is a generative image is 61%, and the probability that the target image type is a generative image is greater than the probability threshold, so it is determined that the target image type is a generative image.

[0180] S78. Determine that the type of the target image is a non-generative image.

[0181] For example, assuming that the preset probability threshold is 55%, the probability that the target image type is a generative image is 50%, and the probability that the target image type is a generative image is less than the probability threshold, so it is determined that the target image type is a generative image.

[0182] To summarize, first, the first probability and the weight of the second probability corresponding to at least one object are respectively determined, and the probability that the type of the target image is a generative image is determined based on the first probability, the weight of the first probability, the second probability corresponding to at least one object and the weight of the second probability corresponding to at least one object, and the probability that the type of the target image is a generative image is compared with a preset probability threshold to determine the type of the target image.

[0183] In addition, the embodiment of the present application also provides a method for determining the type of a target image based on a first probability and a second probability corresponding to at least one object. The method may be: generating a probability vector based on the first probability and the second probability corresponding to at least one object, and inputting the probability vector into a prediction model to obtain a prediction result output by the prediction model, and the prediction result is used to indicate the type of the target image.

[0184] The prediction model is obtained by training according to the sample probability vector and the third label, and the sample probability vector is generated according to the first sample probability corresponding to the third sample image and the second sample probability corresponding to each of the at least one second sample object;

[0185] The first sample probability is the probability that the third sample image belongs to the generative image, the second sample probability is the probability that at least one second sample object belongs to the generative object, and the third label is used to indicate whether the third sample image is a generative image.

[0186] For example, the structure diagram of the prediction model can be as follows: Figure 8 As shown, Figure 8 For a schematic diagram of a prediction model provided in the embodiment of the present application, see Figure 8The prediction model includes an input layer, an n-dimensional fully connected layer, a 2-dimensional fully connected layer and an output layer, and the output layer of the prediction model includes a Sigmoid activation function. The probability vector of the target image is processed by the n-dimensional fully connected layer and the 2-dimensional fully connected layer in the prediction model to obtain a one-dimensional vector that can be predicted. For example, the one-dimensional vector can be [x 1 、x 2 、x 3 、x 4 …x n ]. The one-dimensional vector is input to the output layer of the prediction model. The Sigmoid activation function in the output layer of the prediction model processes the one-dimensional vector to obtain the probability that the type of the target image is a generative image, and the probability that the type of the target image is a generative image is compared with the probability threshold to obtain the prediction result.

[0187] The formula of the Sigmoid activation function is shown in formula (2):

[0188]

[0189] Among them, x i refers to a one-dimensional vector [x 1 、x 2 、x 3 、x 4 …x n ], where i ranges from 1 to n.

[0190] The third sample image is a sample image used for training the prediction model, and the third sample image includes a positive sample image and a negative sample image. The third sample image may be consistent with the first sample image and / or the second sample image, or may be different from the first sample image and / or the second sample image.

[0191] The third sample image includes at least one second sample object, and the second sample object may be a characteristic part in the third sample image. For example, assuming that the third sample image is a face image, the second sample object may be a characteristic part such as eyes, mouth, ears, etc. in the face image.

[0192] For any third sample image, the third sample image is detected by the image detection model, and the detection result obtained is the first sample probability corresponding to the third sample image; the third sample image is detected by the target detection model, and the detection result obtained is the second sample probability corresponding to at least one second sample object corresponding to the third sample image.

[0193] The sample probability vector includes the first sample probability and the second sample probability corresponding to each of the at least one second sample object.

[0194] For example, assuming that the first sample probability is 50%, the sample objects included in the third sample image are eyes, hands, ears, and mouths, and the second sample probability corresponding to the eyes is 40%, the second sample probability corresponding to the hands is 70%, the second sample probability corresponding to the ears is 80%, and the second sample probability corresponding to the mouth is 30%, then the sample probability vector generated according to the first sample probability and the second sample probability corresponding to at least one second sample object can be [50%, 40%, 70%, 80%, 30%]. The order of the first sample probability and the second sample probability corresponding to at least one second sample object in the sample probability vector can be random.

[0195] It should be noted that during the training of the prediction model, in the sample probability vector corresponding to any two third sample images, the first sample probability and the second sample probability corresponding to at least one second sample object are in the same order in the sample probability vector.

[0196] For example, assuming that during the training of the prediction model, the sample objects included in the third sample image M and the third sample image N are eyes, mouth, and nose, and the sample probability vector corresponding to the third sample image M is [20%, 40%, 50%, 10%], where 20% is the first sample probability corresponding to the third sample image M, 40% is the second sample probability corresponding to the eyes, 50% is the second sample probability corresponding to the mouth, and 10% is the second sample probability corresponding to the nose. When the sample probability vector corresponding to the third sample image N is [40%, 30%, 70%, 90%], the first sample probability corresponding to the third sample image N is 40%, the second sample probability corresponding to the eyes is 30%, the second sample probability corresponding to the mouth is 70%, and the second sample probability corresponding to the nose is 90%.

[0197] Each third sample image corresponds to a third label, and for any third sample image, the corresponding third label is used to indicate at least one second sample object included in the third sample image, and whether at least one second sample object is a generative object. In some embodiments, the third label can indicate whether the second sample object is a generative object by a specific numerical value, for example, the number 0 or 1 can be used to indicate whether the second sample object is a generative object, wherein the number 0 indicates that the second sample object is a generative object, and the number 1 indicates that the second sample object is a non-generative object, or the number 0 indicates that the second sample object is a non-generative object, and the number 1 indicates that the second sample object is a generative object.

[0198] In one process of training the prediction model, the server can input the sample probability vector corresponding to the third sample image into the prediction model, process the sample probability vector through the prediction model, and obtain the prediction result output by the prediction model, and the prediction result is used to indicate the type of the third sample image. Then, the server calculates the loss value according to the prediction result and the third label, and adjusts the model parameters of the prediction model according to the calculated loss value, thereby completing one round of training process.

[0199] The server can perform one or more rounds of training on the prediction model until the training termination condition of the prediction model is reached, and the training process is stopped to obtain a trained prediction model. The training termination condition can be set according to actual needs, for example, the training termination condition can be set to a loss value less than or equal to a preset loss value, for example, the training termination condition can be set to a training number of times reaching a preset number, and so on. The trained prediction model has the ability to process the probability vector corresponding to the image to determine the type of the image.

[0200] The performance indicators of the prediction model include inference time and accuracy. The larger the probability threshold, the higher the accuracy of the prediction model, but the lower the recall rate. Therefore, the probability threshold can be adjusted according to the accuracy and recall rate of the prediction model. By adjusting the probability threshold, the trained prediction model can predict the type of the image with higher accuracy.

[0201] At the same time, in the process of performing at least one model training process on the prediction model, the weights of the first sample probability and the second sample probability corresponding to at least one second sample object in the sample probability vector can also be determined, and the weight of the first sample probability is used as the weight of the first probability, and the weight of the second sample probability corresponding to at least one second sample object is used as the weight of the second probability corresponding to at least one object, thereby determining the weights of the first probability and the second probability corresponding to at least one object.

[0202] For example, assuming that the second sample objects are eyes, nose, mouth, and ears, after training the prediction model, the weight parameter of the first sample probability is 0.4, the weight parameter of the second sample probability corresponding to the eyes is 0.3, the weight parameter of the second sample probability corresponding to the nose is 0.1, the weight parameter of the second sample probability corresponding to the mouth is 0.1, and the weight parameter of the second sample probability corresponding to the ears is 0.1. The target image includes at least one object: eyes, nose, mouth, and ears. When the final detection result is calculated according to the first probability and the second probability corresponding to at least one object through the prediction model, the weight parameter of the first probability is 0.4, the weight parameter of the second sample probability corresponding to the eyes is 0.3, the weight parameter of the second sample probability corresponding to the nose is 0.1, the weight parameter of the second sample probability corresponding to the mouth is 0.1, and the weight parameter of the second sample probability corresponding to the ears is 0.1.

[0203] The probability threshold, the weight of the first probability, and the weight of the second probability corresponding to at least one object determined during at least one model training process of the prediction model can more accurately determine the probability that the type of the target image is a generative image compared to the probability threshold, the weight of the first probability, and the weight of the second probability corresponding to at least one object preset in S75.

[0204] The probability vector may be a one-dimensional vector, which includes the first probability and the second probability corresponding to each of the at least one object.

[0205] For example, assuming that the first probability is 60%, the objects included in the target image are eyes, mouth, nose, and ears, where the second probability corresponding to the eyes is 80%, the second probability corresponding to the mouth is 70%, the second probability corresponding to the nose is 20%, and the probability corresponding to the ears is 60%, then the probability vector generated according to the first probability and the second probability corresponding to at least one object can be [60%, 80%, 70%, 20%, 60%].

[0206] It should be noted that the position of the first probability in the probability vector is consistent with the position of the first sample probability in the sample probability vector. For any one of the at least one objects included in the target image, the position of the second sample probability corresponding to the object in the sample probability vector is consistent with the position of the second probability corresponding to the object in the probability vector. When the number of probabilities in the sample probability vector is inconsistent with the number of probabilities in the probability vector, the probability vector can be determined by filling zeros at the corresponding positions.

[0207] For example, assuming that during the training of the prediction model, the sample objects included in the third sample image M are eyes, mouth, ears, and nose, and the sample probability vector corresponding to the third sample image M is [20%, 40%, 50%, 10%, 60%], where 20% is the first sample probability corresponding to the third sample image M, 40% is the second sample probability corresponding to the eyes, 50% is the second sample probability corresponding to the mouth, 10% is the second sample probability corresponding to the ears, and 60% is the second sample probability corresponding to the nose. The objects included in the target image are eyes, mouth, and nose, and the first probability corresponding to the target image is 20%, the second probability corresponding to the eyes is 80%, the second probability corresponding to the mouth is 50%, and the second probability corresponding to the nose is 10%. Since the first sample probability is in the first position in the sample probability vector, the second sample probability corresponding to the eyes is in the second position in the sample probability vector, the second sample probability corresponding to the mouth is in the third position in the sample probability vector, the second sample probability corresponding to the ears is in the fourth position in the sample probability vector, and the second sample probability corresponding to the nose is in the fifth position in the sample probability vector, it can be determined that the first probability is in the first position in the probability vector, the second probability corresponding to the eyes is in the second position in the probability vector, the second probability corresponding to the mouth is in the third position in the probability vector, and the second probability corresponding to the nose is in the fifth position in the probability vector, and zero is added at the fourth position in the probability vector, so that the probability vector of the target image is [20%, 80%, 50%, 0, 10%].

[0208] The type of the target image can be determined according to the trained prediction model in the following manner: the probability vector is input into the prediction model, the probability vector is processed by the prediction model to obtain the probability that the type of the target image is a generative image, and the probability is compared with the probability threshold to obtain a prediction result. If the probability that the type of the target image is a generative image is greater than or equal to the probability threshold, the prediction result is used to indicate that the type of the target image is a generative image; if the probability that the type of the target image is a generative image is less than the probability threshold, the prediction result is used to indicate that the type of the target image is a non-generative image.

[0209] exist Figure 7In the illustrated embodiment, the target image is detected by the image detection model and the target detection model respectively, and the first probability and the second probability corresponding to at least one object are obtained, and the weights of the first probability and the second probability corresponding to at least one object are determined respectively, and the type of the target image is determined according to the weight, the first probability and the second probability corresponding to at least one object. Through the above method, in the process of detecting the target image, the image detection model and the target detection model respectively detect the target image to obtain the first probability and the second probability to determine the type of the target image, thereby improving the accuracy of the safety detection of the target image. In addition, the embodiment of the present application also provides a method of determining the type of the target image by using a prediction model on the basis of the first probability and the second probability corresponding to at least one object, so as to obtain a more accurate weight of the first probability, the weight of the second probability corresponding to at least one object, and the probability threshold, so as to further improve the accuracy of the safety detection of the target image.

[0210] Fig. 9 For a structural diagram of an image safety detection device provided in an embodiment of the present application, see Fig. 9 The image safety detection device 90 includes: an acquisition module 91, a first detection module 92, a second detection module 93 and a determination module 94, wherein:

[0211] An acquisition module 91, used for acquiring a target image;

[0212] A first detection module 92 is used to input the target image into the image detection model to obtain a first probability, where the first probability is the probability that the target image belongs to the generative image; the image detection model is trained based on the first sample image and the first label, and the first label is used to indicate whether the first sample image belongs to the generative image;

[0213] A second detection module 93 is used to input the target image into the target detection model to obtain a second probability corresponding to at least one object, wherein the at least one object is an object in the target image, and the second probability is a probability that the corresponding object belongs to a generative object; the target detection model is trained based on the second sample image and the second label, and the second label is used to indicate the first sample object in the second sample image, and whether the first sample object belongs to a generative object;

[0214] The determination module 94 is used to determine the type of the target image according to the first probability and the second probability corresponding to each of the at least one object, where the type of the target image is a generative image or a non-generative image.

[0215] In a possible implementation, the second detection module 93 is specifically configured to:

[0216] Perform feature extraction processing on the target image to obtain the semantic features of the target image;

[0217] Determine at least one object and at least one category of each object in the target image based on the semantic features;

[0218] Detection processing is performed on at least one object according to the respective category of the at least one object to obtain a second probability corresponding to each of the at least one object.

[0219] In a possible implementation, the second detection module 93 is specifically configured to:

[0220] Perform convolution processing on the target image to obtain the first sample feature map;

[0221] Perform convolution and downsampling processing on the i-th sample feature map to obtain the i+1-th sample feature map, where i is 1, 2, ..., M-1, and M is a positive integer greater than or equal to 2;

[0222] Perform feature fusion processing on M sample feature maps to obtain semantic features.

[0223] In a possible implementation, the second detection module 93 is specifically configured to:

[0224] Detecting the target image according to the semantic features, determining at least one object detection frame and a candidate category of each of the at least one object detection frame in the target image;

[0225] At least one object and a category of the at least one object are determined in the target image according to the at least one object detection box and the candidate category of the at least one object detection box.

[0226] In a possible implementation, the second detection module 93 is specifically configured to:

[0227] Determine a sub-image corresponding to the object detection frame in the target image according to the position information and size information of the object detection frame;

[0228] Determine the target object corresponding to the object detection box in the sub-image;

[0229] Determine the category of the target object among the candidate categories of the object detection box according to the sub-image;

[0230] The at least one object includes a target object corresponding to each of the at least one object detection boxes.

[0231] In a possible implementation, the determination module 94 is specifically configured to:

[0232] Generate a probability vector according to the first probability and the second probability corresponding to each of the at least one object;

[0233] The probability vector is input into the prediction model to obtain the prediction result output by the prediction model, and the prediction result is used to indicate the type of the target image;

[0234] The prediction model is obtained by training according to the sample probability vector and the third label, and the sample probability vector is generated according to the first sample probability corresponding to the third sample image and the second sample probability corresponding to each of the at least one second sample object;

[0235] The first sample probability is the probability that the third sample image belongs to the generative image, the second sample probability is the probability that at least one second sample object belongs to the generative object, and the third label is used to indicate whether the third sample image is a generative image.

[0236] In a possible implementation, the determination module 94 is specifically configured to:

[0237] Obtaining a weight of the first probability;

[0238] Determining a weight of a second probability corresponding to each of the at least one object according to the respective category of the at least one object;

[0239] The type of the target image is determined according to the first probability, the weight of the first probability, the second probability corresponding to each of the at least one object, and the weight of the second probability corresponding to each of the at least one object.

[0240] The image safety detection device provided in the embodiment of the present application can execute the technical solution in the above method embodiment, and its implementation principle and beneficial effects are similar, which will not be repeated here.

[0241] Fig.10 This is a schematic diagram of the structure of an image safety detection device provided in an embodiment of the present application. Fig.10 As shown, the image safety detection device 100 may include: a memory 101 and at least one processor 102. Exemplarily, the memory 101 and at least one processor 102 are interconnected via a bus 103.

[0242] The memory 101 is used to store program instructions;

[0243] At least one processor 102 is used to execute the program instructions stored in the memory, so as to enable the image safety detection device 100 to execute the image safety detection method involved in the above method embodiment.

[0244] Optionally, the processor may be a central processing unit (CPU), a graphics processing unit (GPU), other general-purpose processors, a digital signal processor (DSP), or an application-specific integrated circuit (ASIC). A general-purpose processor may be a microprocessor or any conventional processor. The steps of the method disclosed in the embodiments of the present application may be directly implemented as being executed by a hardware processor, or may be implemented by a combination of hardware and software modules in the processor.

[0245] The memory may include a high-speed memory (Random Access Memory, RAM), and may also include a non-volatile memory (Non-volatile Memory, NVM), such as at least one disk memory.

[0246] The bus may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, the bus in the drawings of the present application is not limited to only one bus or one type of bus.

[0247] The image safety detection device 100 provided in the embodiment of the present application can execute the image safety detection method involved in the above method embodiment. Its implementation principle and beneficial effects are similar and will not be repeated here.

[0248] An embodiment of the present application provides a non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to enable a computer to execute the image safety detection method involved in the above method embodiment.

[0249] An embodiment of the present application provides a computer program product, including a computer program, which, when executed by a processor, implements the image safety detection method involved in the above method embodiment.

[0250] An embodiment of the present application provides a chip having a computer program stored thereon. When the computer program is executed by the chip, the image security detection method in the above method embodiment is implemented.

[0251] An embodiment of the present application provides a chip module, on which a computer program is stored. When the computer program is executed by the chip module, the image security detection method in the above method embodiment is implemented.

[0252] All or part of the steps of the above-mentioned method embodiments can be completed by hardware related to program instructions. The aforementioned program can be stored in any readable memory. When the program is executed, the steps of the above-mentioned method embodiments are executed; and the aforementioned memory (storage medium) includes: read-only memory (English: read-only memory, abbreviated: ROM), RAM, flash memory, hard disk, solid state drive, magnetic tape (English: magnetic tape), floppy disk (English: floppy disk), optical disc (English: optical disc) and any combination thereof.

[0253] The embodiments of the present application are described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processing unit of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable terminal device to generate a machine, so that the instructions executed by the processing unit of the computer or other programmable terminal device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0254] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable terminal device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0255] These computer program instructions can also be loaded onto a computer or other programmable terminal device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0256] Obviously, those skilled in the art can make various changes and modifications to the embodiments of the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the embodiments of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.

[0257] Those skilled in the art can understand that all or part of the steps of implementing the above-mentioned method embodiments can be completed by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, the steps of the above-mentioned method embodiments are executed; and the aforementioned storage medium includes: ROM, RAM, magnetic disk or optical disk and other media that can store program codes.

[0258] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.

Claims

1. An image security detection method, characterized in that: The method comprises: Get the target image; Inputting the target image into an image detection model to obtain a first probability, where the first probability is the probability that the target image belongs to a generative image; the image detection model is trained based on a first sample image and a first label, where the first label is used to indicate whether the first sample image belongs to a generative image; Input the target image into the target detection model to obtain a second probability corresponding to at least one object, wherein the at least one object is an object in the target image, and the second probability is a probability that the corresponding object belongs to a generative object; the target detection model is trained according to a second sample image and a second label, and the second label is used to indicate a first sample object in the second sample image and whether the first sample object belongs to a generative object; The type of the target image is determined according to the first probability and the second probability corresponding to each of the at least one object, where the type of the target image is a generative image or a non-generative image.

2. The method according to claim 1, characterized in that Inputting the target image into the target detection model to obtain a second probability corresponding to at least one object includes: Performing feature extraction processing on the target image to obtain semantic features of the target image; Determine, in the target image, the at least one object and a category of each of the at least one object according to the semantic feature; Detection processing is performed on the at least one object according to the respective category of the at least one object to obtain a second probability corresponding to each of the at least one object.

3. The method according to claim 2, characterized in that The performing feature extraction processing on the target image to obtain the semantic features of the target image includes: Performing convolution processing on the target image to obtain a first sample feature map; Perform convolution processing and downsampling processing on the i-th sample feature map to obtain the i+1-th sample feature map, where i is 1, 2, ..., M-1, and M is a positive integer greater than or equal to 2; Perform feature fusion processing on the M sample feature maps to obtain the semantic feature.

4. The method according to claim 2 or 3, characterized in that: The determining, in the target image according to the semantic feature, the at least one object and the category of each of the at least one object comprises: Detecting the target image according to the semantic features, and determining at least one object detection frame and a candidate category of each of the at least one object detection frame in the target image; According to the at least one object detection frame and the candidate category of each of the at least one object detection frame, the at least one object and the category of each of the at least one object are determined in the target image.

5. The method according to claim 4, characterized in that For any object detection frame in the at least one object detection frame, determining the at least one object and the category of the at least one object in the target image according to the at least one object detection frame and the candidate category of the at least one object detection frame, comprises: Determining a sub-image corresponding to the object detection frame in the target image according to the position information and size information of the object detection frame; Determining a target object corresponding to the object detection frame in the sub-image; Determine, according to the sub-image, a category of the target object among candidate categories of the object detection frame; The at least one object includes a target object corresponding to each of the at least one object detection frames.

6. The method according to any one of claims 1 to 3, characterized in that: The determining the type of the target image according to the first probability and the second probability corresponding to each of the at least one object includes: Generate a probability vector according to the first probability and the second probability corresponding to each of the at least one object; Inputting the probability vector into a prediction model to obtain a prediction result output by the prediction model, wherein the prediction result is used to indicate the type of the target image; The prediction model is obtained by training according to the sample probability vector and the third label, and the sample probability vector is generated according to the first sample probability corresponding to the third sample image and the second sample probability corresponding to each of the at least one second sample object; The first sample probability is the probability that the third sample image belongs to a generative image, the second sample probability is the probability that the at least one second sample object belongs to a generative object, and the third label is used to indicate whether the third sample image is a generative image.

7. The method according to any one of claims 1 to 3, characterized in that: The determining the type of the target image according to the first probability and the second probability corresponding to each of the at least one object includes: Obtaining a weight of the first probability; Determining a weight of a second probability corresponding to each of the at least one object according to the respective category of the at least one object; The type of the target image is determined according to the first probability, the weight of the first probability, the second probability corresponding to each of the at least one object, and the weight of the second probability corresponding to each of the at least one object.

8. An image safety detection device, characterized in that: The device comprises: An acquisition module, used for acquiring a target image; A first detection module, used for inputting the target image into an image detection model to obtain a first probability, where the first probability is the probability that the target image belongs to a generative image; the image detection model is trained based on a first sample image and a first label, where the first label is used to indicate whether the first sample image belongs to a generative image; A second detection module is configured to input the target image into a target detection model to obtain a second probability corresponding to at least one object, wherein the at least one object is an object in the target image, and the second probability is a probability that the corresponding object belongs to a generative object; the target detection model is trained based on a second sample image and a second label, and the second label is used to indicate a first sample object in the second sample image and whether the first sample object belongs to a generative object; A determination module is used to determine the type of the target image according to the first probability and the second probability corresponding to each of the at least one object, wherein the type of the target image is a generative image or a non-generative image.

9. An image safety detection device, characterized in that: include: 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 so that the at least one processor executes the image safety detection method according to any one of claims 1 to 7.

10. A non-transitory computer-readable storage medium storing computer instructions, characterized in that: in, The computer instructions are used to enable a computer to execute the image safety detection method according to any one of claims 1 to 7.