Lesson 2: getting error with creating ImageDataBunch from_folder

how you solved it?? i am getting this error till now and don’t really know how to solve it

can you provide me with any code or something…bcoz i am still getting this error.

np.random.seed(2)
pat = r’/([^/]+)_\d+.jpg$’
ds_tfms=get_transforms()
data = ImageDataBunch.from_name_re(path_img, fnames, pat, size=224, bs=bs).normalize(imagenet_stats)
data.show_batch(rows=3, figsize=(7,6))

it is working fine for from_name_re but the problem is with from_folder.

This is the command I use to install Pytorch, all I did was add the version number to the command.

conda config --set ssl_verify no && conda install -y -c pytorch pytorch=1.4.0 torchvision cuda92

torch version 1.4.0 requires torchvision version 0.5.0
Therefore, if you install using pip, the command should be:

pip install "torch==1.4" "torchvision==0.5.0"

5 Likes

Thank you so much @mattbriancon. I was stuck with this issue for a day or two and finally focused and found your advice. It worked out great.

I use Google Colab and have the same error. Adding this in the begining fix the problem for me, thank you.

1 Like

Best Reply, thank you

1 Like

i am using kaggle kernel. what can i do in kaggle or in colab?

FWIW, your code only “fixes” it because you’ve stopped passing the transforms to ImageDataBunch.from_name_re. I suspect that if you start passing it again, you’ll still get the error.

data = ImageDataBunch.from_name_re(
    path_img, 
    fnames, 
    pat, 
    size=224, 
    bs=bs, 
    ds_tfms=ds_tfms,  # <------
).normalize(imagenet_stats)

Admittedly, I have no idea what transforms are returned from get_transforms() or what they do but I’m guessing they’re important enough that you don’t want to leave them out.

You Sir, are a star!! Thank you.
My Colab training now uses image augmentation - yaaaaay!
Thank you very much.

Is this because there is a change in fastai repo?

https://anaconda.org/pytorch/pytorch had a new release on 2020-04-22 that was impacting me because I was just taking the latest version.

I am sure once the new version of fastai is out the requirement of using PyTorch 1.4.0 will be no longer needed.

1 Like

there are no torch==1.4 version

no torch==1.4

You may need to add the ‘0’ at the end.

For example:
pip install torch==1.0.0 torchvision==0.2.1

I have never used the Kaggle or Colab systems.

I use g4n.xlarge instances from AWS on spot pricing for $0.1588 an hour and only run them for when I’m working on the model.

All other time I spend on my localhost with writing code and collecting datasets.

how much it cost you(average) for a month?

I’m spending about USD $10 or so a month.

I spend about 5 hours each time I spin an instance and do this 2-3 times a week.

So about 15 hours a week, and than data transfer and what not, gets me to about that USD $10.

I also use S3 for backups of my computers so there’s a bunch of that in there as well.

Looking up my current bill for May 2020 here are my details:
g4dn.xlarge Linux/UNIX Spot Instance-hour in US East (N. Virginia) in VPC Zone #7 - 33.591 Hrs - $5.30

There is also some EBS but it’s less than a dollar.