-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
84 lines (67 loc) · 3.58 KB
/
main.py
File metadata and controls
84 lines (67 loc) · 3.58 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
73
74
75
76
77
78
79
80
81
82
83
84
# This is a sample Python script.
# Press Shift+F10 to execute it or replace it with your code.
# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.
import time
import math
import matplotlib.pyplot as plt
from data_initialization import rosbag_ouput_to_dataframe
from distance_filter import distance_filter_remove
from data_matching import data_matching
from sklearn.metrics import classification_report, confusion_matrix, ConfusionMatrixDisplay
def print_hi(name):
# Use a breakpoint in the code line below to debug your script.
print(f'Hi, {name}') # Press Ctrl+F8 to toggle the breakpoint.
# Press the green button in the gutter to run the script.
if __name__ == '__main__':
print_hi('PyCharm')
start = time.clock() # start time
list_args = [
["/home/ubuntu18/liangdao/Data/19-merge.bag", "/home/ubuntu18/liangdao/Data/19_ALT_OD_CP2.bag"],
["/home/ubuntu18/liangdao/Data/20-merge.bag", "/home/ubuntu18/liangdao/Data/20_ALT_OD_CP2.bag"],
["/home/ubuntu18/liangdao/Data/21-merge.bag", "/home/ubuntu18/liangdao/Data/21_ALT_OD_CP2.bag"],
["/home/ubuntu18/liangdao/Data/40-merge.bag", "/home/ubuntu18/liangdao/Data/40_ALT_OD_CP2.bag"],
["/home/ubuntu18/liangdao/Data/42-merge.bag", "/home/ubuntu18/liangdao/Data/42_ALT_OD_CP2.bag"],
["/home/ubuntu18/liangdao/Data/48-merge.bag", "/home/ubuntu18/liangdao/Data/48_ALT_OD_CP2.bag"]
]
# distance filter
distance_range = [[0, 30], [-10, 10], [-math.inf, math.inf]]
dimensions = 2
iou_threshold = 0.5
# obtain data from rosbag document
pred_list_all = []
true_list_all = []
for i in list_args:
print('------------', i, '-----------------')
true_path = i[0]
pred_path = i[1]
msg_df_pred, msg_df_pred_number = rosbag_ouput_to_dataframe(pred_path, topic=['/ld_object_lists'])
msg_df_true, msg_df_true_number = rosbag_ouput_to_dataframe(true_path, topic=['/ld_object_lists'])
# msg_df_true_filtered = distance_filter(msg_df_true, distance_range)
# msg_df_pred_filtered = distance_filter(msg_df_pred, distance_range)
# distance filter remove
msg_df_true_filtered_removed = distance_filter_remove(msg_df_true, distance_range)
msg_df_pred_filtered_removed = distance_filter_remove(msg_df_pred, distance_range)
# print(msg_df_pred_filtered_removed.shape, msg_df_true_filtered_removed.shape)
# matching
pred_list, true_list = data_matching(msg_df_true_filtered_removed,
msg_df_pred_filtered_removed,
dimensions=dimensions, iou_threshold=iou_threshold)
pred_list_all.extend(pred_list)
true_list_all.extend(true_list)
# Multi-Class Classification
print('----------'+'Classification Report'+'----------')
print(classification_report(pred_list_all, true_list_all))
print('----------'+'Confusion matrix'+'----------')
cm = confusion_matrix(pred_list_all, true_list_all)
print(cm)
print('a image of confusion matrix have be save as confusion.png')
disp = ConfusionMatrixDisplay(cm, display_labels=['Car', 'Cyclist', 'Motorcycle', 'Pedestrian', 'Truck', 'UnKnown',
'Van'])
disp.plot()
# plt.figure(dpi=100)
plt.savefig('confusion.png')
# for item in set(msg_df_pred_filtered_removed['msg_number']):
# print(item)
end = time.clock() # end time
print('run time:', str(end - start))
# See PyCharm help at https://www.jetbrains.com/help/pycharm/