Skip to content

Commit 7b283c2

Browse files
Add error message when setting 1D tensor ToImage() (#9114)
Co-authored-by: Nicolas Hug <[email protected]>
1 parent dd1706a commit 7b283c2

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

torchvision/tv_tensors/_image.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def __new__(
4343

4444
tensor = cls._to_tensor(data, dtype=dtype, device=device, requires_grad=requires_grad)
4545
if tensor.ndim < 2:
46-
raise ValueError
46+
raise ValueError(f"Tensor must be 2D or higher, got {tensor.ndim}D tensor.")
4747
elif tensor.ndim == 2:
4848
tensor = tensor.unsqueeze(0)
4949

0 commit comments

Comments
 (0)