If you want to load images from your dataset on Kaggle, you can use the ImageDataLoaders.from_folder method from the fastai library. Just give it the path to your dataset and it’ll create a DataLoaders object for you. Here’s some example code:
from fastai.vision.all import *
path = Path(‘…/input/dataset’)
data = ImageDataLoaders.from_folder(path)
Just make sure your dataset is organized into separate folders for each category and you’re good to go!
Don’t delete that, that’s much more useful than what I was doing.
Thanks for it!
After I have the Data object, how do I pass it to the DataBlock?
I do have two folders with images, so I create two Data objects pointing to each folder and then pass them to DataBlock?
If you’ve already created a DataLoaders object using the ImageDataLoaders.from_folder method, you don’t need to worry about passing it to a DataBlock . The DataBlock API is just another way to create a DataLoaders object that gives you more control over how your data is processed.
I see I see
Thank you, I will give it a try using your method as it looks more clean.
After training my model, I got terrible results. It’s not getting the categorization accurately.
What’s the process of fixing this? I suppose I will learn in other lessons, as I just started lesson 2.
1.When you run a Colab notebook and download images using code in the notebook, the images are downloaded and stored in the cloud where the Colab notebook is running(same of Kaggle nbs). They are not stored on your local computer.
2. The verify_images function is a utility function provided by the fastai library to check if a set of image files can be opened. It does this by attempting to open each image file and returning a list of files that cannot be opened.
For more information about the function you can use these tricks:
?function-name:: Shows the definition and docstring for that function
??function-name:: Shows the source code for that function
doc(function-name):: Shows the definition, docstring and links to the documentation of the function
(only works with fastai library imported)
Shift+Tab (press once):: See which parameters to pass to a function
Shift+Tab (press three times):: Get additional information on the method
4.You can identify overfitting by looking at the traning loss and validation loss,if at some point the training loss is low and the validation loss is high that means that the model is memorizing the traning that and it dosent do well on unseen data (aka overfitting).