Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
mmdetection3d
Commits
8cf1acb2
Unverified
Commit
8cf1acb2
authored
Mar 01, 2023
by
Sun Jiahao
Committed by
GitHub
Mar 01, 2023
Browse files
[Fix] Fix to_tensor bug when array strides is negative (#2315)
* fix polarmix UT * fix bug * fix img list
parent
7b6ce167
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
5 deletions
+13
-5
mmdet3d/datasets/transforms/formating.py
mmdet3d/datasets/transforms/formating.py
+13
-5
No files found.
mmdet3d/datasets/transforms/formating.py
View file @
8cf1acb2
...
@@ -147,10 +147,13 @@ class Pack3DDetInputs(BaseTransform):
...
@@ -147,10 +147,13 @@ class Pack3DDetInputs(BaseTransform):
if
'img'
in
results
:
if
'img'
in
results
:
if
isinstance
(
results
[
'img'
],
list
):
if
isinstance
(
results
[
'img'
],
list
):
# process multiple imgs in single frame
# process multiple imgs in single frame
imgs
=
[
to_tensor
(
img
)
for
img
in
results
[
'img'
]]
imgs
=
np
.
stack
(
results
[
'img'
],
axis
=
0
)
imgs
=
torch
.
stack
(
if
imgs
.
flags
.
c_contiguous
:
imgs
,
dim
=
0
).
permute
(
0
,
3
,
1
,
2
).
contiguous
()
imgs
=
to_tensor
(
imgs
).
permute
(
0
,
3
,
1
,
2
).
contiguous
()
results
[
'img'
]
=
to_tensor
(
imgs
)
else
:
imgs
=
to_tensor
(
np
.
ascontiguousarray
(
imgs
.
transpose
(
0
,
3
,
1
,
2
)))
results
[
'img'
]
=
imgs
else
:
else
:
img
=
results
[
'img'
]
img
=
results
[
'img'
]
if
len
(
img
.
shape
)
<
3
:
if
len
(
img
.
shape
)
<
3
:
...
@@ -159,7 +162,12 @@ class Pack3DDetInputs(BaseTransform):
...
@@ -159,7 +162,12 @@ class Pack3DDetInputs(BaseTransform):
# `torch.permute()` rather than `np.transpose()`.
# `torch.permute()` rather than `np.transpose()`.
# Refer to https://github.com/open-mmlab/mmdetection/pull/9533
# Refer to https://github.com/open-mmlab/mmdetection/pull/9533
# for more details
# 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
[
for
key
in
[
'proposals'
,
'gt_bboxes'
,
'gt_bboxes_ignore'
,
'gt_labels'
,
'proposals'
,
'gt_bboxes'
,
'gt_bboxes_ignore'
,
'gt_labels'
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment