I was running lesson1 of fast.ai in google-colab. When I came to the line
img = plt.imread(f'{PATH}valid/cats/{files[0]}')
plt.imshow(img);
It didn't show an image. Instead I got an error:
AttributeError: module 'PIL.Image' has no attribute 'register_extensions'
What could be causing this?
I was on Google Colab when I encountered this issue.
After the code to install torch
, add:
!pip install pillow==4.1.1
%reload_ext autoreload
%autoreload
The %autoreload
will reload all modules so no kernel restart is required.
Credit goes to this forum post.
For me restarting the runtime using “Runtime / Restart runtime…” from the menu after installing the newer Pillow using pip and running the code that uses it fixed the issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With