Augmenting a small training sample with aug_transform

I’m trying to train an image classifier to be able to identify my vinyl records by looking at the cover art. Given that the artwork is quite distinct, I’m interested to see what kind of results I can get with a relatively small sample for each record e.g 5-20 photos.

Given that I will always be trying to classify photos of the same artwork, I thought that using some augmentations such as cropping, rotations, lighting, and warping would be able to beef up this small training sample. But I’m having a couple of issues that I could do with some advice on:

  1. Using the DataBlock.dataloaders method with such a small training sample, I’ve been fiddling with the bs argument as the default is 64, and I don’t have that many images. How does changing the batch size affect training, and what would you recommend for a small training sample?

  2. How exactly do the following arguments to work:

  • item_tfms=RandomResizedCrop(224, min_scale=0.5),
  • batch_tfms=aug_transforms())
    It is my understand that they are applied randomly each epoch. I would like to apply a variety of transforms to essentially obtain larger training sample than I have. Will training a large number of epochs give me the results I want, or do I need to apply the augmentations first, then train on the variety of augmented images?

If you want to create a larger dataset, you would have to actually save the augmented images to your folder of images. But I would be very careful, since you don’t want to have the original image in the train set and an augmented image in the validation set.

If you just keep the augmentations, then in each epoch, the network sees a slightly different augmented version of the image and it will likely never see the same augmented image. So it’s probably fine to also just train longer. But I would experiment with both, being careful to keep the same validation set perhaps.

Honestly, I would recommend collecting more data if possible.

1 Like