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
256495fe
Commit
256495fe
authored
Sep 26, 2017
by
Sasank Chilamkurthy
Browse files
VerticalFlip converted to follow refactor #240
parent
fbe4ad58
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
2 deletions
+17
-2
torchvision/transforms.py
torchvision/transforms.py
+17
-2
No files found.
torchvision/transforms.py
View file @
256495fe
...
...
@@ -266,6 +266,21 @@ def hflip(img):
return
img
.
transpose
(
Image
.
FLIP_LEFT_RIGHT
)
def
vflip
(
img
):
"""Vertically flip the given PIL.Image.
Args:
img (PIL.Image): Image to be flipped.
Returns:
PIL.Image: Vertically flipped image.
"""
if
not
_is_pil_image
(
img
):
raise
TypeError
(
'img should be PIL Image. Got {}'
.
format
(
type
(
img
)))
return
img
.
transpose
(
Image
.
FLIP_TOP_BOTTOM
)
class
Compose
(
object
):
"""Composes several transforms together.
...
...
@@ -548,7 +563,7 @@ class RandomHorizontalFlip(object):
class
RandomVerticalFlip
(
object
):
"""Vertically flip the given PIL.Image randomly with a probability of 0.5"""
"""Vertically flip the given PIL.Image randomly with a probability of 0.5
.
"""
def
__call__
(
self
,
img
):
"""
...
...
@@ -559,7 +574,7 @@ class RandomVerticalFlip(object):
PIL.Image: Randomly flipped image.
"""
if
random
.
random
()
<
0.5
:
return
img
.
transpose
(
Image
.
FLIP_TOP_BOTTOM
)
return
vflip
(
img
)
return
img
...
...
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