Image detection method and device, electronic equipment and storage medium
By extracting and fusing image features of different scales, and using attention mechanisms and residual networks for analysis, the problem of low image detection accuracy in the prior art is solved, the recognition accuracy of forged images and non-real targets is improved, and the accuracy of intelligent driving strategies is enhanced.
Patent Information
- Application Number
- CN202311228774.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-21
- Publication Date
- 2025-03-21
AI Technical Summary
The existing image detection technology has low recognition accuracy when identifying fake images and non-real targets in intelligent driving scenarios, affecting the accuracy of autonomous driving strategies during intelligent driving.
An image detection method is proposed. By obtaining the image to be detected, image features of at least three different scales are extracted, and the attention mechanism is used to fuse features of different scales to obtain the fusion features. Then, the fusion features are classified in binary, and the fusion analysis is performed using a pre-constructed residual network to determine whether the image is a fake image.
By fusing image features at different scales, the recognition accuracy of forged images is improved and the accuracy of image authenticity detection in intelligent driving scenarios is enhanced.
Smart Images

Figure CN119672478A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence technology, and in particular to an image detection method, device, electronic device and storage medium. Background Art
[0002] With the development of computer and Internet technologies, various image editing technologies have become increasingly powerful, making it impossible to accurately identify forged or synthesized images. Or, in intelligent driving scenarios, it is impossible to accurately identify real targets (e.g., real vehicles or pedestrians on the road) and non-real targets (e.g., vehicle images or human images displayed on roadside signboards) in images taken during driving, thus affecting the accuracy of the autonomous driving strategy during intelligent driving.
[0003] In order to identify images forged by generative adversarial networks or images of non-real targets in intelligent driving scenarios, image detection technology is needed to detect images, but the existing image detection technology has low recognition accuracy. Summary of the invention
[0004] Based on the above-mentioned defects and shortcomings of the prior art, the present application proposes an image detection method, device, electronic device and storage medium, which can improve the recognition accuracy of forged images.
[0005] The technical solutions proposed in this application are as follows:
[0006] According to a first aspect of an embodiment of the present application, an image detection method is provided, the method comprising:
[0007] Acquire the image to be detected;
[0008] Extracting image features of at least three different scales of the image to be detected;
[0009] For each scale of the image to be detected, an attention mechanism is used to fuse the image features of other scales of the image to be detected to obtain a fused feature of the image to be detected;
[0010] Performing binary classification processing on the fused features of the image to be detected, determining a probability feature representing the image category confidence corresponding to the fused features, wherein the image category confidence represents the probability that the image to be detected is true and / or the probability that it is false;
[0011] Using the pre-built residual network, the probability features corresponding to the image to be detected are fused and analyzed to determine whether the image to be detected is a forged image.
[0012] In one embodiment, extracting image features of at least three different scales of the image to be detected includes:
[0013] Using a pre-built feature extraction model, image features of at least three different resolutions of the image to be detected are extracted.
[0014] In one embodiment, for the image features of each scale of the image to be detected, an attention mechanism is used to fuse the image features of other scales of the image to be detected to obtain the fused features of the image to be detected, including:
[0015] Determine at least two sets of image feature combinations corresponding to the image to be detected according to the image features of different resolutions of the image to be detected; wherein each set of image feature combinations includes at least two image features of different resolutions, and the resolutions of the image features included in any two sets of image feature combinations are not completely the same;
[0016] Based on the attention mechanism, feature fusion processing is performed on the image features in each group of image feature combinations to obtain the first image feature corresponding to each group of image feature combinations;
[0017] For each first image feature, other first image features are fused to obtain a fused feature corresponding to each first image feature as the fused feature of the image to be detected.
[0018] In one embodiment, when the number of the feature extraction models is one, determining at least two sets of image feature combinations corresponding to the image to be detected according to image features of different resolutions of the image to be detected includes:
[0019] Selecting image features from the image features of different resolutions of the image to be detected and combining them to obtain at least two groups of image feature combinations; wherein each group of image feature combinations includes at least two image features of different resolutions, and the resolutions of the image features included in the two groups of image feature combinations are not completely the same;
[0020] When the number of the feature extraction models is at least two, determining at least two groups of image feature combinations corresponding to the image to be detected according to image features of different resolutions of the image to be detected includes:
[0021] At least two image features with different resolutions extracted by a feature extraction model are used as a group of image feature combinations to obtain at least two groups of image feature combinations; wherein the resolutions of the image features extracted by any two feature extraction models are not completely the same.
[0022] In one embodiment, if the image to be detected includes at least two images to be detected of different sizes, for image features of each scale of the image to be detected, an attention mechanism is used to fuse image features of other scales of the image to be detected to obtain fused features of the image to be detected, including:
[0023] Determine at least two groups of image feature combinations corresponding to the image to be detected of the first size according to image features of different resolutions of the image to be detected of the first size; wherein each group of image feature combinations includes at least two image features of different resolutions, and the resolutions of the image features included in any two groups of image feature combinations are not completely the same;
[0024] Based on the attention mechanism, feature fusion processing is performed on the image features in each group of image feature combinations corresponding to the image to be detected of the first size to obtain the first image features corresponding to each group of image feature combinations;
[0025] For each first image feature corresponding to the image to be detected of the first size, fuse other first image features corresponding to the image to be detected of the first size to obtain a fused feature corresponding to each first image feature of the image to be detected of the first size as the fused feature of the image to be detected of the first size;
[0026] The first size is the size of any image to be detected in the images to be detected of each size.
[0027] In one embodiment, based on the attention mechanism, feature fusion processing is performed on the image features in the image feature combination corresponding to the image to be detected to obtain the first image feature corresponding to the image feature combination, including:
[0028] Performing channel normalization processing on the image features of each resolution in the image feature combination to obtain channel normalized image features corresponding to the image features of each resolution;
[0029] Performing attention enhancement processing on the channel normalized image features corresponding to the image features of each resolution to obtain the attention enhanced image features of each resolution;
[0030] Fusing all attention-enhanced image features corresponding to the image feature combination to obtain a second image feature corresponding to the image feature combination;
[0031] The second image feature corresponding to the image feature combination is normalized to obtain the first image feature corresponding to the image feature combination.
[0032] In one embodiment, based on the fusion features of the image to be detected, the image to be detected is subjected to binary classification processing into a forged image and a non-forged image to determine whether the image to be detected is a forged image, including:
[0033] Performing binary classification processing on each fused feature of the image to be detected, determining a probability feature representing the image category confidence corresponding to each fused feature, wherein the image category confidence represents the probability that the image to be detected is true and / or the probability that it is false;
[0034] Using the pre-built residual network, the probability features corresponding to the image to be detected are fused and analyzed to determine whether the image to be detected is a forged image.
[0035] In one embodiment, using a pre-built residual network, a fusion analysis is performed on the probability features corresponding to the image to be detected to determine whether the image to be detected is a forged image, including:
[0036] Normalizing the probability features of the image to be detected to obtain normalized probability features;
[0037] Performing linear combination and linear transformation on the normalized probability features to obtain a first intermediate probability feature;
[0038] Performing a nonlinear transformation on the first intermediate probability feature to obtain a second intermediate probability feature;
[0039] Performing linear combination and linear transformation on the second intermediate probability features to obtain a third intermediate probability feature;
[0040] Normalizing the third intermediate probability feature to obtain a fourth intermediate probability feature;
[0041] Performing residual processing on the first intermediate probability feature and the fourth intermediate probability feature to determine a first probability that the image to be detected is true or a second probability that the image to be detected is false;
[0042] Based on a first probability that the image to be detected is true or a second probability that the image to be detected is false, it is determined whether the image to be detected is a forged image.
[0043] According to a second aspect of an embodiment of the present application, an image detection device is provided, the device comprising:
[0044] An acquisition module, used for acquiring an image to be detected;
[0045] An extraction module, used to extract image features of at least three different scales of the image to be detected;
[0046] A feature fusion module, used for fusing image features of each scale of the image to be detected with image features of other scales of the image to be detected by using an attention mechanism to obtain a fused feature of the image to be detected;
[0047] A binary classification module, used to perform binary classification processing on the fused features of the image to be detected, and determine the probability features corresponding to the fused features representing the image category confidence, wherein the image category confidence represents the probability that the image to be detected is true and / or the probability that it is false;
[0048] The probability fusion module is used to use a pre-built residual network to perform a fusion analysis on the probability features corresponding to the image to be detected, so as to determine whether the image to be detected is a forged image.
[0049] According to a third aspect of an embodiment of the present application, there is provided an electronic device, including: a memory and a processor;
[0050] Wherein, the memory is connected to the processor and is used to store programs;
[0051] The processor is used to implement the above-mentioned image detection method by running the program in the memory.
[0052] According to a fourth aspect of an embodiment of the present application, a storage medium is provided, on which computer program instructions are stored. When the computer program instructions are executed by a processor, the above-mentioned image detection method is implemented.
[0053] The present application proposes an image detection method, device, electronic device and storage medium. For an image to be detected, image features of at least three different scales of the image to be detected are extracted, and then, for each scale of the image features of the image to be detected, the attention mechanism is used to fuse the image features of other scales of the image to be detected. The obtained fused features include features of multiple different scales of the image to be detected. The fused features of the image to be detected are subjected to binary classification processing, and the probability features representing the confidence of the image category corresponding to the fused features are determined. The probability features corresponding to the image to be detected are fused and analyzed by using a pre-constructed residual network to determine whether the image to be detected is a forged image. Since the features of different scales of the image to be detected are fused, the authenticity of the image to be detected is detected based on the features of different scales, which can improve the recognition accuracy of forged images. BRIEF DESCRIPTION OF THE DRAWINGS
[0054] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are merely embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.
[0055] Figure 1 It is a flowchart of an image detection method provided in an embodiment of the present application;
[0056] Figure 2 This is a schematic diagram of an overall network architecture for image detection provided by an embodiment of the present application;
[0057] Figure 3 is a schematic diagram of a network architecture of a unified attention module provided in an embodiment of the present application;
[0058] Figure 4 It is a schematic diagram of a network architecture of a probabilistic modeling module provided in an embodiment of the present application;
[0059] Figure 5 It is a flowchart of another image detection method provided in an embodiment of the present application;
[0060] Figure 6 is a structural schematic diagram of an image detection device provided in an embodiment of the present application;
[0061] Figure 7 It is a structural schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0062] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0063] Application Overview
[0064] With the rapid development of intelligent networked vehicles, technologies such as digitalization are driving the evolution of automobiles to the evolving mobile third space. Autonomous driving can not only improve the user's driving experience, but also reduce the accident rate on the road. Intelligent networked vehicles integrate modern communication and network technologies, which can realize the intelligent information exchange and sharing between vehicles, people, roads, and background, and provide powerful driving information for autonomous driving, thereby ensuring the accuracy and safety of autonomous driving. In the intelligent driving scenario, it is necessary to use the images taken during driving as the analysis basis for intelligent driving to generate intelligent driving strategies. Therefore, the accuracy of identifying the images taken during driving can affect the accuracy of the autonomous driving strategy during intelligent driving.
[0065] When identifying images taken during driving, it is necessary to identify the real targets and non-real targets in the images, so that the recognition results can generate corresponding intelligent driving strategies. Among them, real targets include real vehicles or pedestrians on the road, and non-real targets include vehicle images or human images displayed in display boards beside the road. For example, when a real target is identified from a captured image, it is necessary to generate an intelligent driving strategy that includes avoiding the real target. When only non-real targets are identified from the captured image, it means that there are no real vehicles or pedestrians on the road, and only vehicle images or human images are displayed in display boards beside the road. The generated intelligent driving strategy does not include an avoidance strategy, or only includes an intelligent driving strategy that avoids non-real targets. Images with real targets are regarded as real images, and images without real targets and only non-real targets are regarded as forged images. In order to improve the accuracy of the automatic driving strategy during intelligent driving, it is particularly important to improve the recognition accuracy of whether the images of intelligent driving scenes are forged images.
[0066] In addition, with the development of computer and Internet technology, various image editing technologies are becoming increasingly powerful. Therefore, it is necessary to identify whether the face in the picture is real or synthesized through image forgery technology. At this time, it is particularly important to improve the accuracy of identifying whether the image is a forged image.
[0067] In summary, how to improve the accuracy of identifying whether an image to be detected is a forged image is a technical problem that those skilled in the art need to solve urgently.
[0068] In view of the above-mentioned deficiencies in the prior art and existing problems, the inventors of the present application have proposed an image detection method after research and experiments, which can improve the recognition accuracy of forged images.
[0069] Exemplary Methods
[0070] An embodiment of the present application proposes an image detection method, which can be executed by an electronic device. The electronic device can be any device with data and instruction processing functions, such as a computer, a smart terminal, a server, etc. Figure 1 is a flow chart of an image detection method provided in an embodiment of the present application, see Figure 1 As shown, the method includes:
[0071] S101, obtaining an image to be detected.
[0072] In the field of intelligent driving, for images taken during the autonomous driving process, if the target in the image is not a real target (for example, a vehicle or person image displayed on a signboard beside the road), the image is considered a forged image. If the target in the image is a real target (for example, a real vehicle or pedestrian on the road), the image is a real image and can also be called a non-forged image. In the field of face recognition, if the target in the image is a forged face, the image is considered a forged image. If the target in the image is a real face, the image is considered a real image and can also be called a non-forged image.
[0073] Specifically, for the initial image that needs to be tested for forgery, before image detection, the image within the target range in the initial image needs to be cropped out to obtain the image to be detected that contains the detection target. For example, for an original image containing a face, the existing face detection model can be used to detect the face range, and then the image within the face range can be cropped out as the image to be detected. For the original image taken during the autonomous driving process, the image within the area containing the vehicle or person in the original image can be cropped out as the image to be detected.
[0074] S102: extracting image features of at least three different scales from the image to be detected.
[0075] After the present embodiment obtains the image to be detected, it is necessary to extract the image features of the image to be detected, and at least three different scales can be pre-set to extract image features for different scales, so that the image features of at least three different scales of the image to be detected can be extracted. Wherein, the different scales can be different resolutions and / or different sizes. That is, the image features of at least three different resolutions of the image to be detected can be extracted, or the image features of at least three different sizes of the image to be detected can be extracted, or again, the image features of at least three different resolutions of the image to be detected of each size in at least two different sizes of the images to be detected can be extracted.
[0076] Specifically, when the scale is represented by resolution, extracting image features of at least three different scales of the image to be detected includes: extracting image features of at least three different resolutions of the image to be detected using a pre-built feature extraction model.
[0077] In this embodiment, the pre-built feature extraction model can use a convolutional network to extract image features of different resolutions. Among them, the convolutional network can use the EfficientNet network structure to extract features, EfficientNet's stage1, stage2, stage3, stage4, stage5, where stage represents feature downsampling, and after the image to be detected is input into the convolutional network, after passing through EfficientNet's stage1, the image resolution is reduced by 2 times, and then after passing through EfficientNet's stage2, the image resolution is reduced by 4 times, and then after passing through EfficientNet's stage3, the image resolution is reduced by 8 times, and then after passing through EfficientNet's stage4, the image resolution is reduced by 16 times, and then after passing through EfficientNet's stage5, the image resolution is reduced by 32 times. Therefore, the image features output by stage1 of EfficientNet are extracted, which are image features with a resolution of 2 times lower than that of the image to be detected. The image features output by stage2 of EfficientNet are extracted, which are image features with a resolution of 4 times lower than that of the image to be detected. The image features output by stage3 of EfficientNet are extracted, which are image features with a resolution of 8 times lower than that of the image to be detected. The image features output by stage4 of EfficientNet are extracted, which are image features with a resolution of 16 times lower than that of the image to be detected. The image features output by stage5 of EfficientNet are extracted, which are image features with a resolution of 32 times lower than that of the image to be detected. At this point, image features of five different resolutions can be extracted. If only three image features of different resolutions need to be extracted, only three layers of feature downsampling layers can be set, so that image features with a resolution of 2 times lower than that of the image to be detected, image features with a resolution of 4 times lower than that of the image to be detected, and image features with a resolution of 8 times lower than that of the image to be detected can be extracted. Alternatively, five feature downsampling layers are set, and only any three image features of different resolutions are extracted from them. This embodiment does not impose any specific restrictions.
[0078] In addition, when the scale is expressed as resolution, to extract image features of at least three different sizes of the image to be detected, the image to be detected can be directly scaled to obtain at least three images of different sizes, and then image features of each size can be extracted to obtain image features of at least three different sizes. At this time, the image feature extraction can be performed without feature downsampling, that is, the resolution is not adjusted, and the image features are directly extracted, or the images of each size can be downsampled by the same multiple so that the images of each size maintain the same resolution, thereby extracting image features of each size. For the scaling of the image to be detected, the preferred scaling sizes of this embodiment include: 224×224, 299×299, and 384×384. This embodiment can also scale the image to be detected to other sizes, which is not limited in this embodiment.
[0079] In addition, when the scale represents resolution and size, at least three image features with different resolutions are extracted from at least two images to be detected of each size with different resolutions, that is, the image to be detected of each size is extracted according to the above-mentioned image feature extraction method with different resolutions, so that at least three image features with different resolutions can be obtained for each size of the image to be detected.
[0080] S103: For each scale of the image to be detected, an attention mechanism is used to fuse the image features of other scales of the image to be detected to obtain a fused feature of the image to be detected.
[0081] Specifically, after the image features of at least three scales of the image to be detected are extracted in this embodiment, image feature pyramids of different scales can be formed. For example, when the scale is resolution, image feature pyramids of different resolutions can be formed. This embodiment can use an attention mechanism to fuse the image features in the image feature pyramid, so as to obtain the fused features of the image to be detected. The specific steps are as follows:
[0082] First, according to image features of different resolutions of the image to be detected, at least two groups of image feature combinations corresponding to the image to be detected are determined.
[0083] After extracting the image features of different resolutions of the image to be detected through the above steps, at least two image features of different resolutions can be arbitrarily selected from the image features of each resolution to form an image feature combination corresponding to the image to be detected, and the image feature combination is an image feature pyramid of different resolutions. In this embodiment, at least two groups of image feature combinations are formed, wherein each group of image feature combinations contains at least two image features of different resolutions, and the resolutions of the image features contained in the two groups of image feature combinations are not exactly the same. For example, the image feature a1 whose resolution of the image to be detected is reduced by 2 times, the image feature a2 whose resolution of the image to be detected is reduced by 4 times, the image feature a3 whose resolution of the image to be detected is reduced by 8 times, the image feature a4 whose resolution of the image to be detected is reduced by 16 times, and the image feature a5 whose resolution of the image to be detected is reduced by 32 times, the first group of image feature combinations may include a1, a2, a3, the second group of image feature combinations may include a2, a3, a4, the third group of image combinations may include a3, a4, a5, etc.
[0084] Specifically, a feature extraction model can be used to obtain image feature combinations, wherein the feature extraction model can use a convolutional network. When the number of feature extraction models is one (i.e., one convolutional network), the feature extraction model selects image features from the image features of different resolutions extracted from the image to be detected for combination to obtain at least two groups of image feature combinations, that is, all image feature combinations are extracted by the feature extraction model. The convolutional network determines image features of different resolutions through each feature downsampling layer (stage) of EfficientNet, and then selects image features from all image features for combination to combine at least two groups of image feature combinations.
[0085] When the number of feature extraction models is at least two, each feature extraction model extracts at least two image features of different resolutions and combines them together to obtain at least two groups of image feature combinations, and each group of image feature combinations includes at least two image features of different resolutions, and the resolutions of the image features in the image feature combinations determined by any two feature extraction models are not exactly the same.
[0086] Figure 2 is a schematic diagram of an overall network architecture of image detection provided by an embodiment of the present application, such as Figure 2As shown in the figure, three feature extraction models are set, each of which is a convolutional network. Each convolutional network uses each feature downsampling layer (stage) of EfficientNet to obtain image features of different resolutions. The first convolutional network can combine the image feature a3 with an 8-fold reduction in resolution of the image to be detected output by the third feature downsampling layer (stage3), the image feature a4 with a 16-fold reduction in resolution of the image to be detected output by the fourth feature downsampling layer (stage4), and the image feature a5 with a 32-fold reduction in resolution of the image to be detected output by the fifth feature downsampling layer (stage5), thereby obtaining the image feature combination output by the first convolutional network; the second convolutional network can divide the image to be detected output by the second feature downsampling layer (stage2) into The image feature combination output by the second convolutional network can be obtained by combining the image feature a2 with a 4-fold decrease in resolution output by the first feature downsampling layer (stage1), the image feature a2 with a 4-fold decrease in resolution output by the second feature downsampling layer (stage2), the image feature a3 with a 8-fold decrease in resolution output by the third feature downsampling layer (stage3), and the image feature a4 with a 16-fold decrease in resolution output by the fourth feature downsampling layer (stage4), thereby obtaining the image feature combination output by the second convolutional network; the third convolutional network can combine the image feature a1 with a 2-fold decrease in resolution output by the first feature downsampling layer (stage1), the image feature a2 with a 4-fold decrease in resolution output by the second feature downsampling layer (stage2), and the image feature a3 with a 8-fold decrease in resolution output by the third feature downsampling layer (stage3), thereby obtaining the image feature combination output by the third convolutional network.
[0087] Second, based on the attention mechanism, feature fusion processing is performed on the image features in each group of image feature combinations to obtain the first image features corresponding to each group of image feature combinations.
[0088] Each set of image feature combinations is an image feature pyramid with different resolutions. In this embodiment, each image pyramid with different resolutions needs to be subjected to feature fusion processing respectively, that is, for each set of image feature combinations, the image features contained therein are fused respectively, so as to obtain the first image features corresponding to each image feature combination. When the image features in each set of image feature combinations are subjected to feature fusion processing, an attention mechanism is used for feature fusion, so as to realize the combination of context information and improve the accuracy of feature fusion. Figure 3 As shown, a unified attention module is used to perform feature fusion processing on the image features in the image feature combination. The unified attention module includes: an attention module and a normalization layer, wherein the attention module includes a channel normalization module and an Attention module. The specific steps include:
[0089] First, channel normalization is performed on the image features of each resolution in the image feature combination to obtain the channel normalized image features corresponding to the image features of each resolution. Figure 3 is a schematic diagram of a network architecture of a unified attention module provided in an embodiment of the present application, such as Figure 3 As shown, a group of image feature combinations corresponding to the image a to be detected includes three image features a1, a2, and a3 with different resolutions. The image features a1, a2, and a3 are respectively subjected to channel normalization processing by a channel normalization module, and the different channel numbers of the image features a1, a2, and a3 are normalized to a uniform number, thereby obtaining the channel normalized image features corresponding to the image features of each resolution, that is, the channel normalized feature b3 corresponding to the image feature a3, the channel normalized image feature b2 corresponding to the image feature a2, and the channel normalized image feature b1 corresponding to the image feature a1. Among them, the channel normalization module in this embodiment preferably adopts 1×1 convolution.
[0090] Secondly, the channel normalized image features corresponding to the image features of each resolution are subjected to attention enhancement processing to obtain the attention enhanced image features of each resolution. Figure 3 As shown, the Attention module is used to perform attention enhancement processing on the channel-normalized image feature b3, perform attention enhancement processing on the channel-normalized image feature b2, and perform attention enhancement processing on the channel-normalized image feature b1.
[0091] Then, all the attention-enhanced image features corresponding to the image feature combination are fused to obtain the second image feature corresponding to the image feature combination. Figure 3As shown, the channel-normalized image feature b3 is input into the Attention module of the first layer for attention enhancement processing, and the image feature of the channel-normalized image feature b3 after attention enhancement is obtained. Then, the image feature of the channel-normalized image feature b3 after attention enhancement and the channel-normalized image feature b2 are both input into the Attention module of the second layer, so that the channel-normalized image feature b2 is combined with the image feature after attention enhancement processing of the channel-normalized image feature b3 to perform attention enhancement processing, thereby obtaining the image feature of the channel-normalized image feature b2 after attention enhancement processing, and then the image feature of the channel-normalized image feature b2 after attention enhancement processing and the channel-normalized image feature b1 are both input into the Attention module of the third layer, so that the channel-normalized image feature b1 is combined with the image feature after attention enhancement processing of the channel-normalized image feature b2 to perform attention enhancement processing, thereby obtaining the image feature of the channel-normalized image feature b1 after attention enhancement processing, and the image feature is used as the second image feature corresponding to the image feature combination.
[0092] Finally, the second image feature corresponding to the image feature combination is normalized to obtain the first image feature corresponding to the image feature combination. Figure 2 and Figure 3 The normalization layer in the unified attention module in the above steps is used for normalization. Through the above steps, the second image feature corresponding to each image feature combination can be determined, and then the second image feature corresponding to each image feature combination is normalized using the normalization layer to obtain the first image feature corresponding to each image feature combination.
[0093] Third, for each first image feature, other first image features are fused to obtain a fused feature corresponding to each first image feature as the fused feature of the image to be detected.
[0094] After obtaining the first image feature corresponding to each image feature combination through the above steps, it is necessary to fuse each first image feature with other first image features other than the first image feature, so as to obtain the fusion feature corresponding to each first image feature, and all the fusion features obtained by fusion are used as the fusion feature of the image to be detected. That is, for the image to be detected, several image feature combinations are extracted in advance, and the fusion feature of the image to be detected includes several, that is, the number of image feature combinations corresponding to the image to be detected is the same as the number of fusion features of the image to be detected. For example, if the image feature combinations corresponding to three images to be detected are determined in advance, three first image features A, B, and C are obtained. For the first image feature A, the first image feature B and the first image feature C need to be fused to obtain the fusion feature A1 corresponding to the first image feature A. For the first image feature B, the first image feature A and the first image feature C need to be fused to obtain the fusion feature B1 corresponding to the first image feature B. For the first image feature C, the first image feature A and the first image feature B need to be fused to obtain the fusion feature C1 corresponding to the first image feature C. Finally, the fusion feature A1, the fusion feature B1, and the fusion feature C1 are used as the fusion feature of the image to be detected.
[0095] Specifically, before fusing each first image feature, it is first necessary to perform a block operation on the feature map corresponding to each first image feature, cut it into image blocks of different sizes, and determine the unit image features corresponding to each image block, so as to reduce the amount of calculation. For example, if the feature map corresponding to the first image feature A is 32×32, the feature map corresponding to the first image feature B is 64×64, and the feature map corresponding to the first image feature C is 128×128, then the feature map corresponding to the first image feature A is cut into 16 8×8 image blocks, and the unit image features corresponding to each image block are obtained, the feature map corresponding to the first image feature B is cut into 16 16×16 image blocks, and the unit image features corresponding to each image block are obtained, and the feature map corresponding to the first image feature C is cut into 16 32×32 image blocks, and the unit image features corresponding to each image block are obtained.
[0096] like Figure 2As shown, in this embodiment, a Transformer-based fusion module is used to fuse the first image features. Among them, the Transformer-based fusion module includes linear projection, Transformer encoding, cross projection and classification head. In the process of fusing the first image features, firstly, linear projection is used to project each unit image feature cut into one-dimensional features; secondly, Transformer encoding is used to encode all the one-dimensional features corresponding to the first image features to obtain the encoding features corresponding to each first image feature, for example, the encoding features corresponding to the first image feature A, the encoding features corresponding to the first image feature B and the encoding features corresponding to the first image feature C; then, cross projection is used to fuse the probability encoding of the encoding features corresponding to the first image features and the encoding features corresponding to other first image features, so as to obtain the fusion features corresponding to the first image features. For example, the coding feature corresponding to the first image feature A is fused with the probability coding of the coding feature corresponding to the first image feature B and the probability coding of the coding feature corresponding to the first image feature C by cross projection, so as to obtain the fused feature A1 corresponding to the first image feature A; the coding feature corresponding to the first image feature B is fused with the probability coding of the coding feature corresponding to the first image feature A and the probability coding of the coding feature corresponding to the first image feature C by cross projection, so as to obtain the fused feature B1 corresponding to the first image feature B; the coding feature corresponding to the first image feature C is fused with the probability coding of the coding feature corresponding to the first image feature A and the probability coding of the coding feature corresponding to the first image feature B by cross projection, so as to obtain the fused feature C1 corresponding to the first image feature C.
[0097] S104: performing binary classification processing on the fused features of the image to be detected, and determining the probability features representing the confidence of the image category corresponding to the fused features.
[0098] After the fusion features of the image to be detected are determined through the above steps, since the number of fusion features of the image to be detected is the same as the number of predetermined image feature combinations, the fusion features of the image to be detected include at least two, and it is necessary to perform category confidence analysis on each fusion feature of the image to be detected, where the categories include forged images and non-forged images, so that the category confidence of each fusion feature can be determined, and then the confidence of each fusion feature is fused and analyzed, and finally it is determined whether the image to be detected is a forged image. Through the category confidence fusion analysis of each fusion feature of the image to be detected, the recognition accuracy of whether the image to be detected is a forged image can be improved.
[0099] This embodiment needs to perform binary classification processing on each fused feature of the image to be detected based on the image category, so as to determine the probability feature corresponding to each fused feature. Among them, the probability feature corresponding to the fused feature represents the image category confidence, and the image category includes forged images and non-forged images. The image category confidence represents the probability that the image to be detected is true (that is, the probability that the image to be detected is a non-forged OA image) and / or the probability of being false (that is, the probability that the image to be detected is a forged image). The probability feature corresponding to the fused feature may include only the probability that the image to be detected is true, or only the probability that the image to be detected is false, or both the probability that the image to be detected is true and the probability that the image to be detected is false. When the probability feature corresponding to the fused feature includes both the probability that the image to be detected is true and the probability that the image to be detected is false, the probability feature of the fused feature is a two-dimensional vector. As Figure 2 As shown, this embodiment can use the classification head in the Transformer-based fusion module to determine the probability feature corresponding to each fusion feature.
[0100] Because before fusing each first image feature, it is first necessary to perform a block operation on the feature map corresponding to each first image feature, cut it into image blocks of different sizes, and determine the unit image feature corresponding to each image block. Therefore, each fusion feature of the image to be detected includes the fusion feature corresponding to the unit image feature cut by the first image feature corresponding to the fusion feature. Then the probability feature corresponding to each fusion feature also includes the probability feature corresponding to each unit image feature. Therefore, the probability feature corresponding to each fusion feature includes the probability features corresponding to multiple pre-cut image blocks. For example, in the above steps, each first image feature is cut into 16 image blocks. Therefore, the probability feature corresponding to each fusion feature also includes 16 sub-probability features, so that a probability family can be formed, that is, the probability feature corresponding to each fusion feature is a probability family.
[0101] S105: Using the pre-built residual network, perform fusion analysis on the probability features corresponding to the image to be detected to determine whether the image to be detected is a forged image.
[0102] This embodiment pre-constructs a residual network, and uses the residual network to perform fusion analysis on each probability feature (i.e., probability family) corresponding to the image to be detected to determine whether the image to be detected is a forged image. Figure 2 As shown, this embodiment can use a pre-built data-based multi-dimensional feature probability modeling module to perform fusion analysis on various probability features output by the classification head in the Transformer-based fusion module. Figure 4 is a schematic diagram of a network architecture of a probability modeling module provided in an embodiment of the present application, such as Figure 4As shown, the data-based multi-dimensional feature probability modeling module includes a probability family normalization layer and a residual network, wherein the residual network includes: a linear layer, a Relu activation layer, a linear layer, and a Bn normalization layer. The specific steps include: (1) normalizing each probability feature of the image to be detected to obtain a normalized probability feature. Among them, each probability feature of the image to be detected is a probability family, each probability family contains multiple probabilities, and a probability family normalization layer is used to normalize each probability family, and the maximum value of the probability in each probability family is obtained by using the max operation, so as to obtain the normalized probability feature corresponding to each probability family. (2) Linearly combining and linearly transforming the normalized probability features to obtain a first intermediate probability feature. Among them, the linear linear layer in the residual network is used for linear combination and linear transformation. (3) Nonlinearly transforming the first intermediate probability feature to obtain a second intermediate probability feature. Among them, the Relu activation layer in the residual network is used for nonlinear transformation. (4) Linearly combining and linearly transforming the second intermediate probability feature to obtain a third intermediate probability feature. Among them, the Linear layer in the residual network is used for linear combination and linear transformation. (5) The third intermediate probability feature is normalized to obtain a fourth intermediate probability feature. Among them, the Bn normalization layer in the residual network is used for normalization. (5) The first intermediate probability feature and the fourth intermediate probability feature are subjected to residual processing to determine a first probability that the image to be detected is true or a second probability that it is false. (6) Based on the first probability that the image to be detected is true or the second probability that it is false, determine whether the image to be detected is a forged image.
[0103] From the above introduction, it can be seen that the image detection method proposed in the embodiment of the present application extracts image features of at least three different scales of the image to be detected for the image to be detected, and then uses the attention mechanism to fuse the image features of other scales of the image to be detected for each scale of the image to be detected. The obtained fused features include features of multiple different scales of the image to be detected, and the fused features of the image to be detected are subjected to binary classification processing to determine the probability features representing the confidence of the image category corresponding to the fused features. The pre-constructed residual network is used to perform fusion analysis on the probability features corresponding to the image to be detected to determine whether the image to be detected is a forged image. Since the features of different scales of the image to be detected are fused, the authenticity of the image to be detected is detected based on the features of different scales, which can improve the recognition accuracy of forged images.
[0104] As an optional implementation, Figure 5 is a flow chart of another image detection method provided in an embodiment of the present application, such as Figure 5 As shown, in another embodiment of the present application, the image detection method of this embodiment may specifically include the following steps:
[0105] S501: Acquire an image to be detected.
[0106] S502: Adjust the size of the image to be detected to obtain at least two images to be detected of different sizes.
[0107] In this embodiment, the image scaling technology can be used to scale the size of the image to be detected, so as to obtain at least two images to be detected of different sizes. For example, the image to be detected is scaled into images of sizes of 224×224, 299×299, and 384×384.
[0108] S503: Using a pre-built feature extraction model, extract image features of at least three different resolutions of each size of the image to be detected.
[0109] This embodiment can use a pre-built feature extraction model, such as a convolutional network, to extract image features of different resolutions for each size of the image to be detected, so as to obtain at least three image features of different resolutions for each size of the image to be detected. Among them, the image features of at least three different resolutions for each size of the image to be detected can be extracted by using the image feature extraction method of different resolutions in the above embodiment, which will not be specifically described in this embodiment.
[0110] S504: For each scale of the image to be detected, an attention mechanism is used to fuse the image features of other scales of the image to be detected to obtain a fused feature of the image to be detected.
[0111] When the scale includes resolution and size, the image features of each scale of the image to be detected are fused with the image features of other scales, which specifically includes the following steps:
[0112] First, according to the image features of different resolutions of the image to be detected of the first size, at least two groups of image feature combinations corresponding to the image to be detected of the first size are determined, wherein each group of image feature combinations includes at least two image features of different resolutions, and the resolutions of the image features included in any two groups of image feature combinations are not completely the same.
[0113] Second, based on the attention mechanism, feature fusion processing is performed on the image features in each group of image feature combinations corresponding to the image to be detected of the first size to obtain the first image features corresponding to each group of image feature combinations.
[0114] Third, for each first image feature corresponding to the image to be detected of the first size, other first image features corresponding to the image to be detected of the first size are fused to obtain a fused feature corresponding to each first image feature of the image to be detected of the first size as the fused feature of the image to be detected of the first size. The first size is the size of any image to be detected in the images to be detected of each size.
[0115] Through the above steps, the fusion features of the image to be detected of each size can be determined. The specific execution method of each step has been specifically described in the above embodiment, and will not be repeated in this embodiment.
[0116] S505 , based on the fusion features of the image to be detected, performing binary classification processing of the image to be detected into a forged image and a non-forged image, and determining whether the image to be detected is a forged image.
[0117] After determining the fusion features of the image to be detected of each size, the image to be detected can be subjected to binary classification processing of forged images and non-forged images based on all the fusion features to determine whether the image to be detected is a forged image. Specifically, first, each fusion feature of the image to be detected of each size can be subjected to binary classification processing to determine the probability feature representing the image category confidence corresponding to each fusion feature corresponding to each size, wherein the image category confidence represents the probability that the image to be detected is true and / or the probability that it is false. Then, using the pre-constructed residual network, all the probability features corresponding to the image to be detected are subjected to fusion analysis to determine whether the image to be detected is a forged image. The specific steps have been described in the above embodiment and will not be repeated in this embodiment.
[0118] The execution method of step S501 in this embodiment is the same as that of step S101 in the above embodiment, and is not further elaborated in this embodiment.
[0119] Exemplary Devices
[0120] Corresponding to the above-mentioned image detection method, the embodiment of the present application further discloses an image detection device, Figure 6 is a schematic diagram of the structure of an image detection device provided in an embodiment of the present application, see Figure 6 As shown, the device comprises:
[0121] An acquisition module 100 is used to acquire an image to be detected;
[0122] An extraction module 110, used to extract image features of at least three different scales of the image to be detected;
[0123] A feature fusion module 120 is used to fuse image features of each scale of the image to be detected with image features of other scales of the image to be detected using an attention mechanism to obtain fused features of the image to be detected;
[0124] A binary classification module 130 is used to perform binary classification processing on the fused features of the image to be detected, and determine the probability features corresponding to the fused features representing the confidence of the image category, where the image category confidence represents the probability that the image to be detected is true and / or the probability that it is false;
[0125] The probability fusion module 140 is used to use a pre-built residual network to perform fusion analysis on the probability features corresponding to the image to be detected, and determine whether the image to be detected is a forged image.
[0126] The image detection device proposed in the embodiment of the present application, for an image to be detected, uses the extraction module 110 to extract image features of at least three different scales of the image to be detected, and then the fusion module 120 uses the attention mechanism to fuse the image features of each scale of the image to be detected with the image features of other scales of the image to be detected, so that the obtained fused features include features of multiple different scales of the image to be detected. The binary classification module 130 performs binary classification on the fused features of the image to be detected to determine the probability features representing the confidence of the image category corresponding to the fused features. The probability fusion module 140 uses a pre-constructed residual network to perform fusion analysis on the probability features corresponding to the image to be detected to determine whether the image to be detected is a forged image. Since the features of different scales of the image to be detected are fused, the authenticity of the image to be detected is detected based on the features of different scales, which can improve the recognition accuracy of forged images.
[0127] As an optional implementation, another embodiment of the present application discloses that the extraction module 110 of the above embodiment is specifically used to extract image features of at least three different resolutions of the image to be detected by using a pre-built feature extraction model.
[0128] As an optional implementation, another embodiment of the present application discloses that the feature fusion module 120 of the above embodiment includes: a feature combination unit, a first feature fusion unit, and a second feature fusion unit;
[0129] A feature combination unit, used to determine at least two sets of image feature combinations corresponding to the image to be detected according to image features of different resolutions of the image to be detected; wherein each set of image feature combinations includes at least two image features of different resolutions, and the resolutions of the image features included in any two sets of image feature combinations are not completely the same;
[0130] A first feature fusion unit is used to perform feature fusion processing on the image features in each group of image feature combinations based on an attention mechanism to obtain a first image feature corresponding to each group of image feature combinations;
[0131] The second feature fusion unit is used to fuse other first image features with each first image feature to obtain a fusion feature corresponding to each first image feature as the fusion feature of the image to be detected.
[0132] As an optional implementation, another embodiment of the present application discloses that when the number of feature extraction models is one, the feature combination unit of the above embodiment is specifically used to: select image features from image features of different resolutions of the image to be detected for combination to obtain at least two groups of image feature combinations; wherein each group of image feature combinations includes at least two image features of different resolutions, and the resolutions of the image features included in the two groups of image feature combinations are not completely the same;
[0133] When the number of feature extraction models is at least two, the feature combination unit of the above embodiment is specifically used to: combine at least two image features of different resolutions extracted by a feature extraction model as a group of image feature combinations to obtain at least two groups of image feature combinations; wherein the resolutions of the image features extracted by any two feature extraction models are not exactly the same.
[0134] As an optional implementation, another embodiment of the present application discloses that the image detection device in the above embodiment further includes a size adjustment module.
[0135] A size adjustment module, used for adjusting the size of the image to be detected to obtain at least two images to be detected of different sizes;
[0136] The extraction module 110 is further specifically configured to extract image features of at least three different resolutions of each size of the image to be detected by using a pre-built feature extraction model.
[0137] As an optional implementation, another embodiment of the present application discloses that the feature combination unit of the above embodiment is further used to determine at least two groups of image feature combinations corresponding to the image to be detected of the first size according to image features of different resolutions of the image to be detected of the first size; wherein each group of image feature combinations includes at least two image features of different resolutions, and the resolutions of the image features included in any two groups of image feature combinations are not completely the same;
[0138] The first feature fusion unit is further used to perform feature fusion processing on the image features in each group of image feature combinations corresponding to the image to be detected of the first size based on the attention mechanism, so as to obtain the first image features corresponding to each group of image feature combinations;
[0139] The second feature fusion unit is further used to fuse other first image features corresponding to the image to be detected of the first size with each first image feature corresponding to the image to be detected of the first size, to obtain a fused feature corresponding to each first image feature of the image to be detected of the first size as the fused feature of the image to be detected of the first size;
[0140] The first size is the size of any image to be detected in the images to be detected of each size.
[0141] As an optional implementation, another embodiment of the present application discloses that the first feature fusion unit in the above embodiment is specifically used for:
[0142] Perform channel normalization processing on the image features of each resolution in the image feature combination to obtain the channel normalized image features corresponding to the image features of each resolution;
[0143] Performing attention enhancement processing on the channel normalized image features corresponding to the image features of each resolution to obtain the attention enhanced image features of each resolution;
[0144] Fusing all attention-enhanced image features corresponding to the image feature combination to obtain a second image feature corresponding to the image feature combination;
[0145] The second image feature corresponding to the image feature combination is normalized to obtain the first image feature corresponding to the image feature combination.
[0146] As an optional implementation, another embodiment of the present application discloses that the probability fusion module 140 in the above embodiment is specifically used for:
[0147] Normalizing the probability features of the image to be detected to obtain normalized probability features;
[0148] Performing linear combination and linear transformation on the normalized probability features to obtain a first intermediate probability feature;
[0149] Performing a nonlinear transformation on the first intermediate probability feature to obtain a second intermediate probability feature;
[0150] Performing linear combination and linear transformation on the second intermediate probability feature to obtain a third intermediate probability feature;
[0151] Normalizing the third intermediate probability feature to obtain a fourth intermediate probability feature;
[0152] Performing residual processing on the first intermediate probability feature and the fourth intermediate probability feature to determine a first probability that the image to be detected is true or a second probability that the image to be detected is false;
[0153] Based on a first probability that the image to be detected is true or a second probability that it is false, it is determined whether the image to be detected is a forged image.
[0154] The image detection device provided in this embodiment belongs to the same application concept as the image detection method provided in the above embodiments of this application, can execute the image detection method provided in any of the above embodiments of this application, and has the corresponding functional modules and beneficial effects of executing the image detection method. For technical details not fully described in this embodiment, please refer to the specific processing content of the image detection method provided in the above embodiments of this application, which will not be repeated here.
[0155] Exemplary Electronic Devices
[0156] Corresponding to the above-mentioned image detection method, the embodiment of the present application further discloses an electronic device, Figure 7 is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application, see Figure 7 As shown, the electronic device includes:
[0157] Memory 200 and processor 210;
[0158] The memory 200 is connected to the processor 210 and is used to store programs;
[0159] The processor 210 is used to implement the image detection method disclosed in any of the above embodiments by running the program stored in the memory 200.
[0160] Specifically, the electronic device may further include: a bus, a communication interface 220 , an input device 230 and an output device 240 .
[0161] The processor 210, the memory 200, the communication interface 220, the input device 230 and the output device 240 are connected to each other via a bus.
[0162] A bus may include a pathway that transfers information between components of a computer system.
[0163] The processor 210 may be a general-purpose processor, such as a general-purpose central processing unit (CPU), a microprocessor, etc., or an application-specific integrated circuit (ASIC), or one or more integrated circuits for controlling the execution of the program of the present application. It may also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0164] The processor 210 may include a main processor, and may also include a baseband chip, a modem, and the like.
[0165] The memory 200 stores a program for executing the technical solution of the present application, and may also store an operating system and other key services. Specifically, the program may include a program code, and the program code includes computer operation instructions. More specifically, the memory 200 may include a read-only memory (ROM), other types of static storage devices that can store static information and instructions, a random access memory (RAM), other types of dynamic storage devices that can store information and instructions, a disk storage, a flash, and the like.
[0166] The input device 230 may include a device for receiving data and information input by a user, such as a keyboard, a mouse, a camera, a scanner, a light pen, a voice input device, a touch screen, a pedometer, or a gravity sensor.
[0167] Output device 240 may include devices that allow information to be output to a user, such as a display screen, printer, speaker, etc.
[0168] The communication interface 220 may include any transceiver or the like to communicate with other devices or communication networks, such as Ethernet, Radio Access Network (RAN), Wireless Local Area Network (WLAN), etc.
[0169] The processor 210 executes the program stored in the memory 200 and calls other devices, which can be used to implement the various steps of the image detection method provided in the above embodiments of the present application.
[0170] Exemplary computer program products and storage media
[0171] In addition to the above methods and devices, the embodiments of the present application may also be a computer program product, which includes computer program instructions. When the computer program instructions are executed by the processor 210, the processor 210 executes each step of the image detection method provided in the above embodiments.
[0172] The computer program product may be written in any combination of one or more programming languages to write program codes for performing the operations of the embodiments of the present application, including object-oriented programming languages such as Java, C++, etc., and also conventional procedural programming languages such as "C" language or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, as a separate software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server.
[0173] In addition, the embodiment of the present application may also be a computer-readable storage medium on which computer program instructions are stored. When the computer program instructions are executed by the processor, the processor 210 executes each step of the image detection method provided in the above embodiment.
[0174] The computer readable storage medium may adopt any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may include, for example, but is not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples (non-exhaustive list) of readable storage media include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.
[0175] Specifically, the specific working contents of each part of the above-mentioned electronic device, computer program product and storage medium, as well as the specific processing contents when the computer program product or the computer program on the above-mentioned storage medium is executed by the processor, can be found in the contents of the various embodiments of the above-mentioned image detection method, and will not be repeated here.
[0176] For the aforementioned method embodiments, for the sake of simplicity, they are all described as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the order of the actions described, because according to the present application, some steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required for the present application.
[0177] It should be noted that each embodiment in this specification is described in a progressive manner, and each embodiment focuses on the differences from other embodiments, and the same or similar parts between the embodiments can be referred to each other. For the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0178] The steps in the methods of each embodiment of the present application can be adjusted in order, combined and deleted according to actual needs, and the technical features recorded in each embodiment can be replaced or combined.
[0179] The modules and sub-modules in the devices and terminals in the various embodiments of the present application can be combined, divided and deleted according to actual needs.
[0180] In the several embodiments provided in the present application, it should be understood that the disclosed terminals, devices and methods can be implemented in other ways. For example, the terminal embodiments described above are only schematic, for example, the division of modules or submodules is only a logical function division, and there may be other division methods in actual implementation, such as multiple submodules or modules can be combined or integrated into another module, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or modules, which can be electrical, mechanical or other forms.
[0181] The modules or submodules described as separate components may or may not be physically separated, and the components of the modules or submodules may or may not be physical modules or submodules, that is, they may be located in one place, or they may be distributed on multiple network modules or submodules. Some or all of the modules or submodules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0182] In addition, each functional module or submodule in each embodiment of the present application may be integrated into one processing module, or each module or submodule may exist physically separately, or two or more modules or submodules may be integrated into one module. The above-mentioned integrated modules or submodules may be implemented in the form of hardware or in the form of software functional modules or submodules.
[0183] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0184] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly by hardware, software units executed by a processor, or a combination of the two. The software units may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0185] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprises" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "including a..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0186] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. An image detection method, characterized in that: The method comprises: Acquire the image to be detected; Extracting image features of at least three different scales of the image to be detected; For each scale of the image to be detected, an attention mechanism is used to fuse the image features of other scales of the image to be detected to obtain a fused feature of the image to be detected; Performing binary classification processing on the fused features of the image to be detected, determining a probability feature representing the image category confidence corresponding to the fused features, wherein the image category confidence represents the probability that the image to be detected is true and / or the probability that it is false; Using the pre-built residual network, the probability features corresponding to the image to be detected are fused and analyzed to determine whether the image to be detected is a forged image.
2. The method according to claim 1, characterized in that: Extracting image features of at least three different scales of the image to be detected, including: Using a pre-built feature extraction model, image features of at least three different resolutions of the image to be detected are extracted.
3. The method according to claim 2, characterized in that For each scale of the image to be detected, an attention mechanism is used to fuse the image features of other scales of the image to be detected to obtain the fused features of the image to be detected, including: Determine at least two sets of image feature combinations corresponding to the image to be detected according to the image features of different resolutions of the image to be detected; wherein each set of image feature combinations includes at least two image features of different resolutions, and the resolutions of the image features included in any two sets of image feature combinations are not completely the same; Based on the attention mechanism, feature fusion processing is performed on the image features in each group of image feature combinations to obtain the first image feature corresponding to each group of image feature combinations; For each first image feature, other first image features are fused to obtain a fused feature corresponding to each first image feature as the fused feature of the image to be detected.
4. The method according to claim 3, characterized in that: When the number of the feature extraction models is one, determining at least two sets of image feature combinations corresponding to the image to be detected according to image features of different resolutions of the image to be detected includes: Selecting image features from the image features of different resolutions of the image to be detected and combining them to obtain at least two groups of image feature combinations; wherein each group of image feature combinations includes at least two image features of different resolutions, and the resolutions of the image features included in the two groups of image feature combinations are not completely the same; When the number of the feature extraction models is at least two, determining at least two groups of image feature combinations corresponding to the image to be detected according to image features of different resolutions of the image to be detected includes: At least two image features with different resolutions extracted by a feature extraction model are used as a group of image feature combinations to obtain at least two groups of image feature combinations; wherein the resolutions of the image features extracted by any two feature extraction models are not completely the same.
5. The method according to claim 1, characterized in that: If the image to be detected includes at least two images to be detected of different sizes, for image features of each scale of the image to be detected, an attention mechanism is used to fuse image features of other scales of the image to be detected to obtain fused features of the image to be detected, including: Determine at least two groups of image feature combinations corresponding to the image to be detected of the first size according to image features of different resolutions of the image to be detected of the first size; wherein each group of image feature combinations includes at least two image features of different resolutions, and the resolutions of the image features included in any two groups of image feature combinations are not completely the same; Based on the attention mechanism, feature fusion processing is performed on the image features in each group of image feature combinations corresponding to the image to be detected of the first size to obtain the first image features corresponding to each group of image feature combinations; For each first image feature corresponding to the image to be detected of the first size, fuse other first image features corresponding to the image to be detected of the first size to obtain a fused feature corresponding to each first image feature of the image to be detected of the first size as the fused feature of the image to be detected of the first size; The first size is the size of any image to be detected in the images to be detected of each size.
6. The method according to claim 3 or 5, characterized in that: Based on the attention mechanism, feature fusion processing is performed on the image features in the image feature combination corresponding to the image to be detected to obtain the first image feature corresponding to the image feature combination, including: Performing channel normalization processing on the image features of each resolution in the image feature combination to obtain channel normalized image features corresponding to the image features of each resolution; Performing attention enhancement processing on the channel normalized image features corresponding to the image features of each resolution to obtain the attention enhanced image features of each resolution; Fusing all attention-enhanced image features corresponding to the image feature combination to obtain a second image feature corresponding to the image feature combination; The second image feature corresponding to the image feature combination is normalized to obtain the first image feature corresponding to the image feature combination.
7. The method according to claim 1, characterized in that Using a pre-built residual network, a fusion analysis is performed on the probability features corresponding to the image to be detected to determine whether the image to be detected is a forged image, including: Normalizing the probability features of the image to be detected to obtain normalized probability features; Performing linear combination and linear transformation on the normalized probability features to obtain a first intermediate probability feature; Performing a nonlinear transformation on the first intermediate probability feature to obtain a second intermediate probability feature; Performing linear combination and linear transformation on the second intermediate probability features to obtain a third intermediate probability feature; Normalizing the third intermediate probability feature to obtain a fourth intermediate probability feature; Performing residual processing on the first intermediate probability feature and the fourth intermediate probability feature to determine a first probability that the image to be detected is true or a second probability that the image to be detected is false; Based on a first probability that the image to be detected is true or a second probability that the image to be detected is false, it is determined whether the image to be detected is a forged image.
8. An image detection device, characterized in that: The device comprises: An acquisition module, used for acquiring an image to be detected; An extraction module, used to extract image features of at least three different scales of the image to be detected; A feature fusion module, used for fusing image features of each scale of the image to be detected with image features of other scales of the image to be detected by using an attention mechanism to obtain a fused feature of the image to be detected; A binary classification module, used to perform binary classification processing on the fused features of the image to be detected, and determine the probability features corresponding to the fused features representing the image category confidence, wherein the image category confidence represents the probability that the image to be detected is true and / or the probability that it is false; The probability fusion module is used to use a pre-built residual network to perform a fusion analysis on the probability features corresponding to the image to be detected, so as to determine whether the image to be detected is a forged image.
9. An electronic device, characterized in that: include: Memory and processor; Wherein, the memory is connected to the processor and is used to store programs; The processor is used to implement the image detection method according to any one of claims 1 to 7 by running the program in the memory.
10. A storage medium, characterized in that: The storage medium stores computer program instructions, which, when executed by a processor, implement the image detection method according to any one of claims 1 to 7.