问题
I have my dataset on my local device. Is there any way to upload this dataset into google colab directly.
Note:
I tried this code :
from google.colab import files
uploaded = files.upload()
But it loads file by file. I want to upload the whole dataset directly
回答1:
Here's the workflow I used to upload a zip file and create a local data directory:
- zip the file locally. Something like:
$zip -r data.zip data
upload zip file of your data directory to colab using their (Google's) instructions.
from google.colab import files uploaded = files.upload()
Once zip file is uploaded, perform the following operations:
import zipfile import io zf = zipfile.ZipFile(io.BytesIO(uploaded['data.zip']), "r") zf.extractall()
Your data directory should now be in colab's working directory under a 'data' directory.
回答2:
Another way is to store all the dataset into a numpy object and upload to drive. There you can easily retrieve it. (zipping and unzipping also fine but I faced difficulty with it)
回答3:
Zip or tar the files first, and then use tarfile or zipfile to unpack them.
来源:https://stackoverflow.com/questions/48841500/how-to-upload-my-dataset-into-google-colab