Extract Google Drive zip from Google colab notebook

前端 未结 12 1562
醉梦人生
醉梦人生 2020-12-25 12:29

I already have a zip of (2K images) dataset on a google drive. I have to use it in a ML training algorithm. Below Code extracts the content in a string format:



        
12条回答
  •  感情败类
    2020-12-25 13:31

    Colab research team has a notebook for helping you out.

    Still, in short, if you are dealing with a zip file, like for me it is mostly thousands of images and I want to store them in a folder within drive then do this --

    !unzip -u "/content/drive/My Drive/folder/example.zip" -d "/content/drive/My Drive/folder/NewFolder"

    -u part controls extraction only if new/necessary. It is important if suddenly you lose connection or hardware switches off.

    -d creates the directory and extracted files are stored there.

    Of course before doing this you need to mount your drive

    from google.colab import drive 
    drive.mount('/content/drive')
    

    I hope this helps! Cheers!!

提交回复
热议问题