ImageClassifierData.from_arrays() method replacement

Hello all,

I am trying to solve challenge on kaggle. I have completed my first lesson for Part 1. I see that the newer version of fastai library uses the class ImageDataBunch instead of ImageClassifierData. I want to read image data from arrays inside dataframe object similar to following:

data = ImageClassifierData.from_arrays(path=wd, 
                                   trn=(X_train, Y_train),
                                   val=(X_valid, Y_valid),
                                   tfms=tfms_from_model(arch, sz))

I am looking if someone could help me map to ImageDataBunch class. Thanks!

Me too. I need the ImageClassifierData.from_arrays equivalent in the new version. Help will be greatly appreciated.

Found the answer in course-v3’s lesson5-sgd-mnist. It is done via TensorDataset followed by DataBunch.create.

1 Like

X_train,Y_train,X_valid,Y_valid = map(torch.tensor, (x_train,y_train,x_valid,y_valid))
train_ds = TensorDataset( X_train, Y_train)
valid_ds = TensorDataset(X_valid, Y_valid)
data = DataBunch.create(train_ds, valid_ds, bs=bs)