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
98f1a409
Unverified
Commit
98f1a409
authored
Nov 10, 2022
by
Vasilis Vryniotis
Committed by
GitHub
Nov 10, 2022
Browse files
Replace `getbands()` with `get_image_num_channels()` (#6941)
parent
ffd5a567
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
2 deletions
+2
-2
torchvision/transforms/functional.py
torchvision/transforms/functional.py
+2
-2
No files found.
torchvision/transforms/functional.py
View file @
98f1a409
...
...
@@ -167,7 +167,7 @@ def to_tensor(pic) -> Tensor:
if
pic
.
mode
==
"1"
:
img
=
255
*
img
img
=
img
.
view
(
pic
.
size
[
1
],
pic
.
size
[
0
],
len
(
pi
c
.
get
bands
()
))
img
=
img
.
view
(
pic
.
size
[
1
],
pic
.
size
[
0
],
F_
pi
l
.
get
_image_num_channels
(
pic
))
# put it from HWC to CHW format
img
=
img
.
permute
((
2
,
0
,
1
)).
contiguous
()
if
isinstance
(
img
,
torch
.
ByteTensor
):
...
...
@@ -205,7 +205,7 @@ def pil_to_tensor(pic: Any) -> Tensor:
# handle PIL Image
img
=
torch
.
as_tensor
(
np
.
array
(
pic
,
copy
=
True
))
img
=
img
.
view
(
pic
.
size
[
1
],
pic
.
size
[
0
],
len
(
pi
c
.
get
bands
()
))
img
=
img
.
view
(
pic
.
size
[
1
],
pic
.
size
[
0
],
F_
pi
l
.
get
_image_num_channels
(
pic
))
# put it from HWC to CHW format
img
=
img
.
permute
((
2
,
0
,
1
))
return
img
...
...
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