ImageDataBunch doesn't raise a TypeError when invalid arguments are passed

I had a small typo in the arguments passed to ImageDataBunch.from_name_re , that line executed perfectly but an error was raised while normalizing the dataset. Then I checked and found the typo. It would be really useful to check the passed arguments and raise a TypeError if the passed argument is invalid.

This function accepts any random argument passed to it. For example, the following line of code executes without any error.

data = ImageDataBunch.from_name_re(path_img, fnames, pat, xyz=45, pqr=678, ds_tfms=get_transforms(), size=299,bs=48)

Yes, your data line will rarely raise an error, it’s when you try to access the datasets that it will actually realize something is wrong. A quick test I often do is data.train_ds[0] to check how my input is treated.

Thanks for the tip @sgugger

Sadly checking python types is a mess at the moment. It might be some years before that actually works smoothly.