View more Augumented Data

In the cats /dog lesson there is some code that lets you look at a cat picture that has data Augmentation applied to it. Im trying to look at more pictures that have data augmentation applied to them but i am only able to bring up pictures of just 2 different cats. How do I look at other pictures?

The batch size specified in the function

def get_augs():
    data = ImageClassifierData.from_paths(PATH, bs=2, tfms=tfms, num_workers=1)
    x,_ = next(iter(data.aug_dl))
    return data.trn_ds.denorm(x)[1]

is 2 (bs=2). Setting it to 10 will give you 10 different cats to look at. Alternatively (and more instructively, although not necessarily more elegant) take a look at this:

def get_augs():
    data = ImageClassifierData.from_paths(PATH, bs=2, tfms=tfms, num_workers=1)
    aug_iter=iter(data.aug_dl)
    x,_ = next(aug_iter)
    x,_ = next(aug_iter)
    return data.trn_ds.denorm(x)[1]

I also recommend a look at the python documentation for iterators :wink:

1 Like

Benedict’s idea of running iter 2x is a good idea.
Even has the codes for it

aug_iter=iter(data.aug_dl)
x,_ = next(aug_iter)
x,_ = next(aug_iter)

Learn something new. Thanks!