/
test_set.py
30 lines (26 loc) · 1 KB
/
test_set.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
import hog
import os
import numpy
import cv2
filename = 'svc.pkl'
pos_path = 'C:/Users/Piotr/Documents/Studia/7. semestr/TRA/Projekt/Training_set/Test/pos'
neg_path = 'C:/Users/Piotr/Documents/Studia/7. semestr/TRA/Projekt/Training_set/Test/neg'
width = 96
height = 160
def main():
classifier = hog.load_classifier(filename)
pos = [hog.hog(numpy.float32(cv2.resize(cv2.imread(os.path.join(pos_path, image), 0), (width, height)))) for image in os.listdir(pos_path)]
neg = [hog.hog(numpy.float32(cv2.resize(cv2.imread(os.path.join(neg_path, image), 0), (width, height)))) for image in os.listdir(neg_path)]
x_test = pos + neg
y_test = [1] * len(pos) + [0] * len(neg)
accuracy = classifier.score(x_test, y_test)
print("Dokładność")
print(accuracy*100)
positive = classifier.predict(pos)
negative = classifier.predict(neg)
print("Czułość")
print(numpy.mean(positive)*100)
print("Swoistość")
print((1-numpy.mean(negative))*100)
if __name__ == "__main__":
main()