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
81e2831a
Unverified
Commit
81e2831a
authored
Feb 08, 2024
by
Adam Dangoor
Committed by
GitHub
Feb 08, 2024
Browse files
Add parameter type to `to_tensor` (#8251)
Co-authored-by:
Nicolas Hug
<
nh.nicolas.hug@gmail.com
>
parent
6a936e48
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
1 deletion
+2
-1
torchvision/transforms/functional.py
torchvision/transforms/functional.py
+2
-1
No files found.
torchvision/transforms/functional.py
View file @
81e2831a
...
@@ -8,6 +8,7 @@ from typing import Any, List, Optional, Tuple, Union
...
@@ -8,6 +8,7 @@ from typing import Any, List, Optional, Tuple, Union
import
numpy
as
np
import
numpy
as
np
import
torch
import
torch
from
PIL
import
Image
from
PIL
import
Image
from
PIL.Image
import
Image
as
PILImage
from
torch
import
Tensor
from
torch
import
Tensor
try
:
try
:
...
@@ -123,7 +124,7 @@ def _is_numpy_image(img: Any) -> bool:
...
@@ -123,7 +124,7 @@ def _is_numpy_image(img: Any) -> bool:
return
img
.
ndim
in
{
2
,
3
}
return
img
.
ndim
in
{
2
,
3
}
def
to_tensor
(
pic
)
->
Tensor
:
def
to_tensor
(
pic
:
Union
[
PILImage
,
np
.
ndarray
]
)
->
Tensor
:
"""Convert a ``PIL Image`` or ``numpy.ndarray`` to tensor.
"""Convert a ``PIL Image`` or ``numpy.ndarray`` to tensor.
This function does not support torchscript.
This function does not support torchscript.
...
...
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