Skip to content

Commit 9abf734

Browse files
committed
fix error message
1 parent 8e87214 commit 9abf734

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

test/test_transforms_v2_refactored.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5070,7 +5070,7 @@ def test_functional_and_transform(self, make_input, fn):
50705070
assert output.data_ptr() == input.data_ptr()
50715071

50725072
def test_functional_error(self):
5073-
with pytest.raises(TypeError, match="Input can either be a numpy array or a PIL image"):
5073+
with pytest.raises(TypeError, match="Input can either be a pure Tensor, a numpy array, or a PIL image"):
50745074
F.to_image(object())
50755075

50765076

torchvision/transforms/v2/functional/_type_conversion.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ def to_image(inpt: Union[torch.Tensor, PIL.Image.Image, np.ndarray]) -> tv_tenso
1717
elif isinstance(inpt, torch.Tensor):
1818
output = inpt
1919
else:
20-
raise TypeError(f"Input can either be a numpy array or a PIL image, but got {type(inpt)} instead.")
20+
raise TypeError(
21+
f"Input can either be a pure Tensor, a numpy array, or a PIL image, but got {type(inpt)} instead."
22+
)
2123
return tv_tensors.Image(output)
2224

2325

0 commit comments

Comments
 (0)