latest pypi version

This commit is contained in:
Abubakar Abid 2019-04-19 23:07:51 -07:00
parent b8c22d2d66
commit c1d3fbf567
9 changed files with 147 additions and 19 deletions

View File

@ -24,15 +24,17 @@
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"metadata": {
"scrolled": false
},
"outputs": [],
"source": [
"model = tf.keras.applications.inception_v3.InceptionV3()"
"model = tf.keras.applications.MobileNet()"
]
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
@ -47,7 +49,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 4,
"metadata": {
"scrolled": false
},
@ -56,10 +58,9 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Closing existing server...\n",
"NOTE: Gradio is in beta stage, please report all bugs to: contact.gradio@gmail.com\n",
"Model is running locally at: http://localhost:7862/\n",
"Model available publicly at: https://53920.gradio.app -- may take up to a minute to setup.\n"
"NOTE: Gradio is in beta stage, please report all bugs to: gradio.app@gmail.com\n",
"Model is running locally at: http://localhost:7864/\n",
"To create a public link, set `share=True` in the argument to `launch()`.\n"
]
},
{
@ -69,14 +70,14 @@
" <iframe\n",
" width=\"1000\"\n",
" height=\"500\"\n",
" src=\"http://localhost:7862/\"\n",
" src=\"http://localhost:7864/\"\n",
" frameborder=\"0\"\n",
" allowfullscreen\n",
" ></iframe>\n",
" "
],
"text/plain": [
"<IPython.lib.display.IFrame at 0x1f66392cd68>"
"<IPython.lib.display.IFrame at 0x274adb64a90>"
]
},
"metadata": {},
@ -84,7 +85,7 @@
}
],
"source": [
"io.launch(inline=True, inbrowser=False, share=True, validate=False);"
"io.launch(inline=True, share=False, validate=False);"
]
}
],

121
Test Keras.ipynb Normal file
View File

@ -0,0 +1,121 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Load the Model"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"The autoreload extension is already loaded. To reload it, use:\n",
" %reload_ext autoreload\n"
]
}
],
"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": [],
"source": [
"model = tf.keras.applications.MobileNet()"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"inp = gradio.inputs.ImageUpload()\n",
"out = gradio.outputs.Label(label_names='imagenet1000', max_label_length=8)\n",
"\n",
"io = gradio.Interface(inputs=inp, \n",
" outputs=out,\n",
" model=model, \n",
" model_type='keras')"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"scrolled": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Closing existing server...\n",
"NOTE: Gradio is in beta stage, please report all bugs to: gradio.app@gmail.com\n",
"Model is running locally at: http://localhost:7863/\n",
"Model available publicly at: https://25024.gradio.app -- may take up to a minute to setup.\n"
]
},
{
"data": {
"text/html": [
"\n",
" <iframe\n",
" width=\"1000\"\n",
" height=\"500\"\n",
" src=\"http://localhost:7863/\"\n",
" frameborder=\"0\"\n",
" allowfullscreen\n",
" ></iframe>\n",
" "
],
"text/plain": [
"<IPython.lib.display.IFrame at 0x266c18d8940>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"io.launch(inline=True, validate=False);"
]
}
],
"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

@ -89,6 +89,7 @@ class Interface:
if self.model_type == "keras":
import tensorflow as tf
self.graph = tf.get_default_graph()
self.sess = tf.keras.backend.get_session()
self.verbose = verbose
self.status = self.STATUS_TYPES["OFF"]
self.validate_flag = False
@ -135,8 +136,10 @@ class Interface:
if self.model_type == "sklearn":
return self.model_obj.predict(preprocessed_input)
elif self.model_type == "keras":
import tensorflow as tf
with self.graph.as_default():
return self.model_obj.predict(preprocessed_input)
with self.sess.as_default():
return self.model_obj.predict(preprocessed_input)
elif self.model_type == "pyfunc":
return self.model_obj(preprocessed_input)
elif self.model_type == "pytorch":
@ -200,7 +203,7 @@ class Interface:
return
raise RuntimeError("Validation did not pass")
def launch(self, inline=None, inbrowser=None, share=False, validate=True):
def launch(self, inline=None, inbrowser=None, share=True, validate=True):
"""
Standard method shared by interfaces that creates the interface and sets up a websocket to communicate with it.
:param inline: boolean. If True, then a gradio interface is created inline (e.g. in jupyter or colab notebook)

View File

@ -1,5 +1,5 @@
en = {
"BETA_MESSAGE": "NOTE: Gradio is in beta stage, please report all bugs to: contact.gradio@gmail.com",
"BETA_MESSAGE": "NOTE: Gradio is in beta stage, please report all bugs to: gradio.app@gmail.com",
"RUNNING_LOCALLY": "Model is running locally at: {}",
"NGROK_NO_INTERNET": "Unable to create public link for interface, please check internet connection or try "
"restarting python interpreter.",

View File

@ -1,6 +1,6 @@
Metadata-Version: 1.0
Name: gradio
Version: 0.7.1
Version: 0.7.2
Summary: Python library for easily interacting with trained machine learning models
Home-page: https://github.com/abidlabs/gradio
Author: Abubakar Abid

View File

@ -89,6 +89,7 @@ class Interface:
if self.model_type == "keras":
import tensorflow as tf
self.graph = tf.get_default_graph()
self.sess = tf.keras.backend.get_session()
self.verbose = verbose
self.status = self.STATUS_TYPES["OFF"]
self.validate_flag = False
@ -135,8 +136,10 @@ class Interface:
if self.model_type == "sklearn":
return self.model_obj.predict(preprocessed_input)
elif self.model_type == "keras":
import tensorflow as tf
with self.graph.as_default():
return self.model_obj.predict(preprocessed_input)
with self.sess.as_default():
return self.model_obj.predict(preprocessed_input)
elif self.model_type == "pyfunc":
return self.model_obj(preprocessed_input)
elif self.model_type == "pytorch":
@ -200,7 +203,7 @@ class Interface:
return
raise RuntimeError("Validation did not pass")
def launch(self, inline=None, inbrowser=None, share=False, validate=True):
def launch(self, inline=None, inbrowser=None, share=True, validate=True):
"""
Standard method shared by interfaces that creates the interface and sets up a websocket to communicate with it.
:param inline: boolean. If True, then a gradio interface is created inline (e.g. in jupyter or colab notebook)

View File

@ -1,5 +1,5 @@
en = {
"BETA_MESSAGE": "NOTE: Gradio is in beta stage, please report all bugs to: contact.gradio@gmail.com",
"BETA_MESSAGE": "NOTE: Gradio is in beta stage, please report all bugs to: gradio.app@gmail.com",
"RUNNING_LOCALLY": "Model is running locally at: {}",
"NGROK_NO_INTERNET": "Unable to create public link for interface, please check internet connection or try "
"restarting python interpreter.",

View File

@ -5,7 +5,7 @@ except ImportError:
setup(
name='gradio',
version='0.7.1',
version='0.7.2',
include_package_data=True,
description='Python library for easily interacting with trained machine learning models',
author='Abubakar Abid',