Preprocessing a whole image dataset

I was looking around but couldn’t find anything on easily processing a whole dataset prior to training a model with I have a 30GB image dataset on which I wanna apply some of the transformations like zoom, rotate, etc. and resize them to 224. In the normal datablock api this is done on the fly, but I’m bottlenecked by CPU power so I wanna do it once and then omit from the training.

What would be the easiest way to approach this?

I kinda figured it out using some of the examples in the documentation.

def transform_image(path):
    d = open_image(path).apply_tfms(tfms[0])
    p = Path(path)
    target_path = '/'.join([:2]) + '/data_transformed/' + '/'.join([3:])
    if not os.path.exists('/'.join(target_path.split('/')[:-1])):

from joblib import Parallel, delayed

items = ImageList.from_folder(path='../../data').items
Parallel(n_jobs=8)(delayed(transform_image)(i) for i in tqdm(items))

Which works quite nice and is efficient.