简体   繁体   中英

In Python Colab Google, How to upload (read) some or several files (gif) from DRIVE

How to import several images (around 60) from DRIVE in order to read them with Python Colab?. I want to read them in order to compare them

In my search, I follow this treat but it is for just one file. https://colab.research.google.com/notebooks/io.ipynb#scrollTo=XDg9OBaYqRMd

In my try, I made this code https://colab.research.google.com/drive/1hVKMd1xdiUq4Lx4MFt-zbBH5DetaqGI7?usp=sharing

from google.colab import drive   #1/ Montar datos desde Drive, con autorizacion
drive.mount('/content/drive')

change to directory where the files are place

!cd /content/drive/My\ Drive/cursos\ imagenes/ 

and then I process the image, but how to import the 60 images?

import matplotlib.pyplot as plt
from skimage import io
from PIL import Image
#Open the image
image0 = Image.open('0.gif')
image = Image.open('20.gif')
plt.imshow(image) 

I aprecciate any help, thank you in advance

I find a way, but I got error in my code https://colab.research.google.com/drive/1hVKMd1xdiUq4Lx4MFt-zbBH5DetaqGI7?usp=sharing

 #Goal, read multiple files from Drive

# Thanks to  https://github.com/ruelj2/Google_drive

!pip install - U - q PyDrive  
import os  
os.chdir('/content/')  

# in order to clone the instruction of Google_drive
!git clone https://github.com/ruelj2/Google_drive.git  

from Google_drive.handle import *
Gd = Google_drive()  
  
#This is a Google directory link: https://drive.google.com/drive/folders/1TcMSKVAgRXZXymxfBv3WouPkauSIIpDX  
#local_file = 'path/to/local/file'
#drive_dir_ID = '1TcMSKVAgRXZXymxfBv3WouPkauSIIpDX' 

# in my case
# https://drive.google.com/drive/folders/1PTiDDildDxCvMr_rutu-xDgQxmb7bs0u

#local_file = 'path/to/local/file'
drive_dir_ID = '1PTiDDildDxCvMr_rutu-xDgQxmb7bs0u' 
drive_dir = '/content/drive/a enes/transito'

# Read all files
Gd.load_all(drive_dir, drive_dir_ID)  
#Read a single file
#Gd.load_version(local_file, drive_dir_ID)  

Any help I aprecciate

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM