Skip to content

Commit

Permalink
change np.transpose to torch.permute
Browse files Browse the repository at this point in the history
  • Loading branch information
sunjiahao1999 committed Feb 15, 2023
1 parent f4ae6d7 commit 5c50239
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions mmdet3d/datasets/transforms/formating.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,15 +147,15 @@ def pack_single_results(self, results: dict) -> dict:
if 'img' in results:
if isinstance(results['img'], list):
# process multiple imgs in single frame
imgs = [img.transpose(2, 0, 1) for img in results['img']]
imgs = np.ascontiguousarray(np.stack(imgs, axis=0))
imgs = [to_tensor(img) for img in results['img']]
imgs = torch.stack(
imgs, dim=0).permute(0, 3, 1, 2).contiguous()
results['img'] = to_tensor(imgs)
else:
img = results['img']
if len(img.shape) < 3:
img = np.expand_dims(img, -1)
results['img'] = to_tensor(
np.ascontiguousarray(img.transpose(2, 0, 1)))
results['img'] = to_tensor(img).permute(2, 0, 1).contiguous()

for key in [
'proposals', 'gt_bboxes', 'gt_bboxes_ignore', 'gt_labels',
Expand Down

0 comments on commit 5c50239

Please # to comment.