Spaces:
Running
Running
Upload with huggingface_hub
Browse files- README.md +6 -7
- images/cheetah1.jpg +0 -0
- images/lion.jpg +0 -0
- images/logo.png +0 -0
- run.ipynb +1 -0
- run.py +29 -0
README.md
CHANGED
@@ -1,12 +1,11 @@
|
|
|
|
1 |
---
|
2 |
-
title:
|
3 |
-
emoji:
|
4 |
-
colorFrom:
|
5 |
-
colorTo:
|
6 |
sdk: gradio
|
7 |
sdk_version: 3.17.0
|
8 |
-
app_file:
|
9 |
pinned: false
|
10 |
---
|
11 |
-
|
12 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
1 |
+
|
2 |
---
|
3 |
+
title: examples_component
|
4 |
+
emoji: 🔥
|
5 |
+
colorFrom: indigo
|
6 |
+
colorTo: indigo
|
7 |
sdk: gradio
|
8 |
sdk_version: 3.17.0
|
9 |
+
app_file: run.py
|
10 |
pinned: false
|
11 |
---
|
|
|
|
images/cheetah1.jpg
ADDED
images/lion.jpg
ADDED
images/logo.png
ADDED
run.ipynb
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"cells": [{"cell_type": "markdown", "id": 302934307671667531413257853548643485645, "metadata": {}, "source": ["# Gradio Demo: examples_component"]}, {"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", "os.mkdir('images')\n", "!wget -q -O images/cheetah1.jpg https://github.com/gradio-app/gradio/raw/main/demo/examples_component/images/cheetah1.jpg\n", "!wget -q -O images/lion.jpg https://github.com/gradio-app/gradio/raw/main/demo/examples_component/images/lion.jpg\n", "!wget -q -O images/logo.png https://github.com/gradio-app/gradio/raw/main/demo/examples_component/images/logo.png"]}, {"cell_type": "code", "execution_count": null, "id": 44380577570523278879349135829904343037, "metadata": {}, "outputs": [], "source": ["import gradio as gr\n", "import os\n", "\n", "def flip(i):\n", " return i.rotate(180)\n", "\n", "css = \"footer {display: none !important;} .gradio-container {min-height: 0px !important;}\"\n", "\n", "with gr.Blocks(css=css) as demo:\n", " with gr.Row():\n", " with gr.Column():\n", " img_i = gr.Image(label=\"Input Image\", type=\"pil\")\n", " with gr.Column():\n", " img_o = gr.Image(label=\"Output Image\")\n", " with gr.Row():\n", " btn = gr.Button(value=\"Flip Image\")\n", " btn.click(flip, inputs=[img_i], outputs=[img_o])\n", "\n", " gr.Examples(\n", " [ \n", " os.path.join(os.path.abspath(''), \"images/cheetah1.jpg\"),\n", " os.path.join(os.path.abspath(''), \"images/lion.jpg\"),\n", " ],\n", " img_i,\n", " img_o,\n", " flip\n", " )\n", " \n", "demo.launch()"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
|
run.py
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import os
|
3 |
+
|
4 |
+
def flip(i):
|
5 |
+
return i.rotate(180)
|
6 |
+
|
7 |
+
css = "footer {display: none !important;} .gradio-container {min-height: 0px !important;}"
|
8 |
+
|
9 |
+
with gr.Blocks(css=css) as demo:
|
10 |
+
with gr.Row():
|
11 |
+
with gr.Column():
|
12 |
+
img_i = gr.Image(label="Input Image", type="pil")
|
13 |
+
with gr.Column():
|
14 |
+
img_o = gr.Image(label="Output Image")
|
15 |
+
with gr.Row():
|
16 |
+
btn = gr.Button(value="Flip Image")
|
17 |
+
btn.click(flip, inputs=[img_i], outputs=[img_o])
|
18 |
+
|
19 |
+
gr.Examples(
|
20 |
+
[
|
21 |
+
os.path.join(os.path.dirname(__file__), "images/cheetah1.jpg"),
|
22 |
+
os.path.join(os.path.dirname(__file__), "images/lion.jpg"),
|
23 |
+
],
|
24 |
+
img_i,
|
25 |
+
img_o,
|
26 |
+
flip
|
27 |
+
)
|
28 |
+
|
29 |
+
demo.launch()
|