google-colaboratory

In Google's Colab notebook, How do I call a function from a Python file?

半腔热情 提交于 2019-12-03 00:36:36
From a Colab notebook, I would like to call a python function that I wrote in a separate python file. How do I do that? Edit : If you would like to import a local module, you'll want to edit your sys.path to point to that new directory. Here's an example notebook: https://colab.research.google.com/notebook#fileId=1PtYW0hZit-B9y4PL978kV2ppJJPhjQua Original reply : Sure, here's an example notebook: https://colab.research.google.com/notebook#fileId=1KBrq8aAiy8vYIIUiTb5UHG9GKOdEMF3n There are two cells: the first defines a .py file with a function to be imported. %%writefile example.py def f():

Can't read a file in google colaboratory

不问归期 提交于 2019-12-03 00:30:22
Can't read a file in google colaboratory . I have .ipynb file and .csv files in the same directory but when I try to run: train = pd.read_csv("train.csv") I get: FileNotFoundError: File b'train.csv' does not exist I hope you have run this code before opening your train file. Part I # Install a Drive FUSE wrapper. # https://github.com/astrada/google-drive-ocamlfuse !apt-get install -y -qq software-properties-common python-software-properties module-init-tools !add-apt-repository -y ppa:alessandro-strada/ppa 2>&1 > /dev/null !apt-get update -qq 2>&1 > /dev/null !apt-get -y install -qq google

When I use Google Colaboratory, how to save image, weights in my Google Drive?

爱⌒轻易说出口 提交于 2019-12-02 23:40:42
I use Google Colaboratory then I want to save output images in my Google Drive or SSD, HHD but its directory is "/content" import os print(os.getcwd()) # "/content" so is it possible to change path (HDD, SSD, googledrive)? To save the weight you can run the following after training. saver = tf.train.Saver() save_path = saver.save(session, "data/dm.ckpt") print('done saving at',save_path) Check the location where the ckpt files were saved. import os print( os.getcwd() ) print( os.listdir('data') ) Finally download the file! from google.colab import files files.download( "data/dm.ckpt.meta" )

How to upload csv file (and use it) from google drive into google colaboratory

对着背影说爱祢 提交于 2019-12-02 20:55:08
Wanted to try out python, and google colaboratory seemed the easiest option.I have some files in my google drive, and wanted to upload them into google colaboratory. so here is the code that i am using: !pip install -U -q PyDrive from pydrive.auth import GoogleAuth from pydrive.drive import GoogleDrive from google.colab import auth from oauth2client.client import GoogleCredentials # 1. Authenticate and create the PyDrive client. auth.authenticate_user() gauth = GoogleAuth() gauth.credentials = GoogleCredentials.get_application_default() drive = GoogleDrive(gauth) # 2. Create & upload a file

Google Colaboratory vs Google Datalab. How are they different?

非 Y 不嫁゛ 提交于 2019-12-02 20:52:29
I understand both are built over Jupyter noteboooks but run in cloud. Why do we have two then? Jupyter is the only thing these two services have in common. Colaboratory is a tool for education and research. It doesn’t require any setup or other Google products to be used (although notebooks are stored in Google Drive). It’s intended primarily for interactive use and long-running background computations may be stopped. It currently only supports Python. Cloud Datalab allows you to analyse data using Google Cloud resources. You can take full advantage of scalable services such as BigQuery and

Blender Google Colab

删除回忆录丶 提交于 2019-12-02 18:46:39
问题 Up until few days ago I was able to run Blender(or sheep it) headless on Google Colab with an GPU(yes I checked trice that I selected a GPU Instance). Now running keras/tensorflow does work fine but blender can't detect the GPU at all and Sheepit tells me that "cuInit Failed ret: 100" nvidia-smi results with: Sat Aug 24 19:48:06 2019 +-----------------------------------------------------------------------------+ | NVIDIA-SMI 430.40 Driver Version: 418.67 CUDA Version: 10.1 | |----------------

Loading images in google colab

限于喜欢 提交于 2019-12-02 18:38:10
My Jupyter Notebook has the following code to upload an image to Colab: from google.colab import files uploaded = files.upload() I get prompted for the file. Which gets uploaded. I verify that the file upload was successful using: !ls and I see that it's there. I check the current working directory using: import os os.getcwd() and it tells me that it is /content now, any of the following calls... cv2.imread(img_path, 1) cv2.imread(img_path, 0) cv2.imread(img_path) fails to load the file. they also fail whether i'm using just the file name or the full path. Any thoughts on what is going on? Use

Changing directory in Google colab (breaking out of the python interpreter)

大城市里の小女人 提交于 2019-12-02 16:14:31
So I'm trying to git clone and cd into that directory using Google collab - but I cant cd into it. What am I doing wrong? !rm -rf SwitchFrequencyAnalysis && git clone https://github.com/ACECentre/SwitchFrequencyAnalysis.git !cd SwitchFrequencyAnalysis !ls datalab/ SwitchFrequencyAnalysis/ You would expect it to output the directory contents of SwitchFrequencyAnalysis - but instead its the root. I'm feeling I'm missing something obvious - Is it something to do with being within the python interpreter? (where is the documentation??) Demo here. use %cd SwitchFrequencyAnalysis to change the

WebDriverException: Message: invalid argument: can't kill an exited process error with Selenium GeckoDriver and Firefox in Google Colab on Ubuntu

孤街醉人 提交于 2019-12-02 14:41:20
问题 In a previous post (enter link description here) the following code (by DebanjanB) # install firefox, geckodriver, and selenium !apt-get update !pip install selenium !apt install firefox-geckodriver !cp /usr/lib/geckodriver /usr/bin !cp /usr/lib/firefox /usr/bin from selenium import webdriver binary = '/usr/bin/firefox' options = webdriver.FirefoxOptions() options.binary = binary options.add_argument('start-maximized') options.add_argument('--headless') browser = webdriver.Firefox(firefox

Methods for using Git with Google Colab

限于喜欢 提交于 2019-12-02 14:38:22
Are there any recommended methods to integrate git with colab? For example, is it possible to work off code from google source repositories or the likes? Neither google drive nor cloud storage can be used for git functionality. So I was wondering if there is a way to still do it? git is installed on the machine, and you can use ! to invoke shell commands. For example, to clone a git repository: !git clone https://github.com/fastai/courses.git Here's a complete example that clones a repository and loads an Excel file stored therein. https://colab.research.google.com/notebook#fileId=1v-yZk