Xiaodong commited on
Commit
ab45969
·
1 Parent(s): e2dee29
last.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bc835f5b152b8038e7446f8db9cd7c491339bdb9fc2c5def098436c708d6cd82
3
+ size 8444266
preview_1step_scope_1/action_val.json ADDED
The diff for this file is too large to render. See raw diff
 
preview_1step_scope_1/l1.py ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ import numpy as np
3
+
4
+ def denormalize_func(normalized_tensor, min_val=0, max_val=200):
5
+ tensor = (normalized_tensor + 1) / 2
6
+ tensor = tensor * (max_val - min_val) + min_val
7
+ # tensor = t.round(tensor).long()
8
+ return tensor
9
+
10
+
11
+ # 读取JSON文件
12
+ with open('action_val.json', 'r') as file:
13
+ data = json.load(file)
14
+
15
+ # 初始化误差列表
16
+ steering_errors = []
17
+ speed_errors = []
18
+
19
+ # 遍历每个场景,计算L1误差
20
+ for scene_data in data:
21
+ action_pred = scene_data["action_pred"]
22
+ action_gt = scene_data["action_gt"]
23
+
24
+ # 确保 action_pred 和 action_gt 的长度一致
25
+ min_length = min(len(action_pred), len(action_gt))
26
+
27
+ # 计算每个时间步的转向角和速度误差
28
+ for i in range(min_length):
29
+ pred_steering, pred_speed = action_pred[i]
30
+ gt_steering, gt_speed = action_gt[i]
31
+
32
+ # pred_steering = denormalize_func(pred_steering, -500, 500)
33
+ # gt_steering = denormalize_func(gt_steering, -500, 500)
34
+ # pred_speed = denormalize_func(pred_speed, 0, 70)
35
+ # gt_speed = denormalize_func(gt_speed, 0, 70)
36
+
37
+ # 计算转向角和速度的绝对误差
38
+ steering_error = abs(pred_steering - gt_steering)
39
+ speed_error = abs(pred_speed - gt_speed)
40
+
41
+ steering_errors.append(steering_error)
42
+ speed_errors.append(speed_error)
43
+
44
+ # 计算转向角和速度的平均L1误差
45
+ mean_steering_error = np.mean(steering_errors)
46
+ mean_speed_error = np.mean(speed_errors)
47
+
48
+ print("平均转向角L1误差:", mean_steering_error)
49
+ print("平均速度L1误差:", mean_speed_error)
preview_1step_scope_1/plot.py ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ import matplotlib.pyplot as plt
3
+
4
+ # 读取JSON文件
5
+ with open('action_val.json', 'r') as file:
6
+ data = json.load(file)
7
+
8
+ # 提取数据
9
+ scene_data = data[1]
10
+ action_pred = scene_data["action_pred"]
11
+ action_gt = scene_data["action_gt"]
12
+
13
+ # 提取转向角和速度
14
+ pred_steering_angles = [a[0] for a in action_pred]
15
+ pred_speeds = [a[1] for a in action_pred]
16
+
17
+ gt_steering_angles = [a[0] for a in action_gt]
18
+ gt_speeds = [a[1] for a in action_gt]
19
+
20
+ # 绘图
21
+ plt.figure(figsize=(12, 5))
22
+
23
+ # 转向角的 plot
24
+ plt.subplot(1, 2, 1)
25
+ plt.plot(pred_steering_angles, label='Predicted Steering Angle', color='blue', marker='o')
26
+ plt.plot(gt_steering_angles, label='Ground Truth Steering Angle', color='orange', marker='o')
27
+ plt.title("Steering Angle")
28
+ plt.xlabel("Time Step")
29
+ plt.ylabel("Angle")
30
+ plt.legend()
31
+
32
+ # 速度的 plot
33
+ plt.subplot(1, 2, 2)
34
+ plt.plot(pred_speeds, label='Predicted Speed', color='blue', marker='o')
35
+ plt.plot(gt_speeds, label='Ground Truth Speed', color='orange', marker='o')
36
+ plt.title("Speed")
37
+ plt.xlabel("Time Step")
38
+ plt.ylabel("Speed")
39
+ plt.legend()
40
+
41
+ plt.tight_layout()
42
+ plt.savefig('val.jpg')
preview_1step_scope_1/val.jpg ADDED