forked from pjreddie/darknet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparse.py
More file actions
66 lines (54 loc) · 1.56 KB
/
Copy pathparse.py
File metadata and controls
66 lines (54 loc) · 1.56 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
import numpy as np
import matplotlib.pyplot as plt
from scipy.signal import savgol_filter
import argparse
iou = []
class_ = []
obj = []
no_obj = []
recall = []
def clean(_arr, _n):
try:
return float(_arr[_n].replace(",", ""))
except:
pass
def parse(file_):
f = open(file_, "r")
lines = f.readlines()
for line in lines:
splits = line.split()
if len(splits) == 16:
iou.append(clean(splits, 3))
class_.append(clean(splits, 5))
obj.append(clean(splits, 7))
no_obj.append(clean(splits, 10))
recall.append(clean(splits, 13))
f.close()
y1 = savgol_filter(np.asarray(iou), 5001, 3)
y2 = savgol_filter(np.asarray(class_), 5001, 3)
y3 = savgol_filter(np.asarray(obj), 5001, 3)
y4 = savgol_filter(np.asarray(no_obj), 5001, 3)
y5 = savgol_filter(np.asarray(recall), 5001, 3)
x1 = np.arange(len(y1))
x2 = np.arange(len(y2))
x3 = np.arange(len(y3))
x4 = np.arange(len(y4))
x5 = np.arange(len(y5))
plt.subplot(3, 1, 1)
plt.plot(x1, y1, 'o-')
plt.title('IOU')
plt.ylabel('IOU')
plt.subplot(3, 1, 2)
plt.plot(x2, y2, '.-')
plt.xlabel('Epochs')
plt.ylabel('Class')
plt.subplot(3, 1, 3)
plt.plot(x5, y5, '.-')
plt.xlabel('Epochs')
plt.ylabel('Recall')
plt.show()
if __name__ == "__main__":
parser = argparse.ArgumentParser(description='Parse darknet output.')
parser.add_argument('file', help='an integer for the accumulator')
args = parser.parse_args()
parse(args.file)