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

Method __init__

tensorpack/dataflow/imgaug/misc.py:86–115  ·  view source on GitHub ↗

Args: xrange (tuple): a (min, max) tuple. If is floating point, the tuple defines the range of scaling ratio of new width, e.g. (0.9, 1.2). If is integer, the tuple defines the range of new width in pixels, e.g. (200, 350). yrange (tup

(self, xrange, yrange=None, minimum=(0, 0), aspect_ratio_thres=0.15,
                 interp=cv2.INTER_LINEAR)

Source from the content-addressed store, hash-verified

84 """ Randomly rescale width and height of the image."""
85
86 def __init__(self, xrange, yrange=None, minimum=(0, 0), aspect_ratio_thres=0.15,
87 interp=cv2.INTER_LINEAR):
88 """
89 Args:
90 xrange (tuple): a (min, max) tuple. If is floating point, the
91 tuple defines the range of scaling ratio of new width, e.g. (0.9, 1.2).
92 If is integer, the tuple defines the range of new width in pixels, e.g. (200, 350).
93 yrange (tuple): similar to xrange, but for height. Should be None when aspect_ratio_thres==0.
94 minimum (tuple): (xmin, ymin) in pixels. To avoid scaling down too much.
95 aspect_ratio_thres (float): discard samples which change aspect ratio
96 larger than this threshold. Set to 0 to keep aspect ratio.
97 interp: cv2 interpolation method
98 """
99 super(RandomResize, self).__init__()
100 assert aspect_ratio_thres >= 0
101 self._init(locals())
102
103 def is_float(tp):
104 return isinstance(tp[0], float) or isinstance(tp[1], float)
105
106 if yrange is not None:
107 assert is_float(xrange) == is_float(yrange), "xrange and yrange has different type!"
108 self._is_scale = is_float(xrange)
109
110 if aspect_ratio_thres == 0:
111 if self._is_scale:
112 assert xrange == yrange or yrange is None
113 else:
114 if yrange is not None:
115 logger.warn("aspect_ratio_thres==0, yrange is not used!")
116
117 def get_transform(self, img):
118 cnt = 0

Callers

nothing calls this directly

Calls 2

__init__Method · 0.45
_initMethod · 0.45

Tested by

no test coverage detected