Quick Start Tutorial - Cat's image not found

I am working through the quick start example “Computer vision classification”. I have two questions.

  1. 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.

  2. 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?

Thank you in advance.

Hi @Far-Cantaloupe4144:

  1. 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
  2. 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.

Let me know if that helps!

Thank you for the guidance. I had stumbled upon the second point. The first part is instructive. Thanks again.

Just wondering if there is a diagram to understand class hierarchy rather than mentally constructing it by looking at code or documents.