Skip to content

Commit 0f220d9

Browse files
NicolasHugfacebook-github-bot
authored andcommitted
[fbsync] clarifying docs for ToPILImage() (#7679)
Summary: Co-authored-by: Nicolas Hug <[email protected]> Reviewed By: vmoens Differential Revision: D47186568 fbshipit-source-id: e18b4e33bd621d4c6b38bba3f6c6c405bad35cc5
1 parent a7265b2 commit 0f220d9

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

torchvision/transforms/transforms.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -199,21 +199,21 @@ def forward(self, image):
199199

200200

201201
class ToPILImage:
202-
"""Convert a tensor or an ndarray to PIL Image - this does not scale values.
202+
"""Convert a tensor or an ndarray to PIL Image
203203
204204
This transform does not support torchscript.
205205
206206
Converts a torch.*Tensor of shape C x H x W or a numpy ndarray of shape
207-
H x W x C to a PIL Image while preserving the value range.
207+
H x W x C to a PIL Image while adjusting the value range depending on the ``mode``.
208208
209209
Args:
210210
mode (`PIL.Image mode`_): color space and pixel depth of input data (optional).
211211
If ``mode`` is ``None`` (default) there are some assumptions made about the input data:
212+
212213
- If the input has 4 channels, the ``mode`` is assumed to be ``RGBA``.
213214
- If the input has 3 channels, the ``mode`` is assumed to be ``RGB``.
214215
- If the input has 2 channels, the ``mode`` is assumed to be ``LA``.
215-
- If the input has 1 channel, the ``mode`` is determined by the data type (i.e ``int``, ``float``,
216-
``short``).
216+
- If the input has 1 channel, the ``mode`` is determined by the data type (i.e ``int``, ``float``, ``short``).
217217
218218
.. _PIL.Image mode: https://pillow.readthedocs.io/en/latest/handbook/concepts.html#concept-modes
219219
"""

0 commit comments

Comments
 (0)