title: Using image_data_generator from R keras with probabilities like Albumentations
body: <p>Albumentations (in python) has image transformations that can take a probability argument <code>p</code>, <a href="https://albumentations.ai/docs/examples/example/" rel="nofollow noreferrer">for example</a>:</p>
  <pre><code>transform = A.Compose([
          A.RandomRotate90(),
          A.Flip(),
          A.Transpose(),
          A.OneOf([
              A.IAAAdditiveGaussianNoise(),
              A.GaussNoise(),
          ], p=0.2),
          A.OneOf([
              A.MotionBlur(p=.2),
              A.MedianBlur(blur_limit=3, p=0.1),
              A.Blur(blur_limit=3, p=0.1),
          ], p=0.2),
          A.ShiftScaleRotate(shift_limit=0.0625, scale_limit=0.2, rotate_limit=45, p=0.2),
          A.OneOf([
              A.OpticalDistortion(p=0.3),
              A.GridDistortion(p=.1),
              A.IAAPiecewiseAffine(p=0.3),
          ], p=0.2),
          A.OneOf([
              A.CLAHE(clip_limit=2),
              A.IAASharpen(),
              A.IAAEmboss(),
              A.RandomBrightnessContrast(),            
          ], p=0.3),
          A.HueSaturationValue(p=0.3),
      ])
  </code></pre>
  <p>Rstudio's Keras implementation has <a href="https://tensorflow.rstudio.com/reference/keras/image_data_generator/" rel="nofollow noreferrer"><code>image_data_generator</code></a>, which has image transformations, but no probability argument.</p>
  <p>What's the easiest way to put together image transformations in Rstudio's Keras that are applied only at some level of probability?</p>
  <p>One way would be to use Albumentations in python through <a href="https://rstudio.github.io/reticulate/" rel="nofollow noreferrer">reticulate</a>, but practically speaking <a href="https://stackoverflow.com/questions/71974461/install-pythons-albumentations-in-kaggles-r-kernel">it's harder than it looks</a>.</p>
  <p>Ideas?</p>