Hope somone will find this helpful.
For some reason, the upload button doesn’t upload the “chapter1_cat_example.jpg” to the directory. So I manually uploaded the images to the ‘images’ directory and changed the path.
The reason the upload button doesn’t upload the file to local or colab filesystems is because FileUpload only loads the file into memory, never writing it to disk. Writing the file to disk would require additional code/libraries.
Changing ‘img = PILImage.create(‘images/chapter1_cat_example.jpg’) to ‘img = PILImage.create(‘gdrive/MyDrive/cat-1.jpg’)
In colab, the pwd (present working directory) seems to be /content. Click on the ‘Files’ tab in the left sidebar in colab to navigate the directory structure. I find that my google drive is mapped to /content/gdrive.