mirror of
https://github.com/gradio-app/gradio.git
synced 2025-01-06 10:25:17 +08:00
latest pypi version
This commit is contained in:
parent
b8c22d2d66
commit
c1d3fbf567
@ -24,15 +24,17 @@
|
|||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 2,
|
"execution_count": 2,
|
||||||
"metadata": {},
|
"metadata": {
|
||||||
|
"scrolled": false
|
||||||
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"model = tf.keras.applications.inception_v3.InceptionV3()"
|
"model = tf.keras.applications.MobileNet()"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 5,
|
"execution_count": 3,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
@ -47,7 +49,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 7,
|
"execution_count": 4,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"scrolled": false
|
"scrolled": false
|
||||||
},
|
},
|
||||||
@ -56,10 +58,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: gradio.app@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:7864/\n",
|
||||||
"Model is running locally at: http://localhost:7862/\n",
|
"To create a public link, set `share=True` in the argument to `launch()`.\n"
|
||||||
"Model available publicly at: https://53920.gradio.app -- may take up to a minute to setup.\n"
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -69,14 +70,14 @@
|
|||||||
" <iframe\n",
|
" <iframe\n",
|
||||||
" width=\"1000\"\n",
|
" width=\"1000\"\n",
|
||||||
" height=\"500\"\n",
|
" height=\"500\"\n",
|
||||||
" src=\"http://localhost:7862/\"\n",
|
" src=\"http://localhost:7864/\"\n",
|
||||||
" frameborder=\"0\"\n",
|
" frameborder=\"0\"\n",
|
||||||
" allowfullscreen\n",
|
" allowfullscreen\n",
|
||||||
" ></iframe>\n",
|
" ></iframe>\n",
|
||||||
" "
|
" "
|
||||||
],
|
],
|
||||||
"text/plain": [
|
"text/plain": [
|
||||||
"<IPython.lib.display.IFrame at 0x1f66392cd68>"
|
"<IPython.lib.display.IFrame at 0x274adb64a90>"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
@ -84,7 +85,7 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"source": [
|
"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
121
Test Keras.ipynb
Normal 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
|
||||||
|
}
|
@ -89,6 +89,7 @@ class Interface:
|
|||||||
if self.model_type == "keras":
|
if self.model_type == "keras":
|
||||||
import tensorflow as tf
|
import tensorflow as tf
|
||||||
self.graph = tf.get_default_graph()
|
self.graph = tf.get_default_graph()
|
||||||
|
self.sess = tf.keras.backend.get_session()
|
||||||
self.verbose = verbose
|
self.verbose = verbose
|
||||||
self.status = self.STATUS_TYPES["OFF"]
|
self.status = self.STATUS_TYPES["OFF"]
|
||||||
self.validate_flag = False
|
self.validate_flag = False
|
||||||
@ -135,8 +136,10 @@ class Interface:
|
|||||||
if self.model_type == "sklearn":
|
if self.model_type == "sklearn":
|
||||||
return self.model_obj.predict(preprocessed_input)
|
return self.model_obj.predict(preprocessed_input)
|
||||||
elif self.model_type == "keras":
|
elif self.model_type == "keras":
|
||||||
|
import tensorflow as tf
|
||||||
with self.graph.as_default():
|
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":
|
elif self.model_type == "pyfunc":
|
||||||
return self.model_obj(preprocessed_input)
|
return self.model_obj(preprocessed_input)
|
||||||
elif self.model_type == "pytorch":
|
elif self.model_type == "pytorch":
|
||||||
@ -200,7 +203,7 @@ class Interface:
|
|||||||
return
|
return
|
||||||
raise RuntimeError("Validation did not pass")
|
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.
|
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)
|
:param inline: boolean. If True, then a gradio interface is created inline (e.g. in jupyter or colab notebook)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
en = {
|
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: {}",
|
"RUNNING_LOCALLY": "Model is running locally at: {}",
|
||||||
"NGROK_NO_INTERNET": "Unable to create public link for interface, please check internet connection or try "
|
"NGROK_NO_INTERNET": "Unable to create public link for interface, please check internet connection or try "
|
||||||
"restarting python interpreter.",
|
"restarting python interpreter.",
|
||||||
|
Binary file not shown.
@ -1,6 +1,6 @@
|
|||||||
Metadata-Version: 1.0
|
Metadata-Version: 1.0
|
||||||
Name: gradio
|
Name: gradio
|
||||||
Version: 0.7.1
|
Version: 0.7.2
|
||||||
Summary: Python library for easily interacting with trained machine learning models
|
Summary: Python library for easily interacting with trained machine learning models
|
||||||
Home-page: https://github.com/abidlabs/gradio
|
Home-page: https://github.com/abidlabs/gradio
|
||||||
Author: Abubakar Abid
|
Author: Abubakar Abid
|
||||||
|
@ -89,6 +89,7 @@ class Interface:
|
|||||||
if self.model_type == "keras":
|
if self.model_type == "keras":
|
||||||
import tensorflow as tf
|
import tensorflow as tf
|
||||||
self.graph = tf.get_default_graph()
|
self.graph = tf.get_default_graph()
|
||||||
|
self.sess = tf.keras.backend.get_session()
|
||||||
self.verbose = verbose
|
self.verbose = verbose
|
||||||
self.status = self.STATUS_TYPES["OFF"]
|
self.status = self.STATUS_TYPES["OFF"]
|
||||||
self.validate_flag = False
|
self.validate_flag = False
|
||||||
@ -135,8 +136,10 @@ class Interface:
|
|||||||
if self.model_type == "sklearn":
|
if self.model_type == "sklearn":
|
||||||
return self.model_obj.predict(preprocessed_input)
|
return self.model_obj.predict(preprocessed_input)
|
||||||
elif self.model_type == "keras":
|
elif self.model_type == "keras":
|
||||||
|
import tensorflow as tf
|
||||||
with self.graph.as_default():
|
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":
|
elif self.model_type == "pyfunc":
|
||||||
return self.model_obj(preprocessed_input)
|
return self.model_obj(preprocessed_input)
|
||||||
elif self.model_type == "pytorch":
|
elif self.model_type == "pytorch":
|
||||||
@ -200,7 +203,7 @@ class Interface:
|
|||||||
return
|
return
|
||||||
raise RuntimeError("Validation did not pass")
|
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.
|
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)
|
:param inline: boolean. If True, then a gradio interface is created inline (e.g. in jupyter or colab notebook)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
en = {
|
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: {}",
|
"RUNNING_LOCALLY": "Model is running locally at: {}",
|
||||||
"NGROK_NO_INTERNET": "Unable to create public link for interface, please check internet connection or try "
|
"NGROK_NO_INTERNET": "Unable to create public link for interface, please check internet connection or try "
|
||||||
"restarting python interpreter.",
|
"restarting python interpreter.",
|
||||||
|
2
setup.py
2
setup.py
@ -5,7 +5,7 @@ except ImportError:
|
|||||||
|
|
||||||
setup(
|
setup(
|
||||||
name='gradio',
|
name='gradio',
|
||||||
version='0.7.1',
|
version='0.7.2',
|
||||||
include_package_data=True,
|
include_package_data=True,
|
||||||
description='Python library for easily interacting with trained machine learning models',
|
description='Python library for easily interacting with trained machine learning models',
|
||||||
author='Abubakar Abid',
|
author='Abubakar Abid',
|
||||||
|
Loading…
Reference in New Issue
Block a user