Skip to content

Commit

Permalink
Rewriting parts of the README and getting started guides for 4.0 (#6767)
Browse files Browse the repository at this point in the history
* doc rewrite

* changes

* changes

* tip

* changes

* notebook

* add changeset

* history

* add

* quickstart done

* readme

* changes

* quickstart

* changes

* reorder

* link

* changes

* changes

* changes

* quickstart done

* readme

* quickstart

* quickstart'

* moving around

* spaces

* readme

* guides

* guides

* links

* readme

* readme

* readme

* readme

* readme

* readme

* readme

* readme

* readme

* readme

* email address

* add changeset

* shorten quickstart

* readme

* Update README.md

* readme

* changes

* Update guides/01_getting-started/01_quickstart.md

Co-authored-by: Ali Abdalla <ali.si3luwa@gmail.com>

* Update guides/01_getting-started/01_quickstart.md

Co-authored-by: Ali Abdalla <ali.si3luwa@gmail.com>

* Update guides/01_getting-started/01_quickstart.md

Co-authored-by: Ali Abdalla <ali.si3luwa@gmail.com>

* changes

* changes

* remove gr.Interface.load

* guides

* changes

* more changes

* changes

* sharing

* concurrency

* changes

* changes

* components

* key features

* event listeners

* features

* notebook

* test

* guides

* changes

* changes

* changes

* transitions

* readme links

* links

* links

* guides

* new gif

* add gif

* update gif

* Update guides/02_building-interfaces/01_more-on-examples.md

* Update guides/03_building-with-blocks/01_blocks-and-event-listeners.md

* Update guides/01_getting-started/01_quickstart.md

Co-authored-by: Ali Abdalla <ali.si3luwa@gmail.com>

* Update guides/01_getting-started/02_key-features.md

Co-authored-by: Ali Abdalla <ali.si3luwa@gmail.com>

* Update guides/01_getting-started/02_key-features.md

Co-authored-by: Ali Abdalla <ali.si3luwa@gmail.com>

* Update guides/02_building-interfaces/00_the-interface-class.md

Co-authored-by: Ali Abdalla <ali.si3luwa@gmail.com>

* Update guides/01_getting-started/01_quickstart.md

Co-authored-by: Hannah <hannahblair@users.noreply.github.com>

* Update guides/01_getting-started/02_key-features.md

Co-authored-by: Hannah <hannahblair@users.noreply.github.com>

* Update guides/01_getting-started/02_key-features.md

Co-authored-by: Hannah <hannahblair@users.noreply.github.com>

* changes

* replace space

* changes

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
Co-authored-by: Ali Abdalla <ali.si3luwa@gmail.com>
Co-authored-by: Hannah <hannahblair@users.noreply.github.com>
  • Loading branch information
4 people committed Dec 20, 2023
1 parent e528f98 commit 7bb561a
Show file tree
Hide file tree
Showing 48 changed files with 610 additions and 1,216 deletions.
7 changes: 7 additions & 0 deletions .changeset/quick-chairs-check.md
@@ -0,0 +1,7 @@
---
"gradio": patch
"gradio_client": patch
"website": patch
---

fix:Rewriting parts of the README and getting started guides for 4.0
258 changes: 67 additions & 191 deletions README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion client/python/gradio_client/utils.py
Expand Up @@ -255,7 +255,7 @@ def probe_url(possible_url: str) -> bool:
"""
Probe the given URL to see if it responds with a 200 status code (to HEAD, then to GET).
"""
headers = {"User-Agent": "gradio (https://gradio.app/; team@gradio.app)"}
headers = {"User-Agent": "gradio (https://gradio.app/; gradio-team@huggingface.co)"}
try:
with httpx.Client() as client:
head_request = client.head(possible_url, headers=headers)
Expand Down
14 changes: 7 additions & 7 deletions client/python/pyproject.toml
Expand Up @@ -9,13 +9,13 @@ description = "Python library for easily interacting with trained machine learni
license = "Apache-2.0"
requires-python = ">=3.8"
authors = [
{ name = "Abubakar Abid", email = "team@gradio.app" },
{ name = "Ali Abid", email = "team@gradio.app" },
{ name = "Ali Abdalla", email = "team@gradio.app" },
{ name = "Dawood Khan", email = "team@gradio.app" },
{ name = "Ahsen Khaliq", email = "team@gradio.app" },
{ name = "Pete Allen", email = "team@gradio.app" },
{ name = "Freddy Boulton", email = "team@gradio.app" },
{ name = "Abubakar Abid", email = "gradio-team@huggingface.co" },
{ name = "Ali Abid", email = "gradio-team@huggingface.co" },
{ name = "Ali Abdalla", email = "gradio-team@huggingface.co" },
{ name = "Dawood Khan", email = "gradio-team@huggingface.co" },
{ name = "Ahsen Khaliq", email = "gradio-team@huggingface.co" },
{ name = "Pete Allen", email = "gradio-team@huggingface.co" },
{ name = "Freddy Boulton", email = "gradio-team@huggingface.co" },
]
keywords = ["machine learning", "client", "API"]

Expand Down
2 changes: 1 addition & 1 deletion demo/fake_diffusion/run.ipynb
@@ -1 +1 @@
{"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: fake_diffusion\n", "### This demo uses a fake model to showcase iterative output. The Image output will update every time a generator is returned until the final image.\n", " "]}, {"cell_type": "code", "execution_count": null, "id": "272996653310673477252411125948039410165", "metadata": {}, "outputs": [], "source": ["!pip install -q gradio numpy "]}, {"cell_type": "code", "execution_count": null, "id": "288918539441861185822528903084949547379", "metadata": {}, "outputs": [], "source": ["import gradio as gr\n", "import numpy as np\n", "import time\n", "\n", "# define core fn, which returns a generator {steps} times before returning the image\n", "def fake_diffusion(steps):\n", " for _ in range(steps):\n", " time.sleep(1)\n", " image = np.random.random((600, 600, 3))\n", " yield image\n", " image = np.ones((1000,1000,3), np.uint8)\n", " image[:] = [255, 124, 0]\n", " yield image\n", "\n", "\n", "demo = gr.Interface(fake_diffusion, inputs=gr.Slider(1, 10, 3), outputs=\"image\")\n", "\n", "# define queue - required for generators\n", "demo.queue()\n", "\n", "demo.launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
{"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: fake_diffusion\n", "### This demo uses a fake model to showcase iterative output. The Image output will update every time a generator is returned until the final image.\n", " "]}, {"cell_type": "code", "execution_count": null, "id": "272996653310673477252411125948039410165", "metadata": {}, "outputs": [], "source": ["!pip install -q gradio numpy "]}, {"cell_type": "code", "execution_count": null, "id": "288918539441861185822528903084949547379", "metadata": {}, "outputs": [], "source": ["import gradio as gr\n", "import numpy as np\n", "import time\n", "\n", "def fake_diffusion(steps):\n", " for i in range(steps):\n", " time.sleep(1)\n", " image = np.random.random((600, 600, 3))\n", " yield image\n", " image = np.ones((1000,1000,3), np.uint8)\n", " image[:] = [255, 124, 0]\n", " yield image\n", "\n", "\n", "demo = gr.Interface(fake_diffusion, inputs=gr.Slider(1, 10, 3), outputs=\"image\")\n", "\n", "if __name__ == \"__main__\":\n", " demo.launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
9 changes: 3 additions & 6 deletions demo/fake_diffusion/run.py
Expand Up @@ -2,9 +2,8 @@
import numpy as np
import time

# define core fn, which returns a generator {steps} times before returning the image
def fake_diffusion(steps):
for _ in range(steps):
for i in range(steps):
time.sleep(1)
image = np.random.random((600, 600, 3))
yield image
Expand All @@ -15,7 +14,5 @@ def fake_diffusion(steps):

demo = gr.Interface(fake_diffusion, inputs=gr.Slider(1, 10, 3), outputs="image")

# define queue - required for generators
demo.queue()

demo.launch()
if __name__ == "__main__":
demo.launch()
2 changes: 1 addition & 1 deletion demo/hello_blocks/run.ipynb
@@ -1 +1 @@
{"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: hello_blocks"]}, {"cell_type": "code", "execution_count": null, "id": "272996653310673477252411125948039410165", "metadata": {}, "outputs": [], "source": ["!pip install -q gradio "]}, {"cell_type": "code", "execution_count": null, "id": "288918539441861185822528903084949547379", "metadata": {}, "outputs": [], "source": ["import gradio as gr\n", "\n", "\n", "def greet(name):\n", " return \"Hello \" + name + \"!\"\n", "\n", "\n", "with gr.Blocks() as demo:\n", " name = gr.Textbox(label=\"Name\")\n", " output = gr.Textbox(label=\"Output Box\")\n", " greet_btn = gr.Button(\"Greet\")\n", " greet_btn.click(fn=greet, inputs=name, outputs=output, api_name=\"greet\")\n", "\n", "if __name__ == \"__main__\":\n", " demo.launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
{"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: hello_blocks"]}, {"cell_type": "code", "execution_count": null, "id": "272996653310673477252411125948039410165", "metadata": {}, "outputs": [], "source": ["!pip install -q gradio "]}, {"cell_type": "code", "execution_count": null, "id": "288918539441861185822528903084949547379", "metadata": {}, "outputs": [], "source": ["import gradio as gr\n", "\n", "def greet(name):\n", " return \"Hello \" + name + \"!\"\n", "\n", "with gr.Blocks() as demo:\n", " name = gr.Textbox(label=\"Name\")\n", " output = gr.Textbox(label=\"Output Box\")\n", " greet_btn = gr.Button(\"Greet\")\n", " greet_btn.click(fn=greet, inputs=name, outputs=output, api_name=\"greet\")\n", "\n", "if __name__ == \"__main__\":\n", " demo.launch()"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
4 changes: 1 addition & 3 deletions demo/hello_blocks/run.py
@@ -1,15 +1,13 @@
import gradio as gr


def greet(name):
return "Hello " + name + "!"


with gr.Blocks() as demo:
name = gr.Textbox(label="Name")
output = gr.Textbox(label="Output Box")
greet_btn = gr.Button("Greet")
greet_btn.click(fn=greet, inputs=name, outputs=output, api_name="greet")

if __name__ == "__main__":
demo.launch()
demo.launch()
2 changes: 1 addition & 1 deletion demo/hello_world/run.ipynb
@@ -1 +1 @@
{"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: hello_world\n", "### The simplest possible Gradio demo. It wraps a 'Hello {name}!' function in an Interface that accepts and returns text.\n", " "]}, {"cell_type": "code", "execution_count": null, "id": "272996653310673477252411125948039410165", "metadata": {}, "outputs": [], "source": ["!pip install -q gradio "]}, {"cell_type": "code", "execution_count": null, "id": "288918539441861185822528903084949547379", "metadata": {}, "outputs": [], "source": ["import gradio as gr\n", "\n", "def greet(name):\n", " return \"Hello \" + name + \"!\"\n", "\n", "demo = gr.Interface(fn=greet, inputs=\"text\", outputs=\"text\")\n", " \n", "if __name__ == \"__main__\":\n", " demo.launch(show_api=False) "]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
{"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: hello_world\n", "### The simplest possible Gradio demo. It wraps a 'Hello {name}!' function in an Interface that accepts and returns text.\n", " "]}, {"cell_type": "code", "execution_count": null, "id": "272996653310673477252411125948039410165", "metadata": {}, "outputs": [], "source": ["!pip install -q gradio "]}, {"cell_type": "code", "execution_count": null, "id": "288918539441861185822528903084949547379", "metadata": {}, "outputs": [], "source": ["import gradio as gr\n", "\n", "def greet(name):\n", " return \"Hello \" + name + \"!\"\n", "\n", "demo = gr.Interface(fn=greet, inputs=\"textbox\", outputs=\"textbox\")\n", " \n", "if __name__ == \"__main__\":\n", " demo.launch() "]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
4 changes: 2 additions & 2 deletions demo/hello_world/run.py
Expand Up @@ -3,7 +3,7 @@
def greet(name):
return "Hello " + name + "!"

demo = gr.Interface(fn=greet, inputs="text", outputs="text")
demo = gr.Interface(fn=greet, inputs="textbox", outputs="textbox")

if __name__ == "__main__":
demo.launch(show_api=False)
demo.launch()
2 changes: 1 addition & 1 deletion demo/hello_world_2/run.ipynb
@@ -1 +1 @@
{"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: hello_world_2"]}, {"cell_type": "code", "execution_count": null, "id": "272996653310673477252411125948039410165", "metadata": {}, "outputs": [], "source": ["!pip install -q gradio "]}, {"cell_type": "code", "execution_count": null, "id": "288918539441861185822528903084949547379", "metadata": {}, "outputs": [], "source": ["import gradio as gr\n", "\n", "def greet(name):\n", " return \"Hello \" + name + \"!\"\n", "\n", "demo = gr.Interface(\n", " fn=greet,\n", " inputs=gr.Textbox(lines=2, placeholder=\"Name Here...\"),\n", " outputs=\"text\",\n", ")\n", "if __name__ == \"__main__\":\n", " demo.launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
{"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: hello_world_2"]}, {"cell_type": "code", "execution_count": null, "id": "272996653310673477252411125948039410165", "metadata": {}, "outputs": [], "source": ["!pip install -q gradio "]}, {"cell_type": "code", "execution_count": null, "id": "288918539441861185822528903084949547379", "metadata": {}, "outputs": [], "source": ["import gradio as gr\n", "\n", "def greet(name, intensity):\n", " return \"Hello \" * intensity + name + \"!\"\n", "\n", "demo = gr.Interface(\n", " fn=greet,\n", " inputs=[\"text\", gr.Slider(value=2, minimum=1, maximum=10)],\n", " outputs=[gr.Textbox(label=\"greeting\", lines=3)],\n", ")\n", "\n", "if __name__ == \"__main__\":\n", " demo.launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
9 changes: 5 additions & 4 deletions demo/hello_world_2/run.py
@@ -1,12 +1,13 @@
import gradio as gr

def greet(name):
return "Hello " + name + "!"
def greet(name, intensity):
return "Hello " * intensity + name + "!"

demo = gr.Interface(
fn=greet,
inputs=gr.Textbox(lines=2, placeholder="Name Here..."),
outputs="text",
inputs=["text", gr.Slider(value=2, minimum=1, maximum=10)],
outputs=[gr.Textbox(label="greeting", lines=3)],
)

if __name__ == "__main__":
demo.launch()
1 change: 1 addition & 0 deletions demo/hello_world_4/run.ipynb
@@ -0,0 +1 @@
{"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: hello_world_4"]}, {"cell_type": "code", "execution_count": null, "id": "272996653310673477252411125948039410165", "metadata": {}, "outputs": [], "source": ["!pip install -q gradio "]}, {"cell_type": "code", "execution_count": null, "id": "288918539441861185822528903084949547379", "metadata": {}, "outputs": [], "source": ["import gradio as gr\n", "\n", "def greet(name, intensity):\n", " return \"Hello \" * intensity + name + \"!\"\n", "\n", "demo = gr.Interface(\n", " fn=greet,\n", " inputs=[\"text\", \"slider\"],\n", " outputs=[\"text\"],\n", ")\n", "\n", "if __name__ == \"__main__\":\n", " demo.launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
13 changes: 13 additions & 0 deletions demo/hello_world_4/run.py
@@ -0,0 +1,13 @@
import gradio as gr

def greet(name, intensity):
return "Hello " * intensity + name + "!"

demo = gr.Interface(
fn=greet,
inputs=["text", "slider"],
outputs=["text"],
)

if __name__ == "__main__":
demo.launch()
Binary file added demo/hello_world_4/screenshot.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion gradio/utils.py
Expand Up @@ -586,7 +586,7 @@ def append_unique_suffix(name: str, list_of_names: list[str]):


def validate_url(possible_url: str) -> bool:
headers = {"User-Agent": "gradio (https://gradio.app/; team@gradio.app)"}
headers = {"User-Agent": "gradio (https://gradio.app/; gradio-team@huggingface.co)"}
try:
head_request = httpx.head(possible_url, headers=headers, follow_redirects=True)
# some URLs, such as AWS S3 presigned URLs, return a 405 or a 403 for HEAD requests
Expand Down

0 comments on commit 7bb561a

Please sign in to comment.