forked from MSU-NEU-ATL/DFTND
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.py
83 lines (60 loc) · 2.33 KB
/
Main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import sys
import os
def main():
if '--task' in sys.argv and '--attack_type' in sys.argv:
a = sys.argv.index('--attack_type')
attack_type = sys.argv[a + 1]
if attack_type == 'PGD':
attack = 'PGD_Attack'
if attack_type == 'Patch':
attack = 'Patch_Attack'
if attack_type == 'CW':
attack = 'CW_Attack'
if attack_type == 'FGSM':
attack = 'FGSM_Attack'
if attack_type == 'interpret':
attack = 'interpret'
sys.argv[0] = attack + '.py'
if attack_type == 'trojan':
attack = 'trojan_train'
sys.argv[0] = 'DFTND/' + attack + '.py'
# sys.argv[0] = attack + '.py'
command = ' '.join(sys.argv[:])
command = 'python ' + command
print(command)
os.system(command)
elif '--attack_type' in sys.argv:
a = sys.argv.index('--attack_type')
attack_type = sys.argv[a + 1]
if attack_type =='SNGAN':
command = ' '.join(sys.argv[3:])
command = 'python ' + command
print(command)
os.system('ls')
os.chdir('./SNGAN/')
os.system('pwd')
if attack_type =='FSGAN':
command = ' '.join(sys.argv[3:])
print(command)
os.system('ls')
os.chdir('./FSGAN/')
os.system('pwd')
if attack_type =='SEAN':
#command = 'python ' + './evaluations/gen_images.py --config_path ./configs/sn_projection_celeba.yml --snapshot ./models/celeba_align_png_cropped.npz --results_dir ./gen_image/ --num_pngs 1000 --seed 0'
command = ' '.join(sys.argv[3:])
print(command)
os.system('ls')
os.chdir('./SEAN/')
os.system('pwd')
if attack_type =='PGAN':
command = ' '.join(sys.argv[3:])
command = 'python ' + command
print(command)
os.system('ls')
os.chdir('./PGAN/')
os.system('pwd')
os.system(command)
else:
print('attack type error. Please provide attack type.')
if __name__ == '__main__':
main()