A method and system for generating adversarial sample images based on color space components
By determining the color space sampling of the position pixel block and the adversarial perturbation block in the adversarial sample generation method, the robustness of the adversarial sample in the change of color space components is ensured, and the problem of the failure of the adversarial sample under different lighting and equipment in the existing technology is solved. problem, achieving more stable adversarial sample generation.
Patent Information
- Application Number
- CN202210737699.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-28
- Publication Date
- 2024-09-27
- Estimated Expiration
- 2042-06-28
AI Technical Summary
Existing adversarial sample generation methods fail to consider the robustness of adversarial samples during changes in color space components, resulting in failure under different lighting conditions or equipment.
By determining the position of the pixel block in the image to be resisted, setting an adversarial perturbation block of the same size, and sampling in the color space to form multiple adversarial sample images, which are input to the target detection model for prediction and iterative optimization to ensure that the adversarial sample Robustness to changes in color space components.
It improves the robustness of the adversarial sample image in the color space and avoids failure problems in the physical domain caused by factors such as lighting, materials, and printing equipment.
Smart Images

Figure CN115131581B
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of image security technology, and in particular relates to a method and system for generating adversarial sample images based on color space components. Background Art
[0002] Adversarial sample generation refers to adversarial noise generation technology for intelligent models. It artificially adds adversarial noise to normal input samples, including digital and physical domains, to make the output results of intelligent models erroneous. In security-related fields such as face recognition, unmanned driving, and intelligent tracking, adversarial samples play an important role in evaluating the security of intelligent models. At the same time, they also pose a great threat to unreviewed intelligent models.
[0003] The existing adversarial sample generation methods for target detection algorithms only consider the difference in the values of adversarial samples on the display and after printing, and reduce the pixel value deviation between digital display and physical printing by adding the difference in the conversion of a single pixel in RGB space and CMYK space to the loss function. However, this method still lacks consideration of the environment, that is, changes in lighting and differences in imaging devices will also cause the printed adversarial samples to fail at different times or when the target algorithm is equipped with different devices. The reason is that the traditional adversarial sample generation method does not take into account the robustness of adversarial samples in the process of changes in color space components. Summary of the invention
[0004] One of the objectives of the present invention is to provide an adversarial sample image generation method based on color space components, which can ensure the robustness of the adversarial sample image during the change of color space components.
[0005] A second object of the present invention is to provide an adversarial sample image generation system based on color space components.
[0006] In order to achieve one of the above purposes, the present invention adopts the following technical solution:
[0007] A method for generating an adversarial sample image based on a color space component, the method comprising:
[0008] Step S1, determining a pixel block at a position to be confronted in the image to be confronted;
[0009] Step S2, setting an anti-disturbance block having the same color space component and the same size as the pixel block at the position;
[0010] Each bit value on the adversarial perturbation block is between 0 and 1;
[0011] Step S3, sampling the adversarial perturbation block in the color space to form a plurality of adversarial sample images;
[0012] Step S4: input the multiple adversarial sample images into the target detection model to perform target prediction, and obtain a prediction value corresponding to each adversarial sample image;
[0013] Step S5: performing iterative optimization processing on the adversarial sample images according to the prediction values corresponding to the multiple adversarial sample images.
[0014] Furthermore, in the step S1, the specific process of determining the pixel block at the position to be confronted in the image to be confronted includes:
[0015] Step S11, obtaining the image to be countered;
[0016] Step S12: performing target object detection on the image to be confronted to obtain a target area to be confronted;
[0017] Step S13: Select the position pixel block to be confronted from the target area to be confronted.
[0018] Furthermore, in step S3, the process of forming the plurality of adversarial sample images includes:
[0019] Step S31, randomly changing each value of the anti-disturbance block within a preset range of each component of the color space to form a plurality of anti-disturbance pixel blocks;
[0020] Step S32: Use the pixel values of each pixel point on each adversarial perturbation pixel block to replace the pixel values of the pixel points corresponding to the position pixel block, so as to obtain adversarial sample images corresponding to each of the multiple adversarial perturbation pixel blocks.
[0021] Furthermore, in step S4, the specific implementation process of the target prediction includes:
[0022] Step S41: performing target object detection on each adversarial sample image to obtain a target object region on the adversarial sample image;
[0023] Step S42: performing convolution processing, full connection layer transformation and SoftMax function calculation on the target object area in sequence to obtain a prediction value corresponding to the adversarial sample image.
[0024] Furthermore, in step S5, the specific implementation process of iterative optimization of the anti-disturbance block includes:
[0025] Step S51, setting a first threshold for correct target object recognition;
[0026] Step S52: Calculate the difference between the first threshold and each predicted value, and use the difference as the loss value of the objective function of the corresponding adversarial sample image;
[0027] Step S53, determining whether the loss values of the objective functions of the adversarial sample images are all greater than the second threshold value, if so, outputting the adversarial sample images, and ending; if not, proceeding to step S54;
[0028] Step S54: Calculate the gradient corresponding to each adversarial sample image by using the chain rule according to the loss value of the objective function of each adversarial sample image;
[0029] Step S55, calculating the mean of the gradients corresponding to each adversarial sample image;
[0030] Step S56, subtract the mean value from each bit value of the anti-disturbance block and assign the result to the anti-disturbance block, and return to step S3.
[0031] In order to achieve the second objective above, the present invention adopts the following technical solution:
[0032] A system for generating adversarial sample images based on color space components, the system comprising:
[0033] A determination module is configured to: determine a pixel block at a position to be confronted in the image to be confronted;
[0034] A setting module is configured to: set an adversarial disturbance block having the same color space component and the same size as the position pixel block;
[0035] Each bit value on the adversarial perturbation block is between 0 and 1;
[0036] A forming module is configured to: sample the adversarial perturbation block in the color space to form a plurality of adversarial sample images;
[0037] A target prediction module is configured to: input the multiple adversarial sample images into the target detection model to perform target prediction, and obtain a prediction value corresponding to each adversarial sample image;
[0038] The iterative optimization processing module is configured to: perform iterative optimization processing on the adversarial sample images according to the prediction values corresponding to the multiple adversarial sample images.
[0039] Furthermore, the determination module includes:
[0040] The acquisition submodule is configured to: acquire the image to be confronted;
[0041] The first target object detection submodule is configured to: perform target object detection on the image to be antagonized to obtain a target area to be antagonized;
[0042] The selection submodule is configured to: select the position pixel block to be confronted from the target area to be confronted.
[0043] Furthermore, the forming module includes:
[0044] The formation submodule is configured to: randomly change each value of the anti-disturbance block within a preset range of each component of the color space to form a plurality of anti-disturbance pixel blocks;
[0045] The replacement submodule is configured to: use the pixel values of each pixel point on each adversarial perturbation pixel block to replace the pixel values of the pixel points corresponding to the position pixel block, so as to obtain the adversarial sample images corresponding to each of the multiple adversarial perturbation pixel blocks.
[0046] Furthermore, the target prediction module includes:
[0047] The second target object detection submodule is configured to: perform target object detection on each adversarial sample image to obtain a target object region on the adversarial sample image;
[0048] The processing submodule is configured to: perform convolution processing, full connection layer transformation and SoftMax function calculation on the target object area in sequence to obtain a prediction value corresponding to the adversarial sample image.
[0049] Furthermore, the iterative optimization processing module includes:
[0050] The setting submodule is configured to: set a first threshold value for correct target object recognition;
[0051] A first calculation submodule is configured to: calculate the difference between the first threshold and each predicted value, so as to use the difference as the loss value of the objective function of the corresponding adversarial sample image;
[0052] The judgment submodule is configured to: judge whether the loss value of the objective function of each adversarial sample image is greater than a second threshold value, if so, output the adversarial sample image, and end; if not, give the loss value of the objective function of each adversarial sample image to the second calculation submodule;
[0053] The second calculation submodule is configured to: calculate the gradient corresponding to each adversarial sample image by using the chain rule according to the loss value of the objective function of each adversarial sample image;
[0054] A third calculation submodule is configured to: calculate the mean of the gradients corresponding to each adversarial sample image;
[0055] The assigning submodule is configured to assign each bit value of the adversarial disturbance block minus the mean value to the adversarial disturbance block, and to give the adversarial disturbance block to the forming module.
[0056] In summary, the solution proposed by the present invention has the following technical effects:
[0057] The present invention determines the position pixel block to be confronted in the image to be confronted, sets the adversarial perturbation block, and samples the adversarial perturbation block in the color space to form multiple adversarial sample images; obtains the prediction value corresponding to each adversarial sample image through the target detection model; and iteratively optimizes the adversarial sample image according to the prediction values corresponding to the multiple adversarial sample images, thereby improving the range robustness of the adversarial sample image in the color space, avoiding the adversarial sample image only focusing on reducing the value difference of the pixel in the two color spaces, and solving the problem that the adversarial samples generated in the digital domain are invalid in the physical domain due to factors such as lighting, materials, and printing equipment. BRIEF DESCRIPTION OF THE DRAWINGS
[0058] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0059] Figure 1 It is a schematic diagram of the process of the adversarial sample image generation method based on color space components of the present invention;
[0060] Figure 2 Schematic diagram of the process of generating adversarial sample images based on RGB color space components according to an embodiment. DETAILED DESCRIPTION
[0061] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0062] This embodiment provides a method for generating adversarial sample images based on color space components. Figure 1 , the adversarial sample image generation method includes:
[0063] Step S1: Determine a pixel block at a position to be confronted in an image to be confronted.
[0064] The standard size of the image to be antagonized in this embodiment is W*H*C, where W, H and C are the width, height and number of components of the color space of the image to be antagonized. The components of the color space of YOLOv5 are R, G and B, and the number of components is 3. When the image to be antagonized is an RGB image, the number of components of the color space is 3.
[0065] In this embodiment, the position pixel block has the same number of components as the color space of the image to be antagonized. The width and height of the position pixel block are generally 1 / 10 of the width and height of the image to be antagonized. Figure 2 The position pixel block in is the abdomen of the target person. When the size of the image to be confronted is 800*600*3, the size of the position pixel block may be 8*6*3. In this embodiment, the specific process of determining the position pixel block to be confronted in the image to be confronted includes:
[0066] Step S11, obtaining the image to be countered;
[0067] Step S12: performing target object detection on the image to be confronted to obtain a target area to be confronted;
[0068] Step S13: Select the position pixel block to be confronted from the target area to be confronted.
[0069] Step S2: setting an adversarial disturbance block having the same color space component and the same size as the position pixel block.
[0070] The anti-disturbance block (such as Figure 2 Each bit value on the adversarial noise P in is between 0 and 1. When the size of the position pixel block is 8*6*3, the size of the adversarial perturbation block is also 8*6*3.
[0071] Step S3: sampling the adversarial perturbation block in the color space to form a plurality of adversarial sample images.
[0072] In this embodiment, the process of forming multiple adversarial sample images includes:
[0073] Step S31, randomly changing each value of the anti-disturbance block within a preset range of each component of the color space to form a plurality of anti-disturbance pixel blocks;
[0074] Taking the RGB color space as an example, the adversarial perturbation block P is mapped to a pixel block in the RGB space, that is, each bit value of the adversarial perturbation block P is multiplied by 255 and rounded down to obtain an 8*6*3 pixel matrix X P , pixel matrix X P Each bit value is between (0, 255).
[0075] In determining the pixel matrix X P Then, take the threshold d as the radius and draw R h*w*c A high-dimensional sphere in the space and randomly samples a new pixel matrix in this sphere, which is the adversarial perturbation pixel block X Pi ,in, i =1, 2, …, b , b To counter the number of perturbed pixel blocks, b Usually 16 or 64, refer to Figure 2 .
[0076] Step S32: Use the pixel values of each pixel point on each adversarial perturbation pixel block to replace the pixel value of the pixel point corresponding to the position pixel block, and obtain the adversarial sample image Xˊ corresponding to each of the plurality of adversarial perturbation pixel blocks. Pi .
[0077] Take a person picture as an example, by transforming the adversarial perturbation pixel block X Pi The pixel values of the target person’s abdomen (i.e., the position pixel block) in the adversarial image are directly replaced by the pixel values of the target person’s abdomen (i.e., the position pixel block) to obtain the adversarial sample image Xˊ Pi ,refer to Figure 2 .
[0078] Step S4: input the multiple adversarial sample images into the target detection model to perform target prediction, and obtain a prediction value corresponding to each adversarial sample image.
[0079] The target detection model in this embodiment includes two types of models, YOLO and Fast RCNN. The target detection model first selects the target, that is, identifies the target object area on the adversarial sample image, and then performs convolution processing on the target object area. After the fully connected layer transformation, the target features are extracted, and finally the classifier is used to combine and calculate the extracted target features to obtain the probability value of the target belonging to a certain category, which can also be called the model's prediction value of the target in a certain category. The specific implementation process of target prediction includes:
[0080] Step S41: performing target object detection on each adversarial sample image to obtain a target object region on the adversarial sample image;
[0081] Step S42: performing convolution processing, full connection layer transformation and SoftMax function calculation on the target object area in sequence to obtain a prediction value corresponding to the adversarial sample image.
[0082] Taking the above-mentioned target person detection as an example, the target detection model gives the probability value of the target person being classified as a "person", that is, the prediction value.
[0083] Step S5: performing iterative optimization processing on the adversarial sample image according to the prediction value corresponding to the adversarial sample image.
[0084] In step S5, the specific implementation process of iterative optimization of the anti-disturbance block includes:
[0085] Step S51, setting a first threshold for correct target object recognition;
[0086] Step S52: Calculate the difference between the first threshold and each predicted value, and use the difference as the loss value of the objective function of the corresponding adversarial sample image;
[0087] Because the goal of adversarial sample images is to make the model predict incorrectly, the objective function is to minimize the model's prediction value for the person in the class of the person, for example, to make it lower than a certain threshold of 0.3, so that the loss value can be calculated by subtracting the predicted value from the threshold.
[0088] Step S53, determining whether the loss values of the objective functions of the adversarial sample images are all greater than the second threshold value, if so, outputting the adversarial sample images, and ending; if not, proceeding to step S54;
[0089] Step S54: Calculate the gradient corresponding to each adversarial sample image by using the chain rule according to the loss value of the objective function of each adversarial sample image;
[0090] Step S55, calculating the mean of the gradients corresponding to each adversarial sample image;
[0091] Step S56, subtract the mean value from each bit value of the anti-disturbance block and assign the result to the anti-disturbance block, and return to step S3.
[0092] This embodiment determines the pixel block at the position to be confronted in the image to be confronted, sets the adversarial perturbation block, and samples the adversarial perturbation block in the color space to form multiple adversarial sample images; obtains the prediction value corresponding to each adversarial sample image through the target detection model; and iteratively optimizes the adversarial sample image according to the prediction values corresponding to the multiple adversarial sample images, thereby improving the range robustness of the adversarial sample image in the color space, avoiding the adversarial sample image only focusing on reducing the value difference of the pixel in the two color spaces, and solving the problem that the adversarial samples generated in the digital domain are invalid in the physical domain due to factors such as lighting, materials, and printing equipment.
[0093] Another embodiment provides an adversarial sample image generation system based on color space components, the adversarial sample image generation system comprising:
[0094] The determination module is configured to: determine the position pixel block to be confronted in the image to be confronted. The determination module includes:
[0095] The acquisition submodule is configured to: acquire the image to be confronted;
[0096] The first target object detection submodule is configured to: perform target object detection on the image to be antagonized to obtain a target area to be antagonized;
[0097] The selection submodule is configured to: select the position pixel block to be confronted from the target area to be confronted.
[0098] A setting module is configured to: set an adversarial disturbance block having the same color space component and the same size as the position pixel block;
[0099] Each bit value on the adversarial perturbation block is between 0 and 1;
[0100] The forming module is configured to: sample the adversarial perturbation block in the color space to form a plurality of adversarial sample images. The forming module includes:
[0101] The formation submodule is configured to: randomly change each value of the anti-disturbance block within a preset range of each component of the color space to form a plurality of anti-disturbance pixel blocks;
[0102] The replacement submodule is configured to: use the pixel values of each pixel point on each adversarial perturbation pixel block to replace the pixel values of the pixel points corresponding to the position pixel block, so as to obtain the adversarial sample images corresponding to each of the multiple adversarial perturbation pixel blocks.
[0103] The target prediction module is configured to: input the multiple adversarial sample images into the target detection model to perform target prediction, and obtain the prediction value corresponding to each adversarial sample image. The target prediction module includes:
[0104] The second target object detection submodule is configured to: perform target object detection on each adversarial sample image to obtain a target object region on the adversarial sample image;
[0105] The processing submodule is configured to: perform convolution processing, full connection layer transformation and SoftMax function calculation on the target object area in sequence to obtain a prediction value corresponding to the adversarial sample image.
[0106] The iterative optimization processing module is configured to: perform iterative optimization processing on the adversarial sample image according to the prediction value corresponding to the adversarial sample image. The iterative optimization processing module includes:
[0107] The setting submodule is configured to: set a first threshold value for correct target object recognition;
[0108] A first calculation submodule is configured to: calculate the difference between the first threshold and each predicted value, so as to use the difference as the loss value of the objective function of the corresponding adversarial sample image;
[0109] The judgment submodule is configured to: judge whether the loss value of the objective function of each adversarial sample image is greater than a second threshold value, if so, output the adversarial sample image, and end; if not, give the loss value of the objective function of each adversarial sample image to the second calculation submodule;
[0110] The second calculation submodule is configured to: calculate the gradient corresponding to each adversarial sample image by using the chain rule according to the loss value of the objective function of each adversarial sample image;
[0111] A third calculation submodule is configured to: calculate the mean of the gradients corresponding to each adversarial sample image;
[0112] The assigning submodule is configured to assign each bit value of the adversarial disturbance block minus the mean value to the adversarial disturbance block, and to give the adversarial disturbance block to the forming module.
[0113] Please note that the technical features of the above embodiments can be combined arbitrarily. In order to make the description concise, all possible combinations of the technical features in the above embodiments are not described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification. The above embodiments only express several implementation methods of the present application, and their descriptions are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that for ordinary technicians in this field, without departing from the concept of the present application, several variations and improvements can be made, which all belong to the scope of protection of the present application. Therefore, the scope of protection of the patent in this application shall be based on the attached claims.
Claims
1. A method for generating adversarial sample images based on color space components, It is characterized in that The adversarial sample image generation method comprises: Step S1, determining a pixel block at a position to be confronted in the image to be confronted; In the step S1, the specific process of determining the pixel block at the position to be confronted in the image to be confronted includes: Step S11, obtaining the image to be countered; Step S12: performing target object detection on the image to be confronted to obtain a target area to be confronted; Step S13, selecting the position pixel block to be confronted from the target area to be confronted; Step S2, setting an anti-disturbance block having the same color space component and the same size as the pixel block at the position; Each bit value on the adversarial perturbation block is between 0 and 1; Step S3, sampling the adversarial perturbation block in the color space to form a plurality of adversarial sample images; In step S3, the process of forming the plurality of adversarial sample images includes: Step S31, randomly changing each value of the anti-disturbance block within a preset range of each component of the color space to form a plurality of anti-disturbance pixel blocks; Step S32: using the pixel values of each pixel point on each adversarial perturbation pixel block to replace the pixel value of the pixel point corresponding to the position pixel block, to obtain adversarial sample images corresponding to each of the plurality of adversarial perturbation pixel blocks; Step S4: input the multiple adversarial sample images into the target detection model to perform target prediction, and obtain a prediction value corresponding to each adversarial sample image; Step S5, performing iterative optimization processing on the adversarial sample images according to the prediction values corresponding to the multiple adversarial sample images; In step S5, the specific implementation process of iterative optimization of the anti-disturbance block includes: Step S51, setting a first threshold for correct target object recognition; Step S52: Calculate the difference between the first threshold and each predicted value, and use the difference as the loss value of the objective function of the corresponding adversarial sample image; Step S53, determining whether the loss value of the objective function of each adversarial sample image is greater than the second threshold value, if so, outputting the adversarial sample image, and ending; if not, proceeding to step S54; Step S54: Calculate the gradient corresponding to each adversarial sample image by using the chain rule according to the loss value of the objective function of each adversarial sample image; Step S55, calculating the mean of the gradients corresponding to each adversarial sample image; Step S56, subtract the mean value from each bit value of the anti-disturbance block and assign the result to the anti-disturbance block, and return to step S3.
2. The adversarial sample image generation method according to claim 1, It is characterized in that In step S4, the specific implementation process of the target prediction includes: Step S41: performing target object detection on each adversarial sample image to obtain a target object region on the adversarial sample image; Step S42: performing convolution processing, full connection layer transformation and SoftMax function calculation on the target object area in sequence to obtain a prediction value corresponding to the adversarial sample image.
3. A system for generating adversarial sample images based on color space components, It is characterized in that The adversarial sample image generation system comprises: A determination module is configured to: determine a pixel block at a position to be confronted in the image to be confronted; The determination module comprises: The acquisition submodule is configured to: acquire the image to be confronted; The first target object detection submodule is configured to: perform target object detection on the image to be antagonized to obtain a target area to be antagonized; The selection submodule is configured to: select the position pixel block to be confronted from the target area to be confronted; A setting module is configured to: set an adversarial disturbance block having the same color space component and the same size as the position pixel block; Each bit value on the adversarial perturbation block is between 0 and 1; A forming module is configured to: sample the adversarial perturbation block in the color space to form a plurality of adversarial sample images; The formation module comprises: The formation submodule is configured to: randomly change each value of the anti-disturbance block within a preset range of each component of the color space to form a plurality of anti-disturbance pixel blocks; The replacement submodule is configured to: use the pixel values of each pixel point on each adversarial perturbation pixel block to replace the pixel value of the pixel point corresponding to the position pixel block, so as to obtain the adversarial sample images corresponding to each of the plurality of adversarial perturbation pixel blocks; A target prediction module is configured to: input the multiple adversarial sample images into the target detection model to perform target prediction, and obtain a prediction value corresponding to each adversarial sample image; An iterative optimization processing module is configured to: perform iterative optimization processing on the adversarial sample images according to the prediction values corresponding to the multiple adversarial sample images; The iterative optimization processing module includes: The setting submodule is configured to: set a first threshold value for correct target object recognition; A first calculation submodule is configured to: calculate the difference between the first threshold and each predicted value, so as to use the difference as the loss value of the objective function of the corresponding adversarial sample image; The judgment submodule is configured to: judge whether the loss value of the objective function of each adversarial sample image is greater than a second threshold value, if so, output the adversarial sample image, and end; if not, give the loss value of the objective function of each adversarial sample image to the second calculation submodule; The second calculation submodule is configured to: calculate the gradient corresponding to each adversarial sample image by using the chain rule according to the loss value of the objective function of each adversarial sample image; A third calculation submodule is configured to: calculate the mean of the gradients corresponding to each adversarial sample image; The assigning submodule is configured to assign each bit value of the adversarial disturbance block minus the mean value to the adversarial disturbance block, and to give the adversarial disturbance block to the forming module.
4. The adversarial sample image generation system according to claim 3, It is characterized in that The target prediction module comprises: The second target object detection submodule is configured to: perform target object detection on each of the adversarial sample images to obtain a target object region on the adversarial sample image; The processing submodule is configured to: perform convolution processing, full connection layer transformation and SoftMax function calculation on the target object area in sequence to obtain a prediction value corresponding to the adversarial sample image.
Citation Information
Patent Citations
Adversarial sample generation method for face recognition system in physical domain
CN110991299A
Adversarial sample generation method and system for image data
CN110991549A
Improved adversarial sample generation method based on traffic sign target detector
CN112818783A
Privacy protection method for generating adversarial samples based on projection gradient descent method
CN113515774A
Adversarial sample generation method and device, storage medium and electronic equipment
CN113537267A
