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
ModelZoo
SOLOv2-pytorch
Commits
f97d361d
Unverified
Commit
f97d361d
authored
Jul 27, 2019
by
Kai Chen
Committed by
GitHub
Jul 27, 2019
Browse files
bug fix for mask resizing when aspect ratio is unfixed (#1050)
parent
f730b408
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
6 deletions
+20
-6
mmdet/datasets/transforms.py
mmdet/datasets/transforms.py
+20
-6
No files found.
mmdet/datasets/transforms.py
View file @
f97d361d
...
...
@@ -34,8 +34,8 @@ class ImageTransform(object):
else
:
img
,
w_scale
,
h_scale
=
mmcv
.
imresize
(
img
,
scale
,
return_scale
=
True
)
scale_factor
=
np
.
array
(
[
w_scale
,
h_scale
,
w_scale
,
h_scale
],
dtype
=
np
.
float32
)
scale_factor
=
np
.
array
(
[
w_scale
,
h_scale
,
w_scale
,
h_scale
],
dtype
=
np
.
float32
)
img_shape
=
img
.
shape
img
=
mmcv
.
imnormalize
(
img
,
self
.
mean
,
self
.
std
,
self
.
to_rgb
)
if
flip
:
...
...
@@ -99,10 +99,24 @@ class MaskTransform(object):
"""
def
__call__
(
self
,
masks
,
pad_shape
,
scale_factor
,
flip
=
False
):
masks
=
[
mmcv
.
imrescale
(
mask
,
scale_factor
,
interpolation
=
'nearest'
)
for
mask
in
masks
]
# aspect ratio unchanged
if
isinstance
(
scale_factor
,
float
):
masks
=
[
mmcv
.
imrescale
(
mask
,
scale_factor
,
interpolation
=
'nearest'
)
for
mask
in
masks
]
# aspect ratio changed
else
:
w_ratio
,
h_ratio
=
scale_factor
[:
2
]
if
masks
:
h
,
w
=
masks
[
0
].
shape
[:
2
]
new_h
=
int
(
np
.
round
(
h
*
h_ratio
))
new_w
=
int
(
np
.
round
(
w
*
w_ratio
))
new_size
=
(
new_w
,
new_h
)
masks
=
[
mmcv
.
imresize
(
mask
,
new_size
,
interpolation
=
'nearest'
)
for
mask
in
masks
]
if
flip
:
masks
=
[
mask
[:,
::
-
1
]
for
mask
in
masks
]
padded_masks
=
[
...
...
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