NameError: name 'DataBunch' is not defined

Hi,

I want to use the DataBunch.create() method to create a DataBunch with custom PyTorch Datasets, like it is explained here. But the problem is, I can’t import DataBunch. I tried the following import statements:

from fastai import *
from fastai.vision.all import *

What am I doing wrong?

DataBunch is not a part of fastai now. You are looking at old documentation for the old library. You need to do

pip install fastai==1.6.1 as that’s the last version of fastai with that library

Thanks for your reply! I found that the solution is to use DataLoaders rather than DataBunch using fastai2, right? So for example I can use the from_dsets method to load my custom PyTorch DataSet in fastai’s DataLoader, like so:

dls = DataLoaders.from_dsets(train_ds, valid_ds)

You should follow the torch migration guide: https://docs.fast.ai/migrating_pytorch.html