From 890150a5cb8f04667e6a6251052605171212a178 Mon Sep 17 00:00:00 2001 From: Abubakar Abid Date: Fri, 18 Oct 2024 12:41:03 -0700 Subject: [PATCH] fix readme and quickstart guide (#9759) * readme * fix * changes * changes * changes * changes * changes * changes * changes * changes * readme --- README.md | 51 +++++++++++----------- guides/01_getting-started/01_quickstart.md | 15 ++++--- readme_template.md | 23 +++++++--- 3 files changed, 51 insertions(+), 38 deletions(-) diff --git a/README.md b/README.md index dadeb014c3..c12d6b394c 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,20 @@ - +
+ +gradio + +
-[gradio](https://gradio.app)
+
+ +Gradio 5.0 - the easiest way to build AI web apps | Product Hunt +gradio-app%2Fgradio | Trendshift + [![gradio-backend](https://github.com/gradio-app/gradio/actions/workflows/test-python.yml/badge.svg)](https://github.com/gradio-app/gradio/actions/workflows/test-python.yml) -[![gradio-ui](https://github.com/gradio-app/gradio/actions/workflows/tests-js.yml/badge.svg)](https://github.com/gradio-app/gradio/actions/workflows/tests-js.yml) - [![PyPI](https://img.shields.io/pypi/v/gradio)](https://pypi.org/project/gradio/) +[![gradio-ui](https://github.com/gradio-app/gradio/actions/workflows/tests-js.yml/badge.svg)](https://github.com/gradio-app/gradio/actions/workflows/tests-js.yml) +[![PyPI](https://img.shields.io/pypi/v/gradio)](https://pypi.org/project/gradio/) [![PyPI downloads](https://img.shields.io/pypi/dm/gradio)](https://pypi.org/project/gradio/) ![Python version](https://img.shields.io/badge/python-3.10+-important) [![Twitter follow](https://img.shields.io/twitter/follow/gradio?style=social&label=follow)](https://twitter.com/gradio) @@ -25,15 +33,6 @@ English | [δΈ­ζ–‡](readme_files/zh-cn#readme)
-
- -
- -Gradio 5.0 - the easiest way to build AI web apps | Product Hunt -gradio-app%2Fgradio | Trendshift - -
- # Gradio: Build Machine Learning Web Apps β€” in Python @@ -44,6 +43,7 @@ Gradio is an open-source Python package that allows you to quickly **build** a d It just takes a few lines of Python to create your own demo, so let's get started πŸ’« + ### Installation **Prerequisite**: Gradio 5 supports [Python 3.10 - 3.12](https://www.python.org/downloads/). @@ -51,7 +51,7 @@ It just takes a few lines of Python to create your own demo, so let's get starte We recommend installing Gradio using `pip`, which is included by default in Python. Run this in your terminal or command prompt: -``` +```bash pip install --upgrade gradio ``` @@ -68,7 +68,7 @@ You can run Gradio in your favorite code editor, Jupyter notebook, Google Colab, import gradio as gr def greet(name, intensity): - return "Hello " * intensity + name + "!" + return "Hello, " + name + "!" * int(intensity) demo = gr.Interface( fn=greet, @@ -82,9 +82,9 @@ demo.launch() > [!TIP] - > We shorten the imported name from gradio to gr for better readability of code. This is a widely adopted convention that you should follow so that anyone working with your code can easily understand it. + > We shorten the imported name from gradio to gr. This is a widely adopted convention for better readability of code. -Now, run your code. If you've written the Python code in a file named, for example, `app.py`, then you would run `python app.py` from the terminal. +Now, run your code. If you've written the Python code in a file named `app.py`, then you would run `python app.py` from the terminal. The demo below will open in a browser on [http://localhost:7860](http://localhost:7860) if running from a file. If you are running within a notebook, the demo will appear embedded within the notebook. @@ -93,7 +93,7 @@ The demo below will open in a browser on [http://localhost:7860](http://localhos Type your name in the textbox on the left, drag the slider, and then press the Submit button. You should see a friendly greeting on the right. > [!TIP] - > When developing locally, you can run your Gradio app in hot reload mode, which automatically reloads the Gradio app whenever you make changes to the file. To do this, simply type in gradio before the name of the file instead of python. In the example above, you would type: `gradio app.py` in your terminal. Learn more about hot reloading in the Hot Reloading Guide. + > When developing locally, you can run your Gradio app in hot reload mode, which automatically reloads the Gradio app whenever you make changes to the file. To do this, simply type in gradio before the name of the file instead of python. In the example above, you would type: `gradio app.py` in your terminal. Learn more in the Hot Reloading Guide. **Understanding the `Interface` Class** @@ -108,7 +108,7 @@ The `Interface` class has three core arguments: The `fn` argument is very flexible -- you can pass *any* Python function that you want to wrap with a UI. In the example above, we saw a relatively simple function, but the function could be anything from a music generator to a tax calculator to the prediction function of a pretrained machine learning model. -The `input` and `output` arguments take one or more Gradio components. As we'll see, Gradio includes more than [30 built-in components](https://www.gradio.app/docs/gradio/introduction) (such as the `gr.Textbox()`, `gr.Image()`, and `gr.HTML()` components) that are designed for machine learning applications. +The `inputs` and `outputs` arguments take one or more Gradio components. As we'll see, Gradio includes more than [30 built-in components](https://www.gradio.app/docs/gradio/introduction) (such as the `gr.Textbox()`, `gr.Image()`, and `gr.HTML()` components) that are designed for machine learning applications. > [!TIP] > For the `inputs` and `outputs` arguments, you can pass in the name of these components as a string (`"textbox"`) or an instance of the class (`gr.Textbox()`). @@ -143,18 +143,17 @@ To learn more about sharing your demo, read our dedicated guide on [sharing your ### An Overview of Gradio -So far, we've been discussing the `Interface` class, which is a high-level class that lets to build demos quickly with Gradio. But what else does Gradio do? - -#### Chatbots with `gr.ChatInterface` - -Gradio includes another high-level class, `gr.ChatInterface`, which is specifically designed to create Chatbot UIs. Similar to `Interface`, you supply a function and Gradio creates a fully working Chatbot UI. If you're interested in creating a chatbot, you can jump straight [our dedicated guide on `gr.ChatInterface`](https://www.gradio.app/guides/creating-a-chatbot-fast). +So far, we've been discussing the `Interface` class, which is a high-level class that lets to build demos quickly with Gradio. But what else does Gradio include? #### Custom Demos with `gr.Blocks` -Gradio also offers a low-level approach for designing web apps with more flexible layouts and data flows with the `gr.Blocks` class. Blocks allows you to do things like control where components appear on the page, handle complex data flows (e.g. outputs can serve as inputs to other functions), and update properties/visibility of components based on user interaction β€” still all in Python. +Gradio offers a low-level approach for designing web apps with more customizable layouts and data flows with the `gr.Blocks` class. Blocks supports things like controlling where components appear on the page, handling multiple data flows and more complex interactions (e.g. outputs can serve as inputs to other functions), and updating properties/visibility of components based on user interaction β€” still all in Python. You can build very custom and complex applications using `gr.Blocks()`. For example, the popular image generation [Automatic1111 Web UI](https://github.com/AUTOMATIC1111/stable-diffusion-webui) is built using Gradio Blocks. We dive deeper into the `gr.Blocks` on our series on [building with Blocks](https://www.gradio.app/guides/blocks-and-event-listeners). +#### Chatbots with `gr.ChatInterface` + +Gradio includes another high-level class, `gr.ChatInterface`, which is specifically designed to create Chatbot UIs. Similar to `Interface`, you supply a function and Gradio creates a fully working Chatbot UI. If you're interested in creating a chatbot, you can jump straight to [our dedicated guide on `gr.ChatInterface`](https://www.gradio.app/guides/creating-a-chatbot-fast). #### The Gradio Python & JavaScript Ecosystem @@ -167,7 +166,7 @@ That's the gist of the core `gradio` Python library, but Gradio is actually so m ### What's Next? -Keep learning about Gradio sequentially using the Gradio Guides, which include explanations as well as example code and embedded interactive demos. Next up: [key features about Gradio demos](https://www.gradio.app/guides/key-features). +Keep learning about Gradio sequentially using the Gradio Guides, which include explanations as well as example code and embedded interactive demos. Next up: [let's dive deeper into the Interface class](https://www.gradio.app/guides/the-interface-class). Or, if you already know the basics and are looking for something specific, you can search the more [technical API documentation](https://www.gradio.app/docs/). diff --git a/guides/01_getting-started/01_quickstart.md b/guides/01_getting-started/01_quickstart.md index 4cc35cdc8a..72289d413e 100644 --- a/guides/01_getting-started/01_quickstart.md +++ b/guides/01_getting-started/01_quickstart.md @@ -1,10 +1,11 @@ # Quickstart -Gradio is an open-source Python package that allows you to quickly **build a demo** or web application for your machine learning model, API, or any arbitrary Python function. You can then **share your demo** with a a public link in seconds using Gradio's built-in sharing features. *No JavaScript, CSS, or web hosting experience needed!* +Gradio is an open-source Python package that allows you to quickly **build** a demo or web application for your machine learning model, API, or any arbitrary Python function. You can then **share** a link to your demo or web application in just a few seconds using Gradio's built-in sharing features. *No JavaScript, CSS, or web hosting experience needed!* - + + +It just takes a few lines of Python to create your own demo, so let's get started πŸ’« -It just takes a few lines of Python to create a demo like the one above, so let's get started. ## Installation @@ -14,11 +15,11 @@ It just takes a few lines of Python to create a demo like the one above, so let' We recommend installing Gradio using `pip`, which is included by default in Python. Run this in your terminal or command prompt: ```bash -pip install gradio +pip install --upgrade gradio ``` -Tip: it is best to install Gradio in a virtual environment. Detailed installation instructions for all common operating systems are provided here. +Tip: It is best to install Gradio in a virtual environment. Detailed installation instructions for all common operating systems are provided here. ## Building Your First Demo @@ -85,7 +86,7 @@ Now, anyone around the world can try your Gradio demo from their browser, while To learn more about sharing your demo, read our dedicated guide on [sharing your Gradio application](https://www.gradio.app/guides/sharing-your-app). -## Core Gradio Classes +## An Overview of Gradio So far, we've been discussing the `Interface` class, which is a high-level class that lets to build demos quickly with Gradio. But what else does Gradio include? @@ -101,7 +102,7 @@ Gradio includes another high-level class, `gr.ChatInterface`, which is specifica ### The Gradio Python & JavaScript Ecosystem -That's the gist of the core `gradio` Python library, but Gradio is actually so much more! Its an entire ecosystem of Python and JavaScript libraries that let you build machine learning applications, or query them programmatically, in Python or JavaScript. Here are other related parts of the Gradio ecosystem: +That's the gist of the core `gradio` Python library, but Gradio is actually so much more! It's an entire ecosystem of Python and JavaScript libraries that let you build machine learning applications, or query them programmatically, in Python or JavaScript. Here are other related parts of the Gradio ecosystem: * [Gradio Python Client](https://www.gradio.app/guides/getting-started-with-the-python-client) (`gradio_client`): query any Gradio app programmatically in Python. * [Gradio JavaScript Client](https://www.gradio.app/guides/getting-started-with-the-js-client) (`@gradio/client`): query any Gradio app programmatically in JavaScript. diff --git a/readme_template.md b/readme_template.md index aa1f31bcf8..dcc6f09951 100644 --- a/readme_template.md +++ b/readme_template.md @@ -1,10 +1,18 @@
+ +gradio + +
-[gradio](https://gradio.app)
+
+ +Gradio 5.0 - the easiest way to build AI web apps | Product Hunt +gradio-app%2Fgradio | Trendshift + -[![gradio-backend](https://github.com/gradio-app/gradio/actions/workflows/backend.yml/badge.svg)](https://github.com/gradio-app/gradio/actions/workflows/backend.yml) -[![gradio-ui](https://github.com/gradio-app/gradio/actions/workflows/ui.yml/badge.svg)](https://github.com/gradio-app/gradio/actions/workflows/ui.yml) - [![PyPI](https://img.shields.io/pypi/v/gradio)](https://pypi.org/project/gradio/) +[![gradio-backend](https://github.com/gradio-app/gradio/actions/workflows/test-python.yml/badge.svg)](https://github.com/gradio-app/gradio/actions/workflows/test-python.yml) +[![gradio-ui](https://github.com/gradio-app/gradio/actions/workflows/tests-js.yml/badge.svg)](https://github.com/gradio-app/gradio/actions/workflows/tests-js.yml) +[![PyPI](https://img.shields.io/pypi/v/gradio)](https://pypi.org/project/gradio/) [![PyPI downloads](https://img.shields.io/pypi/dm/gradio)](https://pypi.org/project/gradio/) ![Python version](https://img.shields.io/badge/python-3.10+-important) [![Twitter follow](https://img.shields.io/twitter/follow/gradio?style=social&label=follow)](https://twitter.com/gradio) @@ -14,7 +22,12 @@ | [Guides](https://gradio.app/guides/) | [Getting Started](https://gradio.app/getting_started/) | [Examples](demo/) -| [δΈ­ζ–‡](readme_files/zh-cn#readme) + +
+ +
+ +English | [δΈ­ζ–‡](readme_files/zh-cn#readme)