Spaces:
Running
Running
lalashechka
commited on
Commit
•
668af3e
1
Parent(s):
140351d
Update app.py
Browse files
app.py
CHANGED
@@ -11,7 +11,7 @@ from PIL import Image
|
|
11 |
import io
|
12 |
import base64
|
13 |
import re
|
14 |
-
|
15 |
|
16 |
def flip_text(prompt, negative_prompt, task, steps, sampler, cfg_scale, seed):
|
17 |
result = {"prompt": prompt,"negative_prompt": negative_prompt,"task": task,"steps": steps,"sampler": sampler,"cfg_scale": cfg_scale,"seed": seed}
|
@@ -40,34 +40,39 @@ def flip_text(prompt, negative_prompt, task, steps, sampler, cfg_scale, seed):
|
|
40 |
print(task)
|
41 |
|
42 |
try:
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
conn.send(f'{{"data":["{prompt}, 4k photo","[deformed | disfigured], poorly drawn, [bad : wrong] anatomy, [extra | missing | floating | disconnected] limb, (mutated hands and fingers), blurry",7.5,"(No style)"],"event_data":null,"fn_index":3,"session_hash":""}}')
|
47 |
-
while True:
|
48 |
-
status = json.loads(conn.recv())['msg']
|
49 |
-
if status == 'estimation':
|
50 |
-
continue
|
51 |
-
if status == 'process_starts':
|
52 |
-
break
|
53 |
-
photo = json.loads(conn.recv())['output']['data'][0][0]
|
54 |
-
photo = photo.replace('data:image/jpeg;base64,', '').replace('data:image/png;base64,', '')
|
55 |
-
photo = Image.open(io.BytesIO(base64.decodebytes(bytes(photo, "utf-8"))))
|
56 |
-
return photo
|
57 |
except:
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
|
72 |
|
73 |
def flipp():
|
|
|
11 |
import io
|
12 |
import base64
|
13 |
import re
|
14 |
+
from gradio_client import Client
|
15 |
|
16 |
def flip_text(prompt, negative_prompt, task, steps, sampler, cfg_scale, seed):
|
17 |
result = {"prompt": prompt,"negative_prompt": negative_prompt,"task": task,"steps": steps,"sampler": sampler,"cfg_scale": cfg_scale,"seed": seed}
|
|
|
40 |
print(task)
|
41 |
|
42 |
try:
|
43 |
+
client = Client("https://prodia-sdxl-stable-diffusion-xl.hf.space")
|
44 |
+
result = client.predict(prompt,"[deformed | disfigured], poorly drawn, [bad : wrong] anatomy, [extra | missing | floating | disconnected] limb, (mutated hands and fingers), blurry","sd_xl_base_1.0.safetensors [be9edd61]",25,"DPM++ 2M Karras",7,1024,1024,-1,fn_index=0)
|
45 |
+
return result
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
except:
|
47 |
+
try:
|
48 |
+
print('n_1')
|
49 |
+
with closing(create_connection(f"{url_sd3}", timeout=60)) as conn:
|
50 |
+
conn.send('{"fn_index":3,"session_hash":""}')
|
51 |
+
conn.send(f'{{"data":["{prompt}, 4k photo","[deformed | disfigured], poorly drawn, [bad : wrong] anatomy, [extra | missing | floating | disconnected] limb, (mutated hands and fingers), blurry",7.5,"(No style)"],"event_data":null,"fn_index":3,"session_hash":""}}')
|
52 |
+
while True:
|
53 |
+
status = json.loads(conn.recv())['msg']
|
54 |
+
if status == 'estimation':
|
55 |
+
continue
|
56 |
+
if status == 'process_starts':
|
57 |
+
break
|
58 |
+
photo = json.loads(conn.recv())['output']['data'][0][0]
|
59 |
+
photo = photo.replace('data:image/jpeg;base64,', '').replace('data:image/png;base64,', '')
|
60 |
+
photo = Image.open(io.BytesIO(base64.decodebytes(bytes(photo, "utf-8"))))
|
61 |
+
return photo
|
62 |
+
except:
|
63 |
+
print("n_2")
|
64 |
+
print(url_sd4)
|
65 |
+
with closing(create_connection(f"{url_sd4}", timeout=60)) as conn:
|
66 |
+
conn.send('{"fn_index":0,"session_hash":""}')
|
67 |
+
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":""}}')
|
68 |
+
conn.recv()
|
69 |
+
conn.recv()
|
70 |
+
conn.recv()
|
71 |
+
conn.recv()
|
72 |
+
photo = json.loads(conn.recv())['output']['data'][0]
|
73 |
+
photo = photo.replace('data:image/jpeg;base64,', '').replace('data:image/png;base64,', '')
|
74 |
+
photo = Image.open(io.BytesIO(base64.decodebytes(bytes(photo, "utf-8"))))
|
75 |
+
return photo
|
76 |
|
77 |
|
78 |
def flipp():
|