Skip to content

Commit c31c3d7

Browse files
add docs for grayscale + random grayscale transforms (#333)
* add docs for grayscale + random grayscale transforms
1 parent 627ce70 commit c31c3d7

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

docs/source/transforms.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ Transforms on PIL Image
2626

2727
.. autoclass:: RandomSizedCrop
2828

29+
.. autoclass:: Grayscale
30+
31+
.. autoclass:: RandomGrayscale
32+
2933
.. autoclass:: FiveCrop
3034

3135
.. autoclass:: TenCrop

torchvision/transforms/transforms.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -633,13 +633,14 @@ def __call__(self, img):
633633

634634
class Grayscale(object):
635635
"""Convert image to grayscale.
636+
636637
Args:
637638
num_output_channels (int): (1 or 3) number of channels desired for output image
638639
639640
Returns:
640-
PIL Image: grayscale version of the input
641-
if num_output_channels == 1 : returned image is single channel
642-
if num_output_channels == 3 : returned image is 3 channel with r == g == b
641+
PIL Image: Grayscale version of the input.
642+
- If num_output_channels == 1 : returned image is single channel
643+
- If num_output_channels == 3 : returned image is 3 channel with r == g == b
643644
644645
"""
645646

@@ -659,16 +660,15 @@ def __call__(self, img):
659660

660661
class RandomGrayscale(object):
661662
"""Randomly convert image to grayscale with a probability of p (default 0.1).
663+
662664
Args:
663665
p (float): probability that image should be converted to grayscale.
664666
665667
Returns:
666-
PIL Image: grayscale version of the input image with probability p
667-
and unchanged with probability (1-p)
668-
- if input image is 1 channel:
669-
grayscale version is 1 channel
670-
- if input image is 3 channel:
671-
grayscale version is 3 channel with r == g == b
668+
PIL Image: Grayscale version of the input image with probability p and unchanged
669+
with probability (1-p).
670+
- If input image is 1 channel: grayscale version is 1 channel
671+
- If input image is 3 channel: grayscale version is 3 channel with r == g == b
672672
673673
"""
674674

0 commit comments

Comments
 (0)