Multi-target adversarial sample generation method for image recognition and related device
Through the multi-target adversarial sample generation method, using target detection models and adversarial patch replacement technology, we solve the problems of small attack range and large disturbance in adversarial sample generation in the existing technology, achieve efficient image recognition attacks, and improve the reliability of network security. sex.
Patent Information
- Application Number
- CN202411202675.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-29
- Publication Date
- 2024-10-11
AI Technical Summary
The adversarial sample generation method for image recognition in the existing technology has a small attack range, large disturbance, and low attack success rate, making it difficult to effectively respond to the network security threats of image recognition.
A multi-target adversarial sample generation method is adopted to obtain anchor boxes and heat maps through target detection models (such as YOLO series networks), generate initial adversarial samples, and use MI-FGSM and Grad-CAM models to crop and replace adversarial patches to achieve perturbation. Generate adversarial examples that are small and have high attack success rate.
It achieves the generation of multi-target adversarial samples with small disturbance and high attack success rate, improves the reliability of the adversarial defense method, and provides a stronger foundation for the safe operation of the distribution network.
Smart Images

Figure CN118762250A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of image recognition, and in particular relates to a method for generating multi-target adversarial samples for image recognition and a related device. Background Art
[0002] With the development of artificial intelligence, the application of image recognition in distribution networks has become increasingly in-depth, and images are playing an increasingly important role in improving the reliability of distribution networks. For example, in distribution station rooms, image recognition methods are used to detect the wearing of safety helmets and biological intrusions on surveillance videos. During the inspection of distribution lines, fault identification and foreign object identification are performed based on images taken by drones.
[0003] In view of the rise of network security threats such as adversarial attacks on images, the research on adversarial sample generation methods will help further improve adversarial defense methods and provide a more reliable foundation for the safe operation of distribution networks. However, the existing technology can attack images in a small range, and the generated adversarial samples have large disturbances and a low attack success rate. It is urgent to develop new adversarial sample generation schemes. Summary of the invention
[0004] The purpose of the present invention is to provide a method and a related device for generating multi-target adversarial samples for image recognition to solve one or more of the above-mentioned technical problems. The multi-target adversarial sample generation scheme provided by the present invention can generate multi-target adversarial samples with less disturbance and higher attack success rate.
[0005] In order to achieve the above object, the present invention adopts the following technical solutions: In a first aspect, the present invention provides a method for generating multi-target adversarial samples for image recognition, comprising the following steps: Obtain the original image of the multi-target adversarial sample to be generated; Detect the target in the original image using the trained target detection model, obtain the anchor frame of each target on the original image, crop the anchor frame of each target and generate the heat map of each target; for the heat map of each target, select a rectangular frame of a preset size with the same proportion as the anchor frame with the pixel point with the largest R value as the center, and obtain the patch rectangular frame of each target; Generate initial adversarial samples of all targets in the original image, and based on the location and size of the patch rectangle of each target, crop the initial adversarial samples to obtain adversarial patches of each target; The adversarial patches of each target are used to replace the original images with the same location and size to obtain the final multi-target adversarial samples.
[0006] A further improvement of the multi-target adversarial sample generation method of the present invention is that the network architecture of the target detection model is a YOLO (You Only Look Once) series network.
[0007] A further improvement of the method for generating multi-target adversarial samples of the present invention is that the step of clipping the anchor frames of each target and generating the heat map of each target includes: The anchor boxes of each target are cropped and input into the Grad-CAM (Gradient-weighted Class Activation Mapping) model respectively. The heat map of each target is generated in the Grad-CAM model based on the class activation mapping method.
[0008] A further improvement of the method for generating multi-target adversarial samples of the present invention is that the step of generating initial adversarial samples of all targets in the original image comprises: MI-FGSM (Momentum Iterative Fast Gradient Sign Method) is used to generate initial adversarial samples of all targets in the original image.
[0009] In a second aspect, the present invention provides a multi-target adversarial sample generation system for image recognition, comprising: A data acquisition module is used to obtain the original image of the multi-target adversarial sample to be generated; A patch rectangular frame acquisition module is used to perform target detection on the original image using the trained target detection model, obtain the anchor frame of each target on the original image, crop the anchor frame of each target and generate a heat map of each target; for the heat map of each target, a rectangular frame of a preset size with the same proportion as the anchor frame is selected with the pixel point with the largest R value as the center, to obtain a patch rectangular frame of each target; An adversarial patch acquisition module, used to generate initial adversarial samples of all targets in the original image, and to obtain adversarial patches of each target by cropping the initial adversarial samples based on the location and size of the patch rectangle of each target; The multi-target adversarial sample generation module is used to use the adversarial patches of each target, replace them with the same location and size on the original image, and obtain the final multi-target adversarial samples.
[0010] A further improvement of the multi-target adversarial sample generation system of the present invention is that, in the patch rectangle frame acquisition module, the network architecture of the target detection model is a YOLO series network.
[0011] A further improvement of the multi-target adversarial sample generation system of the present invention is that the patch rectangle frame acquisition module executes the steps of clipping the anchor frames of each target and generating the heat map of each target, including: The anchor boxes of each target are cropped and input into the Grad-CAM model respectively, and the heat map of each target is generated in the Grad-CAM model based on the class activation map generation method.
[0012] A further improvement of the multi-target adversarial sample generation system of the present invention is that, in the adversarial patch acquisition module, the step of generating initial adversarial samples of all targets in the original image includes: MI-FGSM is used to generate initial adversarial samples of all targets in the original image.
[0013] According to a third aspect of the present invention, there is provided an electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the method for generating multi-target adversarial samples for image recognition as described in any one of the first aspects of the present invention is implemented.
[0014] According to a fourth aspect of the present invention, a non-transitory computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the method for generating multi-target adversarial samples for image recognition as described in any one of the first aspects of the present invention is implemented.
[0015] Compared with the prior art, the present invention has the following beneficial effects: In the multi-target adversarial sample generation method for image recognition provided by the present invention, an initial adversarial sample is generated for the target, and then the target attack area in the initial adversarial sample generated above is extracted to obtain adversarial patches corresponding to the target positions of the original image; finally, the adversarial patches are replaced at the corresponding positions on the original image to generate the final adversarial sample. In the technical solution of the present invention, an adversarial patch replacement method is innovatively proposed. The location and size of the adversarial patch are determined by combining the heat map with the target positioning, and the patch is cropped and replaced accordingly, achieving a balance between the attack success rate and the disturbance amount. Multi-target adversarial samples with small disturbance and high attack success rate can be obtained, which has certain reference and guidance for the further improvement of subsequent defense methods. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] In order to more clearly illustrate the technical solutions in the present invention or 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 some embodiments of the present invention, and for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0017] Figure 1 It is a flowchart of a method for generating multi-target adversarial samples for image recognition in an embodiment of the present invention.
[0018] Figure 2 It is a schematic diagram of the principle of a method for generating multi-target adversarial samples for image recognition in an embodiment of the present invention.
[0019] Figure 3 It is a schematic diagram of a multi-target adversarial sample generation system for image recognition in an embodiment of the present invention. DETAILED DESCRIPTION
[0020] In order to make the purpose, technical solutions and advantages of the present invention clearer, the technical solutions in the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention; it is obvious that the described embodiments and technical solutions are only part of the embodiments of the present invention, not all of the embodiments.
[0021] All other embodiments obtained by those of ordinary skill in the art without creative work based on the technical solutions disclosed in the embodiments of the present invention belong to the scope of protection of the present invention. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device including a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0022] See also Figure 1 In an embodiment of the present invention, a method for generating multi-target adversarial samples for image recognition is disclosed, which may specifically include the following steps: Step 1, obtain the original image of the multi-target adversarial sample to be generated; Step 2, use the trained target detection model to perform target detection on the original image obtained in step 1, obtain the anchor frame of each target on the original image, crop the anchor frame of each target and generate the heat map of each target; for the heat map of each target, select a rectangular frame of a preset size (for example, 1 / 10 of the size of the anchor frame) with the same proportion as the anchor frame with the pixel point with the largest R value as the center, and obtain the patch rectangular frame of each target; in a specific example explanatory scheme, the R values of all pixels can be compared one by one in the heat map (specifically, since all pixels in a color image have RGB three-color values representing Red, Green, and Blue respectively, according to the characteristics of the heat map, the more prominent the red attribute is, the higher the importance is), and finally select the pixel point with the largest R value (that is, the red attribute value) as the center point; Step 3, generating initial adversarial samples of all targets in the original image obtained in step 1, and based on the location and size of the patch rectangle of each target, cropping the initial adversarial samples to obtain adversarial patches of each target; in a further preferred solution, MI-FGSM can be used to generate initial adversarial samples of all targets in the original image obtained in step 1; In step 4, the adversarial patches of each target are used to replace the original image with the same location and size to obtain the final multi-target adversarial sample.
[0023] In the technical solution provided by the embodiment of the present invention, the original image is processed by an adversarial sample generation algorithm to generate an initial adversarial sample that can deceive the machine learning model; the area with the greatest impact on the model decision, that is, the targeted attack area, is identified from the generated initial adversarial sample, and adversarial patches corresponding to the target positions of the original image are extracted from these areas. These adversarial patches contain key disturbance information that causes the model to misjudge; finally, the corresponding positions on the original image are replaced with the extracted adversarial patches to generate the final adversarial sample. This replacement method ensures that the disturbance is as small as possible while maintaining a high attack success rate.
[0024] In one embodiment of the present invention, in step 2, the network architecture of the target detection model may be a YOLO series.
[0025] Specifically, the network architecture of the target detection model is YOLOv5, and the steps of performing target detection using the trained target detection model specifically include: The original image is scaled to the specified size (length × width is 608*608) and input into the Focus module (explanatory, the convolutional neural network layer for feature extraction) for slicing operation. After slicing operation, it is input into the Backbone module to extract image features and convert the input original image into a multi-layer feature map for subsequent module processing and use. In the Backbone module, the CSP module (Cross Stage Partial) is used to generate a 76*76 feature map of the 608*608 size image, and downsampled twice to generate a 19*19 size feature map. Input the 19*19 size feature map into the FPN structure (Feature Pyramid Network), and use its special pyramid structure to fuse feature maps of different sizes to obtain the fused feature map. The fused feature map is input into the PAN structure (Path Aggregation Network) to better utilize the underlying positioning attributes of the image. Finally, the feature maps of the same size are processed by bitwise addition to obtain the feature map processed by bitwise addition, which facilitates the model to better locate the target. Anchor box prediction is performed based on the feature map after bitwise addition operation to obtain the prediction result; wherein the prediction result includes the anchor box position and the target category; explanatory, in the technical solution of the present invention, only the positioning function is used, so only the anchor box prediction branch is concerned; in addition, GIOU_Loss (Generalized Intersection over Union Loss) can be used to guide the accuracy of the predicted anchor box, and the greater the gap between the predicted anchor box and the true anchor box, the closer the function calculation value is to -1; non-maximum suppression (NMS) is used to filter the predicted anchor box.
[0026] In one embodiment of the present invention, in step 2, the step of clipping the anchor frame of each target and generating the heat map of each target specifically includes: The anchor boxes of each target are cropped and input into the Grad-CAM model respectively, and the heat map of each target is generated in the Grad-CAM model based on the class activation map generation method.
[0027] The existing Fast Gradient Sign Method (FGSM) is widely used as a classic adversarial sample generation method, but because it launches attacks based on linear assumptions, it will not meet the linear assumptions when the image distortion is large, thus limiting the attack capability of the algorithm; in the technical solution disclosed in the embodiment of the present invention, the idea of momentum and iterative attack is used, and the iterative fast gradient sign attack method based on momentum has stronger attack performance. By integrating the momentum term into the iterative attack to stabilize the perturbation direction of each round, it is beneficial to jump out of the local optimum in the iteration; in addition, YOLO, as a classic target detection algorithm, can achieve target detection with a high accuracy, and the YOLOv5 algorithm is used to realize the positioning of all targets in the sample; at the same time, in order to reduce the attack area and reduce the perturbation amount, the attention mechanism is introduced to improve the attack success rate of multi-target images while reducing the perturbation amount, which helps to further determine the key area and thus improve the attack success rate. Using the above means, an innovative method of adversarial patch replacement is proposed, and the location and size of the adversarial patch are determined by combining the heat map with the target positioning, and the corresponding replacement is performed by the cropping tool to achieve a balance between the attack success rate and the perturbation amount.
[0028] Specifically, in step 3, the step of using MI-FGSM to generate initial adversarial samples of all targets in the original image includes: MI-FGSM generates a velocity vector by accumulating in the direction of gradient descent, based on the input parameters: classifier f , loss function J ,sample x ,Label y , disturbance scale ε , number of iterations T , attenuation factor μ ; Execute and output the following data, the output adversarial sample satisfy ;in, There are T rounds of iterations, and the perturbation scale is ε. Then the perturbation scale of each round of iteration is: ; Each round of iteration repeats the following operations: t Adversarial examples of iterations Input classifier f , get the gradient ; Calculate the gradient and update g t+1 , the calculation expression is: ; The final generated global adversarial sample , For the T Iteration of adversarial examples.
[0029] In the embodiment of the present invention, the key attack area of the target is first determined; then the momentum iterative gradient method is used based on MI-FGSM to generate an initial adversarial sample for the target, and then adversarial patches corresponding to the target positions of the original image are obtained; finally, the patches are replaced according to the corresponding positions on the original image to generate adversarial samples; the present invention realizes the attack on all targets on the image based on target detection and attention mechanism, thereby generating multi-target adversarial samples with small disturbance and high attack success rate; it has certain reference and guidance for further improvement of subsequent defense methods.
[0030] See also Figure 2In the embodiment of the present invention, an image sample is taken as an example to simulate the technical solution of the embodiment of the present invention; first, the image sample is input into the target detection model and the MI-FGSM model respectively, and the heat map generation algorithm Grad-CAM is introduced after the target detection model, and the two are combined to jointly generate the heat map of each target anchor frame; then, the MI-FGSM model is used to generate the initial adversarial sample, and according to the technical solution disclosed in the embodiment of the present invention, the location and size of the replacement patch are determined from the heat map of each target anchor frame, and the patch is cropped in the initial adversarial sample, and finally the cropping and replacement are performed on the image sample to complete the generation of the final adversarial sample. Further explanatory, the technical solution of the embodiment of the present invention can be experimentally verified using a large number of image samples, and the embodiment here only uses one image for theoretical verification.
[0031] The following are device embodiments of the present invention, which can be used to implement the method embodiments of the present invention. For details not disclosed in the device embodiments, please refer to the method embodiments of the present invention.
[0032] See also Figure 3 In an embodiment of the present invention, a multi-target adversarial sample generation system for image recognition is provided, comprising: A data acquisition module is used to obtain the original image of the multi-target adversarial sample to be generated; A patch rectangular frame acquisition module is used to perform target detection on the original image using the trained target detection model, obtain the anchor frame of each target on the original image, crop the anchor frame of each target and generate a heat map of each target; for the heat map of each target, a rectangular frame of a preset size with the same proportion as the anchor frame is selected with the pixel point with the largest R value as the center, to obtain a patch rectangular frame of each target; An adversarial patch acquisition module, used to generate initial adversarial samples of all targets in the original image, and to obtain adversarial patches of each target by cropping the initial adversarial samples based on the location and size of the patch rectangle of each target; The multi-target adversarial sample generation module is used to use the adversarial patches of each target, replace them with the same location and size on the original image, and obtain the final multi-target adversarial samples.
[0033] In one embodiment of the present invention, a computer device is provided, the computer device comprising a processor and a memory, the memory being used to store a computer program, the computer program comprising program instructions, and the processor being used to execute the program instructions stored in the computer storage medium. The processor may be a central processing unit (CPU), or may be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. It is the computing core and control core of the terminal, which is suitable for implementing one or more instructions, and is specifically suitable for loading and executing one or more instructions in a computer storage medium to implement a corresponding method flow or corresponding function; the processor described in the embodiment of the present invention can be used to perform operations of a multi-target adversarial sample generation method for image recognition.
[0034] In one embodiment of the present invention, a storage medium is provided, specifically a computer-readable storage medium (Memory), which is a memory device in a computer device for storing programs and data. It is understandable that the computer-readable storage medium here can include both built-in storage media in the computer device and, of course, extended storage media supported by the computer device. The computer-readable storage medium provides a storage space, which stores the operating system of the terminal. In addition, one or more instructions suitable for being loaded and executed by the processor are also stored in the storage space, and these instructions can be one or more computer programs (including program codes). It should be noted that the computer-readable storage medium here can be a high-speed RAM (Random Access Memory) memory, or a non-volatile memory (non-volatile memory), such as at least one disk memory. The processor can load and execute one or more instructions stored in the computer-readable storage medium to implement the corresponding steps of the multi-target adversarial sample generation method for image recognition in the above embodiment.
[0035] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present application may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, optical storage, etc.) containing computer-usable program codes.
[0036] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0037] These computer program instructions may also be stored in a computer readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0038] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0039] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the above embodiments, ordinary technicians in the relevant field should understand that the specific implementation methods of the present invention can still be modified or replaced by equivalents. Any modification or equivalent replacement that does not depart from the spirit and scope of the present invention should be covered within the scope of protection of the claims of the present invention.
Claims
1. A method for generating multi-target adversarial samples for image recognition, characterized in that: The following steps are involved: Obtain the original image of the multi-target adversarial sample to be generated; Detect the target in the original image using the trained target detection model, obtain the anchor frame of each target on the original image, crop the anchor frame of each target and generate the heat map of each target; for the heat map of each target, select a rectangular frame of a preset size with the same proportion as the anchor frame with the pixel point with the largest R value as the center, and obtain the patch rectangular frame of each target; Generate initial adversarial samples of all targets in the original image, and based on the location and size of the patch rectangle of each target, crop the initial adversarial samples to obtain adversarial patches of each target; The adversarial patches of each target are used to replace the original images with the same location and size to obtain the final multi-target adversarial samples.
2. The method for generating multi-target adversarial samples for image recognition according to claim 1, characterized in that: The network architecture of the target detection model is the YOLO series network.
3. The method for generating multi-target adversarial samples for image recognition according to claim 1, characterized in that: The step of cutting out the anchor frames of each target and generating the heat map of each target comprises: The anchor boxes of each target are cropped and input into the Grad-CAM model respectively, and the heat map of each target is generated in the Grad-CAM model based on the class activation map generation method.
4. The method for generating multi-target adversarial samples for image recognition according to claim 1, characterized in that: The step of generating initial adversarial samples of all targets in the original image comprises: MI-FGSM is used to generate initial adversarial samples of all targets in the original image.
5. A multi-target adversarial sample generation system for image recognition, characterized in that: include: A data acquisition module is used to obtain the original image of the multi-target adversarial sample to be generated; A patch rectangular frame acquisition module is used to perform target detection on the original image using the trained target detection model, obtain the anchor frame of each target on the original image, crop the anchor frame of each target and generate a heat map of each target; for the heat map of each target, a rectangular frame of a preset size with the same proportion as the anchor frame is selected with the pixel point with the largest R value as the center, to obtain a patch rectangular frame of each target; An adversarial patch acquisition module, used to generate initial adversarial samples of all targets in the original image, and to obtain adversarial patches of each target by cropping the initial adversarial samples based on the location and size of the patch rectangle of each target; The multi-target adversarial sample generation module is used to use the adversarial patches of each target, replace them with the same location and size on the original image, and obtain the final multi-target adversarial samples.
6. The multi-target adversarial sample generation system for image recognition according to claim 5, characterized in that: In the patch rectangle frame acquisition module, the network architecture of the target detection model is a YOLO series network.
7. The multi-target adversarial sample generation system for image recognition according to claim 5, characterized in that: The patch rectangle frame acquisition module executes the steps of clipping the anchor frames of each target and generating the heat map of each target, including: The anchor boxes of each target are cropped and input into the Grad-CAM model respectively, and the heat map of each target is generated in the Grad-CAM model based on the class activation map generation method.
8. The multi-target adversarial sample generation system for image recognition according to claim 5, characterized in that: In the adversarial patch acquisition module, the step of generating initial adversarial samples of all objects in the original image includes: MI-FGSM is used to generate initial adversarial samples of all targets in the original image.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the method for generating multi-target adversarial samples for image recognition according to any one of claims 1 to 4 is implemented.
10. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method for generating multi-target adversarial samples for image recognition according to any one of claims 1 to 4 is implemented.
Citation Information
Patent Citations
End-to-end method for generating imperceptible adversarial patch
CN118229954A
Image model testing method and apparatus, electronic device and storage medium
WO2021056746A1
