Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
Swin-Transformer-Object-Detection
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to JiHu GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
wanggh
Swin-Transformer-Object-Detection
Commits
56b250f6
Unverified
Commit
56b250f6
authored
4 years ago
by
Luting Wang
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Fix: mask resize (#4520)
* fix: mask resize * test: mask resize * chore: fix lint
parent
0fea302c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
mmdet/core/mask/structures.py
+2
-1
2 additions, 1 deletion
mmdet/core/mask/structures.py
tests/test_masks.py
+25
-0
25 additions, 0 deletions
tests/test_masks.py
with
27 additions
and
1 deletion
mmdet/core/mask/structures.py
+
2
−
1
View file @
56b250f6
...
...
@@ -269,7 +269,8 @@ class BitmapMasks(BaseInstanceMasks):
resized_masks
=
np
.
empty
((
0
,
*
out_shape
),
dtype
=
np
.
uint8
)
else
:
resized_masks
=
np
.
stack
([
mmcv
.
imresize
(
mask
,
out_shape
,
interpolation
=
interpolation
)
mmcv
.
imresize
(
mask
,
out_shape
[::
-
1
],
interpolation
=
interpolation
)
for
mask
in
self
.
masks
])
return
BitmapMasks
(
resized_masks
,
*
out_shape
)
...
...
This diff is collapsed.
Click to expand it.
tests/test_masks.py
+
25
−
0
View file @
56b250f6
...
...
@@ -117,6 +117,17 @@ def test_bitmap_mask_resize():
[
0
,
0
,
0
,
0
,
0
,
0
,
1
,
1
],
[
0
,
0
,
0
,
0
,
0
,
0
,
1
,
1
]]])
assert
(
resized_masks
.
masks
==
truth
).
all
()
# resize to non-square
raw_masks
=
np
.
diag
(
np
.
ones
(
4
,
dtype
=
np
.
uint8
))[
np
.
newaxis
,
...]
bitmap_masks
=
BitmapMasks
(
raw_masks
,
4
,
4
)
resized_masks
=
bitmap_masks
.
resize
((
4
,
8
))
assert
len
(
resized_masks
)
==
1
assert
resized_masks
.
height
==
4
assert
resized_masks
.
width
==
8
truth
=
np
.
array
([[[
1
,
1
,
0
,
0
,
0
,
0
,
0
,
0
],
[
0
,
0
,
1
,
1
,
0
,
0
,
0
,
0
],
[
0
,
0
,
0
,
0
,
1
,
1
,
0
,
0
],
[
0
,
0
,
0
,
0
,
0
,
0
,
1
,
1
]]])
assert
(
resized_masks
.
masks
==
truth
).
all
()
def
test_bitmap_mask_flip
():
# flip with empty bitmap masks
...
...
@@ -420,6 +431,20 @@ def test_polygon_mask_resize():
truth3
=
np
.
stack
([
truth1
,
np
.
pad
(
truth2
,
((
0
,
4
),
(
0
,
4
)),
'
constant
'
)])
assert
(
resized_masks3
.
to_ndarray
()
==
truth3
).
all
()
# resize to non-square
raw_masks4
=
[[
np
.
array
([
1
,
1
,
3
,
1
,
4
,
3
,
2
,
4
,
1
,
3
],
dtype
=
np
.
float
)]]
polygon_masks4
=
PolygonMasks
(
raw_masks4
,
5
,
5
)
resized_masks4
=
polygon_masks4
.
resize
((
5
,
10
))
assert
len
(
resized_masks4
)
==
1
assert
resized_masks4
.
height
==
5
assert
resized_masks4
.
width
==
10
assert
resized_masks4
.
to_ndarray
().
shape
==
(
1
,
5
,
10
)
truth4
=
np
.
array
(
[[
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
],
[
0
,
0
,
1
,
1
,
1
,
1
,
1
,
0
,
0
,
0
],
[
0
,
0
,
1
,
1
,
1
,
1
,
1
,
1
,
0
,
0
],
[
0
,
0
,
0
,
1
,
1
,
1
,
0
,
0
,
0
,
0
],
[
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
]],
np
.
uint8
)
assert
(
resized_masks4
.
to_ndarray
()
==
truth4
).
all
()
def
test_polygon_mask_flip
():
# flip with empty polygon 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