Data Augmentation (xtra_tfms)

I am playing around with the xtra_tfms and i have trouble implementing some of them for my data augmentation.

Contrast for example (https://docs.fast.ai/vision.transform.html#_contrast).
I have tried a couple of different inputs, but i always end up getting errors that something is wrong with my data. Ive read through the doc multiple times, but i simply do not understand the syntax the hyperparameters should be written in. Can someone maybe give me a working example of a contrast on a scale from 0.5 to 1.5?

1 Like

I’ve got contrast working fine, did you put tfms as a list?

Other examples you can find: https://alexiej.github.io/deepnn/#fast-ai-data-augmentation

from fastai import*
from fastai.vision import *

path = untar_data(URLs.PETS);
path_img = path/'images'
fnames = get_image_files(path_img)

def plots_f(image,tfms, rows=1, cols=5, width=12,height=6, **kwargs):
    [image.apply_tfms(tfms, **kwargs).show(ax=ax) 
     for i,ax in enumerate(
         plt.subplots(rows, cols,
                      figsize=(width,height))[1].flatten())]
    
im = open_image(fnames[184])

tfms = [contrast(scale=(0.1,2.0),p=0.9)]
plots_f(im,tfms[0])
tfms

3 Likes

this is exactly the help i was looking for, its now working for me aswell, the list wasnt the problem i misunderstood what log_uniform is.

1 Like