Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
vision
Commits
c31c3d7e
Unverified
Commit
c31c3d7e
authored
Nov 17, 2017
by
Alykhan Tejani
Committed by
GitHub
Nov 17, 2017
Browse files
add docs for grayscale + random grayscale transforms (#333)
* add docs for grayscale + random grayscale transforms
parent
627ce703
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
9 deletions
+13
-9
docs/source/transforms.rst
docs/source/transforms.rst
+4
-0
torchvision/transforms/transforms.py
torchvision/transforms/transforms.py
+9
-9
No files found.
docs/source/transforms.rst
View file @
c31c3d7e
...
@@ -26,6 +26,10 @@ Transforms on PIL Image
...
@@ -26,6 +26,10 @@ Transforms on PIL Image
.. autoclass:: RandomSizedCrop
.. autoclass:: RandomSizedCrop
.. autoclass:: Grayscale
.. autoclass:: RandomGrayscale
.. autoclass:: FiveCrop
.. autoclass:: FiveCrop
.. autoclass:: TenCrop
.. autoclass:: TenCrop
...
...
torchvision/transforms/transforms.py
View file @
c31c3d7e
...
@@ -633,13 +633,14 @@ class RandomRotation(object):
...
@@ -633,13 +633,14 @@ class RandomRotation(object):
class
Grayscale
(
object
):
class
Grayscale
(
object
):
"""Convert image to grayscale.
"""Convert image to grayscale.
Args:
Args:
num_output_channels (int): (1 or 3) number of channels desired for output image
num_output_channels (int): (1 or 3) number of channels desired for output image
Returns:
Returns:
PIL Image:
g
rayscale version of the input
PIL Image:
G
rayscale version of the input
.
i
f num_output_channels == 1 : returned image is single channel
- I
f num_output_channels == 1 : returned image is single channel
i
f num_output_channels == 3 : returned image is 3 channel with r == g == b
- I
f num_output_channels == 3 : returned image is 3 channel with r == g == b
"""
"""
...
@@ -659,16 +660,15 @@ class Grayscale(object):
...
@@ -659,16 +660,15 @@ class Grayscale(object):
class
RandomGrayscale
(
object
):
class
RandomGrayscale
(
object
):
"""Randomly convert image to grayscale with a probability of p (default 0.1).
"""Randomly convert image to grayscale with a probability of p (default 0.1).
Args:
Args:
p (float): probability that image should be converted to grayscale.
p (float): probability that image should be converted to grayscale.
Returns:
Returns:
PIL Image: grayscale version of the input image with probability p
PIL Image: Grayscale version of the input image with probability p and unchanged
and unchanged with probability (1-p)
with probability (1-p).
- if input image is 1 channel:
- If input image is 1 channel: grayscale version is 1 channel
grayscale version is 1 channel
- If input image is 3 channel: grayscale version is 3 channel with r == g == b
- if input image is 3 channel:
grayscale version is 3 channel with r == g == b
"""
"""
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment