fastai / course20

Deep Learning for Coders, 2020, the website
https://book.fast.ai
Apache License 2.0
842 stars 305 forks source link

image_cat() not defined error #55

Open sumitpowar opened 3 years ago

sumitpowar commented 3 years ago

HI,

What is image_cat() in the following code (given in lesson 1)?

img = PILImage.create(image_cat()) img.to_thumb(192)

It gives following error after running it:

**NameError Traceback (most recent call last)

in ----> 1 img = PILImage.create(image_cat()) 2 img.to_thumb(192) NameError: name 'image_cat' is not defined**
venomoustoad commented 3 years ago

make sure you import * from fastbook image_cat is a function that returns a sample cat image built into the fast.ai lib

import fastbook
fastbook.setup_book()
from fastbook import *
PO20 commented 3 years ago

thanks, venomoustoad!

I had the same issue. This one line: from fastbook import * fixes NameError mentioned by sumitpowar above:

from fastbook import *
img1 = PILImage.create(image_cat())
img1.to_thumb(192)

The course page may benefit from this modification.

Best, PO

jasondeegan commented 1 year ago

Still doesn't work. Neither does: from fastai import *

Turns out that you can corrupt a Kaggle notebook with the wrong imports. Starting from scratch and this works: ! pip install -Uqq fastbook import fastbook fastbook.setup_book() from fastbook import * img = PILImage.create(image_cat()) img.to_thumb(192)