Spaces:
Running
Running
Upload with huggingface_hub
Browse files
README.md
CHANGED
@@ -1,12 +1,12 @@
|
|
|
|
1 |
---
|
2 |
-
title:
|
3 |
-
emoji:
|
4 |
-
colorFrom:
|
5 |
-
colorTo:
|
6 |
sdk: gradio
|
7 |
sdk_version: 3.3.1
|
|
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
---
|
11 |
-
|
12 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
1 |
+
|
2 |
---
|
3 |
+
title: blocks_inputs
|
4 |
+
emoji: 🔥
|
5 |
+
colorFrom: indigo
|
6 |
+
colorTo: indigo
|
7 |
sdk: gradio
|
8 |
sdk_version: 3.3.1
|
9 |
+
|
10 |
app_file: app.py
|
11 |
pinned: false
|
12 |
---
|
|
|
|
app.py
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import os
|
3 |
+
|
4 |
+
def combine(a, b):
|
5 |
+
return a + " " + b
|
6 |
+
|
7 |
+
def mirror(x):
|
8 |
+
return x
|
9 |
+
|
10 |
+
with gr.Blocks() as demo:
|
11 |
+
|
12 |
+
txt = gr.Textbox(label="Input", lines=2)
|
13 |
+
txt_2 = gr.Textbox(label="Input 2")
|
14 |
+
txt_3 = gr.Textbox(value="", label="Output")
|
15 |
+
btn = gr.Button(value="Submit")
|
16 |
+
btn.click(combine, inputs=[txt, txt_2], outputs=[txt_3])
|
17 |
+
|
18 |
+
with gr.Row():
|
19 |
+
im = gr.Image()
|
20 |
+
im_2 = gr.Image()
|
21 |
+
|
22 |
+
btn = gr.Button(value="Mirror Image")
|
23 |
+
btn.click(mirror, inputs=[im], outputs=[im_2])
|
24 |
+
|
25 |
+
gr.Markdown("## Text Examples")
|
26 |
+
gr.Examples([["hi", "Adam"], ["hello", "Eve"]], [txt, txt_2], txt_3, combine, cache_examples=True)
|
27 |
+
gr.Markdown("## Image Examples")
|
28 |
+
gr.Examples(
|
29 |
+
examples=[os.path.join(os.path.dirname(__file__), "lion.jpg")],
|
30 |
+
inputs=im,
|
31 |
+
outputs=im_2,
|
32 |
+
fn=mirror,
|
33 |
+
cache_examples=True)
|
34 |
+
|
35 |
+
if __name__ == "__main__":
|
36 |
+
demo.launch()
|
config.json
ADDED
@@ -0,0 +1,306 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"version": "3.1.4",
|
3 |
+
"mode": "blocks",
|
4 |
+
"dev_mode": true,
|
5 |
+
"components": [
|
6 |
+
{
|
7 |
+
"id": 1,
|
8 |
+
"type": "textbox",
|
9 |
+
"props": {
|
10 |
+
"lines": 2,
|
11 |
+
"max_lines": 20,
|
12 |
+
"value": "",
|
13 |
+
"label": "Input",
|
14 |
+
"show_label": true,
|
15 |
+
"name": "textbox",
|
16 |
+
"visible": true,
|
17 |
+
"style": {}
|
18 |
+
}
|
19 |
+
},
|
20 |
+
{
|
21 |
+
"id": 2,
|
22 |
+
"type": "textbox",
|
23 |
+
"props": {
|
24 |
+
"lines": 1,
|
25 |
+
"max_lines": 20,
|
26 |
+
"value": "",
|
27 |
+
"label": "Input 2",
|
28 |
+
"show_label": true,
|
29 |
+
"name": "textbox",
|
30 |
+
"visible": true,
|
31 |
+
"style": {}
|
32 |
+
}
|
33 |
+
},
|
34 |
+
{
|
35 |
+
"id": 3,
|
36 |
+
"type": "textbox",
|
37 |
+
"props": {
|
38 |
+
"lines": 1,
|
39 |
+
"max_lines": 20,
|
40 |
+
"value": "",
|
41 |
+
"label": "Output",
|
42 |
+
"show_label": true,
|
43 |
+
"name": "textbox",
|
44 |
+
"visible": true,
|
45 |
+
"style": {}
|
46 |
+
}
|
47 |
+
},
|
48 |
+
{
|
49 |
+
"id": 4,
|
50 |
+
"type": "button",
|
51 |
+
"props": {
|
52 |
+
"value": "Submit",
|
53 |
+
"variant": "secondary",
|
54 |
+
"name": "button",
|
55 |
+
"visible": true,
|
56 |
+
"style": {}
|
57 |
+
}
|
58 |
+
},
|
59 |
+
{
|
60 |
+
"id": 5,
|
61 |
+
"type": "row",
|
62 |
+
"props": {
|
63 |
+
"type": "row",
|
64 |
+
"visible": true,
|
65 |
+
"style": {}
|
66 |
+
}
|
67 |
+
},
|
68 |
+
{
|
69 |
+
"id": 6,
|
70 |
+
"type": "image",
|
71 |
+
"props": {
|
72 |
+
"image_mode": "RGB",
|
73 |
+
"source": "upload",
|
74 |
+
"tool": "editor",
|
75 |
+
"streaming": false,
|
76 |
+
"mirror_webcam": true,
|
77 |
+
"show_label": true,
|
78 |
+
"name": "image",
|
79 |
+
"visible": true,
|
80 |
+
"style": {}
|
81 |
+
}
|
82 |
+
},
|
83 |
+
{
|
84 |
+
"id": 7,
|
85 |
+
"type": "image",
|
86 |
+
"props": {
|
87 |
+
"image_mode": "RGB",
|
88 |
+
"source": "upload",
|
89 |
+
"tool": "editor",
|
90 |
+
"streaming": false,
|
91 |
+
"mirror_webcam": true,
|
92 |
+
"show_label": true,
|
93 |
+
"name": "image",
|
94 |
+
"visible": true,
|
95 |
+
"style": {}
|
96 |
+
}
|
97 |
+
},
|
98 |
+
{
|
99 |
+
"id": 8,
|
100 |
+
"type": "button",
|
101 |
+
"props": {
|
102 |
+
"value": "Mirror Image",
|
103 |
+
"variant": "secondary",
|
104 |
+
"name": "button",
|
105 |
+
"visible": true,
|
106 |
+
"style": {}
|
107 |
+
}
|
108 |
+
},
|
109 |
+
{
|
110 |
+
"id": 9,
|
111 |
+
"type": "markdown",
|
112 |
+
"props": {
|
113 |
+
"value": "<h2>Text Examples</h2>\n",
|
114 |
+
"name": "markdown",
|
115 |
+
"visible": true,
|
116 |
+
"style": {}
|
117 |
+
}
|
118 |
+
},
|
119 |
+
{
|
120 |
+
"id": 10,
|
121 |
+
"type": "dataset",
|
122 |
+
"props": {
|
123 |
+
"components": [
|
124 |
+
"textbox",
|
125 |
+
"textbox"
|
126 |
+
],
|
127 |
+
"headers": [
|
128 |
+
"Input",
|
129 |
+
"Input 2"
|
130 |
+
],
|
131 |
+
"samples": [
|
132 |
+
[
|
133 |
+
"hi",
|
134 |
+
"Adam"
|
135 |
+
],
|
136 |
+
[
|
137 |
+
"hello",
|
138 |
+
"Eve"
|
139 |
+
]
|
140 |
+
],
|
141 |
+
"type": "index",
|
142 |
+
"name": "dataset",
|
143 |
+
"visible": true,
|
144 |
+
"style": {}
|
145 |
+
}
|
146 |
+
},
|
147 |
+
{
|
148 |
+
"id": 11,
|
149 |
+
"type": "markdown",
|
150 |
+
"props": {
|
151 |
+
"value": "<h2>Image Examples</h2>\n",
|
152 |
+
"name": "markdown",
|
153 |
+
"visible": true,
|
154 |
+
"style": {}
|
155 |
+
}
|
156 |
+
},
|
157 |
+
{
|
158 |
+
"id": 12,
|
159 |
+
"type": "dataset",
|
160 |
+
"props": {
|
161 |
+
"components": [
|
162 |
+
"image"
|
163 |
+
],
|
164 |
+
"headers": [],
|
165 |
+
"samples": [
|
166 |
+
[
|
167 |
+
"/Users/dawoodkhan/Desktop/Developer/gradio/demo/blocks_inputs/lion.jpg"
|
168 |
+
]
|
169 |
+
],
|
170 |
+
"type": "index",
|
171 |
+
"name": "dataset",
|
172 |
+
"visible": true,
|
173 |
+
"style": {}
|
174 |
+
}
|
175 |
+
}
|
176 |
+
],
|
177 |
+
"theme": "default",
|
178 |
+
"css": null,
|
179 |
+
"title": "Gradio",
|
180 |
+
"enable_queue": false,
|
181 |
+
"layout": {
|
182 |
+
"id": 0,
|
183 |
+
"children": [
|
184 |
+
{
|
185 |
+
"id": 1
|
186 |
+
},
|
187 |
+
{
|
188 |
+
"id": 2
|
189 |
+
},
|
190 |
+
{
|
191 |
+
"id": 3
|
192 |
+
},
|
193 |
+
{
|
194 |
+
"id": 4
|
195 |
+
},
|
196 |
+
{
|
197 |
+
"id": 5,
|
198 |
+
"children": [
|
199 |
+
{
|
200 |
+
"id": 6
|
201 |
+
},
|
202 |
+
{
|
203 |
+
"id": 7
|
204 |
+
}
|
205 |
+
]
|
206 |
+
},
|
207 |
+
{
|
208 |
+
"id": 8
|
209 |
+
},
|
210 |
+
{
|
211 |
+
"id": 9
|
212 |
+
},
|
213 |
+
{
|
214 |
+
"id": 10
|
215 |
+
},
|
216 |
+
{
|
217 |
+
"id": 11
|
218 |
+
},
|
219 |
+
{
|
220 |
+
"id": 12
|
221 |
+
}
|
222 |
+
]
|
223 |
+
},
|
224 |
+
"dependencies": [
|
225 |
+
{
|
226 |
+
"targets": [
|
227 |
+
4
|
228 |
+
],
|
229 |
+
"trigger": "click",
|
230 |
+
"inputs": [
|
231 |
+
1,
|
232 |
+
2
|
233 |
+
],
|
234 |
+
"outputs": [
|
235 |
+
3
|
236 |
+
],
|
237 |
+
"backend_fn": true,
|
238 |
+
"js": null,
|
239 |
+
"status_tracker": null,
|
240 |
+
"queue": null,
|
241 |
+
"api_name": null,
|
242 |
+
"scroll_to_output": false,
|
243 |
+
"show_progress": true
|
244 |
+
},
|
245 |
+
{
|
246 |
+
"targets": [
|
247 |
+
8
|
248 |
+
],
|
249 |
+
"trigger": "click",
|
250 |
+
"inputs": [
|
251 |
+
6
|
252 |
+
],
|
253 |
+
"outputs": [
|
254 |
+
7
|
255 |
+
],
|
256 |
+
"backend_fn": true,
|
257 |
+
"js": null,
|
258 |
+
"status_tracker": null,
|
259 |
+
"queue": null,
|
260 |
+
"api_name": null,
|
261 |
+
"scroll_to_output": false,
|
262 |
+
"show_progress": true
|
263 |
+
},
|
264 |
+
{
|
265 |
+
"targets": [
|
266 |
+
10
|
267 |
+
],
|
268 |
+
"trigger": "click",
|
269 |
+
"inputs": [
|
270 |
+
10
|
271 |
+
],
|
272 |
+
"outputs": [
|
273 |
+
1,
|
274 |
+
2,
|
275 |
+
3
|
276 |
+
],
|
277 |
+
"backend_fn": true,
|
278 |
+
"js": null,
|
279 |
+
"status_tracker": null,
|
280 |
+
"queue": false,
|
281 |
+
"api_name": null,
|
282 |
+
"scroll_to_output": false,
|
283 |
+
"show_progress": true
|
284 |
+
},
|
285 |
+
{
|
286 |
+
"targets": [
|
287 |
+
12
|
288 |
+
],
|
289 |
+
"trigger": "click",
|
290 |
+
"inputs": [
|
291 |
+
12
|
292 |
+
],
|
293 |
+
"outputs": [
|
294 |
+
6,
|
295 |
+
7
|
296 |
+
],
|
297 |
+
"backend_fn": true,
|
298 |
+
"js": null,
|
299 |
+
"status_tracker": null,
|
300 |
+
"queue": false,
|
301 |
+
"api_name": null,
|
302 |
+
"scroll_to_output": false,
|
303 |
+
"show_progress": true
|
304 |
+
}
|
305 |
+
]
|
306 |
+
}
|
lion.jpg
ADDED