-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpedestrian_test.py
executable file
·58 lines (42 loc) · 1.7 KB
/
pedestrian_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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#! /usr/bin/python
import numpy as np
import tflearn
import sys
import time
import os.path
model_name = None
data = None
labels = None
channels = None
height = None
width = None
try:
data = np.load(sys.argv[1])
labels = np.load(sys.argv[2])
height = int(sys.argv[3])
width = int(sys.argv[4])
channels = int(sys.argv[5])
model_name = sys.argv[6]
except IndexError:
print("Usage: pedestrian_test $data.npy $labels.npy $height $width $channels $model_name")
sys.exit()
# ------------------------------------------------------------------------------ #
input_layer = tflearn.input_data(shape=[None, height, width, channels])
conv_pool = tflearn.conv_2d(input_layer, 32, [3, 3], activation='relu')
conv_pool = tflearn.max_pool_2d(conv_pool, [2, 2])
conv_pool = tflearn.conv_2d(input_layer, 32, [3, 3], activation='relu')
conv_pool = tflearn.max_pool_2d(conv_pool, [2, 2])
fc = tflearn.fully_connected(conv_pool, 32, activation='relu')
fc = tflearn.dropout(fc, 0.95)
fc = tflearn.fully_connected(fc, 32, activation='relu')
fc = tflearn.dropout(fc, 0.95)
output_layer = tflearn.fully_connected(fc, 2, activation='softmax')
cross_entropy = tflearn.regression(output_layer)
# ------------------------------------------------------------------------------ #
model = tflearn.DNN(cross_entropy, tensorboard_dir='logs')
model.load(model_name)
print("-------------------------------------------------------------------------")
print("Evaluate over %d records of data" % (len(data)))
start_time = time.time()
print("Evaluation score: ", model.evaluate(data.reshape([-1, height, width, channels]), labels))
print("Elapsed time: %d seconds" % (time.time() - start_time))