This commit is contained in:
Ali Abid 2020-12-10 14:31:25 -08:00
commit b49e4733fe
9 changed files with 41 additions and 12 deletions

3
.gitignore vendored
View File

@ -24,4 +24,5 @@ docs.json
demo/tmp.zip
demo/flagged
test.txt
build/
build/
gradio/launches.json

View File

@ -1,2 +1,3 @@
recursive-include gradio/templates *
recursive-include gradio/static *
include gradio/launches.json

View File

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

View File

@ -7,6 +7,7 @@ gradio/embeddings.py
gradio/inputs.py
gradio/interface.py
gradio/interpretation.py
gradio/launches.json
gradio/networking.py
gradio/notebook.py
gradio/outputs.py

View File

@ -1,7 +1,7 @@
numpy
requests
Flask==1.1.1
Flask-Cors==3.0.8
Flask>=1.1.1
Flask-Cors>=3.0.8
flask-cachebuster
paramiko
scipy

View File

@ -7,6 +7,7 @@ from gradio.inputs import InputComponent
from gradio.outputs import OutputComponent
from gradio import networking, strings, utils
from gradio.interpretation import quantify_difference_in_label
import pkg_resources
import requests
import random
import time
@ -19,11 +20,14 @@ import numpy as np
import os
import copy
import markdown2
import json
analytics.write_key = "uxIFddIEuuUcFLf9VgH2teTEtPlWdkNy"
analytics_url = 'https://api.gradio.app/'
ip_address = networking.get_local_ip_address()
JSON_PATH = pkg_resources.resource_filename("gradio", "launches.json")
class Interface:
"""
Interfaces are created with Gradio using the `gradio.Interface()` function.
@ -45,7 +49,7 @@ class Interface:
title=None, description=None, article=None, thumbnail=None,
server_port=None, server_name=networking.LOCALHOST_NAME,
allow_screenshot=True, allow_flagging=True,
embedding="default", flagging_dir="flagged", analytics_enabled=True):
embedding=None, flagging_dir="flagged", analytics_enabled=True):
"""
Parameters:
@ -196,7 +200,8 @@ class Interface:
"thumbnail": self.thumbnail,
"allow_screenshot": self.allow_screenshot,
"allow_flagging": self.allow_flagging,
"allow_interpretation": self.interpretation is not None
"allow_interpretation": self.interpretation is not None,
"allow_embedding": self.embedding is not None,
}
try:
param_names = inspect.getfullargspec(self.predict[0])[0]
@ -373,6 +378,7 @@ class Interface:
path_to_local_server (str): Locally accessible link
share_url (str): Publicly accessible link (if share=True)
"""
config = self.get_config_file()
networking.set_config(config)
networking.set_meta_tags(self.title, self.description, self.thumbnail)
@ -400,6 +406,17 @@ class Interface:
else:
print("Colab notebook detected. To show errors in colab notebook, set debug=True in launch()")
if not os.path.exists(JSON_PATH):
with open(JSON_PATH, "w+") as j:
launches = {"launches": 0}
j.write(json.dumps(launches))
else:
with open(JSON_PATH) as j:
launches = json.load(j)
if launches["launches"] in [25, 50]:
print(strings.en["BETA_INVITE"])
self.share = share
if share:
print("This share link will expire in 24 hours. If you need a "
@ -477,6 +494,10 @@ class Interface:
if not is_in_interactive_mode:
self.run_until_interrupted(thread, path_to_local_server)
launches["launches"] += 1
with open(JSON_PATH, "w") as j:
j.write(json.dumps(launches))
return app, path_to_local_server, share_url

View File

@ -51,8 +51,8 @@ function gradio(config, fn, target, example_file_path) {
<button class="run_examples examples-content">Run All</button>
<button class="load_prev examples-content">Load Previous <em>(CTRL + &larr;)</em></button>
<button class="load_next examples-content">Load Next <em>(CTRL + &rarr;)</em></button>
<button class="order_similar examples-content">Order by Similarity</button>
<button class="view_embeddings examples-content">View Embeddings</button>
<button class="order_similar examples-content embedding">Order by Similarity</button>
<button class="view_embeddings examples-content embedding">View Embeddings</button>
<button class="update_embeddings embeddings-content invisible">Update Embeddings</button>
<button class="view_examples embeddings-content invisible">View Examples</button>
<div class="pages invisible">Page:</div>
@ -200,6 +200,9 @@ function gradio(config, fn, target, example_file_path) {
}
target.find(".clear").click(clear_all);
if (!config["allow_embedding"]) {
target.find(".embedding").css("visibility", "hidden");
}
if (!config["allow_screenshot"] && !config["allow_flagging"] && !config["allow_interpretation"]) {
target.find(".screenshot, .record, .flag, .interpret").css("visibility", "hidden");
} else {

View File

@ -8,5 +8,7 @@ en = {
"MODEL_PUBLICLY_AVAILABLE_URL": "Model available publicly at: {} (may take up to a minute for link to be usable)",
"GENERATING_PUBLIC_LINK": "Generating public link (may take a few seconds...):",
"TF1_ERROR": "It looks like you might be using tensorflow < 2.0. Please pass capture_session=True in Interface() to"
" avoid the 'Tensor is not an element of this graph.' error."
" avoid the 'Tensor is not an element of this graph.' error.",
"BETA_INVITE": "\nWe want to invite you to become a beta user.\nYou'll get early access to new and premium "
"features (persistent links, hosting, and more).\nIf you're interested please email beta@gradio.app\n"
}

View File

@ -5,7 +5,7 @@ except ImportError:
setup(
name='gradio',
version='1.3.1',
version='1.3.2',
include_package_data=True,
description='Python library for easily interacting with trained machine learning models',
author='Abubakar Abid',
@ -16,8 +16,8 @@ setup(
install_requires=[
'numpy',
'requests',
'Flask==1.1.1',
'Flask-Cors==3.0.8',
'Flask>=1.1.1',
'Flask-Cors>=3.0.8',
'flask-cachebuster',
'paramiko',
'scipy',