mirror of
https://github.com/gradio-app/gradio.git
synced 2025-01-06 10:25:17 +08:00
added loading logo
This commit is contained in:
parent
ed789d1e4e
commit
424916db87
126
Demo Gradio.ipynb
Normal file
126
Demo Gradio.ipynb
Normal file
@ -0,0 +1,126 @@
|
||||
{
|
||||
"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": [],
|
||||
"source": [
|
||||
"model = tf.keras.applications.inception_v3.InceptionV3()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"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: contact.gradio@gmail.com\n",
|
||||
"Model is running locally at: http://localhost:7860/\n",
|
||||
"Model available publicly for 8 hours at: https://a5853afe.gradio.app/\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"\n",
|
||||
" <iframe\n",
|
||||
" width=\"1000\"\n",
|
||||
" height=\"500\"\n",
|
||||
" src=\"http://localhost:7860/\"\n",
|
||||
" frameborder=\"0\"\n",
|
||||
" allowfullscreen\n",
|
||||
" ></iframe>\n",
|
||||
" "
|
||||
],
|
||||
"text/plain": [
|
||||
"<IPython.lib.display.IFrame at 0x1ad4e654e48>"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"flagged\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"io.launch(inline=True, inbrowser=True, share=True, validate=False);"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
}
|
||||
],
|
||||
"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
|
||||
}
|
@ -25,17 +25,7 @@
|
||||
"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"
|
||||
]
|
||||
}
|
||||
],
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"model = tf.keras.applications.inception_v3.InceptionV3()"
|
||||
]
|
||||
@ -44,7 +34,7 @@
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# Feed An Image Into the Model Manually"
|
||||
"# Using Gradio"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -52,44 +42,6 @@
|
||||
"execution_count": 3,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# from PIL import Image\n",
|
||||
"# import requests\n",
|
||||
"# from io import BytesIO\n",
|
||||
"\n",
|
||||
"# url = 'https://nationalzoo.si.edu/sites/default/files/animals/cheetah-004.jpg'\n",
|
||||
"\n",
|
||||
"# response = requests.get(url)\n",
|
||||
"# img = Image.open(BytesIO(response.content))\n",
|
||||
"\n",
|
||||
"# # resize the image into an array that the model can accept\n",
|
||||
"# img = np.array(img.resize((299, 299))).reshape((1, 299, 299, 3))\n",
|
||||
"\n",
|
||||
"# # scale the image and do other preprocessing\n",
|
||||
"# img = img/255"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# model.predict(img)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# Use Gradio Instead"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"inp = gradio.inputs.ImageUpload(shape=(299,299,3))\n",
|
||||
"out = gradio.outputs.Label(label_names='imagenet1000', max_label_length=8)\n",
|
||||
@ -102,17 +54,18 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 20,
|
||||
"metadata": {},
|
||||
"execution_count": 4,
|
||||
"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: contact.gradio@gmail.com\n",
|
||||
"Model is running locally at: http://localhost:7860/\n",
|
||||
"Unable to create public link for interface, please check internet connection or try restarting python interpreter.\n"
|
||||
"Model available publicly for 8 hours at: https://c0097190.gradio.app/\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -129,7 +82,7 @@
|
||||
" "
|
||||
],
|
||||
"text/plain": [
|
||||
"<IPython.lib.display.IFrame at 0x19e9d6b37b8>"
|
||||
"<IPython.lib.display.IFrame at 0x22abbdace10>"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
@ -139,20 +92,13 @@
|
||||
"source": [
|
||||
"io.launch(inline=True, inbrowser=False, share=True, validate=False);"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"display_name": "Python 3.6 (tensorflow)",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
"name": "tensorflow"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
@ -164,7 +110,7 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.7.1"
|
||||
"version": "3.6.7"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
|
BIN
gradio/static/img/logo_loading.gif
Normal file
BIN
gradio/static/img/logo_loading.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 188 KiB |
BIN
gradio/static/img/logo_only.png
Normal file
BIN
gradio/static/img/logo_only.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.4 KiB |
@ -7,6 +7,7 @@ const image_output = {
|
||||
this.target.find(".output_image").attr('src', data).show();
|
||||
},
|
||||
submit: function() {
|
||||
this.target.find(".output_image").attr('src', 'static/img/logo_loading.gif').show();
|
||||
},
|
||||
clear: function() {
|
||||
this.target.find(".output_image").attr('src', "").hide();
|
||||
|
@ -20,6 +20,7 @@ const label_output = {
|
||||
}
|
||||
},
|
||||
submit: function() {
|
||||
this.target.find(".output_class").html("<img src='static/img/logo_loading.gif'>")
|
||||
},
|
||||
clear: function() {
|
||||
this.target.find(".output_class").empty();
|
||||
|
BIN
web/img/logo.png
BIN
web/img/logo.png
Binary file not shown.
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 17 KiB |
BIN
web/img/logo_only.png
Normal file
BIN
web/img/logo_only.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.4 KiB |
Loading…
Reference in New Issue
Block a user