Python 如何在colab中解压缩图像文件夹
我想在包含9000张左右图像的Devanagari数据集上训练一个深度学习模型。由于数据集很大,我想使用Google colab,因为它支持GPU。我以Zip格式将文件夹从本地机器上传到colab。但解压缩文件时出错。Python 如何在colab中解压缩图像文件夹,python,deep-learning,Python,Deep Learning,我想在包含9000张左右图像的Devanagari数据集上训练一个深度学习模型。由于数据集很大,我想使用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 {
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])))
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)
当我尝试按以下步骤解压文件时
unzip devanagari-character-dataset.zip
我有以下错误。
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])))
File "<ipython-input-8-92b289004693>", line 1
unzip devanagari-character-dataset.zip
^
SyntaxError: invalid syntax
文件“”,第1行
解压缩devanagari-character-dataset.zip
^
SyntaxError:无效语法
如何解决上述问题。请在回答中添加一些解释。答案是直截了当的,并且可以理解。
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])))
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)