Renecto commited on
Commit
35f26fa
·
verified ·
1 Parent(s): ca86f0f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -4
app.py CHANGED
@@ -1,9 +1,29 @@
1
  import gradio as gr
2
  import time
 
 
3
 
4
- def greet(name):
5
- time.sleep(10)
6
- return "limit 5 " + name + "!!"
 
 
 
 
 
 
 
 
 
7
 
8
- demo = gr.Interface(fn=greet, inputs="text", outputs="text", concurrency_limit=5)
 
 
 
 
 
 
 
 
 
9
  demo.launch()
 
1
  import gradio as gr
2
  import time
3
+ from gradio_client import Client
4
+ import concurrent.futures
5
 
6
+ def grand_para(num):
7
+ client = Client("Renecto/parralel")
8
+ result = client.submit(
9
+ params_text=f"""aaa{num}
10
+ bbb{num}
11
+ ccc{num}
12
+ ddd{num}
13
+ eee{num}
14
+ fff{num}""",
15
+ api_name="/predict"
16
+ )
17
+ return result.result()
18
 
19
+
20
+ def greet(num):
21
+ params = []
22
+ for i in range(0,num):
23
+ params.append(i)
24
+ with concurrent.futures.ThreadPoolExecutor() as executor:
25
+ results = list(executor.map(grand_para, params))
26
+ return results
27
+
28
+ demo = gr.Interface(fn=greet, inputs="number", outputs="text", concurrency_limit=5)
29
  demo.launch()