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()
2 Likes

@matstudent, did you have any luck with this?

@bencoman

This worked for me on google collab.

1 Like