Adversarial attack methods for diffusion models based on state-dependent perturbation injection

By injecting state-dependent perturbations step-by-step and adjusting them in real time during the denoising process of the diffusion model, the problem of perturbations being easily weakened is solved, and the high concealment and efficient generation of adversarial examples are achieved.

CN123115803APending Publication Date: 2026-11-17SOUTHWEST PETROLEUM UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611619949.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-10-20
Publication Date
2026-11-17

AI Technical Summary

Technical Problem

Existing diffusion model attack methods are prone to having their perturbations weakened during the denoising process, resulting in unstable attack effectiveness and insufficient concealment and cross-model transferability of the generated adversarial examples.

Method used

By injecting state-dependent perturbations step-by-step during the denoising process of the diffusion model, and using a state verification mechanism to adjust the perturbation injection strength and update step size in real time, a stable coupling between the perturbation and the denoising process is formed, and the perturbation injection is adaptively terminated.

Benefits of technology

It improves the stealth and cross-model transferability of adversarial examples, shortens attack time, and enhances the effectiveness and practicality of adversarial example generation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123115803A_ABST
    Figure CN123115803A_ABST
Patent Text Reader

Abstract

This invention relates to the field of artificial intelligence technology and includes the following steps: collecting original data samples, mapping latent variables along time steps, adding noise to the latent variables, performing reverse denoising on the noisy latent variables, injecting state-dependent perturbations into the latent variables during the reverse denoising process, obtaining the final latent variables after perturbation injection, and decoding to generate the final adversarial sample. The invention injects state-dependent perturbations step-by-step along the complete denoising trajectory, ensuring gradient information permeates every intermediate state. This solves the problem of perturbations being easily washed away during denoising in existing methods. Furthermore, based on a continuously successfully verified state verification module, the perturbation injection is terminated promptly after a stable coupling is formed between the perturbation and denoising processes, effectively avoiding the destruction of the semantic structure of latent variables by redundant iterations in later stages, and significantly improving the concealment of the adversarial sample.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of artificial intelligence technology, specifically a diffusion model adversarial attack method based on state-dependent perturbation injection. Background Technology

[0002] In the field of artificial intelligence learning, optimization-based adversarial attack methods typically utilize gradient information from surrogate models to iteratively optimize perturbations. However, their operations are limited to the pixel space, and the generated perturbations overfit the surrogate models, resulting in limited cross-model transferability of the generated adversarial examples. Generative adversarial attack methods use generative models such as generative adversarial networks or variational autoencoders to directly apply perturbations to the latent space. However, the generated images are too smooth and lack high-frequency details, resulting in low concealment of the generated adversarial examples.

[0003] In recent years, diffusion models have demonstrated excellent image generation capabilities and have been widely used for adversarial example generation. However, some existing diffusion model attack methods (such as DiffAttack) only perform gradient updates on latent variables at a single time step during the denoising process, without incorporating intermediate time steps in the denoising trajectory into the optimization process. This results in perturbations being easily weakened or washed away by subsequent steps during denoising, leading to unstable attack effectiveness. Summary of the Invention

[0004] In view of this, the present invention provides a diffusion model adversarial attack method based on state-dependent perturbation injection. The adversarial perturbation is regarded as a dynamic intervention in the denoising inference process of the diffusion model, so that it is gradually embedded into latent variables as the denoising process progresses. The coupling degree between the perturbation and the denoising process is judged in real time through a state verification mechanism, and the injection strength and update step size are adaptively adjusted accordingly to achieve efficient and highly covert adversarial attacks.

[0005] The technical solution of this invention is a diffusion model adversarial attack method based on state-dependent perturbation injection, comprising the following steps: Step S1: Collect raw image data samples and map them along the time steps to obtain latent variables; Step S2: Add noise to the latent variables; Step S3: Perform reverse denoising on the noisy latent variables, and inject state-dependent perturbations into the latent variables during the reverse denoising process; Step S4: Obtain the final latent variables after perturbation injection, and decode to generate the final adversarial sample.

[0006] The technical effects of this invention are: (1) The present invention injects state-dependent perturbations step by step along the complete denoising trajectory, so that gradient information runs through each intermediate state, which solves the problem that perturbations in existing methods are easily washed away during the denoising process.

[0007] (2) The present invention terminates the perturbation injection in a timely manner after the state verification module based on continuous successful verification forms a stable coupling between the perturbation and denoising process, effectively avoiding the destruction of the semantic structure of latent variables by redundant iterations in the later stage, and significantly improving the concealment of adversarial samples. (3) The adaptive termination mechanism designed in the perturbation injection process of the present invention also shortens the attack time compared with the fixed iteration round strategy, effectively improving the effectiveness and practicality in the high concealment generation task of adversarial samples. Attached Figure Description

[0008] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used in the embodiments will be briefly introduced below.

[0009] Figure 1 This is a schematic diagram of the overall framework of the method in this invention; Figure 2 A schematic diagram of the adaptive step size control mechanism provided in this embodiment of the invention; Figure 3 This is a comparison of the experimental results of black-box attack testing of the multi-target model in this embodiment of the invention; Figure 4 This figure shows the performance comparison results of ablation experiments on the ImageNet compatible dataset in this embodiment of the invention. Detailed Implementation

[0010] The present invention will be further described in detail below with reference to the embodiments and accompanying drawings.

[0011] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. The described embodiments are only some, not all, of the embodiments of the present invention. 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.

[0012] To facilitate understanding of the embodiments of the present invention, the technical terms involved in this application will first be introduced: DDIM Deterministic Inversion: An image inversion technique based on DDIM (Denoising Diffusion Implicit Models). DDIM reformulates the inverse denoising process of the diffusion model as a deterministic sequence, thereby achieving a reversible mapping from the image space to the latent variable space. Specifically, DDIM deterministic inversion obtains the intermediate states of the image in the diffusion model's denoising trajectory by progressively mapping the real image along the forward time axis to the latent variable sequence. In this invention, DDIM deterministic inversion is used to map the cropped target region to the latent space, obtaining its complete latent variable sequence along the denoising trajectory, as the initial state for subsequent time-step perturbation injection.

[0013] Denoising trajectory: In the reverse generation process of the diffusion model, the sequence of all intermediate states that the latent variable undergoes from a pure noise state to the final generated image. The diffusion model iteratively transforms random noise into a clear image, with each denoising step generating an intermediate latent variable state. These states, arranged chronologically, constitute a denoising trajectory. Each node of the denoising trajectory corresponds to a specific noise level, and adjacent nodes transition between states using noise predicted by U-Net. In this invention, the denoising trajectory serves as a carrier for perturbation injection, progressively embedding adversarial perturbations along each node of the trajectory, achieving deep coupling between the perturbation and the denoising process.

[0014] See Figure 1 A method for adversarial attacks on diffusion models based on state-dependent perturbation injection includes the following steps: Step S1: Collect raw image data samples and map them along the time steps to obtain latent variables; Original image data samples The initial latent variables are obtained by mapping them to the latent space using the encoder: Where E represents a variational autoencoder, This represents the function operation form of the encoder, used to process the input raw data samples. Encoding is a latent variable representation in the latent space. Based on the existing technology in this field, the variational autoencoder is a fixed component of the pre-trained diffusion model. It completes the pre-training together with the corresponding diffusion model. The data type modality of the corresponding diffusion model is the same. For data of different modalities, it is only necessary to switch the diffusion model and encoder of the corresponding modality. The state-dependent perturbation injection attack process of this invention can be applied. This represents the initial latent variable at time step t=0, i.e., at the positive starting time step.

[0015] Step S2: Add noise to the latent variables; The noise addition process is a progressive forward noise addition starting from time step t=0, where t=0, 1, ..., T, and T is the total number of time steps in the forward noise addition process. This yields the latent noise variables corresponding to each time step. Each time step is sampled independently, and the specific values ​​are determined by random sampling without the need to preset a value range.

[0016] Let the latent variable at time step t during the noise addition process be denoted as... The latent noise variables at each time step are shown in the following equation: In the formula, This represents the predefined cumulative noise attenuation coefficient in the diffusion model, which is determined by the noise scheduling strategy. It is a pre-calculated and fixed sequence of constants and belongs to the standard inherent parameters of the diffusion model. Represents the square root function; This represents the standard Gaussian noise added in step t. , This indicates that the mean is 0 and the covariance matrix is ​​the identity matrix. It follows a standard normal distribution.

[0017] Therefore, the latent variables at each time step obtained from the entire forward noise addition process are: , Let T be the final latent noise variable at the final time step t=T during the forward denoising process. Obviously, for the reverse denoising process, the initial latent variable is... Should meet .

[0018] Step S3: Perform reverse denoising on the noisy latent variables, and inject state-dependent perturbations into the latent variables during the reverse denoising process; Specifically, the method for injecting state-dependent perturbations includes the following steps: Step S31: Use the last time step as the starting time step to begin reverse denoising of the latent variables; Step S32: Fix the current time step in the reverse denoising, use the latent variable corresponding to the time step as the initial value, perform multiple gradient iterations to inject perturbation, and determine whether to continue performing gradient iterations based on the state verification counter result; Step S33: If gradient iteration is continued, when the gradient iteration reaches the upper limit of the number of iterations, DDIM denoising sampling is performed on the latent variable corresponding to the current time step, and the latent variable is used as the prediction latent variable for the next time step. A new round of multiple gradient iterations is then performed for the next time step. If gradient iteration is stopped, standard denoising is performed on the latent variables of the remaining time steps. Furthermore, if the state verification counter still has not reached the preset threshold after traversing all time steps, the latent variables output at the final time step are used as the final latent variables, and adversarial examples are directly decoded.

[0019] Step S3 adopts a nested execution architecture of time step outer loop and gradient iteration inner loop. Step S31 belongs to the outer loop, which uses the time step as the loop variable and advances from the final time step t=T to the time step t=1. Each time step corresponds to a latent variable state node on the denoising trajectory.

[0020] Step S32 belongs to the inner loop, which takes the latent variable corresponding to the current time step determined in the outer loop. Using the initial value, perform multiple gradient iterations to update; the entire inner loop only adjusts... The characteristic values ​​do not change their corresponding time step numbers.

[0021] Step S33 belongs to the outer loop. If the gradient iteration reaches the upper limit, but the state verification judgment perturbation has not yet been stably coupled with the denoised trajectory, then it is necessary to process the latent variables that have undergone multiple gradient iterations at the current time step t. Perform one DDIM single-step standard denoising sampling to obtain the predicted latent variable of the next time step t-1 in the reverse denoising, and perform a new round of multiple gradient iterations on the predicted latent variable of the next time step t-1 according to step S32, and traverse all time steps in turn; preferably, the upper limit of the number of gradient iterations R = 6.

[0022] In this invention, DDIM denoising sampling is preferably performed using a U-Net network, which can employ a pre-trained U-Net network and a pre-trained VAE from the Stable Diffusion model.

[0023] The denoising sampling process at each time step is shown in the following equation: In the formula, This represents the predicted latent variable at time step t-1 after denoising. This represents the DDIM single-step denoising sampling operator implemented by the U-Net network; This indicates the operational form of the denoising operator.

[0024] For each gradient iteration, the following steps are performed: Step S32-1: Decode the predicted latent variables of the current time step and input them into the target model to calculate the attack loss, attention distraction loss and structure preservation loss, and construct the total loss; To mislead the target model into making incorrect predictions, a corresponding loss needs to be generated as a perturbation, thereby constructing the total loss at the current time step: In the formula, This represents the total loss at the current time step; Indicates damage caused by the attack; This indicates a loss of attention due to distraction; Indicates structural retention loss; Among them, attack losses The negative log-likelihood loss is shown in the following formula: In the formula, This represents the one-hot indicator vector at time step t-1 (the position corresponding to the true class is 1, and the rest are 0); Indicates the attack loss weight; Indicates the first Predicted probability of class , Indicates category index, The total number of categories. This loss function encourages the target model to predict probabilities of the true categories to approach zero, thus enabling untargeted attacks.

[0025] Loss of attention The variance of the cross-attention map is defined as follows: In the formula, Indicates the weight of distraction loss; This indicates that the variance of all elements in the attention graph is calculated. The cross-attention map represents the time step t-1. This loss minimizes the variance of the cross-attention map, encouraging a more uniform attention distribution. This weakens the diffusion model's ability to align semantics with text guidance, making the generated adversarial perturbations more transferable across different architectures.

[0026] The cross-attention map is shown in the following formula: In the formula, Represents the cross-attention mapping function; Indicates the true category label y Text embedding; By extracting the cross-attention map at the current time step, the semantic correspondence between text conditions and sample regions is disrupted, further enhancing the cross-model transferability of adversarial examples.

[0027] To ensure the effectiveness of the attack while maintaining the consistency of the adversarial sample with the original data sample in terms of structural features, this invention further introduces a structure preservation loss. The self-attention map of the trainable branch at the current time step is constrained to remain consistent with that of the fixed reference branch, and the structure-preserving loss is used. The specific formula is as follows: In the formula, Represents the self-attention mapping function; Indicates the structural retention loss weight; This represents the latent variable at time step t-1 in the forward noise addition process record; This means taking the square of the L2 norm, which means first taking the L2 norm of the vector and then squaring it.

[0028] Structural retention loss The sum of squares of the element-wise differences between the two self-attention maps was calculated to measure the degree of inconsistency in the attention distribution between the perturbation branch and the forward-loaded reference branch. This loss effectively suppresses distortion caused by over-optimization by constraining the consistency of the self-attention maps, ensuring that adversarial perturbations do not disrupt the original spatial structure and semantic layout of the samples.

[0029] Step S32-2: Feedback the total loss to the latent variables The latent variables are updated by using gradient descent in the reverse direction along the gradient. The characteristic components are injected with perturbations; Based on the total loss obtained in step S32-1, gradient descent is used to update the current latent variables to inject perturbations. See also Figure 2 To adaptively adjust the update step size of subsequent time steps based on the local geometric characteristics of the denoised trajectory, this invention calculates the first-order rate of change of the current time step after each gradient update, and further calculates the local curvature of the denoised trajectory to modulate the effective step size of the next time step.

[0030] when At that time, the current latent variables are updated, and the perturbation injection is as follows: In the formula, This represents the preset baseline learning rate, used to control the magnitude of each update of the latent variables; Indicates total loss Regarding latent variables The gradient vector, which indicates the gradient of the latent variables in each dimension that minimizes the total loss. The gradient descent method updates the latent variables in the opposite direction of the increase, thereby reducing the loss and making the latent variables update in a direction that is favorable to the attack.

[0031] In this invention, the learning rate can be adaptively adjusted according to the local geometric characteristics of the denoised trajectory. The learning rate for the current time step is calculated from the previous time step.

[0032] for For any time step t, the operation of injecting perturbations by updating the latent variables through gradient iteration is shown in the following equation: In the formula, Indicates total loss Latent variables about the current time step t The gradient; This represents the effective learning rate at the current time step t.

[0033] The effective learning rate is mainly calculated by taking the first-order rate of change at the current time step after each latent variable update. Furthermore, the local curvature of the denoised trajectory is calculated. The effective learning rate for the next time step is obtained by modulation; specifically, the effective learning rate for the current time step t. for: In the formula, , This is a state-dependent attack strength function. This represents the preset attack strength attenuation coefficient. This indicates the count value of the status verification counter; , For curvature modulation factor, This indicates the preset curvature adjustment coefficient. Local curvature of the denoised trajectory from the previous time step; This represents an exponential function with the natural constant e as its base.

[0034] State-dependent attack strength function Controlling the perturbation intensity at the macro-attack process level: When the perturbation successfully deceives the target model for multiple consecutive time steps, the state verification counter... Increasing, The exponential decay of the perturbation intensity allows for a smooth transition from the initial powerful attack to a fine recovery, preventing over-optimization from compromising sample quality.

[0035] Curvature modulation factor Controlling the learning rate update from a microscopic trajectory geometry level: when the denoised trajectory changes drastically ( When it is relatively large, Attenuation, reducing the learning rate to avoid compromising trajectory stability; when the trajectory is flat ( When it is smaller, The learning rate approaches 1, maintaining the baseline learning rate to sustain the attack guidance effect. Both are independent yet synergistic, working together to achieve dual adaptive step size control.

[0036] After the gradient iteration update of the latent variables is completed, the first-order rate of change at the current time step is calculated: in, These are extremely small positive numbers, used to prevent the denominator from being zero; This represents the predicted latent variable at time step t+1 after denoising. This represents the L2 norm.

[0037] The curvature of the next time step is calculated from the difference between the first-order rate of change of the current time step and the previous time step. : In the formula, This represents the first-order rate of change at the current time step; This represents the first-order rate of change at the previous time step; Indicates the curvature at the next time step; This is the absolute value operator.

[0038] Since the denoising process is executed in reverse chronological order (from T to 0), when the iteration progresses to the current time step t, time step t+1 has already been processed in the previous iteration, and its corresponding... It has been pre-calculated and stored, and can be directly called.

[0039] when At time (i.e., the first time step of inverse denoising), since there is no historical data from the previous time step, the curvature degenerates to the absolute value of the current first-order rate of change: ,in For the current time step The first rate of change, and .

[0040] Step S32-3: Update the latent variables obtained after injecting the perturbation. The model is decoded to input the predicted sample into the target model, and the predicted label at the current time step is obtained. The state verification counter is updated based on the difference between the predicted label and the real class label pre-labeled in the dataset for the current sample. Based on the result of the state verification counter, it is determined whether to continue to perform gradient iteration to inject perturbation or to perform standard denoising on the latent variables of the remaining time steps.

[0041] Updated As the input latent variable for the next denoising step, it continues to participate in subsequent sampling and optimization. Specifically, after each perturbation injection, the state verification counter will update its count value based on the classification result. If the count value does not reach the preset threshold... ,Right now Then, continue to perform the perturbation injection according to the entire process of step S32, and perform a new round of multiple gradient iterations for the next time step according to the method of step S33; If the count value reaches the preset threshold, that is If the state verification counter reaches the preset threshold consecutively, the disturbance has been stably coupled with the denoising trajectory. Then, the disturbance injection is terminated according to the method of step S33, and only standard DDIM denoising sampling is performed on the latent variables of the remaining time steps, including the current time step. The latent variables of the current time step use the latest latent variables after the current disturbance injection. At this time, the loss and the injected disturbance are no longer calculated, and only the latent variables are restored to pure semantics.

[0042] At this point, the perturbation has been continuously deceiving the target model across multiple time steps, indicating that it has become stably coupled with the denoising process. Continuing to apply the perturbation not only offers limited gains in attack effectiveness but may also introduce redundant noise, disrupting the established semantic structure. Phase switching, while preserving the results of previous attacks, effectively avoids excessive perturbation accumulation and redundant iterations, enabling the final adversarial sample to maintain a high attack success rate while possessing superior stealth.

[0043] If the count value still does not reach the preset threshold after traversing all time steps, it proves that the sample or target model has high robustness. At this time, the final latent variable is directly decoded to generate adversarial examples.

[0044] For preset threshold If the threshold is small, injection will stop earlier, resulting in better preservation of sample semantics and higher concealment. However, insufficient injection may reduce the attack success rate. Conversely, a larger threshold will result in more thorough perturbation injection and a higher attack success rate. However, excessive injection can damage the sample structure, leading to a decrease in the concealment of the adversarial example. Therefore, the preset threshold can be optimized through ablation experiments. That is, for specific diffusion models, target models, and task scenarios, the attack success rate and perceptual distortion perceptual indices (LPIPS) under different thresholds are compared within the specified range, and the value with the best overall performance is selected as the final preset threshold. Preferably, the preset threshold in this invention... = 15, thus achieving the best balance between attack success rate and sample concealment.

[0045] For the state verification counter, its initial value is defined as follows: The state verification counter is used to record the number of consecutive differences between the predicted label and the true class label obtained after the sample undergoes perturbation injection at the current time step. The count value of the state verification counter will be updated after each perturbation injection, as shown in the following formula: In the formula, This indicates the count value of the status verification counter; y This represents the true category label of the current sample; This indicates the predicted label of the current sample obtained from the previous time step.

[0046] Each time the predicted label differs from the true class label, the state verification counter increments by 1. When a difference occurs, it proves that the injected perturbation allows the sample to deceive the target model. The more discrepancies occur, the more consistently the perturbation can deceive the target model across multiple time steps.

[0047] Predicted Labels The latent variables, after being injected with perturbations, are decoded into predicted samples by a VAE decoder and input into the target model. After softmax normalization, the sample with the highest probability is obtained. Specifically, for the predicted latent variables at time step t-1 after denoising... ,Will via VAE decoder Decoded into predicted samples: in, This indicates the decoder The corresponding decoding mapping function.

[0048] Then Input target model After softmax normalization, the class probability distribution is obtained: In the formula, Indicates length is The probability vector; The normalization exponential function is used to map the real number vector output by the target model to a probability distribution, such that each component of the output vector takes values ​​between [0,1] and the sum of all components is 1.

[0049] Therefore, the predicted label at time step t-1 As shown in the following formula: The maximum value argument operator is used to return the subscript argument that makes the expression within parentheses the maximum value; The above formula represents the index across all categories. In the middle, select to make Index to get the maximum value This means that the operation returns the index of the class with the highest probability, rather than the probability value itself, thus making It became the predicted category label at time step t-1.

[0050] As can be seen, the above-described "perturbation injection—state verification—standard denoising" operations constitute a complete two-stage framework: step S32-2 injects perturbations along the denoising trajectory step by step over time, and monitors the attack status in real time to achieve efficient injection of adversarial perturbations; step S32-3 switches to clean semantic recovery after the perturbation is stably embedded. This two-stage framework enables the present invention to achieve a synergistic optimization of computational efficiency and stealth while ensuring attack effectiveness.

[0051] Step S4: Obtain the final latent variables after perturbation injection, and decode to generate the final adversarial sample.

[0052] After the iteration terminates, the final latent variable is taken. via VAE decoder Decoded into the final adversarial sample ,Right now .

[0053] Example: This embodiment uses the Stable Diffusion v2 model as the generator and Inception-v3 as the target model. The dataset is in ImageNet-compatible format, and adversarial generation is performed according to the above steps. This embodiment uses image data as an example, but the method of this invention is applicable to any generative model with latent space representation, and is not limited to image data. The specific values ​​below are only preferred parameters for this embodiment and do not constitute a limitation on the scope of protection of this invention.

[0054] In this embodiment, the iteration rounds are set. (That is, each denoising time step is iterated and optimized 6 times in the inner loop), learning rate Continuous success threshold Attack loss weight Distraction loss weight Structure-preserving loss weights Based on existing technologies in this field, all three sets of weight parameters can be optimized through ablation experiments. Under this experimental configuration, the optimal balance between attack success rate, sample concealment, and cross-model transferability can be achieved. Initialize the state verification counter. attenuation coefficient .

[0055] To quantitatively evaluate the performance of generated adversarial examples, this embodiment uses Attack Success Rate (ASR) and Perceptual Distortion Perception (LPIPS) as evaluation metrics. Attack Success Rate is the percentage of samples that successfully deceive the target model out of the total number of samples; LPIPS calculates the perceptual similarity between the adversarial example and the original data samples using a pre-trained AlexNet network, with lower values ​​indicating better imperceptibility.

[0056] To verify the cross-model transfer capability of the method of the present invention in black-box attack scenarios, this embodiment uses Inception-v3 as a white-box substitute model to generate adversarial examples, and then performs black-box attack tests on multiple target models such as ResNet-50, VGG-19, and MobileNet-v2.

[0057] Experimental results are as follows Figure 3 As shown, the SGPP of this invention achieves an average attack success rate of 41.8% on 10 black-box target models, which is significantly better than DiffAttack (34.6%); the LPIPS is 0.102, which is better than all the comparison methods, verifying the effectiveness of this invention.

[0058] like Figure 4 As shown, to verify the contribution of each module, a single-timestep perturbation was used as the baseline, resulting in an attack success rate of 34.6% and an LPIPS of 0.126. After introducing a time-step perturbation, the attack success rate increased to 49.1%, and the LPIPS increased to 0.142, indicating enhanced attack persistence but decreased stealth. Adding an adaptive step size reduced the attack success rate to 48.2% and the LPIPS to 0.123, demonstrating that curvature modulation can suppress noise accumulation. Finally, adding a state counter resulted in an attack success rate of 41.8% and the LPIPS to 0.102, indicating that timely termination of injection avoided redundant perturbations and improved stealth. The three modules worked synergistically to achieve an optimal balance between attack success rate and perceptual distortion. The experimental results demonstrate the effectiveness and practicality of this invention in generating highly stealthy adversarial examples.

[0059] The above description is merely a preferred embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in the embodiments of the present invention should be included within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.

Claims

1. A diffusion model adversarial attack method based on state-dependent perturbation injection, characterized in that, Includes the following steps: Step S1: Collect raw image data samples and map them along the time steps to obtain latent variables; Step S2: Add noise to the latent variables; Step S3: Perform reverse denoising on the noisy latent variables, and inject state-dependent perturbations into the latent variables during the reverse denoising process; Step S4: Obtain the final latent variables after perturbation injection, and decode to generate the final adversarial sample.

2. The method for adversarial attacks on diffusion models based on state-dependent perturbation injection according to claim 1, characterized in that: The method for adding noise to the latent variables in step S2 is as follows: Gaussian noise is gradually added along the positive direction of the time axis to obtain the noisy latent variables corresponding to each time step.

3. The method for adversarial attacks on diffusion models based on state-dependent perturbation injection according to claim 1, characterized in that: The state-dependent perturbation injection method described in step S3 includes the following steps: Step S31: Use the last time step as the starting time step to begin reverse denoising of the latent variables; Step S32: Fix the current time step in the reverse denoising, use the latent variable corresponding to the time step as the initial value, perform multiple gradient iterations to inject perturbation, and determine whether to continue performing gradient iterations based on the state verification counter result; Step S33: If gradient iteration is continued, when the gradient iteration reaches the upper limit of the number of iterations, DDIM denoising sampling is performed on the latent variable corresponding to the current time step, and the latent variable is used as the prediction latent variable for the next time step. A new round of multiple gradient iterations is then performed for the next time step. If gradient iteration is stopped, standard denoising is performed on the latent variables of the remaining time steps.

4. The method for adversarial attacks on diffusion models based on state-dependent perturbation injection according to claim 3, characterized in that: The maximum number of gradient iterations in step S33 is 6.

5. The method for adversarial attacks on diffusion models based on state-dependent perturbation injection according to claim 3, characterized in that: The specific operations for each gradient iteration in step S32 include the following steps: Step S32-1: After decoding the predicted latent variables, input them into the target model, calculate the attack loss, attention distraction loss, and structure preservation loss, and construct the total loss; Step S32-2: Feedback the total loss to the latent variables The latent variables are updated by using gradient descent in the reverse direction along the gradient. The characteristic components are injected with perturbations; Step S32-3: Update the latent variables obtained after injecting the perturbation. The model is decoded to input the predicted sample into the target model, and the predicted label at the current time step is obtained. The state verification counter is updated based on the difference between the predicted label and the true class label of the current sample. Based on the result of the state verification counter, it is determined whether to continue to perform gradient iteration to inject perturbation or to perform standard denoising on the latent variables of the remaining time steps.

6. The method for adversarial attacks on diffusion models based on state-dependent perturbation injection according to claim 5, characterized in that: The total loss mentioned in step S32-1 is shown in the following formula: In the formula, This represents the total loss at the current time step; Indicates damage caused by the attack; This indicates a loss of attention due to distraction; This represents the structural retention loss.

7. The method for adversarial attacks on diffusion models based on state-dependent perturbation injection according to claim 5, characterized in that: The method for injecting perturbation in step S32-3 is as follows: When t=T, the perturbation injection is as shown in the following formula: In the formula, This indicates the preset baseline learning rate; Indicates total loss Regarding latent variables The gradient; When t < T, the perturbation injection is as follows: In the formula, Indicates total loss Latent variables about the current time step t The gradient; This represents the effective learning rate at the current time step t.

8. The method for adversarial attacks on diffusion models based on state-dependent perturbation injection according to claim 5, characterized in that: The method for judging based on the state verification counter result in step S32-3 is as follows: when the state verification counter count value... The preset threshold was not reached. At that time, continue to perform gradient iteration to inject perturbations; When the status verification counter count value Reaching the preset threshold At that time, standard denoising is performed on the latent variables of the remaining time step.

9. A method for adversarial attacks on diffusion models based on state-dependent perturbation injection as described in claim 5, characterized in that: The predicted label is obtained by decoding the injected perturbed latent variables into a predicted sample via a VAE decoder and inputting it into the target model. After softmax normalization, the label with the highest probability is selected.

10. A method for adversarial attacks on diffusion models based on state-dependent perturbation injection according to claim 7, characterized in that: The effective learning rate is calculated by taking the local curvature of the denoised trajectory from the previous time step after each latent variable update, as shown in the following formula: In the formula, This is a state-dependent attack strength function; This is the curvature modulation factor.