python - 如何在colab中解压图片文件夹

标签 python deep-learning

我想在包含大约 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

如何解决上述问题。

最佳答案

import zipfile
with zipfile.ZipFile(path_to_zip_file, 'r') as zip_ref:
    zip_ref.extractall(directory_to_extract_to)

关于python - 如何在colab中解压图片文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59408524/

相关文章:

python - 如何跟踪使用 CPU 与 GPU 进行深度学习的时间?

python - 有没有办法在执行连接操作时证明子字符串的合理性

python - 为什么我不能使用 transforms.ifft2?

python - 回溯排列列表

machine-learning - 如何在 Caffe 中检索图层

python - LSTM-Keras 错误 : ValueError: non-broadcastable output operand with shape (67704, 1) 与广播形状不匹配 (67704,12)

machine-learning - CNN 中部分连接卷积层

tensorflow - 如何在keras中堆叠多个lstm?

python - 我怎样才能告诉 PyCharm 参数应该是什么类型?

python - Pandas Dataframe 自动类型转换