Member-only story

Shorts — FastAI V2 Batch Prediction

Subhaditya Mukherjee
1 min readAug 13, 2022

--

(Snippets from a larger article, so it is easier to find for those looking for a specific topic.)

· Code
·
Explanation
Updating the DataLoader
Monkey Patch
·
Fin

So, you trained a model and now, you want to run predictions over a lot of new images. As of today, the FastAI V2 Documentation does not talk about how to do that.

Code

Without further drama, here you go.

Explanation

So what actually happened here?

Well FastAI V1 had the ability to predict over a batch. V2 does not, yet. So we need to “monkey patch” it in.

Updating the DataLoader

To do that, we first need to add the new files to the DataLoader. We can do this in the following way.

Monkey Patch

--

--

Subhaditya Mukherjee
Subhaditya Mukherjee

Written by Subhaditya Mukherjee

My aim is to push the boundaries of what we deem possible and contribute to the community along the way.

No responses yet