forked from zzmcdc/face-eval
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathplot_AP_fddb.py
83 lines (73 loc) · 2.28 KB
/
plot_AP_fddb.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
#!/usr/bin/env python
# plots all the PR curves for fddb
# As in this case we do not optimize the bbox, we use a separate code
#import matplotlib
# matplotlib.use('Agg')
import glob
import numpy
import pylab
import os
import sys
from getColorLabel import *
def load_fddb(ff):
print ff
ftxt = open(ff, "rb")
if ff == "detections/fddb/OlaworksDiscROC.txt":
data = numpy.genfromtxt(ftxt, delimiter="\t")
else:
data = numpy.genfromtxt(ftxt, delimiter=" ")
data.sort(axis=0)
data = data[::-1]
ln = os.path.splitext(ff)
ln = os.path.basename(ln[0])
if ln[-1] == "_":
ln = ln[:-1]
label = ln
pp = label.find("DiscROC")
label = label[:pp]
if label[-1] == "_":
label = label[:-1]
color, label = getColorLabel(label)
pos = numpy.where(data[:, 1] < 1000)[0][0]
pr = data[pos, 0]
print pr
label = label + " (%0.3f)" % (pr)
plotid, = pylab.plot(data[:, 1], data[:, 0], color=color, linewidth=5)
return plotid, pr, label
if __name__ == "__main__":
import argparse
parser = argparse.ArgumentParser(
description='Plots AP curves on fddb faces')
parser.add_argument('detfile', type=str, nargs="?",
default="", help='Detection file in fddb format')
args = parser.parse_args()
color_list = pylab.cm.Set1(numpy.linspace(0, 1, 26))
colorCounter = 11
pylab.figure(figsize=(12, 8))
lff = glob.glob("detections/fddb/*.txt")
method = []
for idff, ff in enumerate(lff):
pid, pr, l = load_fddb(ff)
method.append((pr, idff, pid, l))
if args.detfile != "":
pid, pr, l = load_fddb(args.detfile)
method.append((pr, idff, pid, l))
method = sorted(method, reverse=True)
ll = []
ii = []
for this_idx, i in enumerate(method):
ii.append(i[2])
ll.append(i[3])
pylab.setp(i[2], zorder=len(method) - this_idx)
pylab.legend(ii, ll, loc='lower right', ncol=2)
pylab.ylabel("True positive rate")
pylab.xlabel("False positives")
pylab.grid()
pylab.gca().set_xlim((0, 2000))
pylab.gca().set_ylim((0, 1))
pylab.yticks(numpy.linspace(0, 1, 11))
savename = "FDDB_final.pdf"
pylab.savefig(savename)
os.system("pdfcrop %s" % (savename))
pylab.show()
pylab.draw()