fastai.dataset.ImageClassifierData.from_paths without transformations?

Preamble/disclaimer: I am not a seasoned Python coder. The following serves to show that.

When I try to create a data object for my ConvLearner model like this:
data1608 = fastai.dataset.ImageClassifierData.from_paths(PATH)
without any tfms transformations, I get errors like these:

~/fastai/courses/dl1/fastai/ in get_sz(self)
    142         super().__init__(transform)
    143     def get_n(self): return len(self.y)
--> 144     def get_sz(self): return
    145     def get_x(self, i): return open_image(os.path.join(self.path, self.fnames[i]))

AttributeError: 'NoneType' object has no attribute 'sz'

Putting the tfms=tfms argument back in resolves this.

Here’s my confusion;
The signature in .from_paths() says that the default value for tfms is (None, None) which suggests to me that it can be omitted during initialization of the object.

Signature: fastai.dataset.ImageClassifierData.from_paths(path, bs=64, tfms=(None, None), trn_name='train', val_name='valid', test_name=None, num_workers=8)

Am I misinterpreting this?

In short: is the transformations argument required and must it refer to a proper fastai.transforms.tfms_from_model(arch, sz) object ?

1 Like

You need to use transforms even if you are not doing data augmentation.
Here is the most basic example

data = ImageClassifierData.from_paths(PATH, tfms=tfms_from_model(arch, sz))
learn = ConvLearner.pretrained(arch, data, precompute=True), 3)

1 Like

Thanks yinterian. That confirms I am trying to do something that I am not supposed to. The whole reason for me to try using a transformation-less data object is to learn the fastai library.
So allow me a follow-up question: why?
Why do I need transforms if not for data augmentation? Is it because the training images all have dimensions that do not conform to the sz * sz format? Is this the way to inform pytorch how to pre-condition my data?

1 Like

Just found a duplicate post here:

and also the answer to my question:

So thanks again @yinterian !