Space-frequency combined three-branch confrontation sample detection method
Through a three-branch adversarial sample detection method that combines space and frequency, discrete cosine transform and Swin Transformer modules are used to extract frequency and depth spatial features, combined with texture features, to solve the vulnerability problem of adversarial sample detection in deep learning models and achieve high accuracy. and robustness, improving the safety of computer vision tasks.
Patent Information
- Application Number
- CN202410598789.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-15
- Publication Date
- 2024-09-06
AI Technical Summary
Deep learning models are vulnerable when faced with adversarial examples, leading to erroneous outputs and affecting the robustness and security of computer vision tasks, especially in security-sensitive applications.
A three-branch adversarial sample detection method combining space and frequency is used to extract the spectrogram through discrete cosine transform. The Swin Transformer module extracts frequency and depth spatial features and combines them with texture feature enhancement. After fusion, the convolutional layer and the fully connected layer are used for binary classification. , detect and process RGB sample images to be classified.
It achieves high-accuracy detection of adversarial samples and excellent generalization performance, improving the robustness and security of computer vision task processing models.
Smart Images

Figure CN118608915A
Abstract
Description
Technical Field
[0001] The present invention relates to a convolutional neural network image recognition technology, and in particular to a space-frequency combined three-branch adversarial sample detection technology. Background Art
[0002] With the rapid development of deep learning, deep neural networks (DNNs) have become an important technology in the field of computer science. This technology not only shines in computer vision image processing. Through deep learning, complex and efficient models can be established. These models can learn and extract abstract features from massive data, thereby realizing the automated processing of various tasks. In the field of computer vision, deep learning technology has achieved remarkable achievements, such as image classification, object detection, image segmentation and other tasks, all thanks to the powerful representation ability of deep neural networks.
[0003] However, with the widespread application of deep learning models in various fields, concerns about their vulnerabilities have gradually increased. In this context, researchers first introduced the concept of adversarial examples. These adversarial examples successfully deceive deep neural networks by applying small but carefully designed perturbations to the original data, causing the model to produce incorrect outputs when faced with these samples. This discovery has attracted widespread discussion and attention in the field of deep learning, because it reveals the inherent fragility of deep learning models, and even changes that are insignificant to humans may have a huge impact on the performance of the model. The emergence of adversarial examples has brought new challenges to the application of deep learning, which is particularly important for security-sensitive applications such as autonomous driving, financial risk assessment, etc. Therefore, researchers are actively exploring various adversarial example defense strategies to improve the robustness and security of computer vision task processing models such as image classification, object detection, or image segmentation models. Summary of the invention
[0004] The technical problem to be solved by the present invention is to provide an adversarial sample detection method set before a computer vision task processing model in order to improve the robustness and security of the training data of the computer vision task processing model.
[0005] The technical solution adopted by the present invention to solve the above technical problems is a three-branch adversarial sample detection method combining space and frequency, comprising the steps of:
[0006] Receiving input step: receiving the RGB sample image to be detected;
[0007] Three-branch feature extraction steps: in the first branch, the input RGB sample image is subjected to discrete cosine transformation to obtain a spectrum graph, and the spectrum graph is subjected to the Swin Transformer module of the first branch to obtain frequency features; in the second branch, the input RGB sample image is subjected to the Swin Transformer module of the second branch to obtain deep spatial domain features; in the third branch, the input RGB sample image is first subjected to a convolutional layer to extract shallow information features with texture information, and the shallow information features are downsampled using an average pooling operation to obtain non-texture features, and then the non-texture features are upsampled so that the upsampled non-texture features and shallow information features have the same size, and finally the texture features with enhanced texture information are obtained by calculating the difference between the shallow information features and the upsampled non-texture features;
[0008] Fusion step: frequency features, depth spatial features and texture features are combined and then processed by the convolution layer to obtain fusion features. The fusion features are processed by the Swin Transformer module and then processed by adaptive average pooling before being output to the fully connected layer.
[0009] Classification step: The fully connected layer acts as a binary classifier and outputs the detection result of the RGB sample image to be detected as a clean sample or an adversarial sample.
[0010] Furthermore, the classification step also includes a detection processing step: for the RGB sample image whose detection result is a clean sample, it is used as input to a computer vision task processing system for image classification, target detection or image segmentation for identification; for the RGB sample image whose detection result is an adversarial sample, it is refused to be input into the system for processing, and the detection information of the adversarial sample is recorded and sent to the human-computer interaction end, or, for the RGB sample image whose detection result is an adversarial sample, it is first restored to a clean sample using an adversarial sample recovery algorithm and then re-output to a computer vision task processing system for image classification, target detection or image segmentation for identification.
[0011] The present invention can capture the frequency domain information of the image by performing discrete cosine transform on the input image and extracting frequency domain features in combination with the Swin Transformer module, thereby increasing the model's sensitivity to adversarial samples during the detection process. Secondly, by using Swin Transformer to extract deep spatial domain features from RGB three-channel images, the global and local information of the image can be captured, improving the model's overall grasp of the image. Third, obtaining the texture features of the image through the texture enhancement module helps the model to identify subtle texture changes in the image, thereby enhancing the model's ability to detect adversarial samples.
[0012] The beneficial effects of the present invention are: achieving a high detection accuracy rate for adversarial samples while having excellent generalization performance, thereby providing security guarantees for subsequent computer vision task processing models, thereby improving the robustness and security of computer vision task processing models. BRIEF DESCRIPTION OF THE DRAWINGS
[0013] Figure 1 The figure is a flow chart of a space-frequency combined three-branch adversarial sample detection method according to an embodiment.
[0014] Figure 2 Schematic diagram of the detection model structure of the embodiment.
[0015] Figure 3 Schematic diagram of the structure of the Swin Transformer used in the embodiment. DETAILED DESCRIPTION
[0016] The present invention will be further described below in conjunction with the accompanying drawings and embodiments.
[0017] like Figure 1 As shown, the specific steps of the embodiment are as follows:
[0018] S1, crop the image to the same size in length and width;
[0019] S2. Input the image into the ResNet classification network for classification, and select all images that can be correctly classified as the clean sample data set;
[0020] S3. Use the adversarial sample attack algorithm to generate adversarial samples corresponding to clean samples, input the adversarial samples into the ResNet network for classification, and select all the images that are misclassified as adversarial sample datasets;
[0021] S4, add Gaussian noise to all images in the clean sample dataset;
[0022] S5. Divide the clean sample and adversarial sample datasets into training set and validation set in a ratio of 7:3 respectively;
[0023] S6. Build a three-branch adversarial sample detection model. The detection model consists of three branches. The first branch is used to extract the frequency domain features of the image. The specific method is: use the two-dimensional discrete cosine transform to process the three channels of the input RGB image respectively to obtain the spectrum of the three channels, and then input all the spectrum into the SwinTransformer module of the first branch to generate frequency features. The second branch is used to extract the deep spatial domain features of the image. This branch uses the Swin Transformer module to process the RGB image to extract the deep spatial domain features of the image. The third branch is a shallow texture enhancement module, which uses a convolution layer to extract texture information from the input image. The specific method is: first, use a convolution layer with a convolution kernel size of 3×3 to extract the shallow information feature map of the image from the input image, and then use the average pooling operation to downsample the feature map to obtain non-texture features, and then use the nearest neighbor interpolation to upsample the non-texture features to make them have the same size as the above-mentioned shallow information features. Finally, the enhanced texture information is obtained by calculating the difference between the shallow information features and the upsampled non-texture features. The input image will be input into three branches respectively to obtain frequency features, depth spatial features and texture features. Finally, the fusion module integrates all features and outputs the final prediction result through the fully connected layer. The specific method is as follows: first, the feature maps of the three branches are spliced together in the channel dimension, and then input into the Swin Transformer module for processing. The processing result is processed by adaptive average pooling and then input into the fully connected layer. The fully connected layer outputs the final detection result as a binary classifier;
[0024] S7. Input the adversarial sample and clean sample training set into the model for training, and obtain the trained three-branch adversarial sample detection model. This detection method supports image inputs of various sizes. Its implementation principle is as follows: In the fusion module, an adaptive average pooling layer is used to reduce the dimension of the features. This pooling method does not require the size of the pooling window to be specified in advance, and can automatically adjust the size of the pooling window according to the size of the input data, thereby outputting a vector of a specified size;
[0025] S8. When applied, the test set or other images that need to be tested are input into the model for calculation and the test results are output.
[0026] In this embodiment, the pictures used in step S1 are from the ImageNet and Caltech-256 datasets. A total of 30,000 pictures are randomly selected from the subsets of the ImageNet dataset, ILSVRC2012, and the Caltech-256 dataset as clean samples, and then adversarial sample attack algorithms such as CW, DDN, DeepFool, and EAD are used to attack ResNet50 without targeting to obtain adversarial samples corresponding to the clean samples. Figure 2The schematic diagram of the structure of the model of the three-branch adversarial sample detection method with space-frequency combination provided by the present invention is as follows: the whole model consists of three branches and a fusion module: the input image Input image I passes through three branches respectively, and in the first branch I is subjected to discrete cosine transform DCT to obtain the spectrum diagram Freequency Image I of the image f , and then use the Swin Transformer module to extract the frequency domain feature Frequency feature F of the spectrogram f ; In the second branch, I extracts the deep spatial feature F of the image from the RGB three-channel image through Swin Transformer s ; In the third branch, I is convolved by Conv to obtain the shallow information feature Shallowfeature F sh , F sh After average pooling Avg Pool and upsampling operation expand, the non-textural feature F is obtained. avg , F sh Subtract F avg Get the texture feature Textual feature F t , the characteristics F of the three branch outputs t 、F s and F f After the merging operation Concat, the fused feature is obtained through the convolution operation Conv. The fused feature is then passed through the Swin Transformer and the average pooling Avg Pool, and then the binary classification network formed by the fully connected layer outputs the detection result. The detection result is a clean sample Real or an adversarial sample Fake. In actual application, the adversarial sample detection model is set before the computer vision task processing model such as image classification, target detection or image segmentation. The data input to the computer vision task processing model is screened. For the data judged as adversarial sample Fake, it is refused to be input into the subsequent computer vision task processing model, or it is restored to a clean sample before being used in the subsequent processing steps.
[0027] The Swin Transformer module is the basic unit in the three-branch adversarial sample detection model. The Swin Transformer structure diagram used in this example is as follows: Figure 3As shown in the figure, the input image Input is processed by Patch partition to convert the smallest unit of the image from pixels to patches. The patch is input to the LinearEmbeding of the first stage1 for linear dimension reduction, and then the feature is extracted by Swim transformer Block. Then, the feature is merged by Patchmcrging of stage2, and the final output feature is obtained by Swim transformer Block. In order to reduce the size of the Swin Transformer model, each Swin Transformer module consists of two stages. The attention head sizes in the two stages are 3 and 6 respectively, and the window size is 7.
Claims
1. A three-branch adversarial sample detection method combining space and frequency. It is characterized in that Includes steps: Receiving input step: receiving the RGB sample image to be detected; Three-branch feature extraction steps: In the first branch, the input RGB sample image is transformed by discrete cosine transform to obtain a spectrum graph, and the spectrum graph is passed through the Swin Transformer module of the first branch to obtain frequency features; In the second branch, the input RGB sample image is processed by the Swin Transformer module of the second branch to obtain the deep spatial domain features; In the third branch, the input RGB sample image is firstly passed through the convolution layer to extract the shallow information features with texture information, and the shallow information features are downsampled using the average pooling operation to obtain the non-texture features, and then the non-texture features are upsampled so that the upsampled non-texture features and the shallow information features have the same size, and finally the texture features with enhanced texture information are obtained by calculating the difference between the shallow information features and the upsampled non-texture features; Fusion step: frequency features, depth spatial features and texture features are combined and then processed by the convolution layer to obtain fusion features. The fusion features are processed by the Swin Transformer module and then processed by adaptive average pooling before being output to the fully connected layer. Classification step: The fully connected layer acts as a binary classifier and outputs the detection result of the RGB sample image to be detected as a clean sample or an adversarial sample.
2. The method according to claim 1, It is characterized in that The classification step is followed by a detection and processing step: for an RGB sample image whose detection result is a clean sample, the image is used as an input to a computer vision task processing system for image classification, target detection, or image segmentation for recognition; for an RGB sample image whose detection result is an adversarial sample, the image is refused to be input into the system for processing, and the detection information of the adversarial sample is recorded and sent to the human-computer interaction terminal. Alternatively, for an RGB sample image whose detection result is an adversarial sample, the image is first restored to a clean sample using an adversarial sample recovery algorithm and then re-output to a computer vision task processing system for image classification, target detection, or image segmentation for recognition.
3. The method according to claim 1, It is characterized in that When the detection model is trained by performing the input receiving step, the three-branch feature extraction step, the fusion step, and the classification step, the training samples are generated in the following way: S1, crop the sample image to the same size in length and width; S2. Input the sample images into the ResNet classification network for classification, and select all images that can be correctly classified as the clean sample data set; use the adversarial sample attack algorithm to generate adversarial samples corresponding to the clean samples, input the adversarial samples into the ResNet network for classification, and select all images that are misclassified as the adversarial sample data set; S3, add Gaussian noise to all sample images in the clean sample data set; S4. Divide the clean sample dataset and the adversarial sample dataset into a training set and a validation set in a ratio of 7:3 respectively; the sample images in the training set are the training samples.
4. The method according to claim 1, It is characterized in that In the third branch, the input RGB sample image first passes through a convolution layer with a convolution kernel size of 3×3 to extract shallow information features with texture information.
5. The method according to claim 1, It is characterized in that In the third branch, non-texture features are upsampled using nearest neighbor interpolation.
