from google.colab import drive
drive.mount('/gdrive')
After having mounted the drive and having copied and pasted the authentication code I can finally see my files in '/gdrive/My\ Drive/', by selecting an image in here I can actually check that:
filePath = '/gdrive/My\ Drive/img.png'
!ls -l $filePath
will return the desired file (with 600 permissions for root which I am), so I'm sure that filePath actually refers to the image I want to read. However os.path.isfile(filePath)
will return False
and cv2.imread(filePath)
will return None
.
Why? Which concept am I actually missing?
Thank you
If you are using a bash command (starting with !
) then using the backslash to escape the space is correct.
However since you are in python environment when doing cv2.imread
, you don't need to escape anymore.
Try removing the escaping backslash
filePath = '/gdrive/My Drive/img.png'
image = cv2.imread(filePath)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.