Zevin2023 commited on
Commit
24010b4
·
verified ·
1 Parent(s): a1b3bdd

Upload 18 files

Browse files
gradio-bbox/CHANGELOG.md ADDED
The diff for this file is too large to render. See raw diff
 
gradio-bbox/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
gradio-bbox/CONTRIBUTING.md ADDED
@@ -0,0 +1,138 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Contributing to Gradio
2
+
3
+ Prerequisites:
4
+
5
+ - [Python 3.8+](https://www.python.org/downloads/)
6
+ - [Node.js v16.14+](https://nodejs.dev/en/download/package-manager/) (only needed if you are making changes to the frontend)
7
+ - [pnpm 8.1+](https://pnpm.io/8.x/installation) (only needed if you are making changes to the frontend)
8
+
9
+ 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:
10
+
11
+ ### Install Gradio locally from the `main` branch
12
+
13
+ - Clone this repo
14
+ - Navigate to the repo folder and run
15
+
16
+ ```bash
17
+ bash scripts/install_gradio.sh
18
+ ```
19
+
20
+ - Build the front end
21
+
22
+ ```
23
+ bash scripts/build_frontend.sh
24
+ ```
25
+
26
+ ### Install development requirements
27
+
28
+ In order to be able to run the Python linter, formatter, and 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
+
36
+ - If you have a different Python version and conflicting packages during the installation, please first run:
37
+
38
+ ```
39
+ bash scripts/create_test_requirements.sh
40
+ ```
41
+
42
+ ### Using dev containers
43
+
44
+ Instead of the above steps, you can alternatively use dev containers. This is supported on all platforms (macOS/Windows/Linux).
45
+
46
+ Prerequisites:
47
+
48
+ - An editor which supports dev containers, like VS Code
49
+ - Docker support on the host computer:
50
+ - macOS: [Docker Desktop 2.0+](https://www.docker.com/products/docker-desktop/)
51
+ - Windows: [Docker Desktop 2.0+](https://www.docker.com/products/docker-desktop/)
52
+ - Linux: [Docker CE/EE 18.06+](https://docs.docker.com/get-docker/) and [Docker Compose 1.21+](https://docs.docker.com/compose/install/)
53
+ - If using VS Code, the [Dev Containers](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) extension
54
+
55
+ Steps:
56
+
57
+ - Clone repository
58
+ - Open it in editor
59
+ - For VS Code, execute `Dev Containers: Reopen in container` command
60
+
61
+ For detailed instructions, please see the [Dev Containers tutorial](https://code.visualstudio.com/docs/devcontainers/tutorial).
62
+
63
+ ### Extra tidbits
64
+
65
+ - 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.
66
+
67
+ ```
68
+ gradio app.py
69
+ ```
70
+
71
+ - To develop the frontend app, you should also follow [js/README.md](js/README.md).
72
+
73
+ - To run all of the tests, do:
74
+
75
+ ```
76
+ bash scripts/run_all_tests.sh
77
+ ```
78
+
79
+ ### Structure of the Repository
80
+
81
+ 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
82
+
83
+ - `/gradio`: contains the Python source code for the library
84
+ - `/gradio/interface.py`: contains the Python source code for the core `Interface` class
85
+ - `/gradio/blocks.py`: contains the Python source code for the core `Blocks` class
86
+ - `/gradio/components.py`: contains the Python source code for the `components`, you can add your custom components here.
87
+ - `/js`: contains the HTML/JS/CSS source code for the library ([start here for frontend changes](/js/README.md))
88
+ - `/test`: contains Python unit tests for the library
89
+ - `/demo`: contains demos that are used in the documentation, you can find `Gradio` examples over here.
90
+ - `/website`: contains the code for the Gradio website (www.gradio.app). See the README in the `/website` folder for more details
91
+
92
+ ### Continuous Integration and Testing
93
+
94
+ All PRs must pass the continuous integration tests before merging. To test locally, you can run `python -m unittest` from the repo directory.
95
+
96
+ ## Submitting PRs
97
+
98
+ 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:
99
+
100
+ - An initial review has been requested, and
101
+ - A description of the change (with a link to the GitHub PR) has been added to CHANGELOG.md, and
102
+ - A maintainer (@abidlabs, @aliabid94, @aliabd, @AK391, @dawoodkhan82, @pngwn, @freddyaboulton) is tagged in the PR comments and asked to complete a review
103
+
104
+ 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.
105
+
106
+ Do not forget the format the backend before pushing.
107
+
108
+ ```
109
+ bash scripts/format_backend.sh
110
+ ```
111
+
112
+ ```
113
+ bash scripts/format_frontend.sh
114
+ ```
115
+
116
+ ## CI checks
117
+
118
+ Currently the following checks are run in CI:
119
+
120
+ ### Gradio library (`gradio` package)
121
+
122
+ ```
123
+ bash scripts/lint_backend.sh
124
+ bash scripts/type_check_backend.sh
125
+ python -m pytest -m "not flaky" --ignore=client
126
+ python -m pytest -m "flaky" --ignore=client
127
+ ```
128
+
129
+ ### Gradio client (`gradio_client` package)
130
+
131
+ ```
132
+ cd client/python
133
+ bash scripts/lint.sh
134
+ python -m pytest -m "not flaky"
135
+ python -m pytest -m "flaky"
136
+ ```
137
+
138
+ _Could these guidelines be clearer? Feel free to open a PR to help us faciltiate open-source contributions!_
gradio-bbox/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.
gradio-bbox/README.md ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Gradio-BBox
2
+
3
+ <img src="https://github.com/chencn2020/SEAGULL/raw/main/imgs/Logo/logo.png" alt="SEAGULL" style="height: auto; width: 100%; margin-bottom: 3%;">
4
+
5
+ It is an extension to official [gradio-3.36.1](https://github.com/gradio-app/gradio), which supports **drawing boxes** on top of an image.
6
+
7
+ This repository is forked from [Gradio-Osprey-Demo](https://github.com/LiWentomng/gradio-osprey-demo).
8
+
9
+ Thanks for their great contribution.
10
+
11
+ ## Install
12
+
13
+ ### 1. Install Node.js
14
+
15
+ We install it on Ubuntu with:
16
+
17
+ ```
18
+ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
19
+
20
+ source ~/.bashrc # or ~/.zshrc based on which one you use
21
+
22
+ nvm install v18.16.0
23
+ ```
24
+
25
+
26
+ ### 2. Install ppnm
27
+
28
+ ```
29
+ curl -fsSL https://get.pnpm.io/install.sh | sh -
30
+
31
+ source ~/.bashrc # or ~/.zshrc based on which one you use
32
+
33
+ pnpm --version # check if success
34
+ ```
35
+
36
+ ### 3. Install gradio
37
+
38
+ ```
39
+ git clone https://github.com/chencn2020/gradio-bbox.git
40
+
41
+ cd gradio-bbox
42
+
43
+ bash scripts/build_frontend.sh
44
+
45
+ pip install -e .
46
+ ```
gradio-bbox/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 [email protected]. 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.
gradio-bbox/globals.d.ts ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ declare global {
2
+ interface Window {
3
+ __gradio_mode__: "app" | "website";
4
+ launchGradio: Function;
5
+ launchGradioFromSpaces: Function;
6
+ gradio_config: Config;
7
+ scoped_css_attach: (link: HTMLLinkElement) => void;
8
+ __is_colab__: boolean;
9
+ parentIFrame?: {
10
+ scrollTo: (x: number, y: number) => void;
11
+ };
12
+ }
13
+ }
14
+
15
+ export interface Config {
16
+ auth_required: boolean | undefined;
17
+ auth_message: string;
18
+ components: any[];
19
+ css: string | null;
20
+ dependencies: any[];
21
+ dev_mode: boolean;
22
+ enable_queue: boolean;
23
+ layout: any;
24
+ mode: "blocks" | "interface";
25
+ root: string;
26
+ theme: string;
27
+ title: string;
28
+ version: string;
29
+ space_id: string | null;
30
+ is_colab: boolean;
31
+ show_api: boolean;
32
+ stylesheets: string[];
33
+ path: string;
34
+ }
gradio-bbox/package.json ADDED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "gradio-ui",
3
+ "version": "0.0.1",
4
+ "description": "Gradio UI packages",
5
+ "scripts": {
6
+ "dev": "pnpm css && pnpm --filter @gradio/client build && pnpm --filter @gradio/app dev",
7
+ "css": "pnpm --filter @gradio/theme generate",
8
+ "build": "pnpm css && pnpm --filter @gradio/client build && pnpm --filter @gradio/app build:local --emptyOutDir",
9
+ "build:cdn": "pnpm --filter @gradio/client build && pnpm --filter @gradio/app build:cdn --emptyOutDir",
10
+ "build:website": "pnpm --filter @gradio/app build:website --emptyOutDir",
11
+ "build:cdn-local": "TEST_CDN=TRUE pnpm build:cdn",
12
+ "preview:cdn-server": "sirv ./gradio/templates/cdn --single --port=4321 --cors",
13
+ "preview:cdn-app": "pnpm --filter @gradio/cdn-test dev",
14
+ "preview:cdn-local": "run-p preview:cdn-server preview:cdn-app",
15
+ "format:check": "prettier --ignore-path .config/.prettierignore --check --config .config/.prettierrc.json .",
16
+ "format:write": "prettier --ignore-path .config/.prettierignore --write --config .config/.prettierrc.json .",
17
+ "lint": "ESLINT_USE_FLAT_CONFIG=true eslint -c .config/eslint.config.js js client/js",
18
+ "ts:check": "svelte-check --tsconfig tsconfig.json",
19
+ "test": "pnpm --filter @gradio/client build && vitest dev --config .config/vitest.config.ts",
20
+ "test:run": "pnpm --filter @gradio/client build && vitest run --config .config/vitest.config.ts --reporter=verbose",
21
+ "test:node": "TEST_MODE=node pnpm vitest run --config .config/vitest.config.ts",
22
+ "test:browser": "pnpm --filter @gradio/app test:browser",
23
+ "test:browser:full": "run-s build test:browser",
24
+ "test:browser:verbose": "GRADIO_TEST_VERBOSE=true pnpm test:browser",
25
+ "test:browser:dev": "pnpm --filter @gradio/app test:browser:dev",
26
+ "ci:publish": "pnpm publish --no-git-checks --access public -r",
27
+ "ci:version": "changeset version && pnpm i --lockfile-only",
28
+ "storybook": "storybook dev -p 6006 --config-dir js/storybook",
29
+ "build-storybook": "storybook build --config-dir js/storybook",
30
+ "chromatic": "chromatic --exit-zero-on-changes",
31
+ "test:ct": "playwright test -c ./.config/playwright-ct.config.ts"
32
+ },
33
+ "type": "module",
34
+ "author": "",
35
+ "license": "ISC",
36
+ "private": true,
37
+ "dependencies": {
38
+ "@changesets/changelog-github": "^0.4.8",
39
+ "@changesets/cli": "^2.26.1",
40
+ "@csstools/postcss-global-data": "^2.0.0",
41
+ "@gradio/tootils": "workspace:^0.0.1",
42
+ "@playwright/experimental-ct-svelte": "^1.35.1",
43
+ "@playwright/test": "^1.35.1",
44
+ "@sveltejs/vite-plugin-svelte": "^2.4.2",
45
+ "@tailwindcss/forms": "^0.5.0",
46
+ "@testing-library/dom": "^9.0.0",
47
+ "@testing-library/jest-dom": "^5.16.5",
48
+ "@testing-library/user-event": "^14.0.0",
49
+ "@types/node": "^20.3.1",
50
+ "@types/testing-library__jest-dom": "^5.14.6",
51
+ "@typescript-eslint/eslint-plugin": "^5.60.0",
52
+ "@typescript-eslint/parser": "^5.60.0",
53
+ "autoprefixer": "^10.4.4",
54
+ "babylonjs": "^5.17.1",
55
+ "babylonjs-loaders": "^5.17.1",
56
+ "eslint": "^8.43.0",
57
+ "eslint-plugin-svelte": "^2.31.0",
58
+ "globals": "^13.20.0",
59
+ "jsdom": "^22.1.0",
60
+ "kleur": "^4.1.5",
61
+ "msw": "^1.2.2",
62
+ "node-html-parser": "^6.0.0",
63
+ "npm-run-all": "^4.1.5",
64
+ "plotly.js-dist-min": "^2.10.1",
65
+ "polka": "^1.0.0-next.22",
66
+ "pollen-css": "^4.6.1",
67
+ "postcss": "^8.4.6",
68
+ "postcss-custom-media": "10",
69
+ "postcss-nested": "^5.0.6",
70
+ "postcss-prefix-selector": "^1.16.0",
71
+ "prettier": "^3.0.0",
72
+ "prettier-plugin-css-order": "^1.3.1",
73
+ "prettier-plugin-svelte": "^2.10.1",
74
+ "sirv": "^2.0.2",
75
+ "sirv-cli": "^2.0.2",
76
+ "svelte": "^4.0.0",
77
+ "svelte-check": "^3.4.4",
78
+ "svelte-i18n": "^3.6.0",
79
+ "svelte-preprocess": "^5.0.4",
80
+ "tailwindcss": "^3.1.6",
81
+ "tinyspy": "^2.0.0",
82
+ "typescript": "^5.0.0",
83
+ "vite": "^4.3.9",
84
+ "vitest": "^0.33.0"
85
+ },
86
+ "devDependencies": {
87
+ "@playwright/test": "^1.35.1",
88
+ "@storybook/addon-a11y": "^7.0.24",
89
+ "@storybook/addon-essentials": "^7.0.23",
90
+ "@storybook/addon-interactions": "^7.0.23",
91
+ "@storybook/addon-links": "^7.0.23",
92
+ "@storybook/addon-styling": "^1.3.1",
93
+ "@storybook/addon-svelte-csf": "^3.0.3",
94
+ "@storybook/blocks": "^7.0.23",
95
+ "@storybook/manager-api": "^7.0.23",
96
+ "@storybook/svelte": "^7.0.23",
97
+ "@storybook/svelte-vite": "^7.0.23",
98
+ "@storybook/testing-library": "^0.2.0",
99
+ "@storybook/theming": "^7.0.23",
100
+ "@types/three": "^0.153.0",
101
+ "chromatic": "^6.19.9",
102
+ "react": "^18.2.0",
103
+ "react-dom": "^18.2.0",
104
+ "storybook": "^7.0.23"
105
+ }
106
+ }
gradio-bbox/pnpm-lock.yaml ADDED
The diff for this file is too large to render. See raw diff
 
gradio-bbox/pnpm-workspace.yaml ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ packages:
2
+ - 'js/*'
3
+ - 'client/js'
gradio-bbox/pyproject.toml ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.8"
11
+ authors = [
12
+ { name = "Abubakar Abid", email = "[email protected]" },
13
+ { name = "Ali Abid", email = "[email protected]" },
14
+ { name = "Ali Abdalla", email = "[email protected]" },
15
+ { name = "Dawood Khan", email = "[email protected]" },
16
+ { name = "Ahsen Khaliq", email = "[email protected]" },
17
+ { name = "Pete Allen", email = "[email protected]" },
18
+ { name = "Ömer Faruk Özdemir", email = "[email protected]" },
19
+ ]
20
+ keywords = ["machine learning", "reproducibility", "visualization"]
21
+
22
+ classifiers = [
23
+ 'Development Status :: 5 - Production/Stable',
24
+ 'License :: OSI Approved :: Apache Software License',
25
+ 'Operating System :: OS Independent',
26
+ 'Programming Language :: Python :: 3',
27
+ 'Programming Language :: Python :: 3 :: Only',
28
+ 'Programming Language :: Python :: 3.8',
29
+ 'Programming Language :: Python :: 3.9',
30
+ 'Programming Language :: Python :: 3.10',
31
+ 'Programming Language :: Python :: 3.11',
32
+ 'Topic :: Scientific/Engineering',
33
+ 'Topic :: Scientific/Engineering :: Artificial Intelligence',
34
+ 'Topic :: Scientific/Engineering :: Visualization',
35
+ ]
36
+
37
+ [project.scripts]
38
+ gradio = "gradio.cli:cli"
39
+ upload_theme = "gradio.themes.upload_theme:main"
40
+
41
+ [project.urls]
42
+ Homepage = "https://github.com/gradio-app/gradio"
43
+
44
+ [tool.hatch.version]
45
+ path = "gradio/version.txt"
46
+ pattern = "(?P<version>.+)"
47
+
48
+ [tool.hatch.metadata.hooks.requirements_txt]
49
+ filename = "requirements.txt"
50
+
51
+ [tool.hatch.metadata.hooks.fancy-pypi-readme]
52
+ content-type = "text/markdown"
53
+ fragments = [
54
+ { path = "README.md" },
55
+ ]
56
+
57
+ [[tool.hatch.metadata.hooks.fancy-pypi-readme.substitutions]]
58
+ pattern = "(website/homepage|readme_files)/"
59
+ replacement = 'https://raw.githubusercontent.com/gradio-app/gradio/main/\g<1>/'
60
+
61
+ [[tool.hatch.metadata.hooks.fancy-pypi-readme.substitutions]]
62
+ pattern = 'demo/([\S]*.gif)'
63
+ replacement = 'https://raw.githubusercontent.com/gradio-app/gradio/main/demo/\g<1>'
64
+
65
+ [tool.hatch.build]
66
+ artifacts = [
67
+ "/gradio/templates",
68
+ ]
69
+
70
+
71
+ [tool.hatch.build.targets.sdist]
72
+ include = [
73
+ "/gradio",
74
+ "/test",
75
+ "/README.md",
76
+ "/requirements.txt",
77
+ ]
78
+
79
+ [tool.ruff]
80
+ target-version = "py37"
81
+ extend-select = [
82
+ "B",
83
+ "C",
84
+ "I",
85
+ "N",
86
+ "SIM",
87
+ "UP",
88
+ ]
89
+ ignore = [
90
+ "C901", # function is too complex (TODO: un-ignore this)
91
+ "B023", # function definition in loop (TODO: un-ignore this)
92
+ "B008", # function call in argument defaults
93
+ "B017", # pytest.raises considered evil
94
+ "B028", # explicit stacklevel for warnings
95
+ "E501", # from scripts/lint_backend.sh
96
+ "SIM105", # contextlib.suppress (has a performance cost)
97
+ "SIM117", # multiple nested with blocks (doesn't look good with gr.Row etc)
98
+ "UP007", # use X | Y for type annotations (TODO: can be enabled once Pydantic plays nice with them)
99
+ ]
100
+
101
+ [tool.ruff.per-file-ignores]
102
+ "demo/*" = [
103
+ "E402", # Demos may have imports not at the top
104
+ "E741", # Demos may have ambiguous variable names
105
+ "F405", # Demos may use star imports
106
+ "I", # Don't care about import order
107
+ ]
108
+ "gradio/__init__.py" = [
109
+ "F401", # "Imported but unused" (TODO: it would be better to be explicit and use __all__)
110
+ ]
111
+ "gradio/routes.py" = [
112
+ "UP006", # Pydantic on Python 3.7 requires old-style type annotations (TODO: drop when Python 3.7 is dropped)
113
+ ]
gradio-bbox/readme_template.md ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ [![gradio-backend](https://github.com/gradio-app/gradio/actions/workflows/backend.yml/badge.svg)](https://github.com/gradio-app/gradio/actions/workflows/backend.yml)
7
+ [![gradio-ui](https://github.com/gradio-app/gradio/actions/workflows/ui.yml/badge.svg)](https://github.com/gradio-app/gradio/actions/workflows/ui.yml)
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.8+-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
+ | [中文](readme_files/zh-cn#readme)
19
+ </div>
20
+
21
+ # Gradio: Build Machine Learning Web Apps — in Python
22
+
23
+ Gradio is an open-source Python library that is used to build machine learning and data science demos and web applications.
24
+
25
+ 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,
26
+ pasting text, recording their own voice, and interacting with your demo, all through the browser.
27
+
28
+ ![Interface montage](readme_files/header-image.jpg)
29
+
30
+ Gradio is useful for:
31
+
32
+ - **Demoing** your machine learning models for clients/collaborators/users/students.
33
+
34
+ - **Deploying** your models quickly with automatic shareable links and getting feedback on model performance.
35
+
36
+ - **Debugging** your model interactively during development using built-in manipulation and interpretation tools.
37
+
38
+ $getting_started
39
+
40
+ ## Open Source Stack
41
+
42
+ Gradio is built with many wonderful open-source libraries, please support them as well!
43
+
44
+ [<img src="readme_files/huggingface_mini.svg" alt="huggingface" height=40>](https://huggingface.co)
45
+ [<img src="readme_files/python.svg" alt="python" height=40>](https://www.python.org)
46
+ [<img src="readme_files/fastapi.svg" alt="fastapi" height=40>](https://fastapi.tiangolo.com)
47
+ [<img src="readme_files/encode.svg" alt="encode" height=40>](https://www.encode.io)
48
+ [<img src="readme_files/svelte.svg" alt="svelte" height=40>](https://svelte.dev)
49
+ [<img src="readme_files/vite.svg" alt="vite" height=40>](https://vitejs.dev)
50
+ [<img src="readme_files/pnpm.svg" alt="pnpm" height=40>](https://pnpm.io)
51
+ [<img src="readme_files/tailwind.svg" alt="tailwind" height=40>](https://tailwindcss.com)
52
+
53
+ ## License
54
+
55
+ Gradio is licensed under the Apache License 2.0 found in the [LICENSE](LICENSE) file in the root directory of this repository.
56
+
57
+ ## Citation
58
+
59
+ 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.
60
+
61
+ ```
62
+ @article{abid2019gradio,
63
+ title = {Gradio: Hassle-Free Sharing and Testing of ML Models in the Wild},
64
+ author = {Abid, Abubakar and Abdalla, Ali and Abid, Ali and Khan, Dawood and Alfozan, Abdulrahman and Zou, James},
65
+ journal = {arXiv preprint arXiv:1906.02569},
66
+ year = {2019},
67
+ }
68
+ ```
gradio-bbox/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/01_getting-started/01_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}")
gradio-bbox/renovate.json ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "$schema": "https://docs.renovatebot.com/renovate-schema.json",
3
+ "extends": [
4
+ "github>whitesource/merge-confidence:beta",
5
+ "config:base",
6
+ ":preserveSemverRanges",
7
+ "group:allNonMajor",
8
+ ":semanticCommitTypeAll(chore)"
9
+ ],
10
+ "ignorePaths": [
11
+ "**/demo/**",
12
+ "**/requirements.txt",
13
+ "**/Dockerfile",
14
+ "**/website/**"
15
+ ],
16
+ "ignoreDeps": [
17
+ "lazy-brush",
18
+ "babylonjs",
19
+ "babylonjs-loaders",
20
+ "postcss-load-config",
21
+ "postcss-nested",
22
+ "svelte"
23
+ ]
24
+ }
gradio-bbox/requirements.txt ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ aiofiles
2
+ aiohttp
3
+ altair>=4.2.0
4
+ fastapi
5
+ ffmpy
6
+ gradio_client>=0.2.7
7
+ httpx
8
+ huggingface_hub>=0.14.0
9
+ Jinja2
10
+ markdown-it-py[linkify]>=2.0.0
11
+ pygments>=2.12.0
12
+ mdit-py-plugins<=0.3.3
13
+ markupsafe
14
+ matplotlib
15
+ numpy
16
+ orjson
17
+ pandas
18
+ pillow
19
+ pydantic
20
+ python-multipart
21
+ pydub
22
+ pyyaml
23
+ requests
24
+ semantic_version
25
+ uvicorn>=0.14.0
26
+ websockets>=10.0
gradio-bbox/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
gradio-bbox/test-strategy.md ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Test Strategy
2
+
3
+ Very brief, mildly aspirational test strategy document. This isn't where we are but it is where we want to get to.
4
+
5
+ This document does not detail how to setup an environment or how to run the tests locally nor does it contain any best practices that we try to follow when writing tests, that information exists in the [contributing guide](https://github.com/gradio-app/gradio/blob/main/CONTRIBUTING.md).
6
+
7
+ ## Objectives
8
+
9
+ The purposes of all testing activities on Gradio fit one of the following objectives:
10
+
11
+ 1. Ensure that the Gradio library functions as we expect it to.
12
+ 2. Enable the maintenance team to quickly identify both the presence and source of defects.
13
+ 3. Prevent regressions, i.e. if we fix something it should stay fixed.
14
+ 4. Improve the quality of the codebase in order to ease maintenance efforts.
15
+ 5. Reduce the amount of manual testing required.
16
+
17
+ ## Scope
18
+
19
+ Testing is always a tradeoff. We can't cover everything unless we want to spend all of our time writing and running tests. We should focus on a few keys areas.
20
+
21
+ We should not focus on code coverage but on test coverage following the below criteria:
22
+
23
+ - The documented Gradio API (that's the bit that users interact with via python) should be tested thoroughly. (1)
24
+ - Additional gradio elements that are both publicly available and used internally (such as the Python and JS client libraries) should be tested thoroughly. (1)
25
+ - Additional gradio elements that are publicly available should be tested as throughly as is reasonable (this could be things like demos/the gradio CLI/ other tooling). The importance of each individual component. and the appropriate investment of effort, needs to assessed on a case-by-case basis. (1)
26
+ - Element boundaries should be tested where there is reasonable cause to do so (e.g. config generation) (1)
27
+ - Implementation details should only be tested where there is sufficient complexity to warrant it. (1)
28
+ - Bug fixes should be accompanied by tests wherever is reasonably possible. (3)
29
+
30
+ ## Types of testing
31
+
32
+ Our tests will broadly fall into one of three categories:
33
+
34
+ - Static Quality checks
35
+ - Dynamic 'Code' tests
36
+ - Dynamic Functional tests
37
+
38
+ ### Static Quality checks
39
+
40
+ Static quality check are generally very fast to run and do not require building the code base. They also provide the least value. These tests would be things like linting, typechecking, and formatting.
41
+
42
+ While they offer little in terms of testing functionality they align very closely with objective (4, 5) as they generally help to keep the codebase in good shape and offer very fast feedback. Such check are almost free from an authoring point of view as fixes can be mostly automated (either via scripts or editor integrations).
43
+
44
+ ### Dynamic code tests
45
+
46
+ These tests generally test either isolated pieces of code or test the relationship between parts of the code base. They sometimes test functionality or give indications of working functionality but never offer enough confidence to rely on them solely.
47
+
48
+ These test are usually either unit or integration tests. They are generally pretty quick to write (especially unit tests) and run and offer a moderate amount of confidence. They align closely with Objectives 2 and 3 and a little bit of 1.
49
+
50
+ This kind of tests should probably make up the bulk of our handwritten tests.
51
+
52
+ ### Dynamic functional tests
53
+
54
+ These tests give by far the most confidence as they are testing only the functionality of the software and do so by running the entire software itself, exactly as a user would.
55
+
56
+ This aligns very closely with objective 1 but significantly impacts objective 5, as these tests are costly to both write and run. Despite the value, due to the downside we should try to get as much out of other tests types as we can, reserving functional testing for complex use cases and end-to-end journey.
57
+
58
+ Tests in this category could be browser-based end-to-end tests, accessibility tests, or performance tests. They are sometimes called acceptance tests.
59
+
60
+ ## Testing tools
61
+
62
+ We currently use the following tools:
63
+
64
+ ### Static quality checks
65
+
66
+ - Python type-checking (python)
67
+ - Black linting (python)
68
+ - ruff formatting (python)
69
+ - prettier formatting (javascript/svelte)
70
+ - TypeScript type-checking (javascript/svelte)
71
+ - eslint linting (javascript/svelte) [in progress]
72
+
73
+ ### Dynamic code tests
74
+
75
+ - pytest (python unit and integration tests)
76
+ - vitest (node-based unit and integration tests)
77
+ - playwright (browser-based unit and integration tests)
78
+
79
+ ### Functional/acceptance tests
80
+
81
+ - playwright (full end to end testing)
82
+ - chromatic (visual testing) [in progress]
83
+ - Accessibility testing [to do]
84
+
85
+ ## Supported environments and versions
86
+
87
+ All operating systems refer to the current runner variants supported by GitHub actions.
88
+
89
+ All unspecified version segments (`x`) refer to latest.
90
+
91
+ | Software | Version(s) | Operating System(s) |
92
+ | -------- | --------------------- | --------------------------------- |
93
+ | Python | `3.8.x` | `ubuntu-latest`, `windows-latest` |
94
+ | Node | `18.x.x` | `ubuntu-latest` |
95
+ | Browser | `playwright-chrome-x` | `ubuntu-latest` |
96
+
97
+ ## Test execution
98
+
99
+ Tests need to be executed in a number of environments and at different stages on the development cycle in orsder to be useful. The requirements for tests are as follows:
100
+
101
+ - **Locally**: it is important that developers can easily run most tests locally to ensure a passing suite before making a PR. There are some exceptions to this, certain tests may require access to secret values which we cannot make available to all possible contributors for practical security reasons. It is reasonable that it isn't possible to run these tests but they should be disabled by default when running locally.
102
+ - **CI** - It is _critical_ that all tests run successfully in CI with no exceptions. Not every tests is required to pass to satisfy CI checks for practical reasons but it is required that all tests should run in CI and notify us if something unexpected happens in order for the development team to take appropriate action.
103
+
104
+ For instructions on how to write and run tests see the [contributing guide](https://github.com/gradio-app/gradio/blob/main/CONTRIBUTING.md).
105
+
106
+ ## Managing defects
107
+
108
+ As we formalise our testing strategy and bring / keep our test up to standard, it is important that we have some principles on managing defects as they ocurr/ are reported. For now we can have one very simple rule:
109
+
110
+ - Every bug fix should be accompanied by a test that failed before the fix and passes afterwards. This test should _typically_ be a dynamic code test but it could be a linting rule or new type if that is appropriate. There are always exceptions but we should think very carefully before ignoring this rule.
gradio-bbox/tsconfig.json ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "compilerOptions": {
3
+ "moduleResolution": "node",
4
+ "module": "es2020",
5
+ "lib": ["es2020", "DOM"],
6
+ "target": "es2020",
7
+ /**
8
+ svelte-preprocess cannot figure out whether you have a value or a type, so tell TypeScript
9
+ to enforce using \`import type\` instead of \`import\` for Types.
10
+ */
11
+ "verbatimModuleSyntax": true,
12
+ "resolveJsonModule": true,
13
+ "strict": true,
14
+ "sourceMap": true,
15
+ "esModuleInterop": true,
16
+ "skipLibCheck": true,
17
+ "forceConsistentCasingInFileNames": true,
18
+ "allowJs": true,
19
+ "checkJs": true,
20
+ "outDir": "dist",
21
+ "baseUrl": ".",
22
+ "paths": {
23
+ "./pure": ["./pure.js"]
24
+ }
25
+ },
26
+ "exclude": [
27
+ "**/dist/**/*",
28
+ "**/public/**/*",
29
+ "**/.config/**/*",
30
+ "**/*.test.ts",
31
+ "**/dist",
32
+ ".github/**/*",
33
+ "**/demo/**/*",
34
+ "**/gradio/**/*",
35
+ "**/guides/**/*",
36
+ "**/readme_files/**/*",
37
+ "**/scripts/**/*",
38
+ "**/test/**/*",
39
+ "**/website/**/*",
40
+ "**/node_modules/**/*",
41
+ "**/venv/**/*",
42
+ "client/js/**",
43
+ "**/vite.config*"
44
+ ],
45
+ "include": [
46
+ "**/*.d.ts",
47
+ "**/*.js",
48
+ "**/*.ts",
49
+ "**/*.svelte",
50
+ "client/js/**/*"
51
+ ]
52
+ }