Spaces:
Sleeping
Sleeping
Commit
·
20928cb
1
Parent(s):
c99a000
Update app.py
Browse files
app.py
CHANGED
@@ -36,14 +36,15 @@ pipe_inpaint = StableDiffusionInpaintPipeline.from_pretrained(
|
|
36 |
)
|
37 |
pipe_inpaint = pipe_inpaint.to("cuda")
|
38 |
|
39 |
-
def pgd(X,
|
40 |
X_adv = X.clone().detach() + (torch.rand(*X.shape)*2*eps-eps).cuda()
|
41 |
pbar = tqdm(range(iters))
|
42 |
for i in pbar:
|
43 |
actual_step_size = step_size - (step_size - step_size / 100) / iters * i
|
44 |
-
X_adv.requires_grad_(True)
|
45 |
|
46 |
-
|
|
|
|
|
47 |
|
48 |
pbar.set_description(f"[Running attack]: Loss {loss.item():.5f} | step size: {actual_step_size:.4}")
|
49 |
|
|
|
36 |
)
|
37 |
pipe_inpaint = pipe_inpaint.to("cuda")
|
38 |
|
39 |
+
def pgd(X, model, eps=0.1, step_size=0.015, iters=40, clamp_min=0, clamp_max=1, mask=None):
|
40 |
X_adv = X.clone().detach() + (torch.rand(*X.shape)*2*eps-eps).cuda()
|
41 |
pbar = tqdm(range(iters))
|
42 |
for i in pbar:
|
43 |
actual_step_size = step_size - (step_size - step_size / 100) / iters * i
|
|
|
44 |
|
45 |
+
X_adv.requires_grad_(True)
|
46 |
+
|
47 |
+
loss = (model(X_adv).latent_dist.mean).norm()
|
48 |
|
49 |
pbar.set_description(f"[Running attack]: Loss {loss.item():.5f} | step size: {actual_step_size:.4}")
|
50 |
|