Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run localhost server in Google Colab notebook

I am trying to implement Tacotron speech synthesis with Tensorflow in Google Colab using this code form a repo in Github, below is my code and working good till the step of using localhost server, how I can to run a localhost server in a notebook in Google Colab?

My code:

!pip install tensorflow==1.3.0
import tensorflow as tf
print("You are using Tensorflow",tf.__version__)
!git clone https://github.com/keithito/tacotron.git
cd tacotron
pip install -r requirements.txt
!curl https://data.keithito.com/data/speech/tacotron-20180906.tar.gz | tar xzC /tmp
!python demo_server.py --checkpoint /tmp/tacotron-20180906/model.ckpt #requires localhost

Unfortunately running in local mode from Google Colab will not help me because to do this I need to download the data in my machine which are too large.
Below is my last output and here I am supposed to open the localhost:8888 to complete the work, so as I mentioned before is there any way to run localhost in Google Colaboratory?

enter image description here

like image 984
Ahmad Avatar asked Feb 03 '23 15:02

Ahmad


2 Answers

You can do this by using tools like ngrok or remote.it

They give you a URL that you can access from any browser to access your web server running on 8888

Example 1: Tunneling tensorboard running on

!wget https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip
!unzip ngrok-stable-linux-amd64.zip

get_ipython().system_raw('tensorboard --logdir /content/trainingdata/objectdetection/ckpt_output/trainingImatges/ --host 0.0.0.0 --port 6006 &')

get_ipython().system_raw('./ngrok http 6006 &')

! curl -s http://localhost:4040/api/tunnels | python3 -c \
 "import sys, json; print(json.load(sys.stdin)['tunnels'][0]['public_url'])"

Running this install ngrok on colab, and makes a link like http://c11e1b53.ngrok.io/

Documentaion for NGROK

like image 59
55597 Avatar answered Feb 06 '23 14:02

55597


Another way of running a publicly accessible server using ngrok:

!pip install pyngrok --quiet
from pyngrok import ngrok

# Terminate open tunnels if exist
ngrok.kill()

# Setting the authtoken (optional)
# Get your authtoken from https://dashboard.ngrok.com/auth
NGROK_AUTH_TOKEN = ""
ngrok.set_auth_token(NGROK_AUTH_TOKEN)

# Open an HTTPs tunnel on port 5000 for http://localhost:5000
public_url = ngrok.connect(port="5000", proto="http", options={"bind_tls": True})
print("Tracking URL:", public_url)
like image 29
AVISHEK GARAIN Avatar answered Feb 06 '23 15:02

AVISHEK GARAIN