MCPcopy Index your code
hub / github.com/tensorpack/tensorpack / Flip

Class Flip

tensorpack/dataflow/imgaug/misc.py:14–38  ·  view source on GitHub ↗

Random flip the image either horizontally or vertically.

Source from the content-addressed store, hash-verified

12
13
14class Flip(ImageAugmentor):
15 """
16 Random flip the image either horizontally or vertically.
17 """
18 def __init__(self, horiz=False, vert=False, prob=0.5):
19 """
20 Args:
21 horiz (bool): use horizontal flip.
22 vert (bool): use vertical flip.
23 prob (float): probability of flip.
24 """
25 super(Flip, self).__init__()
26 if horiz and vert:
27 raise ValueError("Cannot do both horiz and vert. Please use two Flip instead.")
28 if not horiz and not vert:
29 raise ValueError("At least one of horiz or vert has to be True!")
30 self._init(locals())
31
32 def get_transform(self, img):
33 h, w = img.shape[:2]
34 do = self._rand_range() < self.prob
35 if not do:
36 return NoOpTransform()
37 else:
38 return FlipTransform(h, w, self.horiz)
39
40
41class Resize(ImageAugmentor):

Callers 2

_get_augsMethod · 0.85
imgaug_test.pyFile · 0.85

Calls

no outgoing calls

Tested by 1

_get_augsMethod · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…