-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscore
More file actions
executable file
·73 lines (56 loc) · 2.46 KB
/
score
File metadata and controls
executable file
·73 lines (56 loc) · 2.46 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/python
import sys
import json
import base64
import numpy as np
from scipy import misc
student_output = sys.argv[1]
def decode(packet):
img = base64.b64decode(packet)
filename = './image.png'
with open(filename, 'wb') as f:
f.write(img)
result = misc.imread(filename)
return result
with open('../Example/results.json') as json_data:
ans_data = json.loads(json_data.read())
json_data.close()
# Load student data
with open(student_output) as student_data:
student_ans_data = json.loads(student_data.read())
student_data.close()
frames_processed = 0
Car_TP = 0 # True Positives
Car_FP = 0 # Flase Positives
Car_TN = 0 # True Negatives
Car_FN = 0 # True Negatives
Road_TP = 0 # True Positives
Road_FP = 0 # Flase Positives
Road_TN = 0 # True Negatives
Road_FN = 0 # True Negatives
for frame in range(1,len(ans_data.keys())+1):
truth_data_car = decode(ans_data[str(frame)][0])
truth_data_road = decode(ans_data[str(frame)][1])
student_data_car = decode(student_ans_data[str(frame)][0])
student_data_road = decode(student_ans_data[str(frame)][1])
Car_TP += np.sum(np.logical_and(student_data_car == 1, truth_data_car == 1))
Car_FP += np.sum(np.logical_and(student_data_car == 1, truth_data_car == 0))
Car_TN += np.sum(np.logical_and(student_data_car == 0, truth_data_car == 0))
Car_FN += np.sum(np.logical_and(student_data_car == 0, truth_data_car == 1))
Road_TP += np.sum(np.logical_and(student_data_road == 1, truth_data_road == 1))
Road_FP += np.sum(np.logical_and(student_data_road == 1, truth_data_road == 0))
Road_TN += np.sum(np.logical_and(student_data_road == 0, truth_data_road == 0))
Road_FN += np.sum(np.logical_and(student_data_road == 0, truth_data_road == 1))
frames_processed+=1
# Generate results
Car_precision = Car_TP/(Car_TP+Car_FP)/1.0
Car_recall = Car_TP/(Car_TP+Car_FN)/1.0
Car_beta = 2
Car_F = (1+Car_beta**2) * ((Car_precision*Car_recall)/(Car_beta**2 * Car_precision + Car_recall))
Road_precision = Road_TP/(Road_TP+Road_FP)/1.0
Road_recall = Road_TP/(Road_TP+Road_FN)/1.0
Road_beta = 0.5
Road_F = (1+Road_beta**2) * ((Road_precision*Road_recall)/(Road_beta**2 * Road_precision + Road_recall))
print ("Car F score: %05.3f | Car Precision: %05.3f | Car Recall: %05.3f |\n\
Road F score: %05.3f | Road Precision: %05.3f | Road Recall: %05.3f | \n\
Averaged F score: %05.3f" %(Car_F,Car_precision,Car_recall,Road_F,Road_precision,Road_recall,((Car_F+Road_F)/2.0)))