File size: 1,845 Bytes
407df6a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import gradio as gr
import requests
import concurrent.futures
def prompt(pos,hei,wid,no):
 hed={
    "Content-Type": "application/json",
    "Authorization": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoidXNlcl8yYkpvRzhxd1BYV3lreXpVNmhCQWNZZVlNRk4iLCJpYXQiOjE3MDYyMDM2NjV9.ujXZh1la_WZqwLtPSySw772W1oC34CPab4GKVMipwHA",
      }
 j={
       "deployment_id": "2ce5158e-7fa0-4dd6-b533-550c1e8f8c3b",
           "inputs": {
                 "input_text": f"{pos} (clear image: 1.1), (clean image: 1.1), (high contrast: 1.2), (colorful: 1.2), (vibrant: 1.1), ((midlength)) ",
                 "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)",
                 "Width ": wid,
                 "Height ": hei,
                 "Batch": "",
                                             }
 }
 id = []
 urls=[]
 p=0
 no=no
 

 def gen():
  r = requests.post("https://www.comfydeploy.com/api/run",headers=hed,json=j)
  a=r.json()
  a=a['run_id']
  id.append(a)

 futures = []
 with concurrent.futures.ThreadPoolExecutor() as executor:
   for url in range(no):
       futures.append(executor.submit(gen))
   for future in concurrent.futures.as_completed(futures):
     print(future)

 for i in id :
  li = requests.get(f"https://www.comfydeploy.com/api/run?run_id={i}",headers=hed)
  lo=li.json()
  url=lo['outputs'][0]['data']['images'][0]['url']
  urls.append(url)
 return urls


with gr.Blocks() as iface:

    gr.Interface(fn=prompt, inputs=["text","text","text",gr.Slider(1,10)],outputs="gallery")

    
if __name__ == "__main__":
    iface.launch()