replaced ngrok with share_url

This commit is contained in:
Abubakar Abid 2019-04-19 03:06:06 -07:00
parent ded83ae119
commit 15b8d51b90
5 changed files with 17 additions and 190 deletions

View File

@ -47,7 +47,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 6, "execution_count": 4,
"metadata": { "metadata": {
"scrolled": false "scrolled": false
}, },
@ -56,10 +56,9 @@
"name": "stdout", "name": "stdout",
"output_type": "stream", "output_type": "stream",
"text": [ "text": [
"Closing existing server...\n",
"NOTE: Gradio is in beta stage, please report all bugs to: contact.gradio@gmail.com\n", "NOTE: Gradio is in beta stage, please report all bugs to: contact.gradio@gmail.com\n",
"Model is running locally at: http://localhost:7860/\n", "Model is running locally at: http://localhost:7861/\n",
"Model available publicly for 8 hours at: https://a5853afe.gradio.app/\n" "Model available publicly at: https://30008.gradio.app -- may take up to a minute to setup.\n"
] ]
}, },
{ {
@ -69,37 +68,23 @@
" <iframe\n", " <iframe\n",
" width=\"1000\"\n", " width=\"1000\"\n",
" height=\"500\"\n", " height=\"500\"\n",
" src=\"http://localhost:7860/\"\n", " src=\"http://localhost:7861/\"\n",
" frameborder=\"0\"\n", " frameborder=\"0\"\n",
" allowfullscreen\n", " allowfullscreen\n",
" ></iframe>\n", " ></iframe>\n",
" " " "
], ],
"text/plain": [ "text/plain": [
"<IPython.lib.display.IFrame at 0x1ad4e654e48>" "<IPython.lib.display.IFrame at 0x1cc809aa940>"
] ]
}, },
"metadata": {}, "metadata": {},
"output_type": "display_data" "output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"flagged\n"
]
} }
], ],
"source": [ "source": [
"io.launch(inline=True, inbrowser=True, share=True, validate=False);" "io.launch(inline=True, inbrowser=True, share=True, validate=False);"
] ]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
} }
], ],
"metadata": { "metadata": {

View File

@ -1,169 +0,0 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Load the Model"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"%load_ext autoreload\n",
"%autoreload 2\n",
"\n",
"import numpy as np\n",
"import tensorflow as tf\n",
"import gradio"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"WARNING:tensorflow:From C:\\Users\\ALI\\Anaconda3\\lib\\site-packages\\tensorflow\\python\\ops\\resource_variable_ops.py:435: colocate_with (from tensorflow.python.framework.ops) is deprecated and will be removed in a future version.\n",
"Instructions for updating:\n",
"Colocations handled automatically by placer.\n"
]
}
],
"source": [
"model = tf.keras.applications.inception_v3.InceptionV3()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Using Gradio"
]
},
{
"cell_type": "code",
<<<<<<< HEAD
"execution_count": 44,
=======
"execution_count": 3,
>>>>>>> 06bb0375ca3a60d4836a9d6e07c0ba2530b73c80
"metadata": {},
"outputs": [],
"source": [
"inp = gradio.inputs.ImageUpload(shape=(299,299,3))\n",
"out = gradio.outputs.Label(label_names='imagenet1000')\n",
"\n",
"io = gradio.Interface(inputs=inp, \n",
" outputs=out,\n",
" model=model, \n",
" model_type='keras')\n"
]
},
{
"cell_type": "code",
<<<<<<< HEAD
"execution_count": 45,
"metadata": {},
=======
"execution_count": 4,
"metadata": {
"scrolled": false
},
>>>>>>> 06bb0375ca3a60d4836a9d6e07c0ba2530b73c80
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"NOTE: Gradio is in beta stage, please report all bugs to: contact.gradio@gmail.com\n",
<<<<<<< HEAD
"Model is running locally at: http://localhost:7864/\n",
"Unable to create public link for interface, please check internet connection or try restarting python interpreter.\n"
=======
"Model is running locally at: http://localhost:7860/\n",
"Model available publicly at: https://47290.gradio.app -- may take up to a minute to setup.\n"
>>>>>>> 06bb0375ca3a60d4836a9d6e07c0ba2530b73c80
]
},
{
"data": {
"text/html": [
"\n",
" <iframe\n",
" width=\"1000\"\n",
" height=\"500\"\n",
<<<<<<< HEAD
" src=\"http://localhost:7864/\"\n",
=======
" src=\"http://localhost:7860/\"\n",
>>>>>>> 06bb0375ca3a60d4836a9d6e07c0ba2530b73c80
" frameborder=\"0\"\n",
" allowfullscreen\n",
" ></iframe>\n",
" "
],
"text/plain": [
<<<<<<< HEAD
"<IPython.lib.display.IFrame at 0x25256d02b38>"
=======
"<IPython.lib.display.IFrame at 0x288afe67e48>"
>>>>>>> 06bb0375ca3a60d4836a9d6e07c0ba2530b73c80
]
},
"metadata": {},
"output_type": "display_data"
<<<<<<< HEAD
},
{
"data": {
"text/plain": [
"(<gradio.networking.serve_files_in_background.<locals>.HTTPServer at 0x25256d023c8>,\n",
" 'http://localhost:7864/',\n",
" None)"
]
},
"execution_count": 45,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"io.launch(inline=True, inbrowser=False, share=True, validate=False)"
=======
}
],
"source": [
"io.launch(inline=True, inbrowser=False, share=True, validate=False);"
>>>>>>> 06bb0375ca3a60d4836a9d6e07c0ba2530b73c80
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3.6 (tensorflow)",
"language": "python",
"name": "tensorflow"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.7"
}
},
"nbformat": 4,
"nbformat_minor": 2
}

View File

@ -277,6 +277,7 @@ class Interface:
if share_url is not None: if share_url is not None:
if self.verbose: if self.verbose:
print(strings.en["MODEL_PUBLICLY_AVAILABLE_URL"].format(share_url)) print(strings.en["MODEL_PUBLICLY_AVAILABLE_URL"].format(share_url))
networking.set_share_url_in_config_file(output_directory, share_url)
if inline is None: if inline is None:
try: # Check if running interactively using ipython. try: # Check if running interactively using ipython.

View File

@ -151,6 +151,16 @@ def set_interface_types_in_config_file(temp_dir, input_interface, output_interfa
) )
def set_share_url_in_config_file(temp_dir, share_url):
config_file = os.path.join(temp_dir, CONFIG_FILE)
render_template_with_tags(
config_file,
{
"share_url": share_url,
},
)
def get_first_available_port(initial, final): def get_first_available_port(initial, final):
""" """
Gets the first open port in a specified range of port numbers Gets the first open port in a specified range of port numbers

View File

@ -1,5 +1,5 @@
{ {
"input_interface_type": "{{input_interface_type}}", "input_interface_type": "{{input_interface_type}}",
"output_interface_type": "{{output_interface_type}}", "output_interface_type": "{{output_interface_type}}",
"ngrok_socket_url": "{{ngrok_socket_url}}" "share_url": "{{share_url}}"
} }