繁体   English   中英

在 Python Colab Google 中,如何从 DRIVE 上传(读取)一些或多个文件 (gif)

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

如何从 DRIVE 导入多个图像(大约 60 个)以便使用 Python Colab 读取它们? 我想阅读它们以便比较它们

在我的搜索中,我遵循此款待,但它仅适用于一个文件。 https://colab.research.google.com/notebooks/io.ipynb#scrollTo=XDg9OBaYqRMd

在我的尝试中,我制作了这个代码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')

切换到文件所在的目录

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

然后我处理图像,但是如何导入 60 张图像?

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) 

我很感激任何帮助,在此先感谢您

我找到了一种方法,但我的代码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)  

我感谢的任何帮助

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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