Applying batch size for a vision test set for fastai v2

Hi all,

I’m having trouble setting the batch size for a vision test set in fastai v2. I’m sure it’s something obvious I’m missing, so apologies in advance.

In Fastai v1, the basic workflow was as follows:
il = ItemList.from_folder(f'path/to/image/folder', extensions=['.png'], presort=True)
learn = load_learner(f'path/to/learner', modelname.pkl, test=il) = batch_size
predictions, unknown_vector = learn.get_preds(DatasetType.Test)

However, this is the best I’ve been able to do using fastai v2:
imgs = get_image_files('path/to/images')
learn = load_learner('path/to/learner/modelname.pkl')
dl = learn.dls.test_dl(imgs)
predictions, ignored, preds_binary = learn.get_preds(dl=dl, with_decoded=True)

Which works great, but I can’t seem to set the batch size at all in this way. Can someone please clarify?

Thanks so much!

You’d set the batch size here. e.g. dl = learn.dls.test_dl(imgs, bs=128)


Perfect, thanks for that! I really appreciate it.