-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathaverage_csv.py
34 lines (27 loc) · 984 Bytes
/
average_csv.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
#!/usr/bin/python
import sys
path = sys.argv[1]
task = sys.argv[2]
avg_first = 0.
avg_last = 0.
initial = task.split('-')[0]
col_index = int(initial)+1
with open(path, 'r') as f:
for line_index, line in enumerate(f):
split = line.split(',')
a = split[-1]
a = float(a)
step = line.split(',')[0]
if col_index > -1:
if len(split[1:col_index+1]) == 0:
avg_first = 0.
else:
avg_first = sum([float(i) for i in split[1:col_index+1] if i not in ('x', 'X')]) / len(split[1:col_index+1])
if len(split[col_index+1:-1]) == 0:
avg_last = 0.
else:
avg_last = sum([float(i) for i in split[col_index+1:-1] if i not in ('x', 'X')]) / len(split[col_index+1:-1])
print(f"Last Step: {step}")
print(f"Final Mean IoU {round(100 * a, 2)}")
print(f'Mean IoU first {round(100 * avg_first, 2)}')
print(f'Mean IoU last {round(100 * avg_last, 2)}')