Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Access to local folder with Colab

I want to make a deep learning system on Colab. My data are stored in a local folder on my laptop but I don't know how to acceed it.

When I do this, it gives me an error :

import os
output = [dI for dI in os.listdir(main_folder) if os.path.isdir(os.path.join(main_folder,dI))]
print (output)

[Errno 2] No such file or directory:

main_folder is a local path : C:/.../.../

like image 798
MysteryGuy Avatar asked Sep 27 '18 15:09

MysteryGuy


People also ask

Can Google colab access local folders?

Colaboratory lets you connect to a local runtime using Jupyter. This allows you to execute code on your local hardware and have access to your local file system.

How do I open a folder in Colab?

The following steps: Open Google Drive in your browser, go to the notebook (ipynb) file in your repo (sub)folder; Right-click the file and select 'Open with Google Colaboratory', now Colab opens with the notebook; For this you might have to install the 'Open in Colab' chrome extension.


1 Answers

One option to access local files is to use Colab with a local install of Jupyter. Instructions to do that are here:

http://research.google.com/colaboratory/local-runtimes.html

Another option is to install Google Drive on your local machine, put the files there, and then mount your Drive files on Colab using the following snippet:

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

After that, your Drive files will appear in the built-in file browser. For example, enter image description here

like image 82
Bob Smith Avatar answered Oct 06 '22 07:10

Bob Smith