Exemplo n.º 1
0
    def __init__(self, a, b):
        StochasticParameter.__init__(self)

        # for two ints the samples will be from range a <= x <= b
        assert isinstance(
            a, (int, StochasticParameter)
        ), "Expected a to be int or StochasticParameter, got %s" % (type(a), )
        assert isinstance(
            b, (int, StochasticParameter)
        ), "Expected b to be int or StochasticParameter, got %s" % (type(b), )

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

        if ia.is_single_integer(b):
            self.b = Deterministic(b)
        else:
            self.b = b
Exemplo n.º 2
0
def _Pool_worker(batch_idx, batch):
    assert ia.is_single_integer(batch_idx)
    assert isinstance(batch, (UnnormalizedBatch, Batch))
    assert Pool._WORKER_AUGSEQ is not None
    aug = Pool._WORKER_AUGSEQ
    if Pool._WORKER_SEED_START is not None:
        seed = Pool._WORKER_SEED_START + batch_idx
        seed_global = ia.SEED_MIN_VALUE + (seed - 10**9) % (ia.SEED_MAX_VALUE - ia.SEED_MIN_VALUE)
        seed_local = ia.SEED_MIN_VALUE + seed % (ia.SEED_MAX_VALUE - ia.SEED_MIN_VALUE)
        ia.seed(seed_global)
        aug.reseed(seed_local)
    result = aug.augment_batch(batch)
    return result
Exemplo n.º 3
0
def _Pool_worker(batch_idx, batch):
    assert ia.is_single_integer(batch_idx), (
        "Expected `batch_idx` to be an integer. Got type %s instead." %
        (type(batch_idx)))
    assert isinstance(batch, (UnnormalizedBatch, Batch)), (
        "Expected `batch` to be either an instance of "
        "`imgaug.augmentables.batches.UnnormalizedBatch` or "
        "`imgaug.augmentables.batches.Batch`. Got type %s instead." %
        (type(batch)))
    assert Pool._WORKER_AUGSEQ is not None, (
        "Expected `Pool._WORKER_AUGSEQ` to NOT be `None`. Did you manually "
        "call _Pool_worker()?")

    augseq = Pool._WORKER_AUGSEQ
    # TODO why is this if here? _WORKER_SEED_START should always be set?
    if Pool._WORKER_SEED_START is not None:
        seed = Pool._WORKER_SEED_START + batch_idx
        _reseed_global_local(seed, augseq)
    result = augseq.augment_batch(batch)
    return result