mirror of
https://github.com/gradio-app/gradio.git
synced 2025-02-17 11:29:58 +08:00
[Docs] Resolve numerous typos (#4170)
* Resolve numerous typos * Delete test.py * Run generate_notebooks * notebooks --------- Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
This commit is contained in:
parent
d9acdfb7a3
commit
02bd90d7c1
12
CHANGELOG.md
12
CHANGELOG.md
@ -378,7 +378,7 @@ No changes to highlight.
|
||||
|
||||
- Fixes Chatbot issue where new lines were being created every time a message was sent back and forth by [@aliabid94](https://github.com/aliabid94) in [PR 3717](https://github.com/gradio-app/gradio/pull/3717).
|
||||
- Fixes data updating in DataFrame invoking a `select` event once the dataframe has been selected. By [@yiyuezhuo](https://github.com/yiyuezhuo) in [PR 3861](https://github.com/gradio-app/gradio/pull/3861)
|
||||
- Fixes false postive warning which is due to too strict type checking by [@yiyuezhuo](https://github.com/yiyuezhuo) in [PR 3837](https://github.com/gradio-app/gradio/pull/3837).
|
||||
- Fixes false positive warning which is due to too strict type checking by [@yiyuezhuo](https://github.com/yiyuezhuo) in [PR 3837](https://github.com/gradio-app/gradio/pull/3837).
|
||||
|
||||
## Documentation Changes:
|
||||
|
||||
@ -457,7 +457,7 @@ By [@freddyaboulton](https://github.com/freddyaboulton) in [PR 3581](https://git
|
||||
|
||||
## Testing and Infrastructure Changes:
|
||||
|
||||
- Removed heavily-mocked tests related to comet_ml, wandb, and mlflow as they added a significant amount of test dependencies that prevented installation of test dependencies on Windows environemnts. By [@abidlabs](https://github.com/abidlabs) in [PR 3608](https://github.com/gradio-app/gradio/pull/3608)
|
||||
- Removed heavily-mocked tests related to comet_ml, wandb, and mlflow as they added a significant amount of test dependencies that prevented installation of test dependencies on Windows environments. By [@abidlabs](https://github.com/abidlabs) in [PR 3608](https://github.com/gradio-app/gradio/pull/3608)
|
||||
- Added Windows continuous integration, by [@space-nuko](https://github.com/space-nuko) in [PR 3628](https://github.com/gradio-app/gradio/pull/3628)
|
||||
- Switched linting from flake8 + isort to `ruff`, by [@akx](https://github.com/akx) in [PR 3710](https://github.com/gradio-app/gradio/pull/3710)
|
||||
|
||||
@ -1049,7 +1049,7 @@ By [@maxaudron](https://github.com/maxaudron) in [PR 3075](https://github.com/gr
|
||||
|
||||
- Fixes URL resolution on Windows by [@abidlabs](https://github.com/abidlabs) in [PR 3108](https://github.com/gradio-app/gradio/pull/3108)
|
||||
- Example caching now works with components without a label attribute (e.g. `Column`) by [@abidlabs](https://github.com/abidlabs) in [PR 3123](https://github.com/gradio-app/gradio/pull/3123)
|
||||
- Ensure the Video component correctly resets the UI state whe a new video source is loaded and reduce choppiness of UI by [@pngwn](https://github.com/abidlabs) in [PR 3117](https://github.com/gradio-app/gradio/pull/3117)
|
||||
- Ensure the Video component correctly resets the UI state when a new video source is loaded and reduce choppiness of UI by [@pngwn](https://github.com/abidlabs) in [PR 3117](https://github.com/gradio-app/gradio/pull/3117)
|
||||
- Fixes loading private Spaces by [@abidlabs](https://github.com/abidlabs) in [PR 3068](https://github.com/gradio-app/gradio/pull/3068)
|
||||
- Added a warning when attempting to launch an `Interface` via the `%%blocks` jupyter notebook magic command by [@freddyaboulton](https://github.com/freddyaboulton) in [PR 3126](https://github.com/gradio-app/gradio/pull/3126)
|
||||
- Fixes bug where interactive output image cannot be set when in edit mode by [@dawoodkhan82](https://github.com/@dawoodkhan82) in [PR 3135](https://github.com/gradio-app/gradio/pull/3135)
|
||||
@ -1997,7 +1997,7 @@ english_translator = gr.Blocks.load(name="spaces/gradio/english-translator")
|
||||
german = english_translator("My name is Freddy", api_name='translate-to-german')
|
||||
```
|
||||
|
||||
The `api_name` parameter will take precendence over the `fn_index` parameter.
|
||||
The `api_name` parameter will take precedence over the `fn_index` parameter.
|
||||
|
||||
## Bug Fixes:
|
||||
|
||||
@ -2455,7 +2455,7 @@ No changes to highlight.
|
||||
- Fixed small typos in the docs [@julien-c](https://github.com/julien-c) in [PR 2373](https://github.com/gradio-app/gradio/pull/2373)
|
||||
- Adds ability to disable pre/post-processing for examples [@abidlabs](https://github.com/abidlabs) in [PR 2383](https://github.com/gradio-app/gradio/pull/2383)
|
||||
- Copy changelog file in website docker by [@aliabd](https://github.com/aliabd) in [PR 2384](https://github.com/gradio-app/gradio/pull/2384)
|
||||
- Lets users provide a `gr.update()` dictionary even if post-processing is diabled [@abidlabs](https://github.com/abidlabs) in [PR 2385](https://github.com/gradio-app/gradio/pull/2385)
|
||||
- Lets users provide a `gr.update()` dictionary even if post-processing is disabled [@abidlabs](https://github.com/abidlabs) in [PR 2385](https://github.com/gradio-app/gradio/pull/2385)
|
||||
- Fix bug where errors would cause apps run in reload mode to hang forever by [@freddyaboulton](https://github.com/freddyaboulton) in [PR 2394](https://github.com/gradio-app/gradio/pull/2394)
|
||||
- Fix bug where new typeable slider doesn't respect the minimum and maximum values [@dawoodkhan82](https://github.com/dawoodkhan82) in [PR 2380](https://github.com/gradio-app/gradio/pull/2380)
|
||||
|
||||
@ -3116,7 +3116,7 @@ We've introduced a lot of new components in `3.0`, including `Model3D`, `Dataset
|
||||
- add copy functionality to json by [@pngwn](https://github.com/pngwn) in [PR 1205](https://github.com/gradio-app/gradio/pull/1205)
|
||||
- Update component config by [@aliabid94](https://github.com/aliabid94) in [PR 1089](https://github.com/gradio-app/gradio/pull/1089)
|
||||
- fix placeholder prompt by [@pngwn](https://github.com/pngwn) in [PR 1215](https://github.com/gradio-app/gradio/pull/1215)
|
||||
- ensure webcam video value is propogated correctly by [@pngwn](https://github.com/pngwn) in [PR 1218](https://github.com/gradio-app/gradio/pull/1218)
|
||||
- ensure webcam video value is propagated correctly by [@pngwn](https://github.com/pngwn) in [PR 1218](https://github.com/gradio-app/gradio/pull/1218)
|
||||
- Automatic word-break in highlighted text, combine_adjacent support by [@aliabid94](https://github.com/aliabid94) in [PR 1209](https://github.com/gradio-app/gradio/pull/1209)
|
||||
- async-function-support by [@FarukOzderim](https://github.com/FarukOzderim) in [PR 1190](https://github.com/gradio-app/gradio/pull/1190)
|
||||
- Sharing fix for assets by [@aliabid94](https://github.com/aliabid94) in [PR 1208](https://github.com/gradio-app/gradio/pull/1208)
|
||||
|
@ -1,6 +1,6 @@
|
||||
# Contributing to Gradio
|
||||
|
||||
Prequisites:
|
||||
Prerequisites:
|
||||
|
||||
- [Python 3.7+](https://www.python.org/downloads/)
|
||||
- [pnpm version 7.x](https://pnpm.io/7.x/installation) (optional for backend-only changes, but needed for any frontend changes)
|
||||
|
@ -165,7 +165,7 @@ class ImgSerializable(Serializable):
|
||||
load_dir: str | Path = "",
|
||||
) -> str | None:
|
||||
"""
|
||||
Convert from human-friendly version of a file (string filepath) to a seralized
|
||||
Convert from human-friendly version of a file (string filepath) to a serialized
|
||||
representation (base64).
|
||||
Parameters:
|
||||
x: String path to file to serialize
|
||||
@ -308,7 +308,7 @@ class FileSerializable(Serializable):
|
||||
) -> FileData | None | list[FileData | None]:
|
||||
"""
|
||||
Convert from human-friendly version of a file (string filepath) to a
|
||||
seralized representation (base64)
|
||||
serialized representation (base64)
|
||||
Parameters:
|
||||
x: String path to file to serialize
|
||||
load_dir: Path to directory containing x
|
||||
|
@ -169,7 +169,7 @@ def create_initial_status_update():
|
||||
class JobStatus:
|
||||
"""The job status.
|
||||
|
||||
Keeps strack of the latest status update and intermediate outputs (not yet implements).
|
||||
Keeps track of the latest status update and intermediate outputs (not yet implements).
|
||||
"""
|
||||
|
||||
latest_status: StatusUpdate = field(default_factory=create_initial_status_update)
|
||||
|
File diff suppressed because one or more lines are too long
@ -236,7 +236,7 @@ title = "Clustering with Scikit-learn"
|
||||
description = (
|
||||
"This example shows how different clustering algorithms work. Simply pick "
|
||||
"the dataset and the number of clusters to see how the clustering algorithms work. "
|
||||
"Colored cirles are (predicted) labels and black x are outliers."
|
||||
"Colored circles are (predicted) labels and black x are outliers."
|
||||
)
|
||||
|
||||
|
||||
|
@ -1 +1 @@
|
||||
{"cells": [{"cell_type": "markdown", "id": 302934307671667531413257853548643485645, "metadata": {}, "source": ["# Gradio Demo: code"]}, {"cell_type": "code", "execution_count": null, "id": 272996653310673477252411125948039410165, "metadata": {}, "outputs": [], "source": ["!pip install -q gradio "]}, {"cell_type": "code", "execution_count": null, "id": 288918539441861185822528903084949547379, "metadata": {}, "outputs": [], "source": ["# Downloading files from the demo repo\n", "import os\n", "!wget -q https://github.com/gradio-app/gradio/raw/main/demo/code/file.css"]}, {"cell_type": "code", "execution_count": null, "id": 44380577570523278879349135829904343037, "metadata": {}, "outputs": [], "source": ["import gradio as gr\n", "import os\n", "from time import sleep\n", "\n", "\n", "css_file = os.path.join(os.path.abspath(''), \"file.css\")\n", "\n", "\n", "def set_lang(language):\n", " print(language)\n", " return gr.Code.update(language=language)\n", "\n", "\n", "def set_lang_from_path():\n", " sleep(1)\n", " return gr.Code.update((css_file,), language=\"css\")\n", "\n", "\n", "def code(language, code):\n", " return gr.Code.update(code, language=language)\n", "\n", "\n", "io = gr.Interface(lambda x: x, \"code\", \"code\")\n", "\n", "with gr.Blocks() as demo:\n", " lang = gr.Dropdown(value=\"python\", choices=gr.Code.languages)\n", " with gr.Row():\n", " code_in = gr.Code(\n", " language=\"python\",\n", " label=\"Input\",\n", " value='def all_odd_elements(sequence):\\n \"\"\"Returns every odd element of the sequence.\"\"\"',\n", " )\n", " code_out = gr.Code(label=\"Ouput\")\n", " btn = gr.Button(\"Run\")\n", " btn_two = gr.Button(\"Load File\")\n", "\n", " lang.change(set_lang, inputs=lang, outputs=code_in)\n", " btn.click(code, inputs=[lang, code_in], outputs=code_out)\n", " btn_two.click(set_lang_from_path, inputs=None, outputs=code_out)\n", " io.render()\n", "\n", "if __name__ == \"__main__\":\n", " demo.launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
|
||||
{"cells": [{"cell_type": "markdown", "id": 302934307671667531413257853548643485645, "metadata": {}, "source": ["# Gradio Demo: code"]}, {"cell_type": "code", "execution_count": null, "id": 272996653310673477252411125948039410165, "metadata": {}, "outputs": [], "source": ["!pip install -q gradio "]}, {"cell_type": "code", "execution_count": null, "id": 288918539441861185822528903084949547379, "metadata": {}, "outputs": [], "source": ["# Downloading files from the demo repo\n", "import os\n", "!wget -q https://github.com/gradio-app/gradio/raw/main/demo/code/file.css"]}, {"cell_type": "code", "execution_count": null, "id": 44380577570523278879349135829904343037, "metadata": {}, "outputs": [], "source": ["import gradio as gr\n", "import os\n", "from time import sleep\n", "\n", "\n", "css_file = os.path.join(os.path.abspath(''), \"file.css\")\n", "\n", "\n", "def set_lang(language):\n", " print(language)\n", " return gr.Code.update(language=language)\n", "\n", "\n", "def set_lang_from_path():\n", " sleep(1)\n", " return gr.Code.update((css_file,), language=\"css\")\n", "\n", "\n", "def code(language, code):\n", " return gr.Code.update(code, language=language)\n", "\n", "\n", "io = gr.Interface(lambda x: x, \"code\", \"code\")\n", "\n", "with gr.Blocks() as demo:\n", " lang = gr.Dropdown(value=\"python\", choices=gr.Code.languages)\n", " with gr.Row():\n", " code_in = gr.Code(\n", " language=\"python\",\n", " label=\"Input\",\n", " value='def all_odd_elements(sequence):\\n \"\"\"Returns every odd element of the sequence.\"\"\"',\n", " )\n", " code_out = gr.Code(label=\"Output\")\n", " btn = gr.Button(\"Run\")\n", " btn_two = gr.Button(\"Load File\")\n", "\n", " lang.change(set_lang, inputs=lang, outputs=code_in)\n", " btn.click(code, inputs=[lang, code_in], outputs=code_out)\n", " btn_two.click(set_lang_from_path, inputs=None, outputs=code_out)\n", " io.render()\n", "\n", "if __name__ == \"__main__\":\n", " demo.launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
|
@ -30,7 +30,7 @@ with gr.Blocks() as demo:
|
||||
label="Input",
|
||||
value='def all_odd_elements(sequence):\n """Returns every odd element of the sequence."""',
|
||||
)
|
||||
code_out = gr.Code(label="Ouput")
|
||||
code_out = gr.Code(label="Output")
|
||||
btn = gr.Button("Run")
|
||||
btn_two = gr.Button("Load File")
|
||||
|
||||
|
@ -69,9 +69,9 @@ def running_mean(x, N, total_length=-1):
|
||||
return np.pad(cumsum[N:] - cumsum[:-N], (to_pad, 0)) / float(N)
|
||||
|
||||
|
||||
def retrieve_pip_installs(library_names, cummulated):
|
||||
def retrieve_pip_installs(library_names, cumulated):
|
||||
|
||||
if cummulated:
|
||||
if cumulated:
|
||||
returned_values = {}
|
||||
for library_name in library_names:
|
||||
for i in datasets['pip'][library_name]:
|
||||
|
@ -1 +1 @@
|
||||
{"cells": [{"cell_type": "markdown", "id": 302934307671667531413257853548643485645, "metadata": {}, "source": ["# Gradio Demo: sentence_builder"]}, {"cell_type": "code", "execution_count": null, "id": 272996653310673477252411125948039410165, "metadata": {}, "outputs": [], "source": ["!pip install -q gradio "]}, {"cell_type": "code", "execution_count": null, "id": 288918539441861185822528903084949547379, "metadata": {}, "outputs": [], "source": ["import gradio as gr\n", "\n", "\n", "def sentence_builder(quantity, animal, countries, place, activity_list, morning):\n", " return f\"\"\"The {quantity} {animal}s from {\" and \".join(countries)} went to the {place} where they {\" and \".join(activity_list)} until the {\"morning\" if morning else \"night\"}\"\"\"\n", "\n", "\n", "demo = gr.Interface(\n", " sentence_builder,\n", " [\n", " gr.Slider(2, 20, value=4, label=\"Count\", info=\"Choose betwen 2 and 20\"),\n", " gr.Dropdown(\n", " [\"cat\", \"dog\", \"bird\"], label=\"Animal\", info=\"Will add more animals later!\"\n", " ),\n", " gr.CheckboxGroup([\"USA\", \"Japan\", \"Pakistan\"], label=\"Countries\", info=\"Where are they from?\"),\n", " gr.Radio([\"park\", \"zoo\", \"road\"], label=\"Location\", info=\"Where did they go?\"),\n", " gr.Dropdown(\n", " [\"ran\", \"swam\", \"ate\", \"slept\"], value=[\"swam\", \"slept\"], multiselect=True, label=\"Activity\", info=\"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed auctor, nisl eget ultricies aliquam, nunc nisl aliquet nunc, eget aliquam nisl nunc vel nisl.\"\n", " ),\n", " gr.Checkbox(label=\"Morning\", info=\"Did they do it in the morning?\"),\n", " ],\n", " \"text\",\n", " examples=[\n", " [2, \"cat\", [\"Japan\", \"Pakistan\"], \"park\", [\"ate\", \"swam\"], True],\n", " [4, \"dog\", [\"Japan\"], \"zoo\", [\"ate\", \"swam\"], False],\n", " [10, \"bird\", [\"USA\", \"Pakistan\"], \"road\", [\"ran\"], False],\n", " [8, \"cat\", [\"Pakistan\"], \"zoo\", [\"ate\"], True],\n", " ]\n", ")\n", "\n", "if __name__ == \"__main__\":\n", " demo.launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
|
||||
{"cells": [{"cell_type": "markdown", "id": 302934307671667531413257853548643485645, "metadata": {}, "source": ["# Gradio Demo: sentence_builder"]}, {"cell_type": "code", "execution_count": null, "id": 272996653310673477252411125948039410165, "metadata": {}, "outputs": [], "source": ["!pip install -q gradio "]}, {"cell_type": "code", "execution_count": null, "id": 288918539441861185822528903084949547379, "metadata": {}, "outputs": [], "source": ["import gradio as gr\n", "\n", "\n", "def sentence_builder(quantity, animal, countries, place, activity_list, morning):\n", " return f\"\"\"The {quantity} {animal}s from {\" and \".join(countries)} went to the {place} where they {\" and \".join(activity_list)} until the {\"morning\" if morning else \"night\"}\"\"\"\n", "\n", "\n", "demo = gr.Interface(\n", " sentence_builder,\n", " [\n", " gr.Slider(2, 20, value=4, label=\"Count\", info=\"Choose between 2 and 20\"),\n", " gr.Dropdown(\n", " [\"cat\", \"dog\", \"bird\"], label=\"Animal\", info=\"Will add more animals later!\"\n", " ),\n", " gr.CheckboxGroup([\"USA\", \"Japan\", \"Pakistan\"], label=\"Countries\", info=\"Where are they from?\"),\n", " gr.Radio([\"park\", \"zoo\", \"road\"], label=\"Location\", info=\"Where did they go?\"),\n", " gr.Dropdown(\n", " [\"ran\", \"swam\", \"ate\", \"slept\"], value=[\"swam\", \"slept\"], multiselect=True, label=\"Activity\", info=\"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed auctor, nisl eget ultricies aliquam, nunc nisl aliquet nunc, eget aliquam nisl nunc vel nisl.\"\n", " ),\n", " gr.Checkbox(label=\"Morning\", info=\"Did they do it in the morning?\"),\n", " ],\n", " \"text\",\n", " examples=[\n", " [2, \"cat\", [\"Japan\", \"Pakistan\"], \"park\", [\"ate\", \"swam\"], True],\n", " [4, \"dog\", [\"Japan\"], \"zoo\", [\"ate\", \"swam\"], False],\n", " [10, \"bird\", [\"USA\", \"Pakistan\"], \"road\", [\"ran\"], False],\n", " [8, \"cat\", [\"Pakistan\"], \"zoo\", [\"ate\"], True],\n", " ]\n", ")\n", "\n", "if __name__ == \"__main__\":\n", " demo.launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
|
@ -8,7 +8,7 @@ def sentence_builder(quantity, animal, countries, place, activity_list, morning)
|
||||
demo = gr.Interface(
|
||||
sentence_builder,
|
||||
[
|
||||
gr.Slider(2, 20, value=4, label="Count", info="Choose betwen 2 and 20"),
|
||||
gr.Slider(2, 20, value=4, label="Count", info="Choose between 2 and 20"),
|
||||
gr.Dropdown(
|
||||
["cat", "dog", "bird"], label="Animal", info="Will add more animals later!"
|
||||
),
|
||||
|
@ -1 +1 @@
|
||||
{"cells": [{"cell_type": "markdown", "id": 302934307671667531413257853548643485645, "metadata": {}, "source": ["# Gradio Demo: sound_alert"]}, {"cell_type": "code", "execution_count": null, "id": 272996653310673477252411125948039410165, "metadata": {}, "outputs": [], "source": ["!pip install -q gradio "]}, {"cell_type": "code", "execution_count": null, "id": 288918539441861185822528903084949547379, "metadata": {}, "outputs": [], "source": ["# Downloading files from the demo repo\n", "import os\n", "!wget -q https://github.com/gradio-app/gradio/raw/main/demo/sound_alert/beep.mp3"]}, {"cell_type": "code", "execution_count": null, "id": 44380577570523278879349135829904343037, "metadata": {}, "outputs": [], "source": ["import time\n", "import gradio as gr\n", "\n", "\n", "js_function = \"() => {new Audio('file=beep.mp3').play();}\"\n", "\n", "def task(x):\n", " time.sleep(2)\n", " return \"Hello, \" + x \n", "\n", "with gr.Blocks() as demo:\n", " name = gr.Textbox(label=\"name\")\n", " greeting = gr.Textbox(label=\"greeting\")\n", " name.blur(task, name, greeting)\n", " greeting.change(None, [], [], _js=js_function) # Note that _js is a special arugment whose usage may change in the future\n", " \n", "demo.launch()"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
|
||||
{"cells": [{"cell_type": "markdown", "id": 302934307671667531413257853548643485645, "metadata": {}, "source": ["# Gradio Demo: sound_alert"]}, {"cell_type": "code", "execution_count": null, "id": 272996653310673477252411125948039410165, "metadata": {}, "outputs": [], "source": ["!pip install -q gradio "]}, {"cell_type": "code", "execution_count": null, "id": 288918539441861185822528903084949547379, "metadata": {}, "outputs": [], "source": ["# Downloading files from the demo repo\n", "import os\n", "!wget -q https://github.com/gradio-app/gradio/raw/main/demo/sound_alert/beep.mp3"]}, {"cell_type": "code", "execution_count": null, "id": 44380577570523278879349135829904343037, "metadata": {}, "outputs": [], "source": ["import time\n", "import gradio as gr\n", "\n", "\n", "js_function = \"() => {new Audio('file=beep.mp3').play();}\"\n", "\n", "def task(x):\n", " time.sleep(2)\n", " return \"Hello, \" + x \n", "\n", "with gr.Blocks() as demo:\n", " name = gr.Textbox(label=\"name\")\n", " greeting = gr.Textbox(label=\"greeting\")\n", " name.blur(task, name, greeting)\n", " greeting.change(None, [], [], _js=js_function) # Note that _js is a special argument whose usage may change in the future\n", " \n", "demo.launch()"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
|
@ -12,6 +12,6 @@ with gr.Blocks() as demo:
|
||||
name = gr.Textbox(label="name")
|
||||
greeting = gr.Textbox(label="greeting")
|
||||
name.blur(task, name, greeting)
|
||||
greeting.change(None, [], [], _js=js_function) # Note that _js is a special arugment whose usage may change in the future
|
||||
greeting.change(None, [], [], _js=js_function) # Note that _js is a special argument whose usage may change in the future
|
||||
|
||||
demo.launch()
|
@ -874,7 +874,7 @@ class Blocks(BlockContext):
|
||||
)
|
||||
overlapping_ids = set(Context.root_block.blocks).intersection(self.blocks)
|
||||
for id in overlapping_ids:
|
||||
# State componenents are allowed to be reused between Blocks
|
||||
# State components are allowed to be reused between Blocks
|
||||
if not isinstance(self.blocks[id], components.State):
|
||||
raise DuplicateBlockError(
|
||||
"At least one block in this Blocks has already been rendered."
|
||||
|
@ -437,7 +437,7 @@ class Textbox(
|
||||
self.select: EventListenerMethod
|
||||
"""
|
||||
Event listener for when the user selects text in the Textbox.
|
||||
Uses event data gradio.SelectData to carry `value` referring to selected subtring, and `index` tuple referring to selected range endpoints.
|
||||
Uses event data gradio.SelectData to carry `value` referring to selected substring, and `index` tuple referring to selected range endpoints.
|
||||
See EventData documentation on how to use this event data.
|
||||
"""
|
||||
IOComponent.__init__(
|
||||
@ -1083,7 +1083,7 @@ class CheckboxGroup(
|
||||
Parameters:
|
||||
choices: list of options to select from.
|
||||
value: default selected list of options. If callable, the function will be called whenever the app loads to set the initial value of the component.
|
||||
type: Type of value to be returned by component. "value" returns the list of strings of the choices selected, "index" returns the list of indicies of the choices selected.
|
||||
type: Type of value to be returned by component. "value" returns the list of strings of the choices selected, "index" returns the list of indices of the choices selected.
|
||||
label: component name in interface.
|
||||
info: additional component description.
|
||||
every: If `value` is a callable, run the function 'every' number of seconds while the client connection is open. Has no effect otherwise. Queue must be enabled. The event can be accessed (e.g. to cancel it) via this component's .load_event attribute.
|
||||
@ -2857,7 +2857,7 @@ class Dataframe(Changeable, Selectable, IOComponent, JSONSerializable):
|
||||
visible: If False, component will be hidden.
|
||||
elem_id: An optional string that is assigned as the id of this component in the HTML DOM. Can be used for targeting CSS styles.
|
||||
elem_classes: An optional list of strings that are assigned as the classes of this component in the HTML DOM. Can be used for targeting CSS styles.
|
||||
wrap: if True text in table cells will wrap when appropriate, if False the table will scroll horiztonally. Defaults to False.
|
||||
wrap: if True text in table cells will wrap when appropriate, if False the table will scroll horizontally. Defaults to False.
|
||||
"""
|
||||
|
||||
self.wrap = wrap
|
||||
@ -3243,7 +3243,7 @@ class State(IOComponent, SimpleSerializable):
|
||||
):
|
||||
"""
|
||||
Parameters:
|
||||
value: the initial value (of abitrary type) of the state. The provided argument is deepcopied. If a callable is provided, the function will be called whenever the app loads to set the initial value of the state.
|
||||
value: the initial value (of arbitrary type) of the state. The provided argument is deepcopied. If a callable is provided, the function will be called whenever the app loads to set the initial value of the state.
|
||||
"""
|
||||
self.stateful = True
|
||||
IOComponent.__init__(self, value=deepcopy(value), **kwargs)
|
||||
|
@ -142,7 +142,7 @@ class CheckboxGroup(components.CheckboxGroup):
|
||||
Parameters:
|
||||
choices (List[str]): list of options to select from.
|
||||
default (List[str]): default selected list of options.
|
||||
type (str): Type of value to be returned by component. "value" returns the list of strings of the choices selected, "index" returns the list of indicies of the choices selected.
|
||||
type (str): Type of value to be returned by component. "value" returns the list of strings of the choices selected, "index" returns the list of indices of the choices selected.
|
||||
label (str): component name in interface.
|
||||
optional (bool): this parameter is ignored.
|
||||
"""
|
||||
|
@ -245,7 +245,7 @@ async def run_interpret(interface: Interface, raw_input: list):
|
||||
scores.append(None)
|
||||
alternative_outputs.append([])
|
||||
else:
|
||||
raise ValueError(f"Unknown intepretation method: {interp}")
|
||||
raise ValueError(f"Unknown interpretation method: {interp}")
|
||||
return scores, alternative_outputs
|
||||
elif interface.interpretation: # custom interpretation function
|
||||
processed_input = [
|
||||
|
@ -165,7 +165,7 @@ demo.queue()
|
||||
demo.launch()
|
||||
```
|
||||
|
||||
You can control the number of requests processsed at a single time as such:
|
||||
You can control the number of requests processed at a single time as such:
|
||||
|
||||
```python
|
||||
demo.queue(concurrency_count=3)
|
||||
|
@ -40,7 +40,7 @@ You can either drag and drop a folder containing your Gradio model and all relat
|
||||
|
||||
## Embedding Hosted Spaces
|
||||
|
||||
Once you have hosted your app on Hugging Face Spaces (or on your own server), you may want to embed the demo on a different website, such as your blog or your portfolio. Embedding an interactive demo allows people to try out the machine learning model that you have built, without needing to download or install anything — right in their browser! The best part is that you can embed interative demos even in static websites, such as GitHub pages.
|
||||
Once you have hosted your app on Hugging Face Spaces (or on your own server), you may want to embed the demo on a different website, such as your blog or your portfolio. Embedding an interactive demo allows people to try out the machine learning model that you have built, without needing to download or install anything — right in their browser! The best part is that you can embed interactive demos even in static websites, such as GitHub pages.
|
||||
|
||||
There are two ways to embed your Gradio demos. You can find quick links to both options directly on the Hugging Face Space page, in the "Embed this Space" dropdown option:
|
||||
|
||||
@ -87,7 +87,7 @@ You can also customize the appearance and behavior of your web component with at
|
||||
* `src`: as we've seen, the `src` attributes links to the URL of the hosted Gradio demo that you would like to embed
|
||||
* `space`: an optional shorthand if your Gradio demo is hosted on Hugging Face Space. Accepts a `username/space_name` instead of a full URL. Example: `gradio/Echocardiogram-Segmentation`. If this attribute attribute is provided, then `src` does not need to be provided.
|
||||
* `control_page_title`: a boolean designating whether the html title of the page should be set to the title of the Gradio app (by default `"false"`)
|
||||
* `initial_height`: the intial height of the web component while it is loading the Gradio app, (by default `"300px"`). Note that the final height is set based on the size of the Gradio app.
|
||||
* `initial_height`: the initial height of the web component while it is loading the Gradio app, (by default `"300px"`). Note that the final height is set based on the size of the Gradio app.
|
||||
* `container`: whether to show the border frame and information about where the Space is hosted (by default `"true"`)
|
||||
* `info`: whether to show just the information about where the Space is hosted underneath the embedded app (by default `"true"`)
|
||||
* `autoscroll`: whether to autoscroll to the output when prediction has finished (by default `"false"`)
|
||||
|
@ -107,7 +107,7 @@ experiment.add_tag("image-classifier")
|
||||
io.integrate(comet_ml=experiment)
|
||||
```
|
||||
|
||||
The last line in this snippet will log the URL of the Gradio Appication to your Comet Experiment. You can find the URL in the Text Tab of your Experiment.
|
||||
The last line in this snippet will log the URL of the Gradio Application to your Comet Experiment. You can find the URL in the Text Tab of your Experiment.
|
||||
|
||||
<video width="560" height="315" controls>
|
||||
<source src="https://user-images.githubusercontent.com/7529846/214328034-09369d4d-8b94-4c4a-aa3c-25e3ed8394c4.mp4"></source>
|
||||
|
@ -26,7 +26,7 @@ The [ONNX Model Zoo](https://github.com/onnx/models) is a collection of pre-trai
|
||||
|
||||
### Gradio
|
||||
|
||||
Gradio lets users demo their machine learning models as a web app all in python code. Gradio wraps a python function into a user inferface and the demos can be launched inside jupyter notebooks, colab notebooks, as well as embedded in your own website and hosted on Hugging Face Spaces for free.
|
||||
Gradio lets users demo their machine learning models as a web app all in python code. Gradio wraps a python function into a user interface and the demos can be launched inside jupyter notebooks, colab notebooks, as well as embedded in your own website and hosted on Hugging Face Spaces for free.
|
||||
|
||||
Get started [here](https://gradio.app/getting_started)
|
||||
|
||||
@ -52,7 +52,7 @@ EfficientNet-Lite 4 is the largest variant and most accurate of the set of Effic
|
||||
|
||||
Here we walk through setting up a example demo for EfficientNet-Lite4 using Gradio
|
||||
|
||||
First we import our dependencies and download and load the efficientnet-lite4 model from the onnx model zoo. Then load the labels from the labels_map.txt file. We then setup our preprocessing functions, load the model for inference, and setup the inference function. Finally, the inference function is wrapped into a gradio inferface for a user to interact with. See the full code below.
|
||||
First we import our dependencies and download and load the efficientnet-lite4 model from the onnx model zoo. Then load the labels from the labels_map.txt file. We then setup our preprocessing functions, load the model for inference, and setup the inference function. Finally, the inference function is wrapped into a gradio interface for a user to interact with. See the full code below.
|
||||
|
||||
|
||||
```python
|
||||
|
@ -27,7 +27,7 @@ Weights and Biases (W&B) allows data scientists and machine learning scientists
|
||||
|
||||
### Gradio
|
||||
|
||||
Gradio lets users demo their machine learning models as a web app, all in a few lines of Python. Gradio wraps any Python function (such as a machine learning model's inference function) into a user inferface and the demos can be launched inside jupyter notebooks, colab notebooks, as well as embedded in your own website and hosted on Hugging Face Spaces for free.
|
||||
Gradio lets users demo their machine learning models as a web app, all in a few lines of Python. Gradio wraps any Python function (such as a machine learning model's inference function) into a user interface and the demos can be launched inside jupyter notebooks, colab notebooks, as well as embedded in your own website and hosted on Hugging Face Spaces for free.
|
||||
|
||||
Get started [here](https://gradio.app/getting_started)
|
||||
|
||||
@ -74,7 +74,7 @@ Let's get started!
|
||||
|
||||
|
||||
samples = []
|
||||
column_names = ["Referece (y)", "Style Code(w)", "Real Face Image(x)"]
|
||||
column_names = ["Reference (y)", "Style Code(w)", "Real Face Image(x)"]
|
||||
|
||||
wandb.init(project="JoJoGAN")
|
||||
config = wandb.config
|
||||
|
@ -88,7 +88,7 @@ with gr.Blocks() as demo:
|
||||
btn.click(filter_map, [min_price, max_price, boroughs], map)
|
||||
```
|
||||
|
||||
We layout these components using the `gr.Column` and `gr.Row` and wel also add event triggers for when the demo first loads and when our "Update Filter" button is clicked in order to trigger the map to update with our new filters.
|
||||
We layout these components using the `gr.Column` and `gr.Row` and we'll also add event triggers for when the demo first loads and when our "Update Filter" button is clicked in order to trigger the map to update with our new filters.
|
||||
|
||||
This is what the full demo code looks like:
|
||||
|
||||
|
@ -22,7 +22,7 @@ client.predict("audio_sample.wav")
|
||||
|
||||
The Gradio client works with any hosted Gradio app, whether it be an image generator, a text summarizer, a stateful chatbot, a tax calculator, or anything else! The Gradio Client is mostly used with apps hosted on [Hugging Face Spaces](https://hf.space), but your app can be hosted anywhere, such as your own server.
|
||||
|
||||
**Prequisites**: To use the Gradio client, you do *not* need to know the `gradio` library in great detail. However, it is helpful to have general familiarity with Gradio's concepts of input and output components.
|
||||
**Prerequisites**: To use the Gradio client, you do *not* need to know the `gradio` library in great detail. However, it is helpful to have general familiarity with Gradio's concepts of input and output components.
|
||||
|
||||
## Installation
|
||||
|
||||
@ -148,7 +148,7 @@ client.predict("https://audio-samples.github.io/samples/mp3/blizzard_uncondition
|
||||
```
|
||||
|
||||
|
||||
## Running jobs asyncronously
|
||||
## Running jobs asynchronously
|
||||
|
||||
Oe should note that `.predict()` is a *blocking* operation as it waits for the operation to complete before returning the prediction.
|
||||
|
||||
|
@ -5,7 +5,7 @@ Tags: CLIENT, API, WEB APP
|
||||
In this blog post, we will demonstrate how to use the `gradio_client` [Python library](getting-started-with-the-python-client/), which enables developers to make requests to a Gradio app programmatically, by creating an example FastAPI web app. The web app we will be building is called "Acapellify," and it will allow users to upload video files as input and return a version of that video without instrumental music. It will also display a gallery of generated videos.
|
||||
|
||||
|
||||
**Prequisites**
|
||||
**Prerequisites**
|
||||
|
||||
Before we begin, make sure you are running Python 3.9 or later, and have the following libraries installed:
|
||||
|
||||
|
@ -73,7 +73,7 @@ class GradioTool(BaseTool):
|
||||
```
|
||||
The requirements are:
|
||||
1. The name for your tool
|
||||
2. The description for your tool. This is crucial! Agents decide which tool to use based on their description. Be precise and be sure to inclue example of what the input and the output of the tool should look like.
|
||||
2. The description for your tool. This is crucial! Agents decide which tool to use based on their description. Be precise and be sure to include example of what the input and the output of the tool should look like.
|
||||
3. The url or space id, e.g. `freddyaboulton/calculator`, of the Gradio application. Based on this value, `gradio_tool` will create a [gradio client](https://github.com/gradio-app/gradio/blob/main/client/python/README.md) instance to query the upstream application via API. Be sure to click the link and learn more about the gradio client library if you are not familiar with it.
|
||||
4. create_job - Given a string, this method should parse that string and return a job from the client. Most times, this is as simple as passing the string to the `submit` function of the client. More info on creating jobs [here](https://github.com/gradio-app/gradio/blob/main/client/python/README.md#making-a-prediction)
|
||||
5. postprocess - Given the result of the job, convert it to a string the LLM can display to the user.
|
||||
@ -125,7 +125,7 @@ class StableDiffusionTool(GradioTool):
|
||||
Some notes on this implementation:
|
||||
1. All instances of `GradioTool` have an attribute called `client` that is a pointed to the underlying [gradio client](https://github.com/gradio-app/gradio/tree/main/client/python#gradio_client-use-a-gradio-app-as-an-api----in-3-lines-of-python). That is what you should use
|
||||
in the `create_job` method.
|
||||
2. `create_job` just passes the query string to the `submit` function of the client with some other parameters hardcoded, i.e. the negative prompt sting and the guidance scale. We could modify our tool to also accept these values from the input string in a subsequent version.
|
||||
2. `create_job` just passes the query string to the `submit` function of the client with some other parameters hardcoded, i.e. the negative prompt string and the guidance scale. We could modify our tool to also accept these values from the input string in a subsequent version.
|
||||
3. The `postprocess` method simply returns the first image from the gallery of images created by the stable diffusion space. We use the `os` module to get the full path of the image.
|
||||
|
||||
## Conclusion
|
||||
|
@ -43,7 +43,7 @@ You can use the Theme Builder running on Spaces above, though it runs much faste
|
||||
|
||||
As you edit the values in the Theme Builder, the app will preview updates in real time. You can download the code to generate the theme you've created so you can use it in any Gradio app.
|
||||
|
||||
In the rest of the guide, we will cover building themes programatically.
|
||||
In the rest of the guide, we will cover building themes programmatically.
|
||||
|
||||
## Extending Themes via the Constructor
|
||||
|
||||
@ -349,7 +349,7 @@ upload_theme\
|
||||
|
||||
In order to upload a theme, you must have a HuggingFace account and pass your [Access Token](https://huggingface.co/docs/huggingface_hub/quick-start#login)
|
||||
as the `hf_token` argument. However, if you log in via the [HuggingFace command line](https://huggingface.co/docs/huggingface_hub/quick-start#login) (which comes installed with `gradio`),
|
||||
you can ommit the `hf_token` argument.
|
||||
you can omit the `hf_token` argument.
|
||||
|
||||
The `version` argument lets you specify a valid [semantic version](https://www.geeksforgeeks.org/introduction-semantic-versioning/) string for your theme.
|
||||
That way your users are able to specify which version of your theme they want to use in their apps. This also lets you publish updates to your theme without worrying
|
||||
|
@ -138,7 +138,7 @@ class TestOutputPreprocessing:
|
||||
]
|
||||
|
||||
def test_float_conversion_dtype(self):
|
||||
"""Test any convertion from a float dtype to an other."""
|
||||
"""Test any conversion from a float dtype to an other."""
|
||||
|
||||
x = np.array([-1, 1])
|
||||
# Test all combinations of dtypes conversions
|
||||
|
Loading…
Reference in New Issue
Block a user