forked from soprof/face-identification-tpe
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_cnn.py
35 lines (23 loc) · 795 Bytes
/
test_cnn.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
import numpy as np
import matplotlib.pyplot as plt
from cnn import build_cnn
from bottleneck import Bottleneck
from identification import get_scores, calc_metrics
WEIGHTS_DIR = './data/weights/'
BATCH_SIZE = 32
dev_x = np.load('data/dev_x.npy')
model = build_cnn(227, 266)
weights_to_load = WEIGHTS_DIR + 'weights.best.h5'
model.load_weights(weights_to_load)
bottleneck = Bottleneck(model, ~1)
dev_y = bottleneck.predict(dev_x, batch_size=BATCH_SIZE)
protocol = np.load('data/dev_protocol.npy')
tsc, isc = get_scores(dev_y, protocol)
eer, fars, frrs, dists = calc_metrics(tsc, isc)
print('EER: {}'.format(eer * 100))
plt.figure()
plt.hist(tsc, 20, color='g', normed=True, alpha=0.3)
plt.hist(isc, 20, color='r', normed=True, alpha=0.3)
plt.figure()
plt.loglog(fars, frrs)
plt.show()