Closed LukeWood closed 2 years ago
I think that we need to think about this evaluating what we want to achieve at https://github.com/keras-team/keras-cv/issues/41#issuecomment-1024588287
Randomise(layer, p=0.5) RandomiseApply(layer, p=0.5) RandomCall(layer, p=0.5)
@LukeWood @bhack @qlzh727 @kartik4949
I think two types of functions need to be addressed regarding the processing layers. For examples:
random_mixup = RandomApply(Mixup(), prob = 0.5)
random_cutmix = RandomApply(CutMix(), prob = 0.5)
random_equliz = RandomApply(Equalization(), prob = 0.5)
random_mixup = RandomApply(Mixup(), prob = 0.5)
random_cutmix = RandomApply(CutMix(), prob = 0.5)
random_blur = RandomPick(
[
RandomApply(GaussianBlur(), prob = 0.5),
RandomApply(MotionBlur(), prob = 0.5),
RandomApply(MediamBlur(), prob = 0.5)
],
prob = 0.8
)
@innat I think by RandomPick you mean RandAug in defined space!
It's like the OneOf
method that is provided in argumentation (cell 7) or img_aug libraries.
I think that we need to reason a little bit more in general about what kind of access to the augmentation layers an auto augmentation policy need to achieve.
Then I suppose we could think at RandomApply
as just one of the simplest policy.
I don't know if @haifeng-jin has any feedback.
Just a reminder, we had also: https://github.com/keras-team/autokeras/issues/879 https://autokeras.com/block/#imageaugmentation
We've decided to include a rate
argument in a base augmentation layer. This provides the best user API imo:
RandomRotation(rate=0.5)
instead of:
MaybeApply(RandomRotation(), 0.5)
Scott is working on this in his base augmentation layer.
@LukeWood instead of giving its name as rate
, how about prob
?
@LukeWood @bhack @qlzh727 @kartik4949
I think two types of functions need to be addressed regarding the processing layers. For examples:
- Randomly apply the layer
random_mixup = RandomApply(Mixup(), prob = 0.5) random_cutmix = RandomApply(CutMix(), prob = 0.5) random_equliz = RandomApply(Equalization(), prob = 0.5)
- Randomly pick a layers
random_mixup = RandomApply(Mixup(), prob = 0.5) random_cutmix = RandomApply(CutMix(), prob = 0.5) random_blur = RandomPick( [ RandomApply(GaussianBlur(), prob = 0.5), RandomApply(MotionBlur(), prob = 0.5), RandomApply(MediamBlur(), prob = 0.5) ], prob = 0.8 )
@qlzh727 what do you think about the above issue (no. 2). ?
we went back and forth on probability
and rate
and picked rate`. No 2. seems like something I may implement during RandAugment, but I don't think we should offer it until there is a need.
@LukeWood There is a need for no. 2 in practice. What sort of details do you think need to clarify this?
Historically, this is the sort of thing that isn't included in the Keras API and is delegated to users. This is pretty trivial to implement:
class RandomChoice():
def __init__(self, layers):
self.layers = layers
self.n = len(layers)
def call(self, inputs):
return layers[tf.random.choice(range(self.n))](inputs)
with some tensorflow-friendly changes takes care of it.
If we're already using this internally I don't see an issue with exposing it, but I don't particularly think it's a big value add to support is all.
I still hope that we could work more in general with augmentation policy classes or that we could actively coordinate with autokeras (If It Is still an active project)
@LukeWood
What you're referring trivial to implement, in the breath, you can also say that implementing rate
is also trivial to implement to end-users. The feature request in no. 2 is not actually a random request. It's followed in practice.
If you see other popular augmentation libraries, for example, img_aug
and albumentation
, all of them offers such feature to users. In addition, if you see the torch-vision
, you would find the same. In torch
, you can use RandomChoice
to apply a single transformation randomly picked from a list with a given probability. If this info motivates you, please reconsider the request.
Maybe this will look like:
or maybe:
Either way, this is important for the composition of image augmentation pipelines.