-
Notifications
You must be signed in to change notification settings - Fork 54
/
predict.py
33 lines (25 loc) · 878 Bytes
/
predict.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
import os
import cv2
from utils.feature import get_feature_function
from utils.measure import *
model_path = "./trained_models/tiny_XCEPTION.hdf5"
def main():
get_feature = get_feature_function(model=model_path)
features = []
base_feature = None
dir_list = list(list(os.walk("./data/manual_testing"))[0])[2]
dir_list.sort()
for file in dir_list:
path = "./data/manual_testing/" + file
img = cv2.imread(path)
feature = get_feature(img)
features.append((file, feature))
if file == "base.jpg":
base_feature = feature
for file, feature in features:
print(file, '\t',
cosine_similarity(feature, base_feature), '\t',
euclidean_metric(feature, base_feature), '\t',
pearson_correlation(feature, base_feature))
if __name__ == '__main__':
main()