Skip to content

Commit 8d14f9a

Browse files
NicolasHugfacebook-github-bot
authored andcommitted
[fbsync] clarifying docs for v2.ToPILImage() (#7864)
Summary: (Note: this ignores all push blocking failures!) Reviewed By: matteobettini Differential Revision: D48900405 fbshipit-source-id: 4195146ac99837d55e5e38cbc78a4ef70f209138
1 parent dca5b0a commit 8d14f9a

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

torchvision/transforms/v2/_type_conversion.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,23 +44,24 @@ def _transform(
4444

4545

4646
class ToPILImage(Transform):
47-
"""[BETA] Convert a tensor or an ndarray to PIL Image - this does not scale values.
47+
"""[BETA] Convert a tensor or an ndarray to PIL Image
4848
4949
.. v2betastatus:: ToPILImage transform
5050
5151
This transform does not support torchscript.
5252
5353
Converts a torch.*Tensor of shape C x H x W or a numpy ndarray of shape
54-
H x W x C to a PIL Image while preserving the value range.
54+
H x W x C to a PIL Image while adjusting the value range depending on the ``mode``.
5555
5656
Args:
5757
mode (`PIL.Image mode`_): color space and pixel depth of input data (optional).
5858
If ``mode`` is ``None`` (default) there are some assumptions made about the input data:
59+
5960
- If the input has 4 channels, the ``mode`` is assumed to be ``RGBA``.
6061
- If the input has 3 channels, the ``mode`` is assumed to be ``RGB``.
6162
- If the input has 2 channels, the ``mode`` is assumed to be ``LA``.
6263
- If the input has 1 channel, the ``mode`` is determined by the data type (i.e ``int``, ``float``,
63-
``short``).
64+
``short``).
6465
6566
.. _PIL.Image mode: https://pillow.readthedocs.io/en/latest/handbook/concepts.html#concept-modes
6667
"""

0 commit comments

Comments
 (0)