Lesson 1 official topic

I’m getting the exact same error

I can confirm the error. This is by taking my own new copy of Jeremy’s notebook.
It seems the issue is only with version 2.7.11, adding the line two lines here to cell 2…

if iskaggle:
    !pip install -Uqq fastai duckduckgo_search
import fastai
fastai.__version__

2.7.11

It works using the following in cell 2…

if iskaggle:
    !pip install -Uqq fastai==2.7.10 duckduckgo_search
import fastai
fastai.__version__

2.7.10
If it doesn’t say 2.7.10, try a restart or factory reset.

I’m not much practiced at debugging more deeply on kaggle.
@jeremy, you may want to have a look.

4 Likes

@bencoman Thanks for the help! I used your code to switch it to 2.7.10 and can confirm that it works.

1 Like

@bencoman 's fix worked for me as well. I had to “Factory reset” the session (I’m using Kaggle) for it to take.

1 Like

I fixed it by just using bird.jpg instead of PILImage.create('bird.jpg').
So the line would be is_bird,_,probs = learn.predict('bird.jpg')
Cheers!

4 Likes

This seems to have to do with the newest version of fastai, see here Beginner: Basics of fastai, PyTorch, numpy, etc ✅ - #50 by zerotosingularity as well as some messages directly above yours in this thread

2 Likes

Thanks to @lucasvw for sharing where!

Thanks!

You must have missed the immediately preceeding post in your research…

btw, could you please edit your post so that its length doesn’t clutter the page in perpetuity.

Hello, my first day of looking at the fastai course and forums (also in bed with COVID). Stuck at the first exercise of Lesson 1, go figure…

Wondering if anyone can help please?

When I run this line:

is_cat,_,probs = learn.predict(img)

I get an error:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
/tmp/ipykernel_23/1585674285.py in <module>
      1 uploader = SimpleNamespace(data = ['/kaggle/input/images/IMG_6049.jpg'])
      2 img = PILImage.create(uploader.data[0])
----> 3 is_cat = learn.predict(img)
      4 # print(f"Is this a cat?: {is_cat}.")
      5 # print(f"Probability it's a cat: {probs[1].item():.6f}")

Copied straight from the book, so not sure what’s wrong here??
Thanks!

hey @gizzard I believe the issue is coming from line 2 due to PILImage not having a read attribute, after searching the forums for a bit, I wasn’t able to conclude on how to get the read attribute imported.

My workaround was to include the file path directly like so:
image

I’ll get back to you if I can get the read attribute to work

edit:
After searching the forum some more I found that the newest fastAI version doesn’t support PIL image being passed into the learn.predict() method anymore.

3 Likes

Following up my own post, rather than revert to 2.7.10, zerosingularity found a better solution…

3 Likes

@montanoj14 and @bencoman thanks very much for your assistance, much appreciated. All working now!

I thank you all for the assistance, as I was in need of this same bit of help.

Should I/we seek to alert JHoward (or some Fast AI person/entity) to this difficulty? It’s very early in the course, and it seems this could easily “derail” many people just getting their start.

I look forward to any replies.

Again, I thank you.

1 Like

(above - referencing the recent discussion by montanoj14, bencoman, and gizzard)

@SRS-One the bug is noted on the fastai github.

P.S. You can edit your post afterwards. By clicking the pencil button

“You must have missed the immediately preceding post in your research…”. - no shit.

I deleted my question so it does not clutter the forum in perpetuity.

1 Like

I thank you.

Is there a step by step procedure to install RISE on the Kaggle notebook? I have not been able to get the command palette button or the cell toolbar. I used:
pip install RISE as explained in RISE — RISE 5.7.1

Hi, I really hope this is the right place to ask my question.

I’m getting an error when I run the first example of the fastbook (the one that trains a model, shows an upload button, then determines whether my image is of a cat vs a dog)

  • I was able to successfully train the model
  • I was able to successfully load my image (tested that the problem was not with the upload button by showing a small thumbnail of the image I uploaded via to_thumb())
  • everytime a run
     is_cat,_,probs = learn.predict(img)
    
    The predict function throws an error :frowning:

The error starts with learn.predict and ends with:

File ~/jupyter/lib/python3.10/site-packages/PIL/Image.py:529, in Image.__getattr__(self, name)
    527     deprecate("Image categories", 10, "is_animated", plural=True)
    528     return self._category
--> 529 raise AttributeError(name)

AttributeError: read

I can post the full backtrace but it’s quite long. Any help would realy be appreciated.

Note: I’m running jupyter on my linux laptop inside a venv. Python version is 3.10.6.