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
685e8f99
Commit
685e8f99
authored
Sep 02, 2018
by
Kai Chen
Browse files
fix unit test for imflip
parent
1f767847
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
15 deletions
+17
-15
tests/test_image.py
tests/test_image.py
+17
-15
No files found.
tests/test_image.py
View file @
685e8f99
...
@@ -179,34 +179,36 @@ class TestImage(object):
...
@@ -179,34 +179,36 @@ class TestImage(object):
assert
resized_img
.
shape
==
(
150
,
200
,
3
)
and
scale
==
0.5
assert
resized_img
.
shape
==
(
150
,
200
,
3
)
and
scale
==
0.5
def
test_imflip
(
self
):
def
test_imflip
(
self
):
# test color image
# test
horizontal flip (
color image
)
img
=
np
.
random
.
rand
(
80
,
60
,
3
)
img
=
np
.
random
.
rand
(
80
,
60
,
3
)
h
,
w
,
c
=
img
.
shape
h
,
w
,
c
=
img
.
shape
h
f_img
=
mmcv
.
imflip
(
img
)
f
lipped
_img
=
mmcv
.
imflip
(
img
)
assert
h
f_img
.
shape
==
(
h
,
w
,
c
)
assert
f
lipped
_img
.
shape
==
img
.
shape
for
i
in
range
(
h
):
for
i
in
range
(
h
):
for
j
in
range
(
w
):
for
j
in
range
(
w
):
for
k
in
range
(
c
):
for
k
in
range
(
c
):
assert
hf_img
[
i
,
j
,
k
]
==
img
[
i
,
w
-
1
-
j
,
k
]
assert
flipped_img
[
i
,
j
,
k
]
==
img
[
i
,
w
-
1
-
j
,
k
]
hf_img
=
mmcv
.
imflip
(
img
,
direction
=
'vertical'
)
# test vertical flip (color image)
assert
hf_img
.
shape
==
(
h
,
w
,
c
)
flipped_img
=
mmcv
.
imflip
(
img
,
direction
=
'vertical'
)
assert
flipped_img
.
shape
==
img
.
shape
for
i
in
range
(
h
):
for
i
in
range
(
h
):
for
j
in
range
(
w
):
for
j
in
range
(
w
):
for
k
in
range
(
c
):
for
k
in
range
(
c
):
assert
h
f_img
[
i
,
j
,
k
]
==
self
.
img
[
h
-
1
-
i
,
j
,
k
]
assert
f
lipped
_img
[
i
,
j
,
k
]
==
img
[
h
-
1
-
i
,
j
,
k
]
# test grayscale image
# test
horizontal flip (
grayscale image
)
img
=
np
.
random
.
rand
(
80
,
60
)
img
=
np
.
random
.
rand
(
80
,
60
)
h
,
w
,
c
=
img
.
shape
h
,
w
=
img
.
shape
h
f_img
=
mmcv
.
imflip
(
img
)
f
lipped
_img
=
mmcv
.
imflip
(
img
)
assert
h
f_img
.
shape
==
(
h
,
w
,
c
)
assert
f
lipped
_img
.
shape
==
img
.
shape
for
i
in
range
(
h
):
for
i
in
range
(
h
):
for
j
in
range
(
w
):
for
j
in
range
(
w
):
assert
hf_img
[
i
,
j
,
k
]
==
img
[
i
,
w
-
1
-
j
]
assert
flipped_img
[
i
,
j
]
==
img
[
i
,
w
-
1
-
j
]
hf_img
=
mmcv
.
imflip
(
img
,
direction
=
'vertical'
)
# test vertical flip (grayscale image)
assert
hf_img
.
shape
==
(
h
,
w
,
c
)
flipped_img
=
mmcv
.
imflip
(
img
,
direction
=
'vertical'
)
assert
flipped_img
.
shape
==
img
.
shape
for
i
in
range
(
h
):
for
i
in
range
(
h
):
for
j
in
range
(
w
):
for
j
in
range
(
w
):
assert
h
f_img
[
i
,
j
,
k
]
==
self
.
img
[
h
-
1
-
i
,
j
]
assert
f
lipped
_img
[
i
,
j
]
==
img
[
h
-
1
-
i
,
j
]
def
test_imcrop
(
self
):
def
test_imcrop
(
self
):
# yapf: disable
# yapf: disable
...
...
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