fastai / course22

The fast.ai course notebooks
https://course.fast.ai
2.34k stars 914 forks source link

Notebook 00 Is it a bird? - ImportError: cannot import name 'ddg_images' #112

Open JLoodts opened 4 months ago

JLoodts commented 4 months ago

It seems the 1st line in the 4th cell of "00-is-it-a-bird-creating-a-model-from-your-own-data.ipynb": _from duckduckgo_search import ddgimages raises an ImportError. I tried it in Colab and in Kaggle. I found a solution from altcee: https://forums.fast.ai/t/lesson-1-official-topic/95287/623?u=jloodts who referred to SergeyF: https://forums.fast.ai/t/lesson-1-official-topic/95287/608?u=jloodts I added fastbook to the !pip install line and overwrote the _searchimages function with _def search_images(term, max_images=30): print(f"Searching for '{term}'") return search_images_ddg(term, max_images=maximages) After that the entire notebook ran without any errors. Since I am a newbee in all this, I don't know how to propose this code-change myself, but I would certainly want to learn as to keep this wonderfull fastai course notebooks working for all the other students to come. Especially now since Jeremy and co are focussing on Answer.AI.

deedy5 commented 4 months ago

Step 1: Download images of birds and non-birds

#Skip this cell if you already have duckduckgo_search installed
!pip install -Uqq duckduckgo_search

from duckduckgo_search import DDGS
from fastcore.all import *

def search_images(term, max_images=200): return L(DDGS().images(term, max_results=max_images)).itemgot('image')