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).
I’m currently going through the is it a bird? notebook on Kaggle, but I ran into an error.
from duckduckgo_search import ddg_images
from fastcore.all import *
def search_images(term, max_images=30):
print(f"Searching for '{term}'")
return L(ddg_images(term, max_results=max_images)).itemgot('image')
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
/tmp/ipykernel_17/1717929076.py in <module>
----> 1 from duckduckgo_search import ddg_images
2 from fastcore.all import *
3
4 def search_images(term, max_images=30):
5 print(f"Searching for '{term}'")
/opt/conda/lib/python3.7/site-packages/duckduckgo_search/__init__.py in <module>
8
9 # isort: off
---> 10 from .compat import (
11 ddg,
12 ddg_answers,
/opt/conda/lib/python3.7/site-packages/duckduckgo_search/compat.py in <module>
2 import warnings
3
----> 4 from .duckduckgo_search import DDGS
5
6 logger = logging.getLogger(__name__)
/opt/conda/lib/python3.7/site-packages/duckduckgo_search/duckduckgo_search.py in <module>
11
12 import requests
---> 13 from requests.exceptions import HTTPError, JSONDecodeError, Timeout
14 from requests.models import Response
15
ImportError: cannot import name 'JSONDecodeError' from 'requests.exceptions' (/opt/conda/lib/python3.7/site-packages/requests/exceptions.py)
It looks like an error from the duckduckgo_search package, but is it because the code is out of date? What else can I use instead? Is there a latest version of the code maybe?
Thank you that one was solved. Got a new one though.
download_url(search_images_ddg(‘forest photos’, max_images=1)[0], ‘forest.jpg’, show_progress=False)
Image.open(‘forest.jpg’).to_thumb(256,256)
When I run learn.fine_tune(3) in the notebooks or in iPython, I don’t get any tables returned with the training log. Can anyone suggest why this is happening and how I could fix it?
I’ve tried the following:
running the cell as-is in the given notebook (no changes)
using a rewritten notebook and python file
rerouting the stdout to a text file, and there was nothing there
For all, there’s no output. Can anyone suggest why this is happening and how I could fix it?