-
Notifications
You must be signed in to change notification settings - Fork 303
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is it possible to seed augmentations #119
Comments
Hi @ierezell, thanks for this request! We currently have a I will add this to our list of tasks to do soon, to add seed args to all augmentations that involve random sampling which don't already have it. |
It is good that |
AugLy is cool, however many transformations are not random: Here is a code snippet to make any transfomation random, (even with the random distributions you preffer): import numpy as np
import augly.image as imaugs
def random_uniform(min,max):
return lambda: np.random.uniform(min, max)
def random_normal(mean,std):
return lambda: np.random.normal(mean, std)
def randomize(fn_2_randomize, **kwargs):
def randomized_fn(img_pil):
# 1) Compute random_params into fixed_params:
fixed_args = {}
for key_paramName, value_randomFn in kwargs.items():
fixed_args[key_paramName] = value_randomFn()
# 2) Call PIL function with fixed_params
return fn_2_randomize(img_pil, **fixed_args)
return randomized_fn
random_overlay_text = randomize(imaugs.overlay_text,
x_pos=random_uniform(0,0.5),
y_pos=random_uniform(0,0.9))
# Now you can call it :)
random_overlay_text(img) |
🚀 Feature
Checked the code and it doesn't seem possible to seed the augmenters.
Motivation
To reproduce the same augmented test sets.
Also to (deterministically) augment small test sets.
Pitch
Adding the possibility to seed augmenters like
My_Augmenter(**my_params, seed=42)
which would make reproducible augmentations. Not always the same for all the batch but always in the same order in a reproducible manner.Alternatives
Don't use augmentation in the test set.
Additional context
I'm working with text, and I would like to augment a test set but the idea also apply to images and audio.
Thanks in advance and thanks a lot for this nice library !
The text was updated successfully, but these errors were encountered: