Import Image from Google Drive to Google Colab

Viewed 8664

I have mounted my Google drive to my colab notebook:

from google.colab import drive
drive.mount("/content/gdrive")

I can import csv files through it, in my case:

df = pd.read_csv("/content/gdrive/MyDrive/colab/heart-disease.csv")

But when I try to import images in markdown/text in colab nothing happens:

![](/content/gdrive/MyDrive/colab/6-step-ml-framework.png)

Here's my directory on Google drive:

Directory

2 Answers

You can using OpenCV in colab by import cv2 as cv, read image by img = cv.imread('/content/gdrive/MyDrive/colab/6-step-ml-framework.png'), convert image to numpy array using img = np.float32(img)

@Mr. For Example you should not use np.float(img), because OpenCV's method imread has converted it to np.array already

Related