augraphy icon indicating copy to clipboard operation
augraphy copied to clipboard

Randomness for pipeline arguments in example usage

Open SunQpark opened this issue 3 years ago • 1 comments

In example usage section of documentation, I noticed some functions use random function to set arguments randomly.

BleedThrough(
    intensity_range=(0.1, 0.3),
    color_range=(32, 224),
    ksize=(17, 17),
    sigmaX=1,
    alpha=random.uniform(0.1, 0.2),
    offsets=(10, 20),
)

I noticed this random.uniform function(or other random functions) is being called only once initializing BleedThrough class object, which is then passed to AugraphyPipeline, so that the augmentation pipeline is initialized with the already fixed parameter(result of random.uniform) and there is no more randomness being involved after that. I think this kind of sampling should be done in the class definition internally, or example code should just generate multiple instances of transform with different random arguments and selected with OneOf.

SunQpark avatar Sep 23 '22 01:09 SunQpark

Thanks, i will change this in the next update. As a workaround for now, you will need to initialize a same pipeline each time you run a new image to get the randomize effect.

kwcckw avatar Sep 23 '22 01:09 kwcckw

With the latest update, now you can set random_seed in augmentation pipeline to produce a consistent output. You may uninstall Augraphy and reinstall it by using !pip install git+https://github.com/sparkfish/augraphy.

kwcckw avatar Nov 15 '22 08:11 kwcckw