gradio-pr-bot commited on
Commit
2f53921
·
verified ·
1 Parent(s): fc0c688

Upload folder using huggingface_hub

Browse files
Files changed (3) hide show
  1. requirements.txt +2 -2
  2. run.py +5 -8
  3. workflow.json +236 -46
requirements.txt CHANGED
@@ -1,2 +1,2 @@
1
- gradio-client @ git+https://github.com/gradio-app/gradio@265680d889ce9e88b402bd3d644fb28ba8dfaefc#subdirectory=client/python
2
- https://huggingface.co/buckets/gradio/pypi-previews/resolve/265680d889ce9e88b402bd3d644fb28ba8dfaefc/gradio-6.26.0-py3-none-any.whl
 
1
+ gradio-client @ git+https://github.com/gradio-app/gradio@935fee23567274ea9bbc10ddcaa20502d8f718ac#subdirectory=client/python
2
+ https://huggingface.co/buckets/gradio/pypi-previews/resolve/935fee23567274ea9bbc10ddcaa20502d8f718ac/gradio-6.26.0-py3-none-any.whl
run.py CHANGED
@@ -1,19 +1,16 @@
1
  import gradio as gr
2
 
3
 
4
- def shout(text: str) -> str:
5
- return (text or "").upper()
6
-
7
-
8
  def reverse(text: str) -> str:
9
  return (text or "")[::-1]
10
 
11
 
12
- # Two outputs ("Loud" and "Reversed") fed by a shared "Text" input. Because they
 
13
  # form a single connected subgraph, they're exposed as ONE API endpoint that
14
- # returns both outputs as a tuple — see the "View API" panel in the app, or
15
- # connect with the gradio_client.
16
- demo = gr.Workflow(graph="workflow.json", bind={"shout": shout, "reverse": reverse})
17
 
18
  if __name__ == "__main__":
19
  demo.launch()
 
1
  import gradio as gr
2
 
3
 
 
 
 
 
4
  def reverse(text: str) -> str:
5
  return (text or "")[::-1]
6
 
7
 
8
+ # Three outputs ("Reversed", "Generated" and "Image") fed by a shared "Text"
9
+ # input: a local function, a HF Inference model and a HF Space. Because they
10
  # form a single connected subgraph, they're exposed as ONE API endpoint that
11
+ # returns all three outputs as a tuple — see the "View API" panel in the app,
12
+ # or connect with the gradio_client.
13
+ demo = gr.Workflow(graph="workflow.json", bind={"reverse": reverse})
14
 
15
  if __name__ == "__main__":
16
  demo.launch()
workflow.json CHANGED
@@ -1,48 +1,238 @@
1
  {
2
- "schema_version": "2",
3
- "name": "Text Tools",
4
- "runtime": { "default": "client" },
5
- "references": [
6
- {
7
- "id": "ref_text", "label": "Text", "role": "reference", "asset_type": "text",
8
- "inputs": [{ "id": "in", "label": "Text", "type": "text" }],
9
- "outputs": [{ "id": "out", "label": "Text", "type": "text" }],
10
- "x": 80, "y": 120, "width": 220, "height": 120, "data": {}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  }
12
- ],
13
- "operators": [
14
- {
15
- "id": "op_loud", "label": "shout", "role": "operator", "kind": "fn", "fn": "shout",
16
- "inputs": [{ "id": "in_text", "label": "text", "type": "text", "required": true }],
17
- "outputs": [{ "id": "out_0", "label": "output", "type": "text", "output_index": 0 }],
18
- "x": 380, "y": 40, "width": 220, "height": 120, "data": {}
19
- },
20
- {
21
- "id": "op_rev", "label": "reverse", "role": "operator", "kind": "fn", "fn": "reverse",
22
- "inputs": [{ "id": "in_text", "label": "text", "type": "text", "required": true }],
23
- "outputs": [{ "id": "out_0", "label": "output", "type": "text", "output_index": 0 }],
24
- "x": 380, "y": 240, "width": 220, "height": 120, "data": {}
25
- }
26
- ],
27
- "subjects": [
28
- {
29
- "id": "sub_loud", "label": "Loud", "role": "subject", "asset_type": "text",
30
- "inputs": [{ "id": "in", "label": "Text", "type": "text" }],
31
- "outputs": [{ "id": "out", "label": "Text", "type": "text" }],
32
- "x": 700, "y": 40, "width": 220, "height": 107, "data": {}
33
- },
34
- {
35
- "id": "sub_rev", "label": "Reversed", "role": "subject", "asset_type": "text",
36
- "inputs": [{ "id": "in", "label": "Text", "type": "text" }],
37
- "outputs": [{ "id": "out", "label": "Text", "type": "text" }],
38
- "x": 700, "y": 240, "width": 220, "height": 107, "data": {}
39
- }
40
- ],
41
- "edges": [
42
- { "id": "e1", "from_node_id": "ref_text", "from_port_id": "out", "to_node_id": "op_loud", "to_port_id": "in_text", "type": "text" },
43
- { "id": "e2", "from_node_id": "ref_text", "from_port_id": "out", "to_node_id": "op_rev", "to_port_id": "in_text", "type": "text" },
44
- { "id": "e3", "from_node_id": "op_loud", "from_port_id": "out_0", "to_node_id": "sub_loud", "to_port_id": "in", "type": "text" },
45
- { "id": "e4", "from_node_id": "op_rev", "from_port_id": "out_0", "to_node_id": "sub_rev", "to_port_id": "in", "type": "text" }
46
- ],
47
- "view": { "default": "canvas" }
48
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  {
2
+ "schema_version": "2",
3
+ "name": "Text Tools",
4
+ "runtime": {
5
+ "default": "client"
6
+ },
7
+ "references": [
8
+ {
9
+ "id": "ref_text",
10
+ "label": "Text",
11
+ "role": "reference",
12
+ "asset_type": "text",
13
+ "inputs": [
14
+ {
15
+ "id": "in",
16
+ "label": "Text",
17
+ "type": "text"
18
+ }
19
+ ],
20
+ "outputs": [
21
+ {
22
+ "id": "out",
23
+ "label": "Text",
24
+ "type": "text"
25
+ }
26
+ ],
27
+ "width": 220,
28
+ "data": {
29
+ "out": "A red fox in a misty forest"
30
  }
31
+ }
32
+ ],
33
+ "operators": [
34
+ {
35
+ "id": "op_rev",
36
+ "label": "reverse",
37
+ "role": "operator",
38
+ "kind": "fn",
39
+ "fn": "reverse",
40
+ "inputs": [
41
+ {
42
+ "id": "in_text",
43
+ "label": "text",
44
+ "type": "text",
45
+ "required": true
46
+ }
47
+ ],
48
+ "outputs": [
49
+ {
50
+ "id": "out_0",
51
+ "label": "output",
52
+ "type": "text",
53
+ "output_index": 0
54
+ }
55
+ ],
56
+ "width": 220,
57
+ "data": {}
58
+ },
59
+ {
60
+ "id": "op_gen",
61
+ "label": "Llama 3.1 8B",
62
+ "role": "operator",
63
+ "kind": "model",
64
+ "model_id": "meta-llama/Llama-3.1-8B-Instruct",
65
+ "pipeline_tag": "text-generation",
66
+ "endpoint": "chat_completion",
67
+ "inputs": [
68
+ {
69
+ "id": "image",
70
+ "label": "Image",
71
+ "type": "image"
72
+ },
73
+ {
74
+ "id": "text",
75
+ "label": "Prompt",
76
+ "type": "text"
77
+ }
78
+ ],
79
+ "outputs": [
80
+ {
81
+ "id": "out_0",
82
+ "label": "Text",
83
+ "type": "text",
84
+ "output_index": 0
85
+ }
86
+ ],
87
+ "width": 220,
88
+ "data": {}
89
+ },
90
+ {
91
+ "id": "op_space",
92
+ "label": "FLUX.1 merged",
93
+ "role": "operator",
94
+ "kind": "space",
95
+ "space_id": "multimodalart/FLUX.1-merged",
96
+ "runtime": "client",
97
+ "inputs": [
98
+ {
99
+ "id": "in_0",
100
+ "label": "Prompt",
101
+ "type": "text",
102
+ "required": true
103
+ }
104
+ ],
105
+ "outputs": [
106
+ {
107
+ "id": "out_0",
108
+ "label": "Result",
109
+ "type": "image",
110
+ "output_index": 0
111
+ }
112
+ ],
113
+ "width": 220,
114
+ "data": {}
115
+ }
116
+ ],
117
+ "subjects": [
118
+ {
119
+ "id": "sub_rev",
120
+ "label": "Reversed",
121
+ "role": "subject",
122
+ "asset_type": "text",
123
+ "inputs": [
124
+ {
125
+ "id": "in",
126
+ "label": "Text",
127
+ "type": "text"
128
+ }
129
+ ],
130
+ "outputs": [
131
+ {
132
+ "id": "out",
133
+ "label": "Text",
134
+ "type": "text"
135
+ }
136
+ ],
137
+ "width": 220,
138
+ "data": {}
139
+ },
140
+ {
141
+ "id": "sub_gen",
142
+ "label": "Generated",
143
+ "role": "subject",
144
+ "asset_type": "text",
145
+ "inputs": [
146
+ {
147
+ "id": "in",
148
+ "label": "Text",
149
+ "type": "text"
150
+ }
151
+ ],
152
+ "outputs": [
153
+ {
154
+ "id": "out",
155
+ "label": "Text",
156
+ "type": "text"
157
+ }
158
+ ],
159
+ "width": 220,
160
+ "data": {}
161
+ },
162
+ {
163
+ "id": "sub_image",
164
+ "label": "Image",
165
+ "role": "subject",
166
+ "asset_type": "image",
167
+ "inputs": [
168
+ {
169
+ "id": "in",
170
+ "label": "Image",
171
+ "type": "image"
172
+ }
173
+ ],
174
+ "outputs": [
175
+ {
176
+ "id": "out",
177
+ "label": "Image",
178
+ "type": "image"
179
+ }
180
+ ],
181
+ "width": 220,
182
+ "data": {}
183
+ }
184
+ ],
185
+ "edges": [
186
+ {
187
+ "id": "e2",
188
+ "from_node_id": "ref_text",
189
+ "from_port_id": "out",
190
+ "to_node_id": "op_rev",
191
+ "to_port_id": "in_text",
192
+ "type": "text"
193
+ },
194
+ {
195
+ "id": "e3",
196
+ "from_node_id": "ref_text",
197
+ "from_port_id": "out",
198
+ "to_node_id": "op_gen",
199
+ "to_port_id": "text",
200
+ "type": "text"
201
+ },
202
+ {
203
+ "id": "e4",
204
+ "from_node_id": "ref_text",
205
+ "from_port_id": "out",
206
+ "to_node_id": "op_space",
207
+ "to_port_id": "in_0",
208
+ "type": "text"
209
+ },
210
+ {
211
+ "id": "e6",
212
+ "from_node_id": "op_rev",
213
+ "from_port_id": "out_0",
214
+ "to_node_id": "sub_rev",
215
+ "to_port_id": "in",
216
+ "type": "text"
217
+ },
218
+ {
219
+ "id": "e7",
220
+ "from_node_id": "op_gen",
221
+ "from_port_id": "out_0",
222
+ "to_node_id": "sub_gen",
223
+ "to_port_id": "in",
224
+ "type": "text"
225
+ },
226
+ {
227
+ "id": "e8",
228
+ "from_node_id": "op_space",
229
+ "from_port_id": "out_0",
230
+ "to_node_id": "sub_image",
231
+ "to_port_id": "in",
232
+ "type": "image"
233
+ }
234
+ ],
235
+ "view": {
236
+ "default": "canvas"
237
+ }
238
+ }