-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathframerate_calculator.py
114 lines (97 loc) · 3.28 KB
/
framerate_calculator.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
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
import pandas as pd
import xlsxwriter
import sys
if len(sys.argv) != 2:
assert("Error number of arguments")
if sys.argv[1] == "upper":
sampling_strategy = 1
if sys.argv[1] == "lower":
sampling_strategy = 2
if sys.argv[1] == "dynamic":
sampling_strategy = 0
mot_files = [
'MOT16-01_time.xlsx',
'MOT16-02_time.xlsx',
'MOT16-03_time.xlsx',
'MOT16-04_time.xlsx',
'MOT16-05_time.xlsx',
'MOT16-06_time.xlsx',
'MOT16-07_time.xlsx',
'MOT16-08_time.xlsx',
'MOT16-09_time.xlsx',
'MOT16-10_time.xlsx',
'MOT16-11_time.xlsx',
'MOT16-12_time.xlsx',
'MOT16-13_time.xlsx',
'MOT16-14_time.xlsx',
]
# mot_files = [
# 'MOT20-01_time.xlsx',
# 'MOT20-02_time.xlsx',
# 'MOT20-03_time.xlsx',
# 'MOT20-04_time.xlsx',
# 'MOT20-05_time.xlsx',
# 'MOT20-06_time.xlsx',
# 'MOT20-07_time.xlsx',
# 'MOT20-08_time.xlsx',
# ]
workbook = xlsxwriter.Workbook("MOT20_FPS.xlsx")
worksheet = workbook.add_worksheet()
worksheet.write(0, 0, "sequence")
worksheet.write(0, 1, "det_fuse")
worksheet.write(0, 2, "post_fuse")
worksheet.write(0, 3, "track_fuse")
worksheet.write(0, 4, "post_track")
worksheet.write(0, 5, "FPS")
for idx, each in enumerate(mot_files):
df = pd.read_excel(each, engine='openpyxl')
# drop all NAN
detect_fuse = df['detect_fuse'].dropna()
post_detect = df['post_detect'].dropna()
track_fuse = df['track_fuse'].dropna()
post_track = df['post_track'].dropna()
# drop top 5 largest data due to GPU warmup, numba compiling
detect_fuse.drop(index=detect_fuse.nlargest(5).index, inplace=True)
post_detect.drop(index=post_detect.nlargest(5).index, inplace=True)
track_fuse.drop(index=track_fuse.nlargest(5).index, inplace=True)
post_track.drop(index=post_track.nlargest(5).index, inplace=True)
avg_det_fuse = detect_fuse.mean()
avg_post_det = post_detect.mean()
avg_track = track_fuse.mean()
avg_post_tk = post_track.mean()
# change the following line to the measured average inference time
average_infer = 182.9
# change the following lines to the cutomized tuned smapling rate
if sampling_strategy == 1:
if "MOT16-05" in each or "MOT16-06" in each:
average_rate = 6
elif "MOT16-13" in each or "MOT16-14" in each:
average_rate = 8
else:
average_rate = 13
elif sampling_strategy == 2:
if "MOT16-05" in each or "MOT16-06" in each:
average_rate = 3
elif "MOT16-13" in each or "MOT16-14" in each:
average_rate = 6
else:
average_rate = 8
else:
if "MOT16-05" in each or "MOT16-06" in each:
average_rate = 4
elif "MOT16-13" in each or "MOT16-14" in each:
average_rate = 7
else:
average_rate = 9
det_process = avg_det_fuse + avg_post_det + average_infer
tk_process = avg_track + avg_post_tk
one_set_process = det_process + tk_process*(average_rate-1)
num_set = 1000/one_set_process
fps = num_set * average_rate
worksheet.write(idx+1, 0, each)
worksheet.write(idx+1, 1, avg_det_fuse)
worksheet.write(idx+1, 2, avg_post_det)
worksheet.write(idx+1, 3, avg_track)
worksheet.write(idx+1, 4, avg_post_tk)
worksheet.write(idx+1, 5, fps)
workbook.close()