Lesson 1: How to pick pics from a folder on desktop

Hello All,

After completing lesson 1, I want to create an image classifier to classify images of soccer and frisbee. I downloaded 31 images of each sport and put them in a folder on the desktop. I want to model to pick images from this folder; however, I am getting a ‘FileNotFoundError’. Please check the image below.

You’re on Colab. Your code is running on a server at Google. It doesn’t have access to your desktop. You can upload files into the runtime or map your Google drive and refer to files from there.

Either way click the folder on the left hand side near the first cell you highlighted and start there.

2 Likes

Thanks, joedockrill.

Now, I am able to upload the data using the highlighted box towards the left side of the image below.

What would be the path? I am getting an error; please check the highlighted box.

it’s in the current working directory so you don’t need a path, you can just
!unzip soccerfrisbee.zip

Did what you recommended and unzipped the files from the local folder. Refer to the pics below.

But the next 4 lines of code require path to extract annotations and images. How should I handle that? Refer to the pics below.

you’ve overcomplicated things with your folder structure. here’s what i suggest.

use my image scraper notebook to create a new dataset. run the code setup cell at the top and then use

ZIP_NAME = "soccerfrisbee.zip"

duckduckgo_search("Soccer", "people playing soccer", max_results=100)
duckduckgo_search("Frisbee", "people playing frisbee", max_results=100)

run the image cleaner and get rid of any images which don’t look suitable. zip it and transfer it to google drive or download it. when you transfer the new one in and !unzip it you’ll only have images/Soccer and images/Frisbee.

then use

data = ImageDataBunch.from_folder("images", train=".", valid_pct=0.2, ds_tfms=get_transforms(), 
                                  size=224, bs=bs).normalize(imagenet_stats)

instead of the ImageDataBunch.from_name_re line from the lesson notebook. you’ll get a validation set of 20% of the images. you don’t need a seperate test set.

1 Like

Hi joedockrill,

Thanks. I was able to run the model with the approach you suggested (scraping images from DDG and then cleaning and storing them in soccerfrisbee.zip). The efficiency I got was pretty bad but I am glad that I was able to ran the model.

Later on I replaced the pics in soccerfrisbee.zip folder with the pics that I previously downloaded. However, when I ran the model with the new pics, I got the following error message (see the image below).

Any idea how I can get around this?

I’m not sure what that error is telling you. Is the folder structure exactly the same?

Yes, exactly the same. Please see the images below.