Skip to content

Commit

Permalink
makes more sense
Browse files Browse the repository at this point in the history
  • Loading branch information
ZEMUSHKA committed Sep 25, 2018
1 parent 35c3116 commit 7f3ec30
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 17 deletions.
13 changes: 0 additions & 13 deletions keras_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
import keras
from keras import backend as K
import tqdm_utils
import os
import subprocess
import json
import time


class TqdmProgressCallback(keras.callbacks.Callback):
Expand Down Expand Up @@ -81,12 +77,3 @@ def reset_tf_session():
s = tf.InteractiveSession(config=config)
K.set_session(s)
return s


def expose_port_on_colab(port):
os.system("wget https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip")
os.system("unzip ngrok-stable-linux-amd64.zip")
os.system("./ngrok http {0} &".format(port))
tunnels_json = subprocess.check_output("curl -s http://localhost:4040/api/tunnels", shell=True)
time.sleep(5)
print("Open {0} to access your {1} port".format(json.loads(tunnels_json)['tunnels'][0]['public_url'], port))
12 changes: 12 additions & 0 deletions setup_google_colab.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import subprocess
import json
import time


def download_github_code(path):
Expand Down Expand Up @@ -78,3 +81,12 @@ def setup_week6():
def setup_keras():
import download_utils
download_utils.download_all_keras_resources("../readonly/keras/models", "../readonly/keras/datasets")


def expose_port_on_colab(port):
os.system("wget https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip")
os.system("unzip ngrok-stable-linux-amd64.zip")
os.system("./ngrok http {0} &".format(port))
tunnels_json = subprocess.check_output("curl -s http://localhost:4040/api/tunnels", shell=True)
time.sleep(5)
print("Open {0} to access your {1} port".format(json.loads(tunnels_json)['tunnels'][0]['public_url'], port))
6 changes: 2 additions & 4 deletions week2/v2/tensorflow_examples_from_video.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -334,15 +334,13 @@
"# !!! RUN THIS CELL ONLY ON GOOGLE COLAB !!!\n",
"! wget https://raw.githubusercontent.com/hse-aml/intro-to-dl/master/setup_google_colab.py -O setup_google_colab.py\n",
"import setup_google_colab\n",
"setup_google_colab.setup_common()\n",
"\n",
"import os\n",
"import keras_utils\n",
"# run tensorboard in background\n",
"import os\n",
"os.system(\"tensorboard --logdir=./logs --host 0.0.0.0 --port 6006 &\")\n",
"\n",
"# expose port and show the link\n",
"keras_utils.expose_port_on_colab(6006)"
"setup_google_colab.expose_port_on_colab(6006)"
]
},
{
Expand Down

0 comments on commit 7f3ec30

Please sign in to comment.