I am working through the quick start example “Computer vision classification”. I have two questions.
Where are the images loaded from the following command?
dls = ImageDataLoaders.from_name_func(
path, get_image_files(path), valid_pct=0.2, seed=42,
label_func=is_cat, item_tfms=Resize(224))
The above works. No problem here.
The next step is: img = PILImage.create(‘images/cat.jpg’)
This gives me the error
“FileNotFoundError: [Errno 2] No such file or directory: ‘images/cat.jpg’”
I am obviously missing something simple here. How do I create the “images” folder?
The images are coming from the variable path which is defined earlier in the code example, e.g. path = untar_data(URLs.PETS)
Its knows to get the images because of URLs.PETS which comes from the module fastai.data.external
The provided function automatically downloads and stores them by default to your user folder at the .fastai folder. So for example on Windows it stores them here: C:\Users\<username>\.fastai\data\oxford-iiit-pet\images
The images/cat.jpg is a relative filepath so that means you would need to create your own folder called images next to your Python file you are executing and then manually place a cat.jpg file. Simply right-click and save-as on the example cat image from the quick start page (rename the file to end in .jpg) and place it in the location as needed.
Hi @Far-Cantaloupe4144
It’s been a while since you’ve asked this question, so I’m not sure if it would still be relevant.
The image folder is already created by fastai. The “Path” variable contains the path to the images file (you can print it and verify the same, and even access the images folder through your files)
But there is no file at images/cat.jpg
You could try this instead: