File size: 2,139 Bytes
203ac21
407df6a
203ac21
 
3736885
203ac21
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
407df6a
 
203ac21
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
407df6a
 
 
203ac21
407df6a
 
 
203ac21
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
56
57
58
59
# @title Default title text
import concurrent.futures
import time
import gradio as gr
import os
import requests
def pr(positive,Neg,width,height,cfg,no):
 head ={
         "Content-Type": "application/json",
         "Authorization": "Bearer " + "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoidXNlcl8yYkpvRzhxd1BYV3lreXpVNmhCQWNZZVlNRk4iLCJpYXQiOjE3MDYyMDM2NjV9.ujXZh1la_WZqwLtPSySw772W1oC34CPab4GKVMipwHA",
               }
 j =    {
     "deployment_id": "62d2228a-38c3-4894-bdc1-6f2eaf1d9ef8",
     "inputs": {
       "Cfg": cfg ,
       "Width ": f"{width}",
       "Height ": f"{height}",
       "Ps": f"{positive}",
       "Neg": f"{Neg}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) ",
     }
   }
 id=[]
 urls=[]
 def gen():
    r = requests.post("https://www.comfydeploy.com/api/run",headers=head,json=j)
    a=r.json()
    print(a)
    a=a['run_id']
    id.append(a)

    for i in id:
      li = requests.get(f"https://www.comfydeploy.com/api/run?run_id={i}",headers=head)
      lo=li.json()
      url=lo['outputs']
      while url ==[]:
        li = requests.get(f"https://www.comfydeploy.com/api/run?run_id={i}",headers=head)
        lo=li.json()
        url =lo['outputs']
      while 'url' not in url:
        li = requests.get(f"https://www.comfydeploy.com/api/run?run_id={i}",headers=head)
        lo=li.json()
        url=lo['outputs'][0]['data']['images'][0]
      url=url['url']
      urls.append(url)
 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)
 return list(set(urls) )      

with gr.Blocks() as iface:

    gr.Interface(fn=pr, inputs=["text","text",gr.Slider(8,1024,step=8.0 ,value=512),gr.Slider(8,1024,step=8.0, value=512),gr.Slider(1,25,step=1.0,value=7),gr.Slider(1,10,step=1.0)],outputs="gallery")

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