Image_cat is not defined

I am new in fast ai

At first, I was getting error saying that widgets is not defined. Then I used the following code

!pip install ipywidgets
from ipywidgets import *

Then it worked. After that I was fgetting error:

image_cat is not defined.
Please let me know what should I do?

I’d like to help and encourage you to keep at it, but its very hard to guess which code you are referring to. Please follow the advice here in the section “Before You Ask” .

One tip: With your searches put your error message inside quotes.
e.g. fastai "image_cat is not defined"
Let me know what you find out.

I got the same problem when trying the notebook 01_intro.ipynb in the course Deep Learning for Coders. I assume this question should be posted in the forum Deep Learning instead.

Maybe an admin can move the thread?

Code cell:

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

Output;

---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
Input In [3], in <cell line: 1>()
----> 1 img = PILImage.create(image_cat())
      2 img.to_thumb(192)

NameError: name 'image_cat' is not defined

Update:
I’m using the course on Paperspace named Paperspace + Fast.AI 07/16/2022 and it turns out ipywidgets can’t run there, which causes the problem.

The code cell quoted above also seems to be a dummy cell of sorts only to show how the authors display a cat image on their side. The actual uploader using the widget is below in the notebook.

But you can open the the notebook in JupyterLabs from Paperspace clicking on the last icon to the leftmost when viewing it on Paperspace. I found the solution in an issue about this on github.com/fastai.

Just one thing to try. The first cell where it conditionally updates fastbook.

! [ -e /content ] && pip install -Uqq fastbook
import fastbook
fastbook.setup_book()

Remove the condition so it forces an a update. i.e…

!pip install -Uqq fastbook
import fastbook
fastbook.setup_book()
1 Like

@matstudent, did you have any luck with this?

@bencoman

This worked for me on google collab.

1 Like