From c17b32581385754911701907004408254610bd92 Mon Sep 17 00:00:00 2001 From: junghye01 Date: Fri, 29 Nov 2024 11:54:04 +0900 Subject: [PATCH] modifiy video attack code --- options/test_options.py | 2 +- test_video_swapspecific.py | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/options/test_options.py b/options/test_options.py index 3562671b..c1861622 100644 --- a/options/test_options.py +++ b/options/test_options.py @@ -34,5 +34,5 @@ def initialize(self): self.parser.add_argument('--no_simswaplogo', action='store_true', help='Remove the watermark') self.parser.add_argument('--use_mask', action='store_true', help='Use mask for better result') self.parser.add_argument('--crop_size', type=int, default=512, help='Crop of size of input image') - + self.parser.add_argument('--isattack', type=int, default=1, help='Adversarial attack') self.isTrain = False \ No newline at end of file diff --git a/test_video_swapspecific.py b/test_video_swapspecific.py index 7961afe6..7f4f8310 100644 --- a/test_video_swapspecific.py +++ b/test_video_swapspecific.py @@ -93,10 +93,11 @@ def lcm(a, b): return abs(a * b) / fractions.gcd(a, b) if a and b else 0 specific_person_downsample = F.interpolate(specific_person, size=(112,112)) specific_person_id_nonorm = model.netArc(specific_person_downsample) - video_swap(opt.video_path, latend_id,specific_person_id_nonorm, opt.id_thres, \ + if not opt.isattack: + video_swap(opt.video_path, latend_id,specific_person_id_nonorm, opt.id_thres, \ + model, app, opt.output_path,temp_results_dir=opt.temp_path,no_simswaplogo=opt.no_simswaplogo,use_mask=opt.use_mask,crop_size=crop_size) + else: + video_swap_with_attack(opt.video_path, img_id,latend_id,specific_person_id_nonorm, opt.id_thres, \ model, app, opt.output_path,temp_results_dir=opt.temp_path,no_simswaplogo=opt.no_simswaplogo,use_mask=opt.use_mask,crop_size=crop_size) - #video_swap_with_attack(opt.video_path, img_id,latend_id,specific_person_id_nonorm, opt.id_thres, \ - # model, app, opt.output_path,temp_results_dir=opt.temp_path,no_simswaplogo=opt.no_simswaplogo,use_mask=opt.use_mask,crop_size=crop_size) -