Spaces:
Running
Running
lalashechka
commited on
Commit
•
140351d
1
Parent(s):
6f5608c
Update app.py
Browse files
app.py
CHANGED
@@ -40,41 +40,34 @@ def flip_text(prompt, negative_prompt, task, steps, sampler, cfg_scale, seed):
|
|
40 |
print(task)
|
41 |
|
42 |
try:
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
except:
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
photo = Image.open(io.BytesIO(base64.decodebytes(bytes(photo, "utf-8"))))
|
63 |
-
return photo
|
64 |
-
except:
|
65 |
-
print("n_2")
|
66 |
-
print(url_sd4)
|
67 |
-
with closing(create_connection(f"{url_sd4}", timeout=60)) as conn:
|
68 |
-
conn.send('{"fn_index":0,"session_hash":""}')
|
69 |
-
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":""}}')
|
70 |
-
conn.recv()
|
71 |
-
conn.recv()
|
72 |
-
conn.recv()
|
73 |
-
conn.recv()
|
74 |
-
photo = json.loads(conn.recv())['output']['data'][0]
|
75 |
-
photo = photo.replace('data:image/jpeg;base64,', '').replace('data:image/png;base64,', '')
|
76 |
-
photo = Image.open(io.BytesIO(base64.decodebytes(bytes(photo, "utf-8"))))
|
77 |
-
return photo
|
78 |
|
79 |
|
80 |
def flipp():
|
|
|
40 |
print(task)
|
41 |
|
42 |
try:
|
43 |
+
print('n_1')
|
44 |
+
with closing(create_connection(f"{url_sd3}", timeout=60)) as conn:
|
45 |
+
conn.send('{"fn_index":3,"session_hash":""}')
|
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 |
+
print("n_2")
|
59 |
+
print(url_sd4)
|
60 |
+
with closing(create_connection(f"{url_sd4}", timeout=60)) as conn:
|
61 |
+
conn.send('{"fn_index":0,"session_hash":""}')
|
62 |
+
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":""}}')
|
63 |
+
conn.recv()
|
64 |
+
conn.recv()
|
65 |
+
conn.recv()
|
66 |
+
conn.recv()
|
67 |
+
photo = json.loads(conn.recv())['output']['data'][0]
|
68 |
+
photo = photo.replace('data:image/jpeg;base64,', '').replace('data:image/png;base64,', '')
|
69 |
+
photo = Image.open(io.BytesIO(base64.decodebytes(bytes(photo, "utf-8"))))
|
70 |
+
return photo
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
|
72 |
|
73 |
def flipp():
|