File tree 1 file changed +17
-2
lines changed 1 file changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -266,6 +266,21 @@ def hflip(img):
266
266
return img .transpose (Image .FLIP_LEFT_RIGHT )
267
267
268
268
269
+ def vflip (img ):
270
+ """Vertically flip the given PIL.Image.
271
+
272
+ Args:
273
+ img (PIL.Image): Image to be flipped.
274
+
275
+ Returns:
276
+ PIL.Image: Vertically flipped image.
277
+ """
278
+ if not _is_pil_image (img ):
279
+ raise TypeError ('img should be PIL Image. Got {}' .format (type (img )))
280
+
281
+ return img .transpose (Image .FLIP_TOP_BOTTOM )
282
+
283
+
269
284
class Compose (object ):
270
285
"""Composes several transforms together.
271
286
@@ -548,7 +563,7 @@ def __call__(self, img):
548
563
549
564
550
565
class RandomVerticalFlip (object ):
551
- """Vertically flip the given PIL.Image randomly with a probability of 0.5"""
566
+ """Vertically flip the given PIL.Image randomly with a probability of 0.5. """
552
567
553
568
def __call__ (self , img ):
554
569
"""
@@ -559,7 +574,7 @@ def __call__(self, img):
559
574
PIL.Image: Randomly flipped image.
560
575
"""
561
576
if random .random () < 0.5 :
562
- return img . transpose ( Image . FLIP_TOP_BOTTOM )
577
+ return vflip ( img )
563
578
return img
564
579
565
580
You can’t perform that action at this time.
0 commit comments