We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
to_tensor
1 parent 6a936e4 commit 81e2831Copy full SHA for 81e2831
1 file changed
torchvision/transforms/functional.py
@@ -8,6 +8,7 @@
8
import numpy as np
9
import torch
10
from PIL import Image
11
+from PIL.Image import Image as PILImage
12
from torch import Tensor
13
14
try:
@@ -123,7 +124,7 @@ def _is_numpy_image(img: Any) -> bool:
123
124
return img.ndim in {2, 3}
125
126
-def to_tensor(pic) -> Tensor:
127
+def to_tensor(pic: Union[PILImage, np.ndarray]) -> Tensor:
128
"""Convert a ``PIL Image`` or ``numpy.ndarray`` to tensor.
129
This function does not support torchscript.
130
0 commit comments