Spaces:
Running
Running
app.py
Browse files
app.py
ADDED
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import requests
|
3 |
+
import concurrent.futures
|
4 |
+
def prompt(pos,hei,wid,no):
|
5 |
+
hed={
|
6 |
+
"Content-Type": "application/json",
|
7 |
+
"Authorization": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoidXNlcl8yYkpvRzhxd1BYV3lreXpVNmhCQWNZZVlNRk4iLCJpYXQiOjE3MDYyMDM2NjV9.ujXZh1la_WZqwLtPSySw772W1oC34CPab4GKVMipwHA",
|
8 |
+
}
|
9 |
+
j={
|
10 |
+
"deployment_id": "2ce5158e-7fa0-4dd6-b533-550c1e8f8c3b",
|
11 |
+
"inputs": {
|
12 |
+
"input_text": f"{pos} (clear image: 1.1), (clean image: 1.1), (high contrast: 1.2), (colorful: 1.2), (vibrant: 1.1), ((midlength)) ",
|
13 |
+
"Negative": "worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, artist name,text, watermark,(Low quality , blurred , bad hands ,diffused body, ugly face , worst quality, low quality, normal quality, painting, drawing, monochrome, grayscale, bad anatomy, bad proportions, signature, watermark)",
|
14 |
+
"Width ": wid,
|
15 |
+
"Height ": hei,
|
16 |
+
"Batch": "",
|
17 |
+
}
|
18 |
+
}
|
19 |
+
id = []
|
20 |
+
urls=[]
|
21 |
+
p=0
|
22 |
+
no=no
|
23 |
+
|
24 |
+
|
25 |
+
def gen():
|
26 |
+
r = requests.post("https://www.comfydeploy.com/api/run",headers=hed,json=j)
|
27 |
+
a=r.json()
|
28 |
+
a=a['run_id']
|
29 |
+
id.append(a)
|
30 |
+
|
31 |
+
futures = []
|
32 |
+
with concurrent.futures.ThreadPoolExecutor() as executor:
|
33 |
+
for url in range(no):
|
34 |
+
futures.append(executor.submit(gen))
|
35 |
+
for future in concurrent.futures.as_completed(futures):
|
36 |
+
print(future)
|
37 |
+
|
38 |
+
for i in id :
|
39 |
+
li = requests.get(f"https://www.comfydeploy.com/api/run?run_id={i}",headers=hed)
|
40 |
+
lo=li.json()
|
41 |
+
url=lo['outputs'][0]['data']['images'][0]['url']
|
42 |
+
urls.append(url)
|
43 |
+
return urls
|
44 |
+
|
45 |
+
|
46 |
+
with gr.Blocks() as iface:
|
47 |
+
|
48 |
+
gr.Interface(fn=prompt, inputs=["text","text","text",gr.Slider(1,10)],outputs="gallery")
|
49 |
+
|
50 |
+
|
51 |
+
if __name__ == "__main__":
|
52 |
+
iface.launch()
|
53 |
+
|
54 |
+
|