Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
food-round2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Joel Joseph
food-round2
Commits
f97d361d
Unverified
Commit
f97d361d
authored
5 years ago
by
Kai Chen
Committed by
GitHub
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
bug fix for mask resizing when aspect ratio is unfixed (#1050)
parent
f730b408
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
mmdet/datasets/transforms.py
+20
-6
20 additions, 6 deletions
mmdet/datasets/transforms.py
with
20 additions
and
6 deletions
mmdet/datasets/transforms.py
+
20
−
6
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
=
[
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment