Update app.py
Browse files
app.py
CHANGED
|
@@ -1,9 +1,29 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import time
|
|
|
|
|
|
|
| 3 |
|
| 4 |
-
def
|
| 5 |
-
|
| 6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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()
|