Update app.py
Browse files
app.py
CHANGED
@@ -1,87 +1,35 @@
|
|
1 |
-
import
|
2 |
-
import
|
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 |
-
fac = f"{fac} "
|
37 |
-
rn = random.randint(0, 19)
|
38 |
-
model=models[rn]
|
39 |
-
return model(put),fac
|
40 |
-
elif h != o:
|
41 |
-
return(None,None)
|
42 |
-
except Exception:
|
43 |
-
return None, None
|
44 |
-
def cl_fac():
|
45 |
-
return "",gr.HTML.update(f"{loading}")
|
46 |
-
with gr.Blocks() as b:
|
47 |
-
with gr.Row():
|
48 |
-
with gr.Column():
|
49 |
-
put = gr.Textbox()
|
50 |
-
with gr.Column():
|
51 |
-
with gr.Row():
|
52 |
-
btn1 = gr.Button("Run")
|
53 |
-
btn2 = gr.Button("Clear")
|
54 |
-
message=gr.HTML("<div></div>")
|
55 |
-
message2=gr.HTML("",visible=False)
|
56 |
-
|
57 |
-
with gr.Row():
|
58 |
-
out1 = gr.Image()
|
59 |
-
out2 = gr.Image()
|
60 |
-
with gr.Row():
|
61 |
-
out3 = gr.Image()
|
62 |
-
out4 = gr.Image()
|
63 |
-
|
64 |
-
with gr.Row(visible=False):
|
65 |
-
h=gr.Textbox(value="V")
|
66 |
-
t_state=gr.Number()
|
67 |
-
t_switch=gr.Textbox(value=0)
|
68 |
-
def clear_all():
|
69 |
-
return "",None,None,None,None,None,None,1,gr.HTML.update("<div></div>")
|
70 |
-
fac_b = gr.Textbox(value="", visible=False)
|
71 |
-
|
72 |
-
def noth():
|
73 |
-
return gr.HTML.update("<div></div>")
|
74 |
-
#a1=btn1.click(noth,None,btn1,every=1)
|
75 |
-
btn1.click(cl_fac,None,[fac_b,message],show_progress=False)
|
76 |
-
b1=btn1.click(start,None,[t_state,t_switch],show_progress=True)
|
77 |
-
sta = t_state.change(end,t_state,[t_switch,message2],every=1,show_progress=True)
|
78 |
-
b2=btn1.click(im_fn,[put,fac_b,h],[out1,fac_b], show_progress=True)
|
79 |
-
b3=out1.change(im_fn,[put,fac_b,h],[out2,fac_b], show_progress=True)
|
80 |
-
b4=out2.change(im_fn,[put,fac_b,h],[out3,fac_b], show_progress=True)
|
81 |
-
b5=out3.change(im_fn,[put,fac_b,h],[out4,fac_b], show_progress=True)
|
82 |
-
b6=out4.change(noth,None,message, show_progress=False)
|
83 |
-
swi=t_switch.change(clear,None,[t_switch,fac_b], cancels=[sta,b2,b3,b4,b5],show_progress=False)
|
84 |
-
#btn2.click(noth,None,message,cancels=[b1,sta,b2,b3,b4,b5,swi],show_progress=False)
|
85 |
-
btn2.click(clear_all, None,[fac_b,put,out1,out2,out3,out4,t_state,t_switch,message],cancels=[b1,sta,b2,b3,b4,b5,swi],show_progress=False)
|
86 |
-
b.queue(concurrency_count=100).launch(show_api=False)
|
87 |
-
ac()
|
|
|
1 |
+
import requests
|
2 |
+
import json
|
3 |
+
|
4 |
+
url = "https://modelslab.com/api/v6/images/text2img"
|
5 |
+
|
6 |
+
payload = json.dumps({
|
7 |
+
"key": "sHj15HTjxiCkFtV3PHmSeehjaVGdpNotsb1iMbIpniNzfTsjgbN7Z9RFB8Wu",
|
8 |
+
"model_id": "juggernaut-xl-v8",
|
9 |
+
"prompt": "ultra realistic close up portrait ((beautiful pale cyberpunk female with heavy black eyeliner)), blue eyes, shaved side haircut, hyper detail, cinematic lighting, magic neon, dark red city, Canon EOS R3, nikon, f/1.4, ISO 200, 1/160s, 8K, RAW, unedited, symmetrical balance, in-frame, 8K",
|
10 |
+
"negative_prompt": "painting, extra fingers, mutated hands, poorly drawn hands, poorly drawn face, deformed, ugly, blurry, bad anatomy, bad proportions, extra limbs, cloned face, skinny, glitchy, double torso, extra arms, extra hands, mangled fingers, missing lips, ugly face, distorted face, extra legs, anime",
|
11 |
+
"width": "512",
|
12 |
+
"height": "512",
|
13 |
+
"samples": "1",
|
14 |
+
"num_inference_steps": "30",
|
15 |
+
"safety_checker": "no",
|
16 |
+
"enhance_prompt": "yes",
|
17 |
+
"seed": None,
|
18 |
+
"guidance_scale": 7.5,
|
19 |
+
"multi_lingual": "no",
|
20 |
+
"panorama": "no",
|
21 |
+
"self_attention": "no",
|
22 |
+
"upscale": "no",
|
23 |
+
"embeddings": "embeddings_model_id",
|
24 |
+
"lora": "lora_model_id",
|
25 |
+
"webhook": None,
|
26 |
+
"track_id": None
|
27 |
+
})
|
28 |
+
|
29 |
+
headers = {
|
30 |
+
'Content-Type': 'application/json'
|
31 |
+
}
|
32 |
+
|
33 |
+
response = requests.request("POST", url, headers=headers, data=payload)
|
34 |
+
|
35 |
+
print(response.text)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|