Lesson 1 official topic

Thank you! This saved me from going down a DDGS/httpx hole.

Friends I am getting error while running the below command in Kaggle Jupyter
!pip install -Uqq fastai duckduckgo_search

ERROR: Could not install packages due to an OSError: [Errno 2] No such file or directory: '/opt/conda/lib/python3.10/site-packages/nest_asyncio-1.5.8.dist-info/METADATA

Please suggest

Hi, I am getting an HttpError while running Is it a Bird? notebook. Can anyone please help resolve this issue ?

1 Like


I have created a spin-off from the bird vs. forest code that Jeremy provided.
I trained the model to detect a mouse, cat, dog, and eagle.
When I test the code using images of actual mice, cats, dogs, and eagles, it works perfectly fine.
However, when I test the model with an image of a computer, it tells me that the probability of it being a mouse is 0.9993.
Can someone explain why this is?

Thank you.

Any help or suggestion would very helpful

Hey, same problem here. :frowning:

This error crops up because the API for the duckduckgo-search library has changed slightly since the notebook was originally published.

A couple of ways to get the notebook working:
(1) Replace ddg_images with search_images_ddg from the fastbook library. This is the quickest way to get it going. The fix with a code example is originally mentioned here: Lesson 1 official topic - #608 by SergeyF
(2) Rewrite the search_images function using the updated DDGS class. Example:

from duckduckgo_search import DDGS

def search_img_urls(keywords: str, max_results: int) -> list:
    Searches DDG using the keywords string and returns a list of 
    matching image urls up to length max_results.
    with DDGS() as ddgs:
        keywords = keywords
        ddgs_images_gen = ddgs.images(
        r = [result["image"] for result in ddgs_images_gen]
    return r

Hello! I have a question

is_mario_or_luigi,_,probs = learn.predict(PILImage.create('mario.jpg'))
print(f"This is a: {is_mario_or_luigi}.")
print(f"Probability it's Mario or Luigi: {probs[0]:.4f}")
This is a: mario.
Probability it's Mario or Luigi: 0.0353

I’m confused why the probs are so low, any help?

My notebook: Google Colab

The reason is that you are retrieving the element at the 0-th index of probs, with probs[0], but the index corresponding to the prediction, which is the second value return by learn.predict, is 1:

Here is an example using your code. In the second cell, I store the second value returned by learn.predict in idx which has a value of tensor(1)—the element in probs at that index is 0.9976, which is the probability for the mario prediction.

1 Like

Thank you very much!

1 Like

Was this solved? I’m running with the same problem:(

were you able to figure this out? same issue here

were you able to figure this out?

apparently this occurs when the search does not return enough results and there is no ‘next’ item to iterate though. I reduced the number of requested queries and removed the rarer requests

Everything works fine, but if I use anything different than BIRD or FOREST, why the result is “bird”?

Trying to run this in 2024, I found I have to replace ‘pip’ in the birds notebook with ‘pip3’ or I get a lot of dependency errors. But, then I get to the next section where it tries to use ‘search_images’ to get bird photos, but it gets:

NameError: name 'ddg_images' is not defined

I can update the code for the current DDG library, but I’m just wondering whether the course is still maintained? Should I continue with it and is most of it likely to work?


Thank you very much altcee! I implemented option 1) and the notebook ran without any errors. You made my day :wink:

Thank you for charing again SergeyF! I implemented your solution and the notebook ran without any errors. You made my day :wink:

It’s hard to be sure without seeing your whole notebook. If you have downloaded all new images and retrained the models my guess would be you are still using the bird/forest folder names which are then being used as the labels input for the training.
If you are just trying to run the car image through the model without making any changes then it would be because the model has been fine-tuned to only detect birds and forests?

(also, the last print statement has bird hardcoded in the string).

Hi there,

After Lesson 1 and Lesson 2, I built a Kaiju Classifier on HuggingFace Space, in which I trained resnet18 to recognize five types of Kaiju of Monster Universe, Godzilla, King Ghidorah, King Kong, Mothra, and Rodan.

It was a fun project to me because I want to download the datasets myself using the duckduckgo function from Lesson 1 and clean the original images manually. I acutally tried to use the Cleaner function from the vision.widget and then unlink from path. But it turns out really bad given I had downloaded 300 images to each kind of Kaiju. After cleaning data, I use DataBlock of Lesson 1 to store all images and train them. And use learner export of Lesson 2 to export the learner which ultimately integrates into Gradio using HuggingFace Space.

Enjoy it and try to play it with image you downloaded. Give it a like! :heart: And tell me if you like to see other Kaiju to be added! :gorilla: :dragon: :butterfly: :robot:

Tung-Lin Wu