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