【问题标题】:How to unzip image folder in colab如何在colab中解压缩图像文件夹
【发布时间】:2019-12-19 19:29:29
【问题描述】:

我想在包含大约 9000 张图像的梵文数据集上训练深度学习模型。由于数据集很大,我想使用 Google colab,因为它支持 GPU。我以 Zip 格式将文件夹从本地机器上传到 Colab。但是解压文件时出错。

    from google.colab import files

uploaded = files.upload()

for fn in uploaded.keys():
  print('User uploaded file "{name}" with length {length} bytes'.format(
      name=fn, length=len(uploaded[fn])))

当我尝试跟随解压文件时

unzip devanagari-character-dataset.zip  

我有以下错误。

      File "<ipython-input-8-92b289004693>", line 1
        unzip devanagari-character-dataset.zip
                       ^

SyntaxError: invalid syntax

如何解决上述问题。

【问题讨论】:

    标签: python deep-learning


    【解决方案1】:
    import zipfile
    with zipfile.ZipFile(path_to_zip_file, 'r') as zip_ref:
        zip_ref.extractall(directory_to_extract_to)
    

    【讨论】:

    • 请在您的回答中添加一些解释
    • 答案直截了当且易于理解。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-03-09
    相关资源
    最近更新 更多