Skip to content Skip to sidebar Skip to footer

Open Images From Google Drive Using Colab

I am coding a Image Classificator using ResNet18. Train and Test phase work fine. But as a final I want to do a evaluation with 5-10 images. The classificator give out data, targe

Solution 1:

If you will need to upload an image, you can refer to this SO post:

import cv2
import numpy as np
from matplotlib import pyplot as plt

img = cv2.imread("Sample-image.jpg")
img_cvt=cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
plt.imshow(img_cvt)
plt.show()

Use this function to upload files. It will SAVE them as well.

Solution 2:

Somthing like this

from IPython.display import Image

Image('drive/My Drive/folder/image.jpg')

Solution 3:

First you need to mount the drive. Open colab and press the mount button, as below

enter image description here

Next you will see a new directory called drive/MyDrive

enter image description here

You can read files from it using this python code.

import cv2
import matplotlib.pyplot as pltimg= cv2.imread('drive/MyDrive/test1.jpg')
plt.imshow(img)

Post a Comment for "Open Images From Google Drive Using Colab"