Spaces:
Running
Running
lalashechka
commited on
Commit
•
557ed44
1
Parent(s):
9fd82e8
Update app.py
Browse files
app.py
CHANGED
@@ -31,6 +31,7 @@ def flip_text(prompt, negative_prompt, task, steps, sampler, cfg_scale, seed):
|
|
31 |
url_sd1 = os.getenv("url_sd1")
|
32 |
url_sd2 = os.getenv("url_sd2")
|
33 |
url_sd3 = os.getenv("url_sd3")
|
|
|
34 |
|
35 |
print(task)
|
36 |
try:
|
@@ -49,36 +50,50 @@ def flip_text(prompt, negative_prompt, task, steps, sampler, cfg_scale, seed):
|
|
49 |
photo = Image.open(io.BytesIO(base64.decodebytes(bytes(photo, "utf-8"))))
|
50 |
return photo
|
51 |
except:
|
52 |
-
print("n_2")
|
53 |
-
if task == 'Stable Diffusion XL 1.0':
|
54 |
-
model = 'sd_xl_base_1.0'
|
55 |
-
if task == 'Crystal Clear XL':
|
56 |
-
model = '[3d] crystalClearXL_ccxl_97637'
|
57 |
-
if task == 'Juggernaut XL':
|
58 |
-
model = '[photorealistic] juggernautXL_version2_113240'
|
59 |
-
if task == 'DreamShaper XL':
|
60 |
-
model = '[base model] dreamshaperXL09Alpha_alpha2Xl10_91562'
|
61 |
-
if task == 'SDXL Niji':
|
62 |
-
model = '[midjourney] sdxlNijiV51_sdxlNijiV51_112807'
|
63 |
-
if task == 'Cinemax SDXL':
|
64 |
-
model = '[movie] cinemaxAlphaSDXLCinema_alpha1_107473'
|
65 |
-
if task == 'NightVision XL':
|
66 |
-
model = '[photorealistic] nightvisionXLPhotorealisticPortrait_beta0702Bakedvae_113098'
|
67 |
-
|
68 |
-
negative = negative_prompt
|
69 |
-
|
70 |
try:
|
71 |
-
|
72 |
-
|
73 |
-
conn.send(
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
|
|
|
|
|
|
80 |
except:
|
81 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
|
83 |
css = """
|
84 |
#generate {
|
|
|
31 |
url_sd1 = os.getenv("url_sd1")
|
32 |
url_sd2 = os.getenv("url_sd2")
|
33 |
url_sd3 = os.getenv("url_sd3")
|
34 |
+
url_sd4 = os.getenv("url_sd4")
|
35 |
|
36 |
print(task)
|
37 |
try:
|
|
|
50 |
photo = Image.open(io.BytesIO(base64.decodebytes(bytes(photo, "utf-8"))))
|
51 |
return photo
|
52 |
except:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
try:
|
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 |
except:
|
67 |
+
print("n_3")
|
68 |
+
if task == 'Stable Diffusion XL 1.0':
|
69 |
+
model = 'sd_xl_base_1.0'
|
70 |
+
if task == 'Crystal Clear XL':
|
71 |
+
model = '[3d] crystalClearXL_ccxl_97637'
|
72 |
+
if task == 'Juggernaut XL':
|
73 |
+
model = '[photorealistic] juggernautXL_version2_113240'
|
74 |
+
if task == 'DreamShaper XL':
|
75 |
+
model = '[base model] dreamshaperXL09Alpha_alpha2Xl10_91562'
|
76 |
+
if task == 'SDXL Niji':
|
77 |
+
model = '[midjourney] sdxlNijiV51_sdxlNijiV51_112807'
|
78 |
+
if task == 'Cinemax SDXL':
|
79 |
+
model = '[movie] cinemaxAlphaSDXLCinema_alpha1_107473'
|
80 |
+
if task == 'NightVision XL':
|
81 |
+
model = '[photorealistic] nightvisionXLPhotorealisticPortrait_beta0702Bakedvae_113098'
|
82 |
+
|
83 |
+
negative = negative_prompt
|
84 |
+
|
85 |
+
try:
|
86 |
+
with closing(create_connection(f"{url_sd1}")) as conn:
|
87 |
+
conn.send('{"fn_index":231,"session_hash":""}')
|
88 |
+
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":""}}')
|
89 |
+
print(conn.recv())
|
90 |
+
print(conn.recv())
|
91 |
+
print(conn.recv())
|
92 |
+
print(conn.recv())
|
93 |
+
photo = f"{url_sd2}" + str(json.loads(conn.recv())['output']['data'][0][0]["name"])
|
94 |
+
return photo
|
95 |
+
except:
|
96 |
+
return None
|
97 |
|
98 |
css = """
|
99 |
#generate {
|