MCPcopy Create free account
hub / github.com/OpenGVLab/HumanBench / RandomFlip

Class RandomFlip

PATH/core/data/transforms/seg_aug_dev.py:394–423  ·  view source on GitHub ↗

Flip the image horizontally or vertically with the given probability.

Source from the content-addressed store, hash-verified

392
393
394class RandomFlip(Augmentation):
395 """
396 Flip the image horizontally or vertically with the given probability.
397 """
398
399 def __init__(self, prob=0.5, *, horizontal=True, vertical=False):
400 """
401 Args:
402 prob (float): probability of flip.
403 horizontal (boolean): whether to apply horizontal flipping
404 vertical (boolean): whether to apply vertical flipping
405 """
406 super().__init__()
407
408 if horizontal and vertical:
409 raise ValueError("Cannot do both horiz and vert. Please use two Flip instead.")
410 if not horizontal and not vertical:
411 raise ValueError("At least one of horiz or vert has to be True!")
412 self._init(locals())
413
414 def get_transform(self, image):
415 h, w = image.shape[:2]
416 do = self._rand_range() < self.prob
417 if do:
418 if self.horizontal:
419 return HFlipTransform(w)
420 elif self.vertical:
421 return VFlipTransform(h)
422 else:
423 return NoOpTransform()
424
425
426class ResizeShortestEdge(Augmentation):

Callers 1

tta_mapperMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected