How to Import Files/Images in Google Colab from your local system?

Sarthak Agarwal
2 min readApr 22, 2020

--

Google Colab is one of the best platforms to execute deep learning tasks. While doing my assignment I found that there’s not enough source available that explains the method of uploading files/images from your local system and displaying them on the platform. Therefore, I shared the simplest approach to do the same.

  1. First, we need to import the libraries that will help us upload and display them on the notebook (in case of image)

2. After this we can run upload function from files library.

Subsequently, we can choose the relevant image/files from our local system. It will then get automatically uploaded.

3. Then we read the image using imread function from cv2 library. By default, the images are read in the form BGR( Blue Green Red). Therefore we used cvtColor function to convert it into RGB form.

Alternatively, we can also use the image library from matplotlib and used it as below. In this, we don’t need to convert the image into RGB format.

Now you can simply upload the images from your local system and display them on Google Colab.

Please give this article a clap if you liked it.Thanks!!!

--

--

Sarthak Agarwal

Data Scientist @ABNAMRO. AI enthusiast (Gen AI & LLMs) wrangling data (Python, Azure) for insights (ML, NLP). Data Science Coach