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.
For my case, I solved by running the [29], upload jpg image and then run [30]. Do not run [16], works like a charm.
If you want to try with a different photo, rerun [29] to get rid of old photo, then upload and run [30] again.