Unverified Commit 8cf1acb2 authored by Sun Jiahao's avatar Sun Jiahao Committed by GitHub
Browse files

[Fix] Fix to_tensor bug when array strides is negative (#2315)

* fix polarmix UT

* fix bug

* fix img list
parent 7b6ce167
......@@ -147,10 +147,13 @@ class Pack3DDetInputs(BaseTransform):
if 'img' in results:
if isinstance(results['img'], list):
# process multiple imgs in single frame
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)
imgs = np.stack(results['img'], axis=0)
if imgs.flags.c_contiguous:
imgs = to_tensor(imgs).permute(0, 3, 1, 2).contiguous()
else:
imgs = to_tensor(
np.ascontiguousarray(imgs.transpose(0, 3, 1, 2)))
results['img'] = imgs
else:
img = results['img']
if len(img.shape) < 3:
......@@ -159,7 +162,12 @@ class Pack3DDetInputs(BaseTransform):
# `torch.permute()` rather than `np.transpose()`.
# Refer to https://github.com/open-mmlab/mmdetection/pull/9533
# for more details
results['img'] = to_tensor(img).permute(2, 0, 1).contiguous()
if img.flags.c_contiguous:
img = to_tensor(img).permute(2, 0, 1).contiguous()
else:
img = to_tensor(
np.ascontiguousarray(img.transpose(2, 0, 1)))
results['img'] = img
for key in [
'proposals', 'gt_bboxes', 'gt_bboxes_ignore', 'gt_labels',
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment