Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Gallery preview fix and optionally skip download of urls in postprcess (
#6288) * Add code * add changeset * Use urls from our s3 bucket * Add notebook code --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
- Loading branch information
1 parent
e8216be
commit 9227872
Showing
12 changed files
with
98 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@gradio/gallery": patch | ||
"gradio": patch | ||
--- | ||
|
||
fix:Gallery preview fix and optionally skip download of urls in postprcess |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: gallery_component_events"]}, {"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", "with gr.Blocks() as demo:\n", " cheetahs = [\n", " \"https://gradio-builds.s3.amazonaws.com/assets/cheetah-003.jpg\",\n", " \"https://gradio-builds.s3.amazonaws.com/assets/lite-logo.png\",\n", " \"https://gradio-builds.s3.amazonaws.com/assets/TheCheethcat.jpg\",\n", " ]\n", " with gr.Row():\n", " with gr.Column():\n", " btn = gr.Button()\n", " with gr.Column():\n", " gallery = gr.Gallery()\n", " with gr.Column():\n", " select_output = gr.Textbox(label=\"Select Data\")\n", " btn.click(lambda: cheetahs, None, [gallery])\n", "\n", " def select(select_data: gr.SelectData):\n", " return select_data.value['image']['url']\n", "\n", " gallery.select(select, None, select_output)\n", "\n", "\n", "if __name__ == \"__main__\":\n", " demo.launch()"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import gradio as gr | ||
|
||
with gr.Blocks() as demo: | ||
cheetahs = [ | ||
"https://gradio-builds.s3.amazonaws.com/assets/cheetah-003.jpg", | ||
"https://gradio-builds.s3.amazonaws.com/assets/lite-logo.png", | ||
"https://gradio-builds.s3.amazonaws.com/assets/TheCheethcat.jpg", | ||
] | ||
with gr.Row(): | ||
with gr.Column(): | ||
btn = gr.Button() | ||
with gr.Column(): | ||
gallery = gr.Gallery() | ||
with gr.Column(): | ||
select_output = gr.Textbox(label="Select Data") | ||
btn.click(lambda: cheetahs, None, [gallery]) | ||
|
||
def select(select_data: gr.SelectData): | ||
return select_data.value['image']['url'] | ||
|
||
gallery.select(select, None, select_output) | ||
|
||
|
||
if __name__ == "__main__": | ||
demo.launch() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { test, expect } from "@gradio/tootils"; | ||
|
||
test("Gallery preview mode displays all images correctly.", async ({ | ||
page | ||
}) => { | ||
await page.getByRole("button", { name: "Run" }).click(); | ||
await page.getByLabel("Thumbnail 2 of 3").click(); | ||
|
||
expect(await page.getByTestId("detailed-image").getAttribute("src")).toEqual( | ||
"https://gradio-builds.s3.amazonaws.com/assets/lite-logo.png" | ||
); | ||
|
||
expect(await page.getByTestId("thumbnail 1").getAttribute("src")).toEqual( | ||
"https://gradio-builds.s3.amazonaws.com/assets/cheetah-003.jpg" | ||
); | ||
}); | ||
|
||
test("Gallery select event returns the right value", async ({ page }) => { | ||
await page.getByRole("button", { name: "Run" }).click(); | ||
await page.getByLabel("Thumbnail 2 of 3").click(); | ||
expect(await page.getByLabel("Select Data")).toHaveValue( | ||
"https://gradio-builds.s3.amazonaws.com/assets/lite-logo.png" | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters