'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 (tuple): similar to xrange, but for height.
minimum (tuple): (xmin, ymin) in pixels. To avoid scaling down too much.
aspect_ratio_thres (float): discard samples which change aspect ratio
larger than this threshold. Set to 0 to keep aspect ratio.
interp: cv2 interpolation method'

def __init__(self, xrange, yrange, minimum=(0, 0), aspect_ratio_thres=0.15, interp=cv2.INTER_LINEAR):

    super(RandomResize, self).__init__()
    assert (aspect_ratio_thres >= 0)
    if (aspect_ratio_thres == 0):
        assert (xrange == yrange)
    self._init(locals())
    def is_float(tp):
        return (isinstance(tp[0], float) or isinstance(tp[1], float))
    assert (is_float(xrange) == is_float(yrange)), 'xrange    and    yrange    has    different    type!'
    self._is_scale = is_float(xrange)
