-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
draw_adv.py
78 lines (69 loc) · 2.37 KB
/
draw_adv.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
import os
import matplotlib
matplotlib.use('agg')
import matplotlib.pyplot as plt
from PIL import Image
######################################################################
# Draw Curve
#---------------------------
x_epoch = [2,4,8,12,16]
top1 = {}
top10 = {}
mAP = {}
for i in range(10):
top1[i] = []
top10[i] = []
mAP[i] = []
top1[0] = [88.24] *5
top10[0] = [96.88] *5
mAP[0] = [69.70] *5
with open("./Output_adv.txt", "r") as f:
for line in f:
if line[0] =='#': continue
score = line.split('|')
method_id = int(score[2])
top1_acc, top10_acc, mAP_acc = float(score[3]), float(score[5]), float(score[6])
top1[method_id].append(top1_acc*100)
top10[method_id].append(top10_acc*100)
mAP[method_id].append(mAP_acc*100)
fig = plt.figure(figsize=(15,4), dpi=90)
ax0 = fig.add_subplot(131, ylabel="Recall@1(%)",xlabel='epsilon')
ax0.plot(x_epoch, top1[0], 'k-', label='Clean')
ax0.plot(x_epoch, top1[1], 'b^--', label='Fast')
ax0.plot(x_epoch, top1[2], 'rs--', label='Basic')
ax0.plot(x_epoch, top1[3], 'gv--', label='Least-likely')
ax0.plot(x_epoch, top1[6], 'c<--', label='PIRE')
ax0.plot(x_epoch, top1[7], 'm>--', label='TMA')
ax0.plot(x_epoch, top1[9], 'P--', label='SMA')
ax0.plot(x_epoch, top1[5], 'yo--', label='Ours')
ax0.grid(True)
ax0.legend()
plt.ylim(0.0,100.0)
plt.xlim(1,17)
ax0 = fig.add_subplot(132, ylabel="Recall@10(%)",xlabel='epsilon')
ax0.plot(x_epoch, top10[0], 'k-', label='Clean')
ax0.plot(x_epoch, top10[1], 'b^--', label='Fast')
ax0.plot(x_epoch, top10[2], 'rs--', label='Basic')
ax0.plot(x_epoch, top10[3], 'gv--', label='Least-likely')
ax0.plot(x_epoch, top10[6], 'c<--', label='PIRE')
ax0.plot(x_epoch, top10[7], 'm>--', label='TMA')
ax0.plot(x_epoch, top10[9], 'P--', label='SMA')
ax0.plot(x_epoch, top10[5], 'yo--', label='Ours')
ax0.grid(True)
ax0.legend()
plt.ylim(0,100)
plt.xlim(1,17)
ax0 = fig.add_subplot(133, ylabel="mAP(%)", xlabel='epsilon')
ax0.plot(x_epoch, mAP[0], 'k-', label='Clean')
ax0.plot(x_epoch, mAP[1], 'b^--', label='Fast')
ax0.plot(x_epoch, mAP[2], 'rs--', label='Basic')
ax0.plot(x_epoch, mAP[3], 'gv--', label='Least-likely')
ax0.plot(x_epoch, mAP[6], 'c<--', label='PIRE')
ax0.plot(x_epoch, mAP[7], 'm>--', label='TMA')
ax0.plot(x_epoch, mAP[9], 'P--', label='SMA')
ax0.plot(x_epoch, mAP[5], 'yo--', label='Ours')
ax0.grid(True)
ax0.legend()
plt.ylim(0,100)
plt.xlim(1,17)
fig.savefig('adv.jpg')