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.