Пример #1
0
    def __init__(self, other_param, minval=None, maxval=None):
        StochasticParameter.__init__(self)

        assert isinstance(other_param, StochasticParameter)
        assert minval is None or ia.is_single_number(minval)
        assert maxval is None or ia.is_single_number(maxval)

        self.other_param = other_param
        self.minval = minval
        self.maxval = maxval
Пример #2
0
    def __init__(self, value):
        StochasticParameter.__init__(self)

        if isinstance(value, StochasticParameter):
            self.value = value.draw_sample()
        elif ia.is_single_number(value) or ia.is_string(value):
            self.value = value
        else:
            raise Exception(
                "Expected StochasticParameter object or number or string, got %s."
                % (type(value), ))
Пример #3
0
    def __init__(self, a, b):
        StochasticParameter.__init__(self)

        assert isinstance(
            a, (int, float, StochasticParameter)
        ), "Expected a to be int, float or StochasticParameter, got %s" % (
            type(a), )
        assert isinstance(
            b, (int, float, StochasticParameter)
        ), "Expected b to be int, float or StochasticParameter, got %s" % (
            type(b), )

        if ia.is_single_number(a):
            self.a = Deterministic(a)
        else:
            self.a = a

        if ia.is_single_number(b):
            self.b = Deterministic(b)
        else:
            self.b = b
Пример #4
0
    def __init__(self, p):
        StochasticParameter.__init__(self)

        if isinstance(p, StochasticParameter):
            self.p = p
        elif ia.is_single_number(p):
            assert 0 <= p <= 1.0, "Expected probability p to be in range [0.0, 1.0], got %s." % (
                p, )
            self.p = Deterministic(float(p))
        else:
            raise Exception(
                "Expected StochasticParameter or float/int value, got %s." %
                (type(p), ))
Пример #5
0
    def __init__(self, loc, scale):
        StochasticParameter.__init__(self)

        if isinstance(loc, StochasticParameter):
            self.loc = loc
        elif ia.is_single_number(loc):
            self.loc = Deterministic(loc)
        else:
            raise Exception(
                "Expected float, int or StochasticParameter as loc, got %s, %s."
                % (type(loc), ))

        if isinstance(scale, StochasticParameter):
            self.scale = scale
        elif ia.is_single_number(scale):
            assert scale >= 0, "Expected scale to be in range [0, inf) got %s (type %s)." % (
                scale, type(scale))
            self.scale = Deterministic(scale)
        else:
            raise Exception(
                "Expected float, int or StochasticParameter as scale, got %s, %s."
                % (type(scale), ))
Пример #6
0
    def __init__(self,
                 shear=(-40, 41),
                 cval=255,
                 vertical=False,
                 name=None,
                 deterministic=False,
                 random_state=None):
        """Initialize the augmentator

        # Arguments
            shear [float or tuple of 2 floats]: if it is a single number, then
                image will be sheared in that degree. If it is a tuple of 2
                numbers, then the shear value will be chosen randomly
            cval [int]: fill-in value to new pixels
        """
        super(ItalicizeLine, self).__init__(name=name,
                                            deterministic=deterministic,
                                            random_state=random_state)

        if isinstance(shear, StochasticParameter):
            self.shear = shear
        elif ia.is_single_number(shear):
            self.shear = Deterministic(shear)
        elif ia.is_iterable(shear):
            ia.do_assert(
                len(shear) == 2,
                "Expected rotate tuple/list with 2 entries, got {} entries.".
                format((len(shear))))
            ia.do_assert(all([ia.is_single_number(val) for val in shear]),
                         "Expected floats/ints in shear tuple/list.")
            self.shear = Uniform(shear[0], shear[1])
        else:
            raise Exception(
                "Expected float, int, tuple/list with 2 entries or "
                "StochasticParameter. Got {}.".format(type(shear)))

        self.cval = cval
        self.vertical = vertical
Пример #7
0
    def __init__(self,
                 angle=(-10, 10),
                 cval=255,
                 name=None,
                 deterministic=False,
                 random_state=None):
        """Initialize the augmentator

        # Arguments
            angle [float or tuple of 2 floats]: if it is a single number, then
                image will be rotated in that degree. If it is a tuple of 2
                numbers, then the angle value will be chosen randomly
            cval [int]: fill-in value to new pixels
        """
        super(RotateLine, self).__init__(name=name,
                                         deterministic=deterministic,
                                         random_state=random_state)

        if isinstance(angle, StochasticParameter):
            self.angle = angle
        elif ia.is_single_number(angle):
            self.angle = Deterministic(angle)
        elif ia.is_iterable(angle):
            ia.do_assert(
                len(angle) == 2,
                "Expected rotate tuple/list with 2 entries, got {} entries.".
                format((len(angle))))
            ia.do_assert(all([ia.is_single_number(val) for val in angle]),
                         "Expected floats/ints in angle tuple/list.")
            self.angle = Uniform(angle[0], angle[1])
        else:
            raise Exception(
                "Expected float, int, tuple/list with 2 entries or "
                "StochasticParameter. Got {}.".format(type(angle)))

        self.cval = cval