Upload 14 files
Browse files- .dockerignore +40 -0
- .gitignore +53 -0
- CHANGELOG.md +0 -0
- CITATION.cff +45 -0
- CONTRIBUTING.md +99 -0
- LICENSE +201 -0
- README.md +274 -3
- SECURITY.md +5 -0
- codecov.yml +17 -0
- pyproject.toml +60 -0
- readme_template.md +67 -0
- render_readme.py +39 -0
- requirements.txt +22 -0
- style.md +160 -0
.dockerignore
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Python build
|
2 |
+
.eggs/
|
3 |
+
gradio.egg-info/*
|
4 |
+
!gradio.egg-info/requires.txt
|
5 |
+
!gradio.egg-info/PKG-INFO
|
6 |
+
dist/
|
7 |
+
*.pyc
|
8 |
+
__pycache__/
|
9 |
+
*.py[cod]
|
10 |
+
*$py.class
|
11 |
+
build/
|
12 |
+
|
13 |
+
# JS build
|
14 |
+
gradio/templates/frontend/static
|
15 |
+
gradio/templates/frontend/cdn
|
16 |
+
|
17 |
+
# Secrets
|
18 |
+
.env
|
19 |
+
|
20 |
+
# Gradio run artifacts
|
21 |
+
*.db
|
22 |
+
*.sqlite3
|
23 |
+
gradio/launches.json
|
24 |
+
|
25 |
+
# Tests
|
26 |
+
.coverage
|
27 |
+
coverage.xml
|
28 |
+
test.txt
|
29 |
+
|
30 |
+
# Demos
|
31 |
+
demo/tmp.zip
|
32 |
+
demo/flagged
|
33 |
+
demo/files/*.avi
|
34 |
+
demo/files/*.mp4
|
35 |
+
|
36 |
+
# Etc
|
37 |
+
.idea/*
|
38 |
+
.DS_Store
|
39 |
+
*.bak
|
40 |
+
workspace.code-workspace
|
.gitignore
ADDED
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Python build
|
2 |
+
.eggs/
|
3 |
+
gradio.egg-info
|
4 |
+
dist/
|
5 |
+
*.pyc
|
6 |
+
__pycache__/
|
7 |
+
*.py[cod]
|
8 |
+
*$py.class
|
9 |
+
build/
|
10 |
+
|
11 |
+
# JS build
|
12 |
+
gradio/templates/cdn
|
13 |
+
gradio/templates/frontend
|
14 |
+
|
15 |
+
# Secrets
|
16 |
+
.env
|
17 |
+
|
18 |
+
# Gradio run artifacts
|
19 |
+
*.db
|
20 |
+
*.sqlite3
|
21 |
+
gradio/launches.json
|
22 |
+
flagged/
|
23 |
+
gradio_cached_examples/
|
24 |
+
|
25 |
+
# Tests
|
26 |
+
.coverage
|
27 |
+
coverage.xml
|
28 |
+
test.txt
|
29 |
+
**/snapshots/**/*.png
|
30 |
+
|
31 |
+
# Demos
|
32 |
+
demo/tmp.zip
|
33 |
+
demo/files/*.avi
|
34 |
+
demo/files/*.mp4
|
35 |
+
demo/all_demos/demos/*
|
36 |
+
demo/all_demos/requirements.txt
|
37 |
+
demo/*/config.json
|
38 |
+
|
39 |
+
# Etc
|
40 |
+
.idea/*
|
41 |
+
.DS_Store
|
42 |
+
*.bak
|
43 |
+
workspace.code-workspace
|
44 |
+
*.h5
|
45 |
+
|
46 |
+
# log files
|
47 |
+
.pnpm-debug.log
|
48 |
+
|
49 |
+
# Local virtualenv for devs
|
50 |
+
.venv*
|
51 |
+
|
52 |
+
# FRP
|
53 |
+
gradio/frpc_*
|
CHANGELOG.md
ADDED
The diff for this file is too large to render.
See raw diff
|
|
CITATION.cff
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
cff-version: 1.2.0
|
2 |
+
message: Please cite this project using these metadata.
|
3 |
+
title: "Gradio: Hassle-free sharing and testing of ML models in the wild"
|
4 |
+
abstract: >-
|
5 |
+
Accessibility is a major challenge of machine learning (ML).
|
6 |
+
Typical ML models are built by specialists and require
|
7 |
+
specialized hardware/software as well as ML experience to
|
8 |
+
validate. This makes it challenging for non-technical
|
9 |
+
collaborators and endpoint users (e.g. physicians) to easily
|
10 |
+
provide feedback on model development and to gain trust in
|
11 |
+
ML. The accessibility challenge also makes collaboration
|
12 |
+
more difficult and limits the ML researcher's exposure to
|
13 |
+
realistic data and scenarios that occur in the wild. To
|
14 |
+
improve accessibility and facilitate collaboration, we
|
15 |
+
developed an open-source Python package, Gradio, which
|
16 |
+
allows researchers to rapidly generate a visual interface
|
17 |
+
for their ML models. Gradio makes accessing any ML model as
|
18 |
+
easy as sharing a URL. Our development of Gradio is informed
|
19 |
+
by interviews with a number of machine learning researchers
|
20 |
+
who participate in interdisciplinary collaborations. Their
|
21 |
+
feedback identified that Gradio should support a variety of
|
22 |
+
interfaces and frameworks, allow for easy sharing of the
|
23 |
+
interface, allow for input manipulation and interactive
|
24 |
+
inference by the domain expert, as well as allow embedding
|
25 |
+
the interface in iPython notebooks. We developed these
|
26 |
+
features and carried out a case study to understand Gradio's
|
27 |
+
usefulness and usability in the setting of a machine
|
28 |
+
learning collaboration between a researcher and a
|
29 |
+
cardiologist.
|
30 |
+
authors:
|
31 |
+
- family-names: Abid
|
32 |
+
given-names: Abubakar
|
33 |
+
- family-names: Abdalla
|
34 |
+
given-names: Ali
|
35 |
+
- family-names: Abid
|
36 |
+
given-names: Ali
|
37 |
+
- family-names: Khan
|
38 |
+
given-names: Dawood
|
39 |
+
- family-names: Alfozan
|
40 |
+
given-names: Abdulrahman
|
41 |
+
- family-names: Zou
|
42 |
+
given-names: James
|
43 |
+
doi: 10.48550/arXiv.1906.02569
|
44 |
+
date-released: 2019-06-06
|
45 |
+
url: https://arxiv.org/abs/1906.02569
|
CONTRIBUTING.md
ADDED
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Contributing to Gradio
|
2 |
+
|
3 |
+
Prequisites:
|
4 |
+
|
5 |
+
* [Python 3.7+](https://www.python.org/downloads/)
|
6 |
+
* [pnpm version 7.x](https://pnpm.io/7.x/installation) (optional for backend-only changes, but needed for any frontend changes)
|
7 |
+
|
8 |
+
More than 80 awesome developers have contributed to the `gradio` library, and we'd be thrilled if you would like be the next `gradio` contributor! Start by cloning this repo and installing Gradio locally:
|
9 |
+
|
10 |
+
### Install Gradio locally from the `main` branch
|
11 |
+
|
12 |
+
* Clone this repo
|
13 |
+
* Navigate to the repo folder and run
|
14 |
+
|
15 |
+
```bash
|
16 |
+
bash scripts/install_gradio.sh
|
17 |
+
```
|
18 |
+
|
19 |
+
* Build the front end
|
20 |
+
|
21 |
+
```
|
22 |
+
bash scripts/build_frontend.sh
|
23 |
+
```
|
24 |
+
|
25 |
+
|
26 |
+
### Install testing requirements
|
27 |
+
|
28 |
+
In order to be able to run the Python unit tests, do the following:
|
29 |
+
|
30 |
+
* Navigate to the repo folder and install test requirements (note that it is highly recommended to use a virtual environment running **Python 3.9** since the versions are pinned)
|
31 |
+
|
32 |
+
```
|
33 |
+
bash scripts/install_test_requirements.sh
|
34 |
+
```
|
35 |
+
* If you have a different Python version and conflicting packages during the installation, please first run:
|
36 |
+
|
37 |
+
```
|
38 |
+
bash scripts/create_test_requirements.sh
|
39 |
+
```
|
40 |
+
|
41 |
+
### Extra tidbits
|
42 |
+
|
43 |
+
* You can run gradio scripts in reload mode which will watch for changes in the `gradio` folder and reload the app if changes are made.
|
44 |
+
```
|
45 |
+
gradio app.py
|
46 |
+
```
|
47 |
+
|
48 |
+
* You can also start a local frontend development server (on port 3000 by default) that responds to any changes in the frontend.
|
49 |
+
|
50 |
+
```
|
51 |
+
bash scripts/run_frontend.sh
|
52 |
+
```
|
53 |
+
* To run all of the tests, do:
|
54 |
+
|
55 |
+
```
|
56 |
+
bash scripts/run_all_tests.sh
|
57 |
+
```
|
58 |
+
|
59 |
+
|
60 |
+
### Structure of the Repository
|
61 |
+
|
62 |
+
It's helpful to know the overall structure of the repository so that you can focus on the part of the source code you'd like to contribute to
|
63 |
+
|
64 |
+
* `/gradio`: contains the Python source code for the library
|
65 |
+
* `/gradio/interface.py`: contains the Python source code for the core `Interface` class
|
66 |
+
* `/gradio/blocks.py`: contains the Python source code for the core `Blocks` class
|
67 |
+
* `/gradio/components.py`: contains the Python source code for the `components`, you can add your custom components here.
|
68 |
+
* `/ui`: contains the HTML/JS/CSS source code for the library ([start here for frontend changes](/ui/README.md))
|
69 |
+
* `/test`: contains Python unit tests for the library
|
70 |
+
* `/demo`: contains demos that are used in the documentation, you can find `Gradio` examples over here.
|
71 |
+
* `/website`: contains the code for the Gradio website (www.gradio.app). See the README in the `/website` folder for more details
|
72 |
+
|
73 |
+
### Continuous Integration and Testing
|
74 |
+
|
75 |
+
All PRs must pass the continuous integration tests before merging. To test locally, you can run `python -m unittest` from the repo directory.
|
76 |
+
|
77 |
+
## Submitting PRs
|
78 |
+
|
79 |
+
All PRs should be against `main`. Direct commits to main are blocked, and PRs require an approving review to merge into main. By convention, the Gradio maintainers will review PRs when:
|
80 |
+
|
81 |
+
* An initial review has been requested, and
|
82 |
+
* A description of the change (with a link to the GitHub PR) has been added to CHANGELOG.md, and
|
83 |
+
* A maintainer (@abidlabs, @aliabid94, @aliabd, @AK391, @dawoodkhan82, @pngwn, @freddyaboulton) is tagged in the PR comments and asked to complete a review
|
84 |
+
|
85 |
+
We ask that you make sure initial CI checks are passing before requesting a review. One of the Gradio maintainers will merge the PR when all the checks are passing.
|
86 |
+
|
87 |
+
Do not forget the format the backend before pushing.
|
88 |
+
```
|
89 |
+
bash scripts/format_backend.sh
|
90 |
+
```
|
91 |
+
```
|
92 |
+
bash scripts/format_frontend.sh
|
93 |
+
```
|
94 |
+
You can run the circleci checks locally as well.
|
95 |
+
```
|
96 |
+
bash scripts/run_circleci.sh
|
97 |
+
```
|
98 |
+
|
99 |
+
*Could these guidelines be clearer? Feel free to open a PR to help us faciltiate open-source contributions!*
|
LICENSE
ADDED
@@ -0,0 +1,201 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Apache License
|
2 |
+
Version 2.0, January 2004
|
3 |
+
http://www.apache.org/licenses/
|
4 |
+
|
5 |
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
6 |
+
|
7 |
+
1. Definitions.
|
8 |
+
|
9 |
+
"License" shall mean the terms and conditions for use, reproduction,
|
10 |
+
and distribution as defined by Sections 1 through 9 of this document.
|
11 |
+
|
12 |
+
"Licensor" shall mean the copyright owner or entity authorized by
|
13 |
+
the copyright owner that is granting the License.
|
14 |
+
|
15 |
+
"Legal Entity" shall mean the union of the acting entity and all
|
16 |
+
other entities that control, are controlled by, or are under common
|
17 |
+
control with that entity. For the purposes of this definition,
|
18 |
+
"control" means (i) the power, direct or indirect, to cause the
|
19 |
+
direction or management of such entity, whether by contract or
|
20 |
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
21 |
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
22 |
+
|
23 |
+
"You" (or "Your") shall mean an individual or Legal Entity
|
24 |
+
exercising permissions granted by this License.
|
25 |
+
|
26 |
+
"Source" form shall mean the preferred form for making modifications,
|
27 |
+
including but not limited to software source code, documentation
|
28 |
+
source, and configuration files.
|
29 |
+
|
30 |
+
"Object" form shall mean any form resulting from mechanical
|
31 |
+
transformation or translation of a Source form, including but
|
32 |
+
not limited to compiled object code, generated documentation,
|
33 |
+
and conversions to other media types.
|
34 |
+
|
35 |
+
"Work" shall mean the work of authorship, whether in Source or
|
36 |
+
Object form, made available under the License, as indicated by a
|
37 |
+
copyright notice that is included in or attached to the work
|
38 |
+
(an example is provided in the Appendix below).
|
39 |
+
|
40 |
+
"Derivative Works" shall mean any work, whether in Source or Object
|
41 |
+
form, that is based on (or derived from) the Work and for which the
|
42 |
+
editorial revisions, annotations, elaborations, or other modifications
|
43 |
+
represent, as a whole, an original work of authorship. For the purposes
|
44 |
+
of this License, Derivative Works shall not include works that remain
|
45 |
+
separable from, or merely link (or bind by name) to the interfaces of,
|
46 |
+
the Work and Derivative Works thereof.
|
47 |
+
|
48 |
+
"Contribution" shall mean any work of authorship, including
|
49 |
+
the original version of the Work and any modifications or additions
|
50 |
+
to that Work or Derivative Works thereof, that is intentionally
|
51 |
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
52 |
+
or by an individual or Legal Entity authorized to submit on behalf of
|
53 |
+
the copyright owner. For the purposes of this definition, "submitted"
|
54 |
+
means any form of electronic, verbal, or written communication sent
|
55 |
+
to the Licensor or its representatives, including but not limited to
|
56 |
+
communication on electronic mailing lists, source code control systems,
|
57 |
+
and issue tracking systems that are managed by, or on behalf of, the
|
58 |
+
Licensor for the purpose of discussing and improving the Work, but
|
59 |
+
excluding communication that is conspicuously marked or otherwise
|
60 |
+
designated in writing by the copyright owner as "Not a Contribution."
|
61 |
+
|
62 |
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
63 |
+
on behalf of whom a Contribution has been received by Licensor and
|
64 |
+
subsequently incorporated within the Work.
|
65 |
+
|
66 |
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
67 |
+
this License, each Contributor hereby grants to You a perpetual,
|
68 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
69 |
+
copyright license to reproduce, prepare Derivative Works of,
|
70 |
+
publicly display, publicly perform, sublicense, and distribute the
|
71 |
+
Work and such Derivative Works in Source or Object form.
|
72 |
+
|
73 |
+
3. Grant of Patent License. Subject to the terms and conditions of
|
74 |
+
this License, each Contributor hereby grants to You a perpetual,
|
75 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
76 |
+
(except as stated in this section) patent license to make, have made,
|
77 |
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
78 |
+
where such license applies only to those patent claims licensable
|
79 |
+
by such Contributor that are necessarily infringed by their
|
80 |
+
Contribution(s) alone or by combination of their Contribution(s)
|
81 |
+
with the Work to which such Contribution(s) was submitted. If You
|
82 |
+
institute patent litigation against any entity (including a
|
83 |
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
84 |
+
or a Contribution incorporated within the Work constitutes direct
|
85 |
+
or contributory patent infringement, then any patent licenses
|
86 |
+
granted to You under this License for that Work shall terminate
|
87 |
+
as of the date such litigation is filed.
|
88 |
+
|
89 |
+
4. Redistribution. You may reproduce and distribute copies of the
|
90 |
+
Work or Derivative Works thereof in any medium, with or without
|
91 |
+
modifications, and in Source or Object form, provided that You
|
92 |
+
meet the following conditions:
|
93 |
+
|
94 |
+
(a) You must give any other recipients of the Work or
|
95 |
+
Derivative Works a copy of this License; and
|
96 |
+
|
97 |
+
(b) You must cause any modified files to carry prominent notices
|
98 |
+
stating that You changed the files; and
|
99 |
+
|
100 |
+
(c) You must retain, in the Source form of any Derivative Works
|
101 |
+
that You distribute, all copyright, patent, trademark, and
|
102 |
+
attribution notices from the Source form of the Work,
|
103 |
+
excluding those notices that do not pertain to any part of
|
104 |
+
the Derivative Works; and
|
105 |
+
|
106 |
+
(d) If the Work includes a "NOTICE" text file as part of its
|
107 |
+
distribution, then any Derivative Works that You distribute must
|
108 |
+
include a readable copy of the attribution notices contained
|
109 |
+
within such NOTICE file, excluding those notices that do not
|
110 |
+
pertain to any part of the Derivative Works, in at least one
|
111 |
+
of the following places: within a NOTICE text file distributed
|
112 |
+
as part of the Derivative Works; within the Source form or
|
113 |
+
documentation, if provided along with the Derivative Works; or,
|
114 |
+
within a display generated by the Derivative Works, if and
|
115 |
+
wherever such third-party notices normally appear. The contents
|
116 |
+
of the NOTICE file are for informational purposes only and
|
117 |
+
do not modify the License. You may add Your own attribution
|
118 |
+
notices within Derivative Works that You distribute, alongside
|
119 |
+
or as an addendum to the NOTICE text from the Work, provided
|
120 |
+
that such additional attribution notices cannot be construed
|
121 |
+
as modifying the License.
|
122 |
+
|
123 |
+
You may add Your own copyright statement to Your modifications and
|
124 |
+
may provide additional or different license terms and conditions
|
125 |
+
for use, reproduction, or distribution of Your modifications, or
|
126 |
+
for any such Derivative Works as a whole, provided Your use,
|
127 |
+
reproduction, and distribution of the Work otherwise complies with
|
128 |
+
the conditions stated in this License.
|
129 |
+
|
130 |
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
131 |
+
any Contribution intentionally submitted for inclusion in the Work
|
132 |
+
by You to the Licensor shall be under the terms and conditions of
|
133 |
+
this License, without any additional terms or conditions.
|
134 |
+
Notwithstanding the above, nothing herein shall supersede or modify
|
135 |
+
the terms of any separate license agreement you may have executed
|
136 |
+
with Licensor regarding such Contributions.
|
137 |
+
|
138 |
+
6. Trademarks. This License does not grant permission to use the trade
|
139 |
+
names, trademarks, service marks, or product names of the Licensor,
|
140 |
+
except as required for reasonable and customary use in describing the
|
141 |
+
origin of the Work and reproducing the content of the NOTICE file.
|
142 |
+
|
143 |
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
144 |
+
agreed to in writing, Licensor provides the Work (and each
|
145 |
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
146 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
147 |
+
implied, including, without limitation, any warranties or conditions
|
148 |
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
149 |
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
150 |
+
appropriateness of using or redistributing the Work and assume any
|
151 |
+
risks associated with Your exercise of permissions under this License.
|
152 |
+
|
153 |
+
8. Limitation of Liability. In no event and under no legal theory,
|
154 |
+
whether in tort (including negligence), contract, or otherwise,
|
155 |
+
unless required by applicable law (such as deliberate and grossly
|
156 |
+
negligent acts) or agreed to in writing, shall any Contributor be
|
157 |
+
liable to You for damages, including any direct, indirect, special,
|
158 |
+
incidental, or consequential damages of any character arising as a
|
159 |
+
result of this License or out of the use or inability to use the
|
160 |
+
Work (including but not limited to damages for loss of goodwill,
|
161 |
+
work stoppage, computer failure or malfunction, or any and all
|
162 |
+
other commercial damages or losses), even if such Contributor
|
163 |
+
has been advised of the possibility of such damages.
|
164 |
+
|
165 |
+
9. Accepting Warranty or Additional Liability. While redistributing
|
166 |
+
the Work or Derivative Works thereof, You may choose to offer,
|
167 |
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
168 |
+
or other liability obligations and/or rights consistent with this
|
169 |
+
License. However, in accepting such obligations, You may act only
|
170 |
+
on Your own behalf and on Your sole responsibility, not on behalf
|
171 |
+
of any other Contributor, and only if You agree to indemnify,
|
172 |
+
defend, and hold each Contributor harmless for any liability
|
173 |
+
incurred by, or claims asserted against, such Contributor by reason
|
174 |
+
of your accepting any such warranty or additional liability.
|
175 |
+
|
176 |
+
END OF TERMS AND CONDITIONS
|
177 |
+
|
178 |
+
APPENDIX: How to apply the Apache License to your work.
|
179 |
+
|
180 |
+
To apply the Apache License to your work, attach the following
|
181 |
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
182 |
+
replaced with your own identifying information. (Don't include
|
183 |
+
the brackets!) The text should be enclosed in the appropriate
|
184 |
+
comment syntax for the file format. We also recommend that a
|
185 |
+
file or class name and description of purpose be included on the
|
186 |
+
same "printed page" as the copyright notice for easier
|
187 |
+
identification within third-party archives.
|
188 |
+
|
189 |
+
Copyright [yyyy] [name of copyright owner]
|
190 |
+
|
191 |
+
Licensed under the Apache License, Version 2.0 (the "License");
|
192 |
+
you may not use this file except in compliance with the License.
|
193 |
+
You may obtain a copy of the License at
|
194 |
+
|
195 |
+
http://www.apache.org/licenses/LICENSE-2.0
|
196 |
+
|
197 |
+
Unless required by applicable law or agreed to in writing, software
|
198 |
+
distributed under the License is distributed on an "AS IS" BASIS,
|
199 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
200 |
+
See the License for the specific language governing permissions and
|
201 |
+
limitations under the License.
|
README.md
CHANGED
@@ -1,3 +1,274 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!-- DO NOT EDIT THIS FILE DIRECTLY. INSTEAD EDIT THE `readme_template.md` OR `guides/1)getting_started/1)quickstart.md` TEMPLATES AND THEN RUN `render_readme.py` SCRIPT. -->
|
2 |
+
|
3 |
+
<div align="center">
|
4 |
+
|
5 |
+
[<img src="readme_files/gradio.svg" alt="gradio" width=300>](https://gradio.app)<br>
|
6 |
+
<em>Build & share delightful machine learning apps easily</em>
|
7 |
+
|
8 |
+
[<img src="https://circleci.com/gh/gradio-app/gradio.svg?style=svg" alt="circleci">](https://circleci.com/gh/gradio-app/gradio)
|
9 |
+
[<img src="https://codecov.io/gh/gradio-app/gradio/branch/master/graph/badge.svg" alt="codecov">](https://app.codecov.io/gh/gradio-app/gradio)
|
10 |
+
[![PyPI](https://img.shields.io/pypi/v/gradio)](https://pypi.org/project/gradio/)
|
11 |
+
[![PyPI downloads](https://img.shields.io/pypi/dm/gradio)](https://pypi.org/project/gradio/)
|
12 |
+
![Python version](https://img.shields.io/badge/python-3.7+-important)
|
13 |
+
[![Twitter follow](https://img.shields.io/twitter/follow/gradio?style=social&label=follow)](https://twitter.com/gradio)
|
14 |
+
|
15 |
+
[Website](https://gradio.app)
|
16 |
+
| [Documentation](https://gradio.app/docs/)
|
17 |
+
| [Guides](https://gradio.app/guides/)
|
18 |
+
| [Getting Started](https://gradio.app/getting_started/)
|
19 |
+
| [Examples](demo/)
|
20 |
+
</div>
|
21 |
+
|
22 |
+
# Gradio: Build Machine Learning Web Apps — in Python
|
23 |
+
|
24 |
+
Gradio is an open-source Python library that is used to build machine learning and data science demos and web applications.
|
25 |
+
|
26 |
+
With Gradio, you can quickly create a beautiful user interface around your machine learning models or data science workflow and let people "try it out" by dragging-and-dropping in their own images,
|
27 |
+
pasting text, recording their own voice, and interacting with your demo, all through the browser.
|
28 |
+
|
29 |
+
![Interface montage](readme_files/header-image.jpg)
|
30 |
+
|
31 |
+
Gradio is useful for:
|
32 |
+
|
33 |
+
- **Demoing** your machine learning models for clients/collaborators/users/students.
|
34 |
+
|
35 |
+
- **Deploying** your models quickly with automatic shareable links and getting feedback on model performance.
|
36 |
+
|
37 |
+
- **Debugging** your model interactively during development using built-in manipulation and interpretation tools.
|
38 |
+
|
39 |
+
## Quickstart
|
40 |
+
|
41 |
+
**Prerequisite**: Gradio requires Python 3.7 or higher, that's all!
|
42 |
+
|
43 |
+
### What Does Gradio Do?
|
44 |
+
|
45 |
+
One of the *best ways to share* your machine learning model, API, or data science workflow with others is to create an **interactive app** that allows your users or colleagues to try out the demo in their browsers.
|
46 |
+
|
47 |
+
Gradio allows you to **build demos and share them, all in Python.** And usually in just a few lines of code! So let's get started.
|
48 |
+
|
49 |
+
### Hello, World
|
50 |
+
|
51 |
+
To get Gradio running with a simple "Hello, World" example, follow these three steps:
|
52 |
+
|
53 |
+
1\. Install Gradio using pip:
|
54 |
+
|
55 |
+
```bash
|
56 |
+
pip install gradio
|
57 |
+
```
|
58 |
+
|
59 |
+
2\. Run the code below as a Python script or in a Jupyter Notebook (or [Google Colab](https://colab.research.google.com/drive/18ODkJvyxHutTN0P5APWyGFO_xwNcgHDZ?usp=sharing)):
|
60 |
+
|
61 |
+
```python
|
62 |
+
import gradio as gr
|
63 |
+
|
64 |
+
def greet(name):
|
65 |
+
return "Hello " + name + "!"
|
66 |
+
|
67 |
+
demo = gr.Interface(fn=greet, inputs="text", outputs="text")
|
68 |
+
demo.launch()
|
69 |
+
```
|
70 |
+
|
71 |
+
|
72 |
+
3\. The demo below will appear automatically within the Jupyter Notebook, or pop in a browser on [http://localhost:7860](http://localhost:7860) if running from a script:
|
73 |
+
|
74 |
+
![`hello_world` demo](demo/hello_world/screenshot.gif)
|
75 |
+
|
76 |
+
### The `Interface` Class
|
77 |
+
|
78 |
+
You'll notice that in order to make the demo, we created a `gradio.Interface`. This `Interface` class can wrap any Python function with a user interface. In the example above, we saw a simple text-based function, but the function could be anything from music generator to a tax calculator to the prediction function of a pretrained machine learning model.
|
79 |
+
|
80 |
+
The core `Interface` class is initialized with three required parameters:
|
81 |
+
|
82 |
+
- `fn`: the function to wrap a UI around
|
83 |
+
- `inputs`: which component(s) to use for the input (e.g. `"text"`, `"image"` or `"audio"`)
|
84 |
+
- `outputs`: which component(s) to use for the output (e.g. `"text"`, `"image"` or `"label"`)
|
85 |
+
|
86 |
+
Let's take a closer look at these components used to provide input and output.
|
87 |
+
|
88 |
+
### Components Attributes
|
89 |
+
|
90 |
+
We saw some simple `Textbox` components in the previous examples, but what if you want to change how the UI components look or behave?
|
91 |
+
|
92 |
+
Let's say you want to customize the input text field — for example, you wanted it to be larger and have a text placeholder. If we use the actual class for `Textbox` instead of using the string shortcut, you have access to much more customizability through component attributes.
|
93 |
+
|
94 |
+
```python
|
95 |
+
import gradio as gr
|
96 |
+
|
97 |
+
def greet(name):
|
98 |
+
return "Hello " + name + "!"
|
99 |
+
|
100 |
+
demo = gr.Interface(
|
101 |
+
fn=greet,
|
102 |
+
inputs=gr.Textbox(lines=2, placeholder="Name Here..."),
|
103 |
+
outputs="text",
|
104 |
+
)
|
105 |
+
demo.launch()
|
106 |
+
```
|
107 |
+
|
108 |
+
![`hello_world_2` demo](demo/hello_world_2/screenshot.gif)
|
109 |
+
|
110 |
+
### Multiple Input and Output Components
|
111 |
+
|
112 |
+
Suppose you had a more complex function, with multiple inputs and outputs. In the example below, we define a function that takes a string, boolean, and number, and returns a string and number. Take a look how you pass a list of input and output components.
|
113 |
+
|
114 |
+
```python
|
115 |
+
import gradio as gr
|
116 |
+
|
117 |
+
def greet(name, is_morning, temperature):
|
118 |
+
salutation = "Good morning" if is_morning else "Good evening"
|
119 |
+
greeting = f"{salutation} {name}. It is {temperature} degrees today"
|
120 |
+
celsius = (temperature - 32) * 5 / 9
|
121 |
+
return greeting, round(celsius, 2)
|
122 |
+
|
123 |
+
demo = gr.Interface(
|
124 |
+
fn=greet,
|
125 |
+
inputs=["text", "checkbox", gr.Slider(0, 100)],
|
126 |
+
outputs=["text", "number"],
|
127 |
+
)
|
128 |
+
demo.launch()
|
129 |
+
```
|
130 |
+
|
131 |
+
![`hello_world_3` demo](demo/hello_world_3/screenshot.gif)
|
132 |
+
|
133 |
+
You simply wrap the components in a list. Each component in the `inputs` list corresponds to one of the parameters of the function, in order. Each component in the `outputs` list corresponds to one of the values returned by the function, again in order.
|
134 |
+
|
135 |
+
### An Image Example
|
136 |
+
|
137 |
+
Gradio supports many types of components, such as `Image`, `DataFrame`, `Video`, or `Label`. Let's try an image-to-image function to get a feel for these!
|
138 |
+
|
139 |
+
```python
|
140 |
+
import numpy as np
|
141 |
+
import gradio as gr
|
142 |
+
|
143 |
+
def sepia(input_img):
|
144 |
+
sepia_filter = np.array([
|
145 |
+
[0.393, 0.769, 0.189],
|
146 |
+
[0.349, 0.686, 0.168],
|
147 |
+
[0.272, 0.534, 0.131]
|
148 |
+
])
|
149 |
+
sepia_img = input_img.dot(sepia_filter.T)
|
150 |
+
sepia_img /= sepia_img.max()
|
151 |
+
return sepia_img
|
152 |
+
|
153 |
+
demo = gr.Interface(sepia, gr.Image(shape=(200, 200)), "image")
|
154 |
+
demo.launch()
|
155 |
+
```
|
156 |
+
|
157 |
+
![`sepia_filter` demo](demo/sepia_filter/screenshot.gif)
|
158 |
+
|
159 |
+
When using the `Image` component as input, your function will receive a NumPy array with the shape `(width, height, 3)`, where the last dimension represents the RGB values. We'll return an image as well in the form of a NumPy array.
|
160 |
+
|
161 |
+
You can also set the datatype used by the component with the `type=` keyword argument. For example, if you wanted your function to take a file path to an image instead of a NumPy array, the input `Image` component could be written as:
|
162 |
+
|
163 |
+
```python
|
164 |
+
gr.Image(type="filepath", shape=...)
|
165 |
+
```
|
166 |
+
|
167 |
+
Also note that our input `Image` component comes with an edit button 🖉, which allows for cropping and zooming into images. Manipulating images in this way can help reveal biases or hidden flaws in a machine learning model!
|
168 |
+
|
169 |
+
You can read more about the many components and how to use them in the [Gradio docs](https://gradio.app/docs).
|
170 |
+
|
171 |
+
### Blocks: More Flexibility and Control
|
172 |
+
|
173 |
+
Gradio offers two classes to build apps:
|
174 |
+
|
175 |
+
1\. **Interface**, that provides a high-level abstraction for creating demos that we've been discussing so far.
|
176 |
+
|
177 |
+
2\. **Blocks**, a low-level API for designing web apps with more flexible layouts and data flows. Blocks allows you to do things like feature multiple data flows and demos, 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. If this customizability is what you need, try `Blocks` instead!
|
178 |
+
|
179 |
+
### Hello, Blocks
|
180 |
+
|
181 |
+
Let's take a look at a simple example. Note how the API here differs from `Interface`.
|
182 |
+
|
183 |
+
```python
|
184 |
+
import gradio as gr
|
185 |
+
|
186 |
+
def greet(name):
|
187 |
+
return "Hello " + name + "!"
|
188 |
+
|
189 |
+
with gr.Blocks() as demo:
|
190 |
+
name = gr.Textbox(label="Name")
|
191 |
+
output = gr.Textbox(label="Output Box")
|
192 |
+
greet_btn = gr.Button("Greet")
|
193 |
+
greet_btn.click(fn=greet, inputs=name, outputs=output)
|
194 |
+
|
195 |
+
demo.launch()
|
196 |
+
```
|
197 |
+
|
198 |
+
![`hello_blocks` demo](demo/hello_blocks/screenshot.gif)
|
199 |
+
|
200 |
+
Things to note:
|
201 |
+
|
202 |
+
- `Blocks` are made with a `with` clause, and any component created inside this clause is automatically added to the app.
|
203 |
+
- Components appear vertically in the app in the order they are created. (Later we will cover customizing layouts!)
|
204 |
+
- A `Button` was created, and then a `click` event-listener was added to this button. The API for this should look familiar! Like an `Interface`, the `click` method takes a Python function, input components, and output components.
|
205 |
+
|
206 |
+
### More Complexity
|
207 |
+
|
208 |
+
Here's an app to give you a taste of what's possible with `Blocks`:
|
209 |
+
|
210 |
+
```python
|
211 |
+
import numpy as np
|
212 |
+
import gradio as gr
|
213 |
+
|
214 |
+
def flip_text(x):
|
215 |
+
return x[::-1]
|
216 |
+
|
217 |
+
def flip_image(x):
|
218 |
+
return np.fliplr(x)
|
219 |
+
|
220 |
+
with gr.Blocks() as demo:
|
221 |
+
gr.Markdown("Flip text or image files using this demo.")
|
222 |
+
with gr.Tabs():
|
223 |
+
with gr.TabItem("Flip Text"):
|
224 |
+
text_input = gr.Textbox()
|
225 |
+
text_output = gr.Textbox()
|
226 |
+
text_button = gr.Button("Flip")
|
227 |
+
with gr.TabItem("Flip Image"):
|
228 |
+
with gr.Row():
|
229 |
+
image_input = gr.Image()
|
230 |
+
image_output = gr.Image()
|
231 |
+
image_button = gr.Button("Flip")
|
232 |
+
|
233 |
+
text_button.click(flip_text, inputs=text_input, outputs=text_output)
|
234 |
+
image_button.click(flip_image, inputs=image_input, outputs=image_output)
|
235 |
+
|
236 |
+
demo.launch()
|
237 |
+
```
|
238 |
+
|
239 |
+
![`blocks_flipper` demo](demo/blocks_flipper/screenshot.gif)
|
240 |
+
|
241 |
+
A lot more going on here! We'll cover how to create complex `Blocks` apps like this in the [building with blocks](https://github.com/gradio-app/gradio/tree/main/guides/3\)building_with_blocks) section for you.
|
242 |
+
|
243 |
+
Congrats, you're now familiar with the basics of Gradio! 🥳 Go to our [next guide](https://gradio.app/key_features) to learn more about the key features of Gradio.
|
244 |
+
|
245 |
+
|
246 |
+
## Open Source Stack
|
247 |
+
|
248 |
+
Gradio is built with many wonderful open-source libraries, please support them as well!
|
249 |
+
|
250 |
+
[<img src="readme_files/huggingface_mini.svg" alt="huggingface" height=40>](https://huggingface.co)
|
251 |
+
[<img src="readme_files/python.svg" alt="python" height=40>](https://www.python.org)
|
252 |
+
[<img src="readme_files/fastapi.svg" alt="fastapi" height=40>](https://fastapi.tiangolo.com)
|
253 |
+
[<img src="readme_files/encode.svg" alt="encode" height=40>](https://www.encode.io)
|
254 |
+
[<img src="readme_files/svelte.svg" alt="svelte" height=40>](https://svelte.dev)
|
255 |
+
[<img src="readme_files/vite.svg" alt="vite" height=40>](https://vitejs.dev)
|
256 |
+
[<img src="readme_files/pnpm.svg" alt="pnpm" height=40>](https://pnpm.io)
|
257 |
+
[<img src="readme_files/tailwind.svg" alt="tailwind" height=40>](https://tailwindcss.com)
|
258 |
+
|
259 |
+
## License
|
260 |
+
|
261 |
+
Gradio is licensed under the Apache License 2.0 found in the [LICENSE](LICENSE) file in the root directory of this repository.
|
262 |
+
|
263 |
+
## Citation
|
264 |
+
|
265 |
+
Also check out the paper *[Gradio: Hassle-Free Sharing and Testing of ML Models in the Wild](https://arxiv.org/abs/1906.02569), ICML HILL 2019*, and please cite it if you use Gradio in your work.
|
266 |
+
|
267 |
+
```
|
268 |
+
@article{abid2019gradio,
|
269 |
+
title = {Gradio: Hassle-Free Sharing and Testing of ML Models in the Wild},
|
270 |
+
author = {Abid, Abubakar and Abdalla, Ali and Abid, Ali and Khan, Dawood and Alfozan, Abdulrahman and Zou, James},
|
271 |
+
journal = {arXiv preprint arXiv:1906.02569},
|
272 |
+
year = {2019},
|
273 |
+
}
|
274 |
+
```
|
SECURITY.md
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Security Policy
|
2 |
+
|
3 |
+
## Reporting a Vulnerability
|
4 |
+
|
5 |
+
If you discover a security vulnerability, we would be very grateful if you could email us at team@gradio.app. This is the preferred approach instead of opening a public issue. We take all vulnerability reports seriously, and will work to patch the vulnerability immediately. Whenever possible, we will credit the person or people who report the security vulnerabilities after it has been patched.
|
codecov.yml
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
coverage:
|
2 |
+
range: 0..100
|
3 |
+
round: down
|
4 |
+
precision: 2
|
5 |
+
status:
|
6 |
+
project:
|
7 |
+
default: false # disable the default status that measures entire project
|
8 |
+
source:
|
9 |
+
paths:
|
10 |
+
- "gradio/"
|
11 |
+
target: 70%
|
12 |
+
threshold: 0.1
|
13 |
+
patch: off
|
14 |
+
|
15 |
+
comment: false
|
16 |
+
codecov:
|
17 |
+
require_ci_to_pass: yes
|
pyproject.toml
ADDED
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
[build-system]
|
2 |
+
requires = ["hatchling", "hatch-requirements-txt", "hatch-fancy-pypi-readme>=22.5.0"]
|
3 |
+
build-backend = "hatchling.build"
|
4 |
+
|
5 |
+
[project]
|
6 |
+
name = "gradio"
|
7 |
+
dynamic = ["version", "dependencies", "readme"]
|
8 |
+
description = "Python library for easily interacting with trained machine learning models"
|
9 |
+
license = "Apache-2.0"
|
10 |
+
requires-python = ">=3.7"
|
11 |
+
authors = [
|
12 |
+
{ name = "Abubakar Abid", email = "team@gradio.app" },
|
13 |
+
{ name = "Ali Abid", email = "team@gradio.app" },
|
14 |
+
{ name = "Ali Abdalla", email = "team@gradio.app" },
|
15 |
+
{ name = "Dawood Khan", email = "team@gradio.app" },
|
16 |
+
{ name = "Ahsen Khaliq", email = "team@gradio.app" },
|
17 |
+
{ name = "Pete Allen", email = "team@gradio.app" },
|
18 |
+
{ name = "Ömer Faruk Özdemir", email = "team@gradio.app" },
|
19 |
+
]
|
20 |
+
keywords = ["machine learning", "reproducibility", "visualization"]
|
21 |
+
|
22 |
+
[project.scripts]
|
23 |
+
gradio = "gradio.reload:run_in_reload_mode"
|
24 |
+
|
25 |
+
[project.urls]
|
26 |
+
Homepage = "https://github.com/gradio-app/gradio"
|
27 |
+
|
28 |
+
[tool.hatch.version]
|
29 |
+
path = "gradio/version.txt"
|
30 |
+
pattern = "(?P<version>.+)"
|
31 |
+
|
32 |
+
[tool.hatch.metadata.hooks.requirements_txt]
|
33 |
+
filename = "requirements.txt"
|
34 |
+
|
35 |
+
[tool.hatch.metadata.hooks.fancy-pypi-readme]
|
36 |
+
content-type = "text/markdown"
|
37 |
+
fragments = [
|
38 |
+
{ path = "README.md" },
|
39 |
+
]
|
40 |
+
|
41 |
+
[[tool.hatch.metadata.hooks.fancy-pypi-readme.substitutions]]
|
42 |
+
pattern = "(website/homepage|readme_files)/"
|
43 |
+
replacement = 'https://raw.githubusercontent.com/gradio-app/gradio/main/\g<1>/'
|
44 |
+
|
45 |
+
[[tool.hatch.metadata.hooks.fancy-pypi-readme.substitutions]]
|
46 |
+
pattern = 'demo/([\S]*.gif)'
|
47 |
+
replacement = 'https://raw.githubusercontent.com/gradio-app/gradio/main/demo/\g<1>'
|
48 |
+
|
49 |
+
[tool.hatch.build]
|
50 |
+
artifacts = [
|
51 |
+
"/gradio/templates",
|
52 |
+
]
|
53 |
+
|
54 |
+
[tool.hatch.build.targets.sdist]
|
55 |
+
include = [
|
56 |
+
"/gradio",
|
57 |
+
"/test",
|
58 |
+
"/README.md",
|
59 |
+
"/requirements.txt",
|
60 |
+
]
|
readme_template.md
ADDED
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<div align="center">
|
2 |
+
|
3 |
+
[<img src="readme_files/gradio.svg" alt="gradio" width=300>](https://gradio.app)<br>
|
4 |
+
<em>Build & share delightful machine learning apps easily</em>
|
5 |
+
|
6 |
+
[<img src="https://circleci.com/gh/gradio-app/gradio.svg?style=svg" alt="circleci">](https://circleci.com/gh/gradio-app/gradio)
|
7 |
+
[<img src="https://codecov.io/gh/gradio-app/gradio/branch/master/graph/badge.svg" alt="codecov">](https://app.codecov.io/gh/gradio-app/gradio)
|
8 |
+
[![PyPI](https://img.shields.io/pypi/v/gradio)](https://pypi.org/project/gradio/)
|
9 |
+
[![PyPI downloads](https://img.shields.io/pypi/dm/gradio)](https://pypi.org/project/gradio/)
|
10 |
+
![Python version](https://img.shields.io/badge/python-3.7+-important)
|
11 |
+
[![Twitter follow](https://img.shields.io/twitter/follow/gradio?style=social&label=follow)](https://twitter.com/gradio)
|
12 |
+
|
13 |
+
[Website](https://gradio.app)
|
14 |
+
| [Documentation](https://gradio.app/docs/)
|
15 |
+
| [Guides](https://gradio.app/guides/)
|
16 |
+
| [Getting Started](https://gradio.app/getting_started/)
|
17 |
+
| [Examples](demo/)
|
18 |
+
</div>
|
19 |
+
|
20 |
+
# Gradio: Build Machine Learning Web Apps — in Python
|
21 |
+
|
22 |
+
Gradio is an open-source Python library that is used to build machine learning and data science demos and web applications.
|
23 |
+
|
24 |
+
With Gradio, you can quickly create a beautiful user interface around your machine learning models or data science workflow and let people "try it out" by dragging-and-dropping in their own images,
|
25 |
+
pasting text, recording their own voice, and interacting with your demo, all through the browser.
|
26 |
+
|
27 |
+
![Interface montage](readme_files/header-image.jpg)
|
28 |
+
|
29 |
+
Gradio is useful for:
|
30 |
+
|
31 |
+
- **Demoing** your machine learning models for clients/collaborators/users/students.
|
32 |
+
|
33 |
+
- **Deploying** your models quickly with automatic shareable links and getting feedback on model performance.
|
34 |
+
|
35 |
+
- **Debugging** your model interactively during development using built-in manipulation and interpretation tools.
|
36 |
+
|
37 |
+
$getting_started
|
38 |
+
|
39 |
+
## Open Source Stack
|
40 |
+
|
41 |
+
Gradio is built with many wonderful open-source libraries, please support them as well!
|
42 |
+
|
43 |
+
[<img src="readme_files/huggingface_mini.svg" alt="huggingface" height=40>](https://huggingface.co)
|
44 |
+
[<img src="readme_files/python.svg" alt="python" height=40>](https://www.python.org)
|
45 |
+
[<img src="readme_files/fastapi.svg" alt="fastapi" height=40>](https://fastapi.tiangolo.com)
|
46 |
+
[<img src="readme_files/encode.svg" alt="encode" height=40>](https://www.encode.io)
|
47 |
+
[<img src="readme_files/svelte.svg" alt="svelte" height=40>](https://svelte.dev)
|
48 |
+
[<img src="readme_files/vite.svg" alt="vite" height=40>](https://vitejs.dev)
|
49 |
+
[<img src="readme_files/pnpm.svg" alt="pnpm" height=40>](https://pnpm.io)
|
50 |
+
[<img src="readme_files/tailwind.svg" alt="tailwind" height=40>](https://tailwindcss.com)
|
51 |
+
|
52 |
+
## License
|
53 |
+
|
54 |
+
Gradio is licensed under the Apache License 2.0 found in the [LICENSE](LICENSE) file in the root directory of this repository.
|
55 |
+
|
56 |
+
## Citation
|
57 |
+
|
58 |
+
Also check out the paper *[Gradio: Hassle-Free Sharing and Testing of ML Models in the Wild](https://arxiv.org/abs/1906.02569), ICML HILL 2019*, and please cite it if you use Gradio in your work.
|
59 |
+
|
60 |
+
```
|
61 |
+
@article{abid2019gradio,
|
62 |
+
title = {Gradio: Hassle-Free Sharing and Testing of ML Models in the Wild},
|
63 |
+
author = {Abid, Abubakar and Abdalla, Ali and Abid, Ali and Khan, Dawood and Alfozan, Abdulrahman and Zou, James},
|
64 |
+
journal = {arXiv preprint arXiv:1906.02569},
|
65 |
+
year = {2019},
|
66 |
+
}
|
67 |
+
```
|
render_readme.py
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/usr/bin/env python
|
2 |
+
|
3 |
+
import re
|
4 |
+
from pathlib import Path
|
5 |
+
|
6 |
+
README_TEMPLATE_FILEPATH = "readme_template.md"
|
7 |
+
GETTING_STARTED_TEMPLATE_FILEPATH = "guides/1)getting_started/1)quickstart.md"
|
8 |
+
|
9 |
+
readme_template = Path(README_TEMPLATE_FILEPATH).read_text()
|
10 |
+
getting_started_template = Path(GETTING_STARTED_TEMPLATE_FILEPATH).read_text()
|
11 |
+
|
12 |
+
# Extract all the code and demo tags from the getting started template
|
13 |
+
code_tags = re.findall(r"\$code_([^\s]+)", getting_started_template)
|
14 |
+
demo_tags = re.findall(r"\$demo_([^\s]+)", getting_started_template)
|
15 |
+
codes = {}
|
16 |
+
demos = {}
|
17 |
+
|
18 |
+
for src in code_tags:
|
19 |
+
context = Path(f"demo/{src}/run.py").read_text()
|
20 |
+
# Replace the condition to run the demo directly with actual launch code
|
21 |
+
context = re.sub(r"if __name__(.*[\n$]*)*", "demo.launch()", context)
|
22 |
+
codes[src] = f"```python\n{context}\n```\n" # Convert to Markdown code block
|
23 |
+
|
24 |
+
for src in demo_tags:
|
25 |
+
demos[src] = f"![`{src}` demo](demo/{src}/screenshot.gif)"
|
26 |
+
|
27 |
+
# Replace the headers in the getting started template with a smaller header (e.g. H3 instead of H2) to
|
28 |
+
# make the README more readable and less cluttered.
|
29 |
+
getting_started_template = re.sub(r"^(#+)", r"#\1", getting_started_template, flags=re.MULTILINE)
|
30 |
+
readme_template = readme_template.replace("$getting_started", getting_started_template)
|
31 |
+
|
32 |
+
# Now put the codes and the screenshots in the README template
|
33 |
+
readme_template = re.sub(r"\$code_([^\s]+)", lambda x: codes[x.group(1)], readme_template)
|
34 |
+
readme_template = re.sub(r"\$demo_([^\s]+)", lambda x: demos[x.group(1)], readme_template)
|
35 |
+
|
36 |
+
# Save the README template to the actual README.md file (with a note about the editing)
|
37 |
+
EDITING_NOTE = ("<!-- DO NOT EDIT THIS FILE DIRECTLY. INSTEAD EDIT THE `readme_template.md` OR "
|
38 |
+
"`guides/1)getting_started/1)quickstart.md` TEMPLATES AND THEN RUN `render_readme.py` SCRIPT. -->")
|
39 |
+
Path("README.md").write_text(f"{EDITING_NOTE}\n\n{readme_template}")
|
requirements.txt
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
aiohttp
|
2 |
+
altair
|
3 |
+
fastapi
|
4 |
+
ffmpy
|
5 |
+
markdown-it-py[linkify,plugins]
|
6 |
+
markupsafe
|
7 |
+
matplotlib
|
8 |
+
numpy
|
9 |
+
orjson
|
10 |
+
pandas
|
11 |
+
pillow
|
12 |
+
pycryptodome
|
13 |
+
python-multipart
|
14 |
+
pydub
|
15 |
+
pyyaml
|
16 |
+
requests
|
17 |
+
uvicorn
|
18 |
+
Jinja2
|
19 |
+
fsspec
|
20 |
+
httpx
|
21 |
+
pydantic
|
22 |
+
websockets>=10.0
|
style.md
ADDED
@@ -0,0 +1,160 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# component-styles
|
2 |
+
|
3 |
+
## Textbox
|
4 |
+
|
5 |
+
| name | type | description |
|
6 |
+
| ----------- | ------------------------------------ | ------------------------------ |
|
7 |
+
| `rounded` | `bool` or `(bool, bool, bool, bool)` | corners of text input |
|
8 |
+
| `border` | `bool` or `(bool, bool, bool, bool)` | borders of text input |
|
9 |
+
| `container` | `bool` | show or hide the container box |
|
10 |
+
|
11 |
+
## Number
|
12 |
+
|
13 |
+
| name | type | description |
|
14 |
+
| ----------- | ------------------------------------ | ------------------------------ |
|
15 |
+
| `rounded` | `bool` or `(bool, bool, bool, bool)` | corners of text input |
|
16 |
+
| `border` | `bool` or `(bool, bool, bool, bool)` | borders of text input |
|
17 |
+
| `container` | `bool` | show or hide the container box |
|
18 |
+
|
19 |
+
## Slider
|
20 |
+
|
21 |
+
| name | type | description |
|
22 |
+
| ----------- | ------ | ------------------------------ |
|
23 |
+
| `container` | `bool` | show or hide the container box |
|
24 |
+
|
25 |
+
## Checkbox
|
26 |
+
|
27 |
+
| name | type | description |
|
28 |
+
| ----------- | ------------------------------------ | ------------------------------ |
|
29 |
+
| `rounded` | `bool` or `(bool, bool, bool, bool)` | corners of checkbox |
|
30 |
+
| `border` | `bool` or `(bool, bool, bool, bool)` | borders of checkbox |
|
31 |
+
| `container` | `bool` | show or hide the container box |
|
32 |
+
|
33 |
+
## Checkbox Group
|
34 |
+
|
35 |
+
| name | type | description |
|
36 |
+
| ---------------- | ------------------------------------ | ----------------------------------------- |
|
37 |
+
| `rounded` | `bool` or `(bool, bool, bool, bool)` | corners of checkboxes |
|
38 |
+
| `container` | `bool` | show or hide the container box |
|
39 |
+
| `item_container` | `bool` | show or hide the checkbox container boxes |
|
40 |
+
|
41 |
+
## Radio
|
42 |
+
|
43 |
+
| name | type | description |
|
44 |
+
| ---------------- | ------ | -------------------------------------- |
|
45 |
+
| `container` | `bool` | show or hide the container box |
|
46 |
+
| `item_container` | `bool` | show or hide the radio container boxes |
|
47 |
+
|
48 |
+
## Dropdown
|
49 |
+
|
50 |
+
| name | type | description |
|
51 |
+
| ----------- | ------------------------------------ | ------------------------------ |
|
52 |
+
| `rounded` | `bool` or `(bool, bool, bool, bool)` | corners of input |
|
53 |
+
| `border` | `bool` or `(bool, bool, bool, bool)` | borders of input |
|
54 |
+
| `container` | `bool` | show or hide the container box |
|
55 |
+
|
56 |
+
## Image
|
57 |
+
|
58 |
+
| name | type | description |
|
59 |
+
| --------- | ------------------------------------ | ------------------- |
|
60 |
+
| `rounded` | `bool` or `(bool, bool, bool, bool)` | corners of main box |
|
61 |
+
|
62 |
+
## Video
|
63 |
+
|
64 |
+
| name | type | description |
|
65 |
+
| --------- | ------------------------------------ | ------------------- |
|
66 |
+
| `rounded` | `bool` or `(bool, bool, bool, bool)` | corners of main box |
|
67 |
+
|
68 |
+
## Audio
|
69 |
+
|
70 |
+
| name | type | description |
|
71 |
+
| --------- | ------------------------------------ | ------------------- |
|
72 |
+
| `rounded` | `bool` or `(bool, bool, bool, bool)` | corners of main box |
|
73 |
+
|
74 |
+
## File
|
75 |
+
|
76 |
+
| name | type | description |
|
77 |
+
| --------- | ------------------------------------ | ------------------- |
|
78 |
+
| `rounded` | `bool` or `(bool, bool, bool, bool)` | corners of main box |
|
79 |
+
|
80 |
+
## Dataframe
|
81 |
+
|
82 |
+
| name | type | description |
|
83 |
+
| --------- | ------------------------------------ | ------------------- |
|
84 |
+
| `rounded` | `bool` or `(bool, bool, bool, bool)` | corners of main box |
|
85 |
+
|
86 |
+
## Timeseries
|
87 |
+
|
88 |
+
| name | type | description |
|
89 |
+
| --------- | ------------------------------------ | ------------------- |
|
90 |
+
| `rounded` | `bool` or `(bool, bool, bool, bool)` | corners of main box |
|
91 |
+
|
92 |
+
## Label
|
93 |
+
|
94 |
+
| name | type | description |
|
95 |
+
| ----------- | ------ | ------------------------------ |
|
96 |
+
| `container` | `bool` | show or hide the container box |
|
97 |
+
|
98 |
+
## HighlightedText
|
99 |
+
|
100 |
+
| name | type | description |
|
101 |
+
| ----------- | ------------------------------------ | ------------------------------ |
|
102 |
+
| `rounded` | `bool` or `(bool, bool, bool, bool)` | corners of labels |
|
103 |
+
| `color_map` | `Dict[str, str]` | color map of labels and colors |
|
104 |
+
| `container` | `bool` | show or hide the container box |
|
105 |
+
|
106 |
+
## JSON
|
107 |
+
|
108 |
+
| name | type | description |
|
109 |
+
| ----------- | ------ | ------------------------------ |
|
110 |
+
| `container` | `bool` | show or hide the container box |
|
111 |
+
|
112 |
+
## HTML
|
113 |
+
|
114 |
+
Nothing
|
115 |
+
|
116 |
+
## Gallery
|
117 |
+
|
118 |
+
| name | type | description |
|
119 |
+
| ----------- | ----------------------------------------- | ----------------------------------- |
|
120 |
+
| `rounded` | `bool` or `(bool, bool, bool, bool)` | corners of images |
|
121 |
+
| `grid` | `int` or `(int, int, int, int, int, int)` | grid for images |
|
122 |
+
| `height` | `"auto"` | height of gallery (auto or default) |
|
123 |
+
| `container` | `bool` | show or hide the container box |
|
124 |
+
|
125 |
+
## Chatbot
|
126 |
+
|
127 |
+
| name | type | description |
|
128 |
+
| ----------- | ------------------------------------ | ------------------------------------------------ |
|
129 |
+
| `rounded` | `bool` or `(bool, bool, bool, bool)` | corners of chat bubbles |
|
130 |
+
| `color_map` | `Dict[str, str]` | color map of user and bot color for chat bubbles |
|
131 |
+
|
132 |
+
## Model3D
|
133 |
+
|
134 |
+
| name | type | description |
|
135 |
+
| --------- | ------------------------------------ | ------------------- |
|
136 |
+
| `rounded` | `bool` or `(bool, bool, bool, bool)` | corners of main box |
|
137 |
+
|
138 |
+
## Plot
|
139 |
+
|
140 |
+
Nothing (yet)
|
141 |
+
|
142 |
+
## Markdown
|
143 |
+
|
144 |
+
Nothing
|
145 |
+
|
146 |
+
## Button
|
147 |
+
|
148 |
+
| name | type | description |
|
149 |
+
| ------------ | ------------------------------------ | --------------------------------------- |
|
150 |
+
| `rounded` | `bool` or `(bool, bool, bool, bool)` | corners of button |
|
151 |
+
| `border` | `bool` or `(bool, bool, bool, bool)` | borders of button |
|
152 |
+
| `full_width` | `bool` | whether button expand to fill container |
|
153 |
+
|
154 |
+
## Dataset
|
155 |
+
|
156 |
+
Nothing
|
157 |
+
|
158 |
+
## Variable
|
159 |
+
|
160 |
+
Nothing
|