-
Notifications
You must be signed in to change notification settings - Fork 2
/
eval.py
31 lines (23 loc) · 762 Bytes
/
eval.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
import keras
import sys
import h5py
import numpy as np
clean_data_filename = str(sys.argv[1])
model_filename = str(sys.argv[2])
def data_loader(filepath):
data = h5py.File(filepath, 'r')
x_data = np.array(data['data'])
y_data = np.array(data['label'])
x_data = x_data.transpose((0,2,3,1))
return x_data, y_data
def data_preprocess(x_data):
return x_data/255
def main():
x_test, y_test = data_loader(clean_data_filename)
x_test = data_preprocess(x_test)
bd_model = keras.models.load_model(model_filename)
clean_label_p = np.argmax(bd_model.predict(x_test), axis=1)
class_accu = np.mean(np.equal(clean_label_p, y_test))*100
print('Classification accuracy:', class_accu)
if __name__ == '__main__':
main()