-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
42 lines (35 loc) · 970 Bytes
/
test.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
import BatchReader as dataset
import os
import time
from CaptchaModel import Captcha
# load model
model = Captcha()
model.load_checkpoint('crack_capcha0.994400002956.model-9960')
# load dataset
dataset = dataset.BatchReader(ratio=0.01, test_size=1000)
images, labels = dataset.get_val_batch(0, 1000)
count = len(labels)
correct = 0
# start timing
start = time.time()
t = start
# start testing
for i in range(count):
image = images[i]
label = labels[i]
pred = model.predict(image)
text = ''.join(map(str, pred))
if text == label:
correct += 1
else:
print(label, text)
pass
if i % 50 == 0:
t = time.time() - t
print('[%d/%d] average: %f'%(i, count, t / 50))
t = time.time()
end = time.time()
# output result
print('Total time: %f s'%(end - start))
print('Average time: %f s'%((end - start) / count))
print('Total: %d, Correct: %d, Acc: %f'%(count, correct, float(correct) / float(count)))