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
MMCV
Commits
43ca0e57
Unverified
Commit
43ca0e57
authored
Jan 11, 2020
by
Kai Chen
Committed by
GitHub
Jan 11, 2020
Browse files
fix the shape assertion in impad (#172)
parent
10fa1eea
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
2 deletions
+12
-2
mmcv/image/transforms/geometry.py
mmcv/image/transforms/geometry.py
+1
-1
mmcv/version.py
mmcv/version.py
+1
-1
tests/test_image.py
tests/test_image.py
+10
-0
No files found.
mmcv/image/transforms/geometry.py
View file @
43ca0e57
...
...
@@ -180,7 +180,7 @@ def impad(img, shape, pad_val=0):
if
len
(
shape
)
<
len
(
img
.
shape
):
shape
=
shape
+
(
img
.
shape
[
-
1
],
)
assert
len
(
shape
)
==
len
(
img
.
shape
)
for
i
in
range
(
len
(
shape
)
-
1
):
for
i
in
range
(
len
(
shape
)):
assert
shape
[
i
]
>=
img
.
shape
[
i
]
pad
=
np
.
empty
(
shape
,
dtype
=
img
.
dtype
)
pad
[...]
=
pad_val
...
...
mmcv/version.py
View file @
43ca0e57
# Copyright (c) Open-MMLab. All rights reserved.
__version__
=
'0.2.1
5
'
__version__
=
'0.2.1
6
'
tests/test_image.py
View file @
43ca0e57
...
...
@@ -281,6 +281,16 @@ class TestImage(object):
self
.
assert_img_equal
(
patches
[
i
],
ref_patch
)
def
test_impad
(
self
):
# grayscale image
img
=
np
.
random
.
rand
(
10
,
10
).
astype
(
np
.
float32
)
padded_img
=
mmcv
.
impad
(
img
,
(
15
,
12
),
0
)
assert_array_equal
(
img
,
padded_img
[:
10
,
:
10
])
assert_array_equal
(
np
.
zeros
((
5
,
12
),
dtype
=
'float32'
),
padded_img
[
10
:,
:])
assert_array_equal
(
np
.
zeros
((
15
,
2
),
dtype
=
'float32'
),
padded_img
[:,
10
:])
# RGB image
img
=
np
.
random
.
rand
(
10
,
10
,
3
).
astype
(
np
.
float32
)
padded_img
=
mmcv
.
impad
(
img
,
(
15
,
12
),
0
)
assert_array_equal
(
img
,
padded_img
[:
10
,
:
10
,
:])
...
...
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