-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
44 lines (34 loc) · 1.46 KB
/
main.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
from utils import *
if __name__ == '__main__':
if not os.path.isdir(OUTPUT_DIR):
crop_train_dataset()
images_whitened = white_all_train_folders(False, True)
images_hogged = hog_whitened_images(images_whitened)
min_max_scaler = preprocessing.MinMaxScaler()
imgs_normalized = {}
for folder in images_hogged.keys():
images_normalized = min_max_scaler.fit_transform(images_hogged[folder])
imgs_normalized[folder] = images_normalized
train, validation = divide_dataset(imgs_normalized)
svms = create_exemplar_svms(train)
for folder in svms.keys():
#selected_for_validation = []
#selected_validation_classes = []
#for i in range(0, len(validation)):
# if len(validation[i]) == classes_sizes[folder]:
# selected_for_validation.append(validation[i])
# selected_validation_classes.append(validation_classes[i])
#print "Selected", len(selected_for_validation), "images for validation"
#if len(selected_for_validation) > 0:
print "Starting validation for", folder
progBar = ProgressBar(len(folder_images))
progBar.start()
count = 0
for svm in svms[folder]:
for img in validation[folder]:
predict = svm.predict([img])
if predict == folder:
print "ACERTEI"
count = count+1
progBar.update(count)
progBar.finish()