Platform: Colab (Free; $10/month Pro)

Just a note – the widgets.FileUpload() line doesn’t work for Colab (no support for ipywidgets) … so I created my own:

from google.colab import files
class GoogleColabUploader:
    def __init__(self):
        uploaded = files.upload()
        self.data = list(uploaded.keys())

To use it, just replace the widgets.FileUpload() with GoogleColabUploader
like so:

uploader = GoogleColabUploader()
uploader

It will open a button you can click to upload a file from your browser.

Caveat: it does time out so just click again on the run button for the cell
and you have to select the image on your pc before it times out.

Once uploaded, you can continue with the next cell with the PILImage.create
statement unchanged.

HTH.

7 Likes