Loading images in google colab

后端 未结 11 1917
梦如初夏
梦如初夏 2021-01-30 15:01

My Jupyter Notebook has the following code to upload an image to Colab:

from google.colab import files
uploaded = files.upload()

I get prompted

11条回答
  •  广开言路
    2021-01-30 15:44

    Hack to upload image file in colab!

    https://colab.research.google.com/

    Following code loads image (file(s)) from local drive to colab.

    from google.colab import files
    from io import BytesIO
    from PIL import Image
    
    uploaded = files.upload()
    im = Image.open(BytesIO(uploaded['Image_file_name.jpg']))
    

    View the image in google colab notebook using following command:

    import matplotlib.pyplot as plt
    
    plt.imshow(im)
    plt.show()
    

提交回复
热议问题