From 5dcfd711f3fc9e9dd4aab746a226a773128fa887 Mon Sep 17 00:00:00 2001 From: Nataniel Ruiz Date: Tue, 31 Dec 2019 21:05:46 -0400 Subject: [PATCH] next --- ganimation/solver.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/ganimation/solver.py b/ganimation/solver.py index 299ce46..1e9ac73 100644 --- a/ganimation/solver.py +++ b/ganimation/solver.py @@ -409,10 +409,10 @@ class Solver(Utils): all_images = torch.cat([regular_image_transform(Image.open(path)).unsqueeze(0) for path in images_to_animate_path], dim=0).cuda() - # if idx == 0: - # for target_idx in range(targets.size(0)): - # x_adv, perturb = pgd_attack.perturb(image_to_animate, black, targets[target_idx, :].unsqueeze(0).cuda()) - # x_advs.append((x_adv, perturb)) + if idx == 0: + for target_idx in range(targets.size(0)): + x_adv, perturb = pgd_attack.perturb(image_to_animate, black, targets[target_idx, :].unsqueeze(0).cuda()) + x_advs.append((x_adv, perturb)) for target_idx in range(targets.size(0)): # if target_idx == 0: @@ -423,9 +423,8 @@ class Solver(Utils): targets_au = targets[target_idx, :].unsqueeze(0).cuda() # x_adv, perturb = pgd_attack.perturb(image_to_animate, black, targets_au) - # x_adv, perturb = x_advs[target_idx] - # x_adv = image_to_animate + perturb - x_adv = image_to_animate + x_adv, perturb = x_advs[target_idx] + x_adv = image_to_animate + perturb # print(image_to_animate.shape, x_adv.shape) with torch.no_grad(): resulting_images_att, resulting_images_reg = self.G(