Update inference_axmodel.py
Browse files- inference_axmodel.py +4 -5
inference_axmodel.py
CHANGED
|
@@ -25,7 +25,8 @@ def parse_args():
|
|
| 25 |
|
| 26 |
def load_axmodel(axmodel_path):
|
| 27 |
"""Load AXModel"""
|
| 28 |
-
|
|
|
|
| 29 |
return session
|
| 30 |
|
| 31 |
|
|
@@ -301,7 +302,7 @@ def rotation_3d_in_axis_np(points, angles, axis=2):
|
|
| 301 |
rot_mat[:, 2, 1] = zeros
|
| 302 |
rot_mat[:, 2, 2] = ones
|
| 303 |
|
| 304 |
-
#
|
| 305 |
return np.einsum('aij,ajk->aik', points, rot_mat)
|
| 306 |
else:
|
| 307 |
raise ValueError(f'Only axis=2 (z-axis) is supported for LiDAR boxes')
|
|
@@ -322,7 +323,7 @@ def compute_bbox_corners_np(bboxes):
|
|
| 322 |
dims = np.concatenate([l, w, h], axis=1) # (N, 3) [x_size, y_size, z_size] = [l, w, h]
|
| 323 |
yaws = bboxes[:, 6] # (N,) yaw angle
|
| 324 |
|
| 325 |
-
#
|
| 326 |
yaws = yaws - (np.pi / 2.0 - np.pi / 18.0)
|
| 327 |
|
| 328 |
# Generate corners
|
|
@@ -378,10 +379,8 @@ def draw_bbox3d_on_img_custom_np(bboxes, raw_img, lidar2img_rt, color=(0, 255, 0
|
|
| 378 |
pts_2d[:, 0] /= pts_2d[:, 2]
|
| 379 |
pts_2d[:, 1] /= pts_2d[:, 2]
|
| 380 |
|
| 381 |
-
# Reshape to (N, 8, 2)
|
| 382 |
imgfov_pts_2d = pts_2d[:, :2].reshape(num_bbox, 8, 2)
|
| 383 |
|
| 384 |
-
# Draw 12 lines
|
| 385 |
line_indices = ((0, 1), (0, 3), (0, 4), (1, 2), (1, 5), (3, 2), (3, 7),
|
| 386 |
(4, 5), (4, 7), (2, 6), (5, 6), (6, 7))
|
| 387 |
|
|
|
|
| 25 |
|
| 26 |
def load_axmodel(axmodel_path):
|
| 27 |
"""Load AXModel"""
|
| 28 |
+
providers = ['AxEngineExecutionProvider']
|
| 29 |
+
session = axe.InferenceSession(axmodel_path, providers=providers)
|
| 30 |
return session
|
| 31 |
|
| 32 |
|
|
|
|
| 302 |
rot_mat[:, 2, 1] = zeros
|
| 303 |
rot_mat[:, 2, 2] = ones
|
| 304 |
|
| 305 |
+
# Rotation: (N, M, 3) @ (N, 3, 3) -> (N, M, 3)
|
| 306 |
return np.einsum('aij,ajk->aik', points, rot_mat)
|
| 307 |
else:
|
| 308 |
raise ValueError(f'Only axis=2 (z-axis) is supported for LiDAR boxes')
|
|
|
|
| 323 |
dims = np.concatenate([l, w, h], axis=1) # (N, 3) [x_size, y_size, z_size] = [l, w, h]
|
| 324 |
yaws = bboxes[:, 6] # (N,) yaw angle
|
| 325 |
|
| 326 |
+
# Fix: offset yaw by -80 degrees
|
| 327 |
yaws = yaws - (np.pi / 2.0 - np.pi / 18.0)
|
| 328 |
|
| 329 |
# Generate corners
|
|
|
|
| 379 |
pts_2d[:, 0] /= pts_2d[:, 2]
|
| 380 |
pts_2d[:, 1] /= pts_2d[:, 2]
|
| 381 |
|
|
|
|
| 382 |
imgfov_pts_2d = pts_2d[:, :2].reshape(num_bbox, 8, 2)
|
| 383 |
|
|
|
|
| 384 |
line_indices = ((0, 1), (0, 3), (0, 4), (1, 2), (1, 5), (3, 2), (3, 7),
|
| 385 |
(4, 5), (4, 7), (2, 6), (5, 6), (6, 7))
|
| 386 |
|