Skip to content

Commit e159b3d

Browse files
Merge branch 'main' into main
2 parents 8368f3c + cfbc5c2 commit e159b3d

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

torchvision/models/mnasnet.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ def _load_from_state_dict(
173173
) -> None:
174174
version = local_metadata.get("version", None)
175175
if version not in [1, 2]:
176-
raise ValueError(f"version shluld be set to 1 or 2 instead of {version}")
176+
raise ValueError(f"version should be set to 1 or 2 instead of {version}")
177177

178178
if version == 1 and not self.alpha == 1.0:
179179
# In the initial version of the model (v1), stem was fixed-size.

torchvision/transforms/transforms.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,15 @@ class PILToTensor:
145145
146146
This transform does not support torchscript.
147147
148-
Converts a PIL Image (H x W x C) to a Tensor of shape (C x H x W).
148+
Convert a PIL Image with H height, W width, and C channels to a Tensor of shape (C x H x W).
149+
150+
Example:
151+
>>> from PIL import Image
152+
>>> import torchvision.transforms as T
153+
>>> img = Image.new("RGB", (320, 240)) # size (W=320, H=240)
154+
>>> tensor = T.PILToTensor()(img)
155+
>>> print(tensor.shape)
156+
torch.Size([3, 240, 320])
149157
"""
150158

151159
def __init__(self) -> None:

torchvision/transforms/v2/_type_conversion.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,15 @@ class PILToTensor(Transform):
1515
1616
This transform does not support torchscript.
1717
18-
Converts a PIL Image (H x W x C) to a Tensor of shape (C x H x W).
18+
Convert a PIL Image with H height, W width, and C channels to a Tensor of shape (C x H x W).
19+
20+
Example:
21+
>>> from PIL import Image
22+
>>> from torchvision.transforms import v2
23+
>>> img = Image.new("RGB", (320, 240)) # size (W=320, H=240)
24+
>>> tensor = v2.PILToTensor()(img)
25+
>>> print(tensor.shape)
26+
torch.Size([3, 240, 320])
1927
"""
2028

2129
_transformed_types = (PIL.Image.Image,)

0 commit comments

Comments
 (0)