【发布时间】:2020-12-30 05:44:15
【问题描述】:
我一直在使用 Google Colab 编写我的 Python 脚本,到目前为止它使用“仅代码”非常舒适
我想开始处理图像,我正在寻找一个包含一百个或更多图像的脚本,但不确定在 Colab 中执行此操作的可接受方法是什么,因为“没有本地驱动器”
原码:
import cv2 as cv
import glob
def get_imgs(path_to_imgs):
all_files = glob.glob(path_to_imgs + "**/*.png")
return ( cv.imread(file, flags=cv.IMREAD_GRAYSCALE) for file in all_files)
def show_img(img):
cv.imshow('window_name', img)
cv.waitKey(0)
cv.destroyAllWindows()
for each_img in get_imgs('./myImages/'):
if counter == 10:
break
show_img(each_img)
到目前为止,我已经考虑将所有图像存储在自己的驱动器上(并使用访问密钥将 Colab 连接到驱动器,有点不舒服)或将它们存储在 raw-github 上。
在这两种情况下,我都无法使其在构造函数中工作,我认为主要是因为我无法像在本地那样通过“文件夹”。
有什么想法和建议吗?
【问题讨论】:
标签: python image-processing google-colaboratory