Skip to main content
. 2026 May 1;26(9):2823. doi: 10.3390/s26092823
Algorithm 1. The optimization procedure of DeDiAttack
Input:
  Clean image x
  Ground-truth label y
  Surrogate classifier Fθ
  Stable Diffusion Model SDM
  Number of optimization iterations N
  Number of deformation samplings K
Output:
  Unrestricted adversarial example x′
1: z′ <- DDIM Inversion (x)
2: Initialize the adversarial latent variable with z′
3: for i=1 to N do
4:   x^ <- Decode (z′)
5:   for k = 1 to K do
6:     Sample a random deformation noise map nk
7:     Update nk according to the classification loss in Equation (4)
8:     xk <- T (x^, nk)
9:   end for
10:    Compute the classification loss Lcls using Equation (6) and Fθ
11:    Compute the distribution alignment loss Lkl using Equations (7) and (8)
12:    Compute the structure preservation loss Lstruct using Equation (9)
13:    Update z′ by AdamW according to the total objective in Equation (10)
14: end for
15: x′ <- Decode (z′)
16: return x′