Spaces:
Running
Running
lalashechka
commited on
Commit
•
ecd8121
1
Parent(s):
557ed44
Update app.py
Browse files
app.py
CHANGED
@@ -34,6 +34,7 @@ def flip_text(prompt, negative_prompt, task, steps, sampler, cfg_scale, seed):
|
|
34 |
url_sd4 = os.getenv("url_sd4")
|
35 |
|
36 |
print(task)
|
|
|
37 |
try:
|
38 |
print('n_1')
|
39 |
with closing(create_connection(f"{url_sd3}", timeout=60)) as conn:
|
@@ -50,50 +51,51 @@ def flip_text(prompt, negative_prompt, task, steps, sampler, cfg_scale, seed):
|
|
50 |
photo = Image.open(io.BytesIO(base64.decodebytes(bytes(photo, "utf-8"))))
|
51 |
return photo
|
52 |
except:
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
|
|
97 |
|
98 |
css = """
|
99 |
#generate {
|
|
|
34 |
url_sd4 = os.getenv("url_sd4")
|
35 |
|
36 |
print(task)
|
37 |
+
|
38 |
try:
|
39 |
print('n_1')
|
40 |
with closing(create_connection(f"{url_sd3}", timeout=60)) as conn:
|
|
|
51 |
photo = Image.open(io.BytesIO(base64.decodebytes(bytes(photo, "utf-8"))))
|
52 |
return photo
|
53 |
except:
|
54 |
+
print("n_2")
|
55 |
+
with closing(create_connection(f"{url_sd4}", timeout=60)) as conn:
|
56 |
+
conn.send('{"fn_index":0,"session_hash":""}')
|
57 |
+
conn.send(f'{{"data":["{prompt}","[deformed | disfigured], poorly drawn, [bad : wrong] anatomy, [extra | missing | floating | disconnected] limb, (mutated hands and fingers), blurry","dreamshaperXL10_alpha2.safetensors [c8afe2ef]",30,"DPM++ 2M Karras",7,1024,1024,-1],"event_data":null,"fn_index":0,"session_hash":""}}')
|
58 |
+
conn.recv()
|
59 |
+
conn.recv()
|
60 |
+
conn.recv()
|
61 |
+
conn.recv()
|
62 |
+
photo = json.loads(conn.recv())['output']['data'][0]
|
63 |
+
photo = photo.replace('data:image/jpeg;base64,', '').replace('data:image/png;base64,', '')
|
64 |
+
photo = Image.open(io.BytesIO(base64.decodebytes(bytes(photo, "utf-8"))))
|
65 |
+
return photo
|
66 |
+
|
67 |
+
|
68 |
+
def flipp():
|
69 |
+
if task == 'Stable Diffusion XL 1.0':
|
70 |
+
model = 'sd_xl_base_1.0'
|
71 |
+
if task == 'Crystal Clear XL':
|
72 |
+
model = '[3d] crystalClearXL_ccxl_97637'
|
73 |
+
if task == 'Juggernaut XL':
|
74 |
+
model = '[photorealistic] juggernautXL_version2_113240'
|
75 |
+
if task == 'DreamShaper XL':
|
76 |
+
model = '[base model] dreamshaperXL09Alpha_alpha2Xl10_91562'
|
77 |
+
if task == 'SDXL Niji':
|
78 |
+
model = '[midjourney] sdxlNijiV51_sdxlNijiV51_112807'
|
79 |
+
if task == 'Cinemax SDXL':
|
80 |
+
model = '[movie] cinemaxAlphaSDXLCinema_alpha1_107473'
|
81 |
+
if task == 'NightVision XL':
|
82 |
+
model = '[photorealistic] nightvisionXLPhotorealisticPortrait_beta0702Bakedvae_113098'
|
83 |
+
|
84 |
+
print("n_3")
|
85 |
+
negative = negative_prompt
|
86 |
+
|
87 |
+
try:
|
88 |
+
with closing(create_connection(f"{url_sd1}")) as conn:
|
89 |
+
conn.send('{"fn_index":231,"session_hash":""}')
|
90 |
+
conn.send(f'{{"data":["task()","{prompt}","{negative}",[],{steps},"{sampler}",false,false,1,1,{cfg},{seed},-1,0,0,0,false,{width},{height},false,0.7,2,"Lanczos",0,0,0,"Use same sampler","","",[],"None",true,"{model}","Automatic",null,null,null,false,false,"positive","comma",0,false,false,"","Seed","",[],"Nothing","",[],"Nothing","",[],true,false,false,false,0,null,null,false,null,null,false,null,null,false,50,[],"","",""],"event_data":null,"fn_index":231,"session_hash":""}}')
|
91 |
+
print(conn.recv())
|
92 |
+
print(conn.recv())
|
93 |
+
print(conn.recv())
|
94 |
+
print(conn.recv())
|
95 |
+
photo = f"{url_sd2}" + str(json.loads(conn.recv())['output']['data'][0][0]["name"])
|
96 |
+
return photo
|
97 |
+
except:
|
98 |
+
return None
|
99 |
|
100 |
css = """
|
101 |
#generate {
|