UniAD
UniAD copied to clipboard
dimension misamatch in fut_traj[:fut_traj_scence_centric.shape[0], :] = fut_traj_scence_centric when getting future trajectory info
Hi, I met a dimension mismatch error when I creating the trajectory info for uniad using
def _get_future_traj_info(nusc, sample, predict_steps=16):
sample_token = sample['token']
ann_tokens = np.array(sample['anns'])
sd_rec = nusc.get('sample', sample_token)
fut_traj_all = []
fut_traj_valid_mask_all = []
_, boxes, _ = nusc.get_sample_data(sd_rec['data']['LIDAR_TOP'], selected_anntokens=ann_tokens)
predict_helper = PredictHelper(nusc)
for i, ann_token in enumerate(ann_tokens):
box = boxes[i]
instance_token = nusc.get('sample_annotation', ann_token)['instance_token']
fut_traj_local = predict_helper.get_future_for_agent(instance_token,
sample_token,
seconds=predict_steps//2,
in_agent_frame=True)
fut_traj = np.zeros((predict_steps, 2))
fut_traj_valid_mask = np.zeros((predict_steps, 2))
if fut_traj_local.shape[0] > 0:
# trans = box.center
# trans = np.array([0, 0, 0])
# rot = Quaternion(matrix=box.rotation_matrix)
# fut_traj_scence_centric = convert_local_coords_to_global(fut_traj_local, trans, rot)
fut_traj_scence_centric = fut_traj_local
print(f"fut_traj.shape: {fut_traj.shape}, fut_traj_scence_centric.shape: {fut_traj_scence_centric.shape}")
fut_traj[:fut_traj_scence_centric.shape[0], :] = fut_traj_scence_centric
fut_traj_valid_mask[:fut_traj_scence_centric.shape[0], :] = 1
fut_traj_all.append(fut_traj)
fut_traj_valid_mask_all.append(fut_traj_valid_mask)
if len(ann_tokens) > 0:
fut_traj_all = np.stack(fut_traj_all, axis=0)
fut_traj_valid_mask_all = np.stack(fut_traj_valid_mask_all, axis=0)
else:
fut_traj_all = np.zeros((0, predict_steps, 2))
fut_traj_valid_mask_all = np.zeros((0, predict_steps, 2))
return fut_traj_all, fut_traj_valid_mask_all
the error shows that
Traceback (most recent call last):
File "tools/create_data.py", line 85, in <module>
nuscenes_data_prep(
File "tools/create_data.py", line 28, in nuscenes_data_prep
nuscenes_converter.create_nuscenes_infos(
File "/mnt/ws-frb/users/yiliuhh/mmpretraining/ViDAR/UniAD/tools/data_converter/uniad_nuscenes_converter.py", line 86, in create_nuscenes_infos
train_nusc_infos, val_nusc_infos = _fill_trainval_infos(
File "/mnt/ws-frb/users/yiliuhh/mmpretraining/ViDAR/UniAD/tools/data_converter/uniad_nuscenes_converter.py", line 321, in _fill_trainval_infos
future_traj_all, future_traj_valid_mask_all = _get_future_traj_info(nusc, sample)
File "/mnt/ws-frb/users/yiliuhh/mmpretraining/ViDAR/UniAD/tools/data_converter/uniad_nuscenes_converter.py", line 199, in _get_future_traj_info
fut_traj[:fut_traj_scence_centric.shape[0], :] = fut_traj_scence_centric
ValueError: could not broadcast input array from shape (17,2) into shape (16,2)
it seems like there is a dimension mismatch between fut_traj.shape and fut_traj_scence_centric fut_traj.shape: (16, 2), fut_traj_scence_centric.shape: (17, 2) have anyone met similar issue before? are there any suggestions/ thanks!
the value of the fut_traj_local is
array([[ 0.00000000e+00, 0.00000000e+00],
[ 0.00000000e+00, 0.00000000e+00],
[ 0.00000000e+00, 0.00000000e+00],
[ 0.00000000e+00, 0.00000000e+00],
[-3.86562523e-02, -2.90808211e-02],
[-3.86562523e-02, -2.90808211e-02],
[-1.20419962e-01, -1.22078928e-02],
[-1.95717329e-01, -6.61265921e-03],
[-3.00412895e-01, 3.03866304e-04],
[-3.73306838e-01, 5.86174417e-02],
[-4.46326270e-01, 1.17923112e-01],
[-4.46326270e-01, 1.17923112e-01],
[-4.83386618e-01, 1.00131803e-01],
[-4.96648502e-01, 9.34144811e-02],
[-5.47519961e-01, 1.05123227e-01],
[-5.68938635e-01, 1.62892080e-01],
[-5.91548608e-01, 1.02577992e-01]])
you use your custom data? you need to change the predict_steps=16 to a big number (more than 17)