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
vision
Commits
9e8258d1
Unverified
Commit
9e8258d1
authored
Jan 29, 2020
by
Francisco Massa
Committed by
GitHub
Jan 29, 2020
Browse files
Fix for rotate fill with Images of type F (#1828)
parent
30538b5d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
3 deletions
+3
-3
test/test_transforms.py
test/test_transforms.py
+1
-1
torchvision/transforms/functional.py
torchvision/transforms/functional.py
+2
-2
No files found.
test/test_transforms.py
View file @
9e8258d1
...
@@ -1078,7 +1078,7 @@ class Tester(unittest.TestCase):
...
@@ -1078,7 +1078,7 @@ class Tester(unittest.TestCase):
def
test_rotate_fill
(
self
):
def
test_rotate_fill
(
self
):
img
=
F
.
to_pil_image
(
np
.
ones
((
100
,
100
,
3
),
dtype
=
np
.
uint8
)
*
255
,
"RGB"
)
img
=
F
.
to_pil_image
(
np
.
ones
((
100
,
100
,
3
),
dtype
=
np
.
uint8
)
*
255
,
"RGB"
)
modes
=
(
"L"
,
"RGB"
)
modes
=
(
"L"
,
"RGB"
,
"F"
)
nums_bands
=
[
len
(
mode
)
for
mode
in
modes
]
nums_bands
=
[
len
(
mode
)
for
mode
in
modes
]
fill
=
127
fill
=
127
...
...
torchvision/transforms/functional.py
View file @
9e8258d1
...
@@ -725,9 +725,9 @@ def rotate(img, angle, resample=False, expand=False, center=None, fill=None):
...
@@ -725,9 +725,9 @@ def rotate(img, angle, resample=False, expand=False, center=None, fill=None):
if
fill
is
None
:
if
fill
is
None
:
fill
=
0
fill
=
0
if
isinstance
(
fill
,
(
int
,
float
)):
if
isinstance
(
fill
,
(
int
,
float
))
and
num_bands
>
1
:
fill
=
tuple
([
fill
]
*
num_bands
)
fill
=
tuple
([
fill
]
*
num_bands
)
if
len
(
fill
)
!=
num_bands
:
if
not
isinstance
(
fill
,
(
int
,
float
))
and
len
(
fill
)
!=
num_bands
:
msg
=
(
"The number of elements in 'fill' does not match the number of "
msg
=
(
"The number of elements in 'fill' does not match the number of "
"bands of the image ({} != {})"
)
"bands of the image ({} != {})"
)
raise
ValueError
(
msg
.
format
(
len
(
fill
),
num_bands
))
raise
ValueError
(
msg
.
format
(
len
(
fill
),
num_bands
))
...
...
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