From abfb70940bcbb5b4cdbb58c4db526c83c2f7ac54 Mon Sep 17 00:00:00 2001 From: Ali Abid Date: Thu, 3 Dec 2020 11:47:08 -0800 Subject: [PATCH] added article, hosted information --- README.md | 4 ++++ gradio.egg-info/requires.txt | 1 + gradio/interface.py | 8 +++++++- gradio/static/js/gradio.js | 7 ++++++- readme_template.md | 4 ++++ setup.py | 3 ++- 6 files changed, 24 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 7ecd390fb1..4e8be8b7f3 100644 --- a/README.md +++ b/README.md @@ -244,6 +244,10 @@ Links expire after 6 hours. Need longer links, or private links? [Contact us fo ![Sharing diagram](demo/images/sharing.svg) +### Permanent Hosting + +You can share your interface publicly and permanently by hosting on Gradio's infrastructure. You will need to create a Gradio premium account. First, log into Gradio on [gradio.app](https://gradio.app) and click Sign In at the top. Once you've logged in with your Github account, you can specify which repositories from your Github profile you'd like to have hosted by Gradio. You must also specify the file within the repository that runs the Gradio `launch()` command. Once you've taken these steps, Gradio will launch your interface on a URL of the format **XXXXXX.gradio.app** where **XXXXXX** is any string you specify. + ## Contributing: If you would like to contribute and your contribution is small, you can directly open a pull request (PR). If you would like to contribute a larger feature, we recommend first creating an issue with a proposed design for discussion. Please see our contributing guidelines for more info. diff --git a/gradio.egg-info/requires.txt b/gradio.egg-info/requires.txt index 1316063c56..9f5cdbae5c 100644 --- a/gradio.egg-info/requires.txt +++ b/gradio.egg-info/requires.txt @@ -10,3 +10,4 @@ scikit-learn scikit-image analytics-python pandas +markdown2 diff --git a/gradio/interface.py b/gradio/interface.py index d5e05d4070..697016756e 100644 --- a/gradio/interface.py +++ b/gradio/interface.py @@ -18,6 +18,7 @@ import analytics import numpy as np import os import copy +import markdown2 analytics.write_key = "uxIFddIEuuUcFLf9VgH2teTEtPlWdkNy" analytics_url = 'https://api.gradio.app/' @@ -41,7 +42,7 @@ class Interface: examples_per_page=10, live=False, layout="horizontal", show_input=True, show_output=True, capture_session=False, interpretation=None, - title=None, description=None, thumbnail=None, + 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): @@ -60,6 +61,7 @@ class Interface: interpretation (Union[Callable, str]): function that provides interpretation explaining prediction output. Pass "default" to use built-in interpreter. title (str): a title for the interface; if provided, appears above the input and output components. description (str): a description for the interface; if provided, appears above the input and output components. + article (str): an expanded article explaining the interface; if provided, appears below the input and output components. Accepts Markdown and HTML content. thumbnail (str): path to image or src to use as display picture for models listed in gradio.app/hub server_name (str): to make app accessible on local network set to "0.0.0.0". allow_screenshot (bool): if False, users will not see a button to take a screenshot of the interface. @@ -115,6 +117,9 @@ class Interface: self.server_name = server_name self.title = title self.description = description + if article is not None: + article = markdown2.markdown(article) + self.article = article self.thumbnail = thumbnail self.examples = examples self.examples_per_page = examples_per_page @@ -186,6 +191,7 @@ class Interface: "show_output": self.show_output, "title": self.title, "description": self.description, + "article": self.article, "thumbnail": self.thumbnail, "allow_screenshot": self.allow_screenshot, "allow_flagging": self.allow_flagging, diff --git a/gradio/static/js/gradio.js b/gradio/static/js/gradio.js index 4866f9fc97..94bd8f838e 100644 --- a/gradio/static/js/gradio.js +++ b/gradio/static/js/gradio.js @@ -59,7 +59,9 @@ function gradio(config, fn, target, example_file_path) {
- `); + +

+ `); let io_master = Object.create(io_master_template); io_master.fn = fn io_master.target = target; @@ -109,6 +111,9 @@ function gradio(config, fn, target, example_file_path) { if (config["description"]) { target.find(".description").text(config["description"]); } + if (config["article"]) { + target.find(".article").html(config["article"]); + } if (config["share_url"]) { let share_url = config["share_url"]; target.find(".share").removeClass("invisible"); diff --git a/readme_template.md b/readme_template.md index bcf802ad49..eb28575f77 100644 --- a/readme_template.md +++ b/readme_template.md @@ -124,6 +124,10 @@ Links expire after 6 hours. Need longer links, or private links? [Contact us fo ![Sharing diagram](demo/images/sharing.svg) +### Permanent Hosting + +You can share your interface publicly and permanently by hosting on Gradio's infrastructure. You will need to create a Gradio premium account. First, log into Gradio on [gradio.app](https://gradio.app) and click Sign In at the top. Once you've logged in with your Github account, you can specify which repositories from your Github profile you'd like to have hosted by Gradio. You must also specify the file within the repository that runs the Gradio `launch()` command. Once you've taken these steps, Gradio will launch your interface on a URL of the format **XXXXXX.gradio.app** where **XXXXXX** is any string you specify. + ## Contributing: If you would like to contribute and your contribution is small, you can directly open a pull request (PR). If you would like to contribute a larger feature, we recommend first creating an issue with a proposed design for discussion. Please see our contributing guidelines for more info. diff --git a/setup.py b/setup.py index c2c67055d5..de62bfac53 100644 --- a/setup.py +++ b/setup.py @@ -25,6 +25,7 @@ setup( 'scikit-learn', 'scikit-image', 'analytics-python', - 'pandas' + 'pandas', + 'markdown2' ], )