Target detection adversarial sample generation method based on diffusion model and LoRA fine-tuning
By using a diffusion model and LoRA fine-tuning method, the problems of low efficiency, reliance on a single model, and insufficient transferability in existing object detection adversarial example generation are solved. This method achieves efficient and visually high-quality adversarial example generation, which is applicable to multi-class object detection scenarios.
Patent Information
- Application Number
- CN202611330900.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-31
- Publication Date
- 2026-11-24
AI Technical Summary
Existing methods for generating adversarial examples for object detection are inefficient, rely on a single detection model, lack black-box transfer capabilities, result in degraded visual quality of generated images, and struggle to learn general mapping relationships.
We employ a diffusion model and LoRA fine-tuning method. By pre-training a VAE encoding network, we map images to the latent space. We then use partial DDIM inversion and LoRA parameters to adjust the diffusion model to generate adversarial images. Finally, we optimize the LoRA parameters using class-independent detection confidence suppression loss and CLIP feature perturbation loss to achieve adversarial example generation.
It improves the efficiency of adversarial example generation, enhances black-box transfer capability, maintains the visual quality of generated images, and reduces training costs, making it suitable for multi-class object detection scenarios.
Smart Images

Figure CN123160995A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of embodied intelligent security, deep learning model adversarial security, and computer vision target detection technology, especially a target detection adversarial example generation method based on diffusion model and LoRA fine-tuning. It can be applied to scenarios such as autonomous driving perception systems, intelligent monitoring systems, robot vision systems, and deep learning model security testing, and is used to detect and improve the robustness of target detection models to abnormal inputs. Background Technology
[0002] With the development of deep learning technology, neural network-based object detection models have been widely applied in fields such as autonomous driving, intelligent transportation, video surveillance, and robot perception. Currently, mainstream object detection models include two-stage detection models, single-stage detection models, and Transformer-based detection models, such as Faster R-CNN, the YOLO series, and DETR.
[0003] However, numerous studies have found that deep neural networks have certain security vulnerabilities. When optimized subtle perturbations are added to the input image, the object detection model may exhibit anomalies such as missed object detection, misclassification, and location deviation, thereby affecting the reliability of practical application systems.
[0004] Existing adversarial example generation methods for object detection mainly employ image-level perturbation search based on gradient optimization. This involves continuously updating pixel-level perturbations for each input image through multiple rounds of forward and backward propagation, reducing the confidence score of the object detection model or generating erroneous detection results. For example, the Dense Adversarial Generation (DAG) method iteratively optimizes the loss corresponding to the object detector's output bounding box, gradually rendering the detection box ineffective; the Targeted Object Gradient (TOG) method optimizes the object detector's targetability response, reducing the probability of detecting real targets; and recently proposed methods such as LGP and AFOG further improve attack effectiveness from the perspectives of salient feature perturbation, candidate region optimization, and attention guidance. However, these methods essentially still rely on gradient iterative optimization processes for single images. During the testing phase, a large number of forward and backward computations of the network need to be repeatedly performed, resulting in low adversarial example generation efficiency and difficulty in meeting the requirements of real-time applications. Meanwhile, because the perturbation optimization process is highly dependent on the current input image and the proxy detection model, the generated attack patterns are prone to overfitting specific detector structures. When facing target detection models with different architectures (such as YOLO series, Faster R-CNN, DETR, etc.), the black-box transfer capability is significantly reduced. In addition, existing methods mainly seek local optimal perturbations within a single image space, making it difficult to learn the universal mapping relationship between natural image distribution and adversarial image distribution, resulting in difficulty in reusing attack knowledge. To improve generation efficiency, some studies have attempted to use generative methods, such as UEA, which uses GAN generators to generate adversarial images through a single forward propagation. However, such methods usually require training the generative network from scratch, making it difficult to fully utilize the existing natural image priors in large-scale pre-trained generative models. At the same time, it is difficult to balance image content adaptability, attack strength, and cross-model transfer capability. Therefore, existing technologies still lack a target detection adversarial example generation method that can fully utilize the knowledge of pre-trained generative models, avoid image-by-image gradient optimization in the testing phase, and simultaneously possess efficient generation capability and cross-detector transfer capability. Summary of the Invention
[0005] To overcome the shortcomings of the prior art, this invention provides a target detection adversarial example generation method based on diffusion model and LoRA fine-tuning, which solves the problems of low generation efficiency due to repeated optimization of a single image, heavy dependence on a single detection model, insufficient black-box transfer capability, and decreased visual quality of generated images in the existing target detection adversarial example generation process.
[0006] To achieve the above objectives, the present invention adopts the following technical solution, including: The adversarial example generation method for target detection based on diffusion model and LoRA fine-tuning includes the following steps: S1: Obtain a clean image, encode the clean image in the latent space using a pre-trained VAE encoding network, and map the pixel space image to a low-dimensional latent space to obtain the initial latent variables; S2: Perform partial DDIM inversion operation on the initial latent variables, and complete a finite number of noise addition steps through the frozen pre-trained diffusion model U-Net to obtain an intermediate noise state that preserves the original image structure and semantics; S3: Insert the LoRA parameter structure into the pre-trained diffusion model U-Net, freeze the original parameters of the pre-trained diffusion model U-Net, adjust the noise prediction direction of the diffusion model U-Net only through the trainable LoRA parameters, and learn the adversarial noise prediction offset corresponding to the target detection attack. S4: Starting with the intermediate noise state, the DDIM reverse denoising process is executed through the adjusted diffusion model U-Net to iteratively update the latent variables and obtain the adversarial latent variables; S5: Decode the adversarial latent variables through a pre-trained VAE decoding network to generate an adversarial image, and limit the visual difference between the adversarial image and the clean image through pixel perturbation constraints to obtain a constrained adversarial image; S6: During training, the generated adversarial images are input into the proxy target detector and CLIP visual encoder respectively. The class-independent detection confidence suppression loss and CLIP feature perturbation loss are calculated. A joint optimization loss function is constructed, and the LoRA parameters are iteratively optimized. The parameters of the proxy target detector, CLIP visual encoder, pre-trained diffusion model and pre-trained VAE are fixed. Only the LoRA parameters are updated by backpropagation to complete the training of the adversarial example generation model. S7: After training is complete, freeze the optimal LoRA parameters. For any clean input image, repeat steps S1-S5 to generate adversarial examples adapted to the object detection model.
[0007] Preferably, in step S2, the DDIM inversion operation uses a partial inversion method, rather than completely diffusing to a pure noise state. The noise addition process is represented as follows:
[0008] in, This represents the noise in the frozen pre-trained U-Net predictions; The parameters of the frozen pre-trained U-Net; Indicates the number of inversion steps; This is an intermediate noise state; This indicates DDIM inversion.
[0009] Preferably, in step S3, the noise prediction formula for U-Net after adding the LoRA parameter is:
[0010] in, This represents the conditional input for the diffusion model; The adversarial noise prediction offset is learned from the LoRA parameters; The raw noise prediction results of the frozen pre-trained U-Net output; The noise prediction results of the U-Net output after adding the LoRA parameter; Let be the noisy latent variable for the t-th inversion step.
[0011] Preferably, in step S4, starting with the intermediate noise state, the DDIM reverse denoising process performed using the adjusted diffusion model U-Net is represented as follows:
[0012] in, This indicates DDIM inverse denoising; Let be the denoising latent variable for the t-th inversion step; The noise prediction results of the U-Net output after adding the LoRA parameter; Inversion step Execute in reverse chronological order:
[0013] in, This represents the number of noise reduction steps.
[0014] Preferably, in step S5, the method for calculating the category-independent detection confidence suppression loss is as follows: The generated adversarial image Input proxy target detector Output:
[0015] Where j represents the j-th detection box output by the proxy target detector. Let J be the position coordinates of the j-th detection box. Let be the confidence score of the j-th detection box. Let j be the predicted category of the j-th detection box; For the position coordinates of each ground truth bounding box Select a set of candidate detection boxes that meet the conditions. :
[0016] in, Indicates intersection, union, and ratio. Indicates the intersection-union ratio threshold; Calculate the class-independent detection confidence suppression loss :
[0017] in, This represents the number of actual target bounding boxes.
[0018] Preferably, in step S5, the CLIP feature perturbation loss is calculated as follows: Original image and generated adversarial images Input CLIP visual encoder Output the corresponding visual encoding and Calculate the feature distance between the two in the visual semantic space. :
[0019] Calculate CLIP feature perturbation loss :
[0020] Joint loss function Includes class-independent detection confidence suppression loss CLIP feature perturbation loss The combined loss is ;in, This is the balance coefficient.
[0021] Preferably, the model architecture of the method includes a latent space coding module, a diffusion inversion module, a LoRA enhanced diffusion generation module, and an image reconstruction module; The latent space coding module is used to implement the mapping from image pixel space to latent space; The diffusion inversion module is used to generate a controllable intermediate noise state; The LoRA enhanced diffusion generation module is used to learn adversarial generation rules based on fine-tuned LoRA parameters; The image reconstruction module is used to restore latent variables to the image space and to impose perturbation constraints.
[0022] Preferably, the method is applied to autonomous driving perception systems, intelligent monitoring systems, robot vision systems, and deep learning model safety testing scenarios to detect and improve the robustness of target detection models to abnormal inputs.
[0023] The present invention also provides an electronic device, which includes a processor, a memory, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the target detection adversarial example generation method based on diffusion model and LoRA fine-tuning.
[0024] The present invention also provides a computer program product comprising a computer program that, when executed by a processor, implements the aforementioned method for generating adversarial examples for target detection based on diffusion model and LoRA fine-tuning.
[0025] The advantages of this invention are: (1) This invention proposes an adversarial distribution learning framework for target detectors based on a diffusion model, redefining the traditional problem of perturbation optimization for a single image as an adversarial distribution shift learning problem at the generator level. During the inference stage, gradient optimization is not required for each test image, and adversarial images with attack effects can be directly generated.
[0026] (2) This invention designs a class-independent detection confidence suppression loss function, which directly reduces the confidence of high-response candidate detection boxes near the real target region, thereby achieving the target disappearance attack, and is independent of the specific target category label. At the same time, a CLIP feature disruption loss is further introduced, which improves the black-box transfer capability of generated adversarial examples by expanding the difference between clean images and adversarial images in the general visual semantic feature space.
[0027] (3) Traditional methods require multiple rounds of gradient calculation for each image. After training, the present invention only requires one diffusion generation process to obtain the adversarial image for target detection, which greatly reduces the generation time and improves the efficiency of adversarial example generation.
[0028] (4) The present invention uses CLIP feature perturbation constraints to make the generated results independent of a single detector structure, thereby improving the transfer effect between different detection models and enhancing the transfer capability.
[0029] (5) This invention utilizes the natural image prior in the pre-trained diffusion model to maintain good visual naturalness in the generated results and improve the generation quality.
[0030] (6) The present invention uses LoRA parameter efficient fine-tuning, and only a small number of parameters need to be updated to complete the model adaptation, thereby reducing training costs.
[0031] (7) The present invention adopts a class-independent confidence suppression strategy, which does not require redesigning attack targets for different classes, and can be applied to multi-class target detection scenarios, thereby enhancing class adaptability.
[0032] (8) By Figure 1As shown, existing attack methods (image-level gradient optimization) repeatedly calculate gradients and optimize pixel-level perturbations for each input image, resulting in low generation efficiency and limited attack knowledge reuse capabilities. In contrast, the method of this invention, DASH (Generator-level Adversarial Distribution Learning), learns a reusable mapping relationship between natural image distributions and adversarial image distributions through a pre-trained diffusion network backbone and LoRA fine-tuning techniques. After training, adversarial images can be directly generated without gradient optimization for each image, significantly improving efficiency while maintaining image adaptive attack capabilities and black-box transfer capabilities. Attached Figure Description
[0033] Figure 1 This is a schematic diagram comparing existing attack methods with the method of this invention.
[0034] Figure 2 This is a flowchart of the method of the present invention. Detailed Implementation
[0035] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0036] Depend on Figure 2 As shown, the adversarial example generation method for target detection based on diffusion model and LoRA fine-tuning of this invention, given a clean image, first encodes it into the latent space and obtains an intermediate noisy state through partial DDIM inversion. Subsequently, a LoRA-injected U-Net performs an adversarial DDIM denoising process, where the pre-trained U-Net remains frozen, only updating the injected LoRA parameters. The decoded adversarial image is then processed... The projection constrains the perturbation magnitude, and training supervision is provided by two frozen modules: a surrogate detector provides a class-independent detection confidence suppression loss, and a CLIP visual encoder provides a CLIP feature perturbation loss. The weighted total loss is backpropagated only to the LoRA parameters, enabling the model to learn reusable adversarial distribution shifts while preserving pre-trained diffusion priors.
[0037] The adversarial example generation method for target detection based on diffusion model and LoRA fine-tuning provided by this invention includes a latent space coding module, a diffusion inversion module, a LoRA enhanced diffusion generation module, and an image reconstruction module. The components are connected through data transmission to jointly realize the generation of adversarial images (adversarial examples) against the target detection model.
[0038] The specific details of each part are shown below.
[0039] (1) Latent space coding module
[0040] The latent space coding module includes a pre-trained variational autoencoder (VAE) coding network. It is used to map a two-dimensional pixel space image to a low-dimensional latent space.
[0041] For input clean image The corresponding latent variables are obtained through the encoding network E:
[0042] in, This represents the initial representation of the image in the latent space, i.e., the initial latent variables.
[0043] This module reduces the image dimensionality, allowing the subsequent diffusion process to be performed in the latent space, thereby reducing computational overhead while preserving the image's structural and semantic information.
[0044] (2) Diffusion Inversion Module
[0045] The diffusion inversion module includes a frozen pre-trained diffusion model U-Net (noise prediction network) and a DDIM inversion unit.
[0046] This section connects to the latent space coding module and is used to process the initial latent variables. Gradually map to the intermediate noise state.
[0047] The DDIM inversion unit employs a partial inversion method, rather than completely diffusing to a pure noise state. Its inversion process is expressed as follows:
[0048] in, This represents the noise in the frozen pre-trained U-Net predictions; The parameters of the frozen pre-trained U-Net; Indicates the number of inversion steps; This is an intermediate noise state; This indicates DDIM inversion (with noise added).
[0049] In this embodiment, the inversion steps are set to 6 steps, so that the generation process can simultaneously retain the original image structure information and the adjustable latent space perturbation capability.
[0050] (3) LoRA Enhanced Diffusion Generation Module
[0051] The LoRA-enhanced diffusion generation module is built on the pre-trained diffusion model U-Net. It is used to adjust the noise prediction process of the diffusion model by introducing LoRA parameters, and to perform the DDIM reverse denoising process using the adjusted diffusion model, thereby generating adversarial latent variables with target detection attack effects.
[0052] This module inserts the LoRA parameter structure into the pre-trained diffusion model U-Net, optimizing only the LoRA parameters while keeping the original U-Net parameters frozen. This enables the adjusted diffusion model U-Net to learn noise prediction biases for target detection attack tasks.
[0053] Its noise prediction process is expressed as follows:
[0054] in, This represents the conditional input for the diffusion model; The adversarial noise prediction offset is learned from the LoRA parameters; The raw noise prediction results of the frozen pre-trained U-Net output; The noise prediction results output by the adjusted diffusion model U-Net (U-Net with LoRA parameters added); Let be the noisy latent variable for the t-th inversion step; After completing the noise prediction adjustment, this module obtains the intermediate noise state from the diffusion inversion module. Initially, the DDIM inverse denoising generation process is performed using the U-Net with LoRA parameters added:
[0055] in, This indicates DDIM inverse denoising; Let be the denoising latent variable for the t-th inversion step; The noise prediction results of the U-Net output after adding the LoRA parameter; Time step (inversion step) Execute in reverse chronological order:
[0056] in, In this embodiment, the number of denoising steps is [number]. To obtain the final adversarial latent variables .
[0057] (4) Image reconstruction module
[0058] The image reconstruction module includes a pre-trained VAE decoding network. This is used to transform the adversarial latent variables output by the LoRA enhanced diffusion generation module back into the image space.
[0059] Its input is connected to the LoRA enhanced diffusion generation module, and its output generates the final adversarial image. :
[0060] At the same time, to limit the generated adversarial images With the original image To address the visual differences between the images, the image reconstruction module sets perturbation constraint units to ensure that:
[0061] in, As the perturbation threshold, in this embodiment ; express projection.
[0062] After completing the construction of the above modules, the LoRA parameters are updated through the training and optimization process, enabling the diffusion model to generate adversarial examples for target detection.
[0063] During training, the adversarial image output by the image reconstruction module is used. Input the proxy target detector and CLIP visual encoder respectively, and construct a joint optimization target based on their outputs.
[0064] The surrogate target detector is used to provide detection response constraints. By reducing the confidence of candidate detection boxes near the real target region, it causes the target detection model to produce a false negative effect.
[0065] For adversarial images Proxy target detector Output:
[0066] Where j represents the j-th detection box output by the proxy target detector. Let J be the position coordinates of the j-th detection box. Let be the confidence score of the j-th detection box. Let be the predicted category of the j-th detection box.
[0067] For the position coordinates of each ground truth bounding box Select a set of candidate detection boxes that meet the conditions. :
[0068] in, Indicates intersection, union, and ratio. Indicates the intersection-union ratio threshold; Constructing class-independent detection confidence suppression loss :
[0069] in, This represents the number of actual target bounding boxes.
[0070] Suppressing loss by minimizing detection confidence. Reduce the detection response in the target area.
[0071] At the same time, the original image and generated adversarial images Input CLIP visual encoder Output the corresponding visual encoding and :
[0072] Calculate the feature distance between the two in the visual semantic space. :
[0073] Construct CLIP feature perturbation loss :
[0074] The joint optimization objective is finally obtained. for:
[0075] in, This is the balance coefficient.
[0076] Update LoRA parameters via backpropagation This enables the diffusion model (adversarial example generation model) to learn adversarial noise prediction biases for target detection attack tasks.
[0077] After training, the optimized LoRA parameters are frozen. During the inference phase, only the image to be processed needs to be input. Through latent space coding, partial DDIM inversion, LoRA enhanced diffusion generation, and image reconstruction, adversarial images for object detection can be generated quickly.
[0078] The present invention provides a target detection adversarial example generation method based on diffusion model and LoRA fine-tuning. This method uses a pre-trained latent space diffusion model as the generation basis, obtains controllable latent variables through partial DDIM inversion, and uses LoRA fine-tuning to learn the detection attack direction, so that the generation model can quickly generate adversarial images with target detection attack effects.
[0079] The method of the present invention includes the following steps.
[0080] Step S1: Acquire the input image and perform latent space encoding.
[0081] Obtain a clean image x to be attacked and input it into a pre-trained VAE encoding network E. The encoder maps the image from pixel space to latent space to obtain the initial latent variables. :
[0082] in, For input natural images, This corresponds to the latent space representation.
[0083] Step S1 uses the latent space representation to replace the original pixel space for subsequent diffusion processing to reduce computational cost.
[0084] Step S2: Perform partial DDIM inversion to obtain intermediate noise state.
[0085] The initial latent variables obtained in step S1 Input diffusion inversion module.
[0086] Using a frozen pre-trained U-Net (noise prediction network), the DDIM inversion method is used to... Mapping to intermediate noise state :
[0087] in, This represents the noise in the frozen pre-trained U-Net predictions; The parameters of the frozen pre-trained U-Net; Indicates the number of inversion steps; This is an intermediate noise state; This indicates DDIM inversion (with noise). In this embodiment, the number of inversion steps is set to 6, so that the generation process simultaneously preserves the original image structure information and adjustable latent space perturbation capability.
[0088] Compared to the complete diffusion process, step S2 only performs partial inversion, allowing latent variables to retain the target structure and semantic information in the original image, while providing space for subsequent attack generation.
[0089] Step S3: Adjust the direction of the spread noise prediction using the LoRA parameter structure.
[0090] Add the LoRA parameter structure to the diffusion model U-Net.
[0091] Keep the original U-Net parameters frozen and train only the LoRA parameters. .
[0092] The adjusted diffusion model U-Net learns the noise prediction offset corresponding to the attack direction of the target detection:
[0093] in, Indicates conditional input; This represents the adversarial noise prediction offset learned from the LoRA parameters; The raw noise prediction results of the frozen pre-trained U-Net output; The noise prediction results output by the adjusted diffusion model U-Net (U-Net with LoRA parameters added); Let be the noisy latent variable for the t-th inversion step.
[0094] Through step S3, the diffusion model is transformed from a general image generation model into an adversarial image generation model oriented towards target detection attacks.
[0095] Step S4: Perform backdiffusion to generate adversarial latent variables.
[0096] Starting from the intermediate noise state obtained in step S2, DDIM inverse denoising is performed using the U-Net with LoRA parameters added.
[0097] Update the latent variable formula at each step:
[0098] go through After the generation process, the final adversarial latent variables are obtained. .
[0099] Step S5: Decode latent variables to generate adversarial images.
[0100] Input the adversarial latent variables obtained in step S4 into the VAE decoding network D:
[0101] Obtain the initially generated adversarial image .
[0102] Then, perturbation constraints are applied:
[0103] Limit the maximum range of pixel variation between the generated image and the original image to maintain visual consistency in the generated result.
[0104] Step S6: Calculate the attack loss and optimize the LoRA parameters.
[0105] The generated adversarial image is simultaneously fed into the proxy target detector and the CLIP visual encoder.
[0106] (1) Proxy target detector.
[0107] The surrogate target detector outputs the prediction results:
[0108] Where j represents the j-th detection box output by the proxy target detector. Let J be the position coordinates of the j-th detection box. Let be the confidence score of the j-th detection box. Let j be the predicted category of the j-th detection box; For the position coordinates of each ground truth bounding box Select a set of candidate detection boxes that meet the conditions. :
[0109] in, Indicates intersection, union, and ratio. Indicates the intersection-union ratio threshold; Constructing class-independent detection confidence suppression loss :
[0110] in, This represents the number of actual target bounding boxes.
[0111] Suppressing loss by minimizing detection confidence. Reduce the detection response in the target area.
[0112] (2) CLIP visual encoder.
[0113] Original image and generated adversarial images Input CLIP visual encoder Output the corresponding visual encoding and :
[0114] Calculate the cosine distance, which is the feature distance between the two in the visual semantic space. :
[0115] Construct CLIP feature perturbation loss :
[0116] Final joint optimization objective for:
[0117] in, This is the balance coefficient.
[0118] Update LoRA parameters via backpropagation This enables the diffusion model to learn adversarial noise prediction shifts for target detection attack tasks.
[0119] Step S7: Inference phase generates adversarial examples for target detection.
[0120] After LoRA parameter training is completed, for a new input image, only VAE encoding, partial DDIM inversion, LoRA enhanced diffusion generation, and VAE decoding are required to obtain the adversarial image for object detection.
[0121] It eliminates the need to perform gradient search for each test image, thus improving the efficiency of adversarial example generation. At the same time, it leverages diffusion model priors to enhance the quality of generated images and cross-detector transferability.
[0122] Depend on Figure 1 As shown, existing attack methods (image-level gradient optimization) repeatedly calculate gradients and optimize pixel-level perturbations for each input image, resulting in low generation efficiency and limited ability to reuse attack knowledge. In contrast, the method of this invention (generator-level adversarial distribution learning) learns a reusable mapping relationship between natural image distribution and adversarial image distribution through a pre-trained diffusion network backbone and LoRA fine-tuning technique. After training, adversarial images can be generated directly without gradient optimization for each image, significantly improving efficiency while maintaining image adaptive attack capability and black-box transfer capability.
[0123] Compared with the prior art, the present invention has the following advantages: (1) Improve the efficiency of adversarial example generation: Traditional methods require multiple rounds of gradient calculation for each image. After training, this invention only requires one diffusion generation process to obtain the adversarial image for target detection, which greatly reduces the generation time.
[0124] (2) Improved transferability: By using CLIP feature perturbation constraints, the generated results are not dependent on a single detector structure, thus improving the transfer effect between different detection models.
[0125] (3) Improve generation quality: Utilize the natural image prior in the pre-trained diffusion model to maintain good visual naturalness in the generation results.
[0126] (4) Reduce training costs: LoRA parameters are used for efficient fine-tuning, and model adaptation can be completed by updating only a small number of parameters.
[0127] (5) Enhanced category adaptability: The class-independent confidence suppression strategy is adopted, which does not require redesigning attack targets for different categories and can be applied to multi-class target detection scenarios.
[0128] This embodiment selects four representative target detection attack methods—DAG, UEA, OSFD, and AFOG—as baseline methods and conducts comparative experiments with the proposed DASH (Generator-Level Adversarial Distributed Learning) method based on the VOC2012 dataset. Attack success rate (ASR) and inference time per image are used as evaluation metrics to measure the attack performance and inference efficiency of different methods. The experimental results are shown in Tables 1 and 2, respectively.
[0129] Table 1 presents the ASR comparison results of various methods on nine object detection models (YOLOv5, YOLOv8, YOLOv10s, YOLO11s, YOLO26s, F-RCNN, SSD, DETR, and TOOD). As shown in Table 1, the DASH method proposed in this invention achieves the highest attack success rate on eight detection models (YOLOv5, YOLOv8, YOLOv10s, YOLO11s, YOLO26s, SSD, DETR, and TOOD), and ranks second in attack success rate on Faster R-CNN (F-RCNN). Furthermore, the average ASR of this method on the nine detection models reaches 66.02%, higher than DAG, UEA, OSFD, and AFOG methods, indicating that the method of this invention has strong attack capability and black-box transferability against object detection models with different structures and detection mechanisms.
[0130] Table 1. Evaluation of the attack effectiveness on the Voc2012 dataset using the Attack Success Rate (ASR) metric.
[0131] Table 2 presents the comparison results of inference efficiency for each method, with the time required to complete a single image attack (single image inference time) used as the evaluation index; a smaller value indicates higher inference efficiency. Experimental results show that the proposed DASH (Generator-Level Adversarial Distributed Learning) method has a single image inference time of 0.75s, ranking second among all compared methods, second only to the UEA method's 0.17s. Although UEA has a shorter inference time, as shown in Table 1, its average ASR on the nine detection models is only 24.12%, and its attack success rate on non-proxy detection models is relatively low, indicating limited black-box transfer attack capabilities. In contrast, the method of this invention maintains high inference efficiency while increasing the average ASR to 66.02%, achieving a better overall balance between attack performance and inference efficiency, thus possessing stronger practical application value.
[0132] Table 2 Comparison of Inference Time
[0133] The above are merely preferred embodiments of the present invention and are not intended to limit the scope of the present invention. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. A target detection adversarial sample generation method based on a diffusion model and LoRA fine-tuning, characterized in that, Includes the following steps: S1: Obtain a clean image, encode the clean image in the latent space using a pre-trained VAE encoding network, and map the pixel space image to a low-dimensional latent space to obtain the initial latent variables; S2: Perform partial DDIM inversion operation on the initial latent variables, and complete a finite number of noise addition steps through the frozen pre-trained diffusion model U-Net to obtain an intermediate noise state that preserves the original image structure and semantics; S3: Insert the LoRA parameter structure into the pre-trained diffusion model U-Net, freeze the original parameters of the pre-trained diffusion model U-Net, adjust the noise prediction direction of the diffusion model U-Net only through the trainable LoRA parameters, and learn the adversarial noise prediction offset corresponding to the target detection attack. S4: Starting with the intermediate noise state, the DDIM reverse denoising process is executed through the adjusted diffusion model U-Net to iteratively update the latent variables and obtain the adversarial latent variables; S5: Decode the adversarial latent variables through a pre-trained VAE decoding network to generate an adversarial image, and limit the visual difference between the adversarial image and the clean image through pixel perturbation constraints to obtain a constrained adversarial image; S6: During training, the generated adversarial images are input into the proxy target detector and CLIP visual encoder respectively. The class-independent detection confidence suppression loss and CLIP feature perturbation loss are calculated. A joint optimization loss function is constructed, and the LoRA parameters are iteratively optimized. The parameters of the proxy target detector, CLIP visual encoder, pre-trained diffusion model and pre-trained VAE are fixed. Only the LoRA parameters are updated by backpropagation to complete the training of the adversarial example generation model. S7: After training is complete, freeze the optimal LoRA parameters. For any clean input image, repeat steps S1-S5 to generate adversarial examples adapted to the object detection model.
2. The target detection adversarial sample generation method based on diffusion model and LoRA fine-tuning according to claim 1, wherein In step S2, the DDIM inversion operation uses a partial inversion method, rather than completely diffusing to a pure noise state. The noise addition process is represented as follows: wherein, denotes the frozen pre-trained U-Net predicted noise; are parameters of the frozen pre-trained U-Net; denotes the number of inversion steps; is the intermediate noise state; denotes the DDIM inversion.
3. The target detection adversarial sample generation method based on diffusion model and LoRA fine-tuning according to claim 1, characterized in that, In step S3, the noise prediction formula for U-Net after adding the LoRA parameter is: wherein, represents a diffusion model condition input; is a learned adversarial noise prediction offset from LoRA parameters; is the original noise prediction result from the frozen pre-trained U-Net output; is the noise prediction result from the U-Net output after adding LoRA parameters; is the noisy latent variable of the t-th inversion step.
4. The target detection adversarial sample generation method based on diffusion model and LoRA fine-tuning according to claim 3, characterized in that, In step S4, starting with the intermediate noise state, the DDIM reverse denoising process is performed using the adjusted diffusion model U-Net, as follows: wherein, denotes DDIM reverse denoising; is the denoising latent variable of the t-th inversion step; is the noise prediction result of the U-Net output after adding the LoRA parameter; Inversion step In reverse chronological order: wherein, is the number of denoising steps.
5. The target detection adversarial example generation method based on diffusion model and LoRA fine-tuning according to claim 1, characterized in that, In step S5, the method for calculating the detection confidence suppression loss for category-independent detection is as follows: The generated adversarial image Input proxy target detector Output: Where j represents the j-th detection box output by the proxy target detector. Let J be the position coordinates of the j-th detection box. Let be the confidence score of the j-th detection box. Let j be the predicted category of the j-th detection box; For the position coordinates of each ground truth bounding box Select a set of candidate detection boxes that meet the conditions. : in, Indicates intersection, union, and ratio. Indicates the intersection-union ratio threshold; Calculate the class-independent detection confidence suppression loss : in, This represents the number of actual target bounding boxes.
6. The target detection adversarial example generation method based on diffusion model and LoRA fine-tuning according to claim 1, characterized in that, In step S5, the CLIP feature perturbation loss is calculated as follows: Original image and generated adversarial images Input CLIP visual encoder Output the corresponding visual encoding and Calculate the feature distance between the two in the visual semantic space. : Calculate CLIP feature perturbation loss : Joint loss function Including class-independent detection confidence suppression loss CLIP feature disturbance loss The combined loss is ;in, This is the balance coefficient.
7. The target detection adversarial example generation method based on diffusion model and LoRA fine-tuning according to claim 1, characterized in that, The model architecture of the method includes a latent space coding module, a diffusion inversion module, a LoRA enhanced diffusion generation module, and an image reconstruction module; The latent space coding module is used to implement the mapping from image pixel space to latent space; The diffusion inversion module is used to generate a controllable intermediate noise state; The LoRA enhanced diffusion generation module is used to learn adversarial generation rules based on fine-tuned LoRA parameters; The image reconstruction module is used to restore latent variables to the image space and to impose perturbation constraints.
8. The target detection adversarial example generation method based on diffusion model and LoRA fine-tuning according to claim 1, characterized in that, The method is applied to autonomous driving perception systems, intelligent monitoring systems, robot vision systems, and deep learning model safety testing scenarios to detect and improve the robustness of target detection models to abnormal inputs.
9. An electronic device, characterized in that, It includes a processor, a memory, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the target detection adversarial example generation method based on diffusion model and LoRA fine-tuning as described in claim 1.
10. A computer program product, characterized in that, It includes a computer program that, when executed by a processor, implements the target detection adversarial example generation method based on diffusion model and LoRA fine-tuning as described in claim 1.
