Spaces:
Running
Running
lalashechka
commited on
Commit
•
3f028f9
1
Parent(s):
4f2e466
Update app.py
Browse files
app.py
CHANGED
@@ -97,57 +97,17 @@ def flip_text(prompt, negative_prompt, task, steps, sampler, cfg_scale, seed):
|
|
97 |
photo = Image.open(io.BytesIO(base64.decodebytes(bytes(photo, "utf-8"))))
|
98 |
return photo
|
99 |
except:
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
photo = json.loads(a)['output']['data'][0]
|
112 |
-
photo = photo.replace('data:image/jpeg;base64,', '').replace('data:image/png;base64,', '')
|
113 |
-
photo = Image.open(io.BytesIO(base64.decodebytes(bytes(photo, "utf-8"))))
|
114 |
-
return photo
|
115 |
-
except:
|
116 |
-
artigen = str(os.getenv("artigen"))
|
117 |
-
with closing(create_connection("wss://ashrafb-arv3s.hf.space/queue/join", timeout=60)) as conn:
|
118 |
-
conn.send('{"fn_index":0,"session_hash":""}')
|
119 |
-
conn.send(f'{{"fn_index":0,"data":["{prompt}", 0, "No style"],"session_hash":""}}')
|
120 |
-
conn.recv()
|
121 |
-
conn.recv()
|
122 |
-
conn.recv()
|
123 |
-
conn.recv()
|
124 |
-
a = conn.recv()
|
125 |
-
print(">> A:", a)
|
126 |
-
photo = json.loads(a)['output']['data'][0]
|
127 |
-
photo = photo.replace('data:image/jpeg;base64,', '').replace('data:image/png;base64,', '')
|
128 |
-
photo = Image.open(io.BytesIO(base64.decodebytes(bytes(photo, "utf-8"))))
|
129 |
-
return photo
|
130 |
-
|
131 |
-
#data = {"inputs":f"{prompt}, 4k photo","options":{"negative_prompt":"[deformed | disfigured], poorly drawn, [bad : wrong] anatomy, [extra | missing | floating | disconnected] limb, (mutated hands and fingers), blurry","width":1024,"height":1024,"guidance_scale":7,"num_inference_steps":35}}
|
132 |
-
#response = requests.post(f'{url_sd5}', json=data)
|
133 |
-
#print(response.text)
|
134 |
-
#print(response.json()['image']['file_name'])
|
135 |
-
#file_name = response.json()['image']['file_name']
|
136 |
-
#photo = f"{url_sd6}{file_name}.png"
|
137 |
-
#return photo
|
138 |
-
#except Exception as e:
|
139 |
-
# print("e: --> ",e)
|
140 |
-
# with closing(create_connection(f"{url_sd4}")) as conn:
|
141 |
-
# conn.send('{"fn_index":0,"session_hash":""}')
|
142 |
-
# 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":""}}')
|
143 |
-
# conn.recv()
|
144 |
-
# conn.recv()
|
145 |
-
# conn.recv()
|
146 |
-
# conn.recv()
|
147 |
-
# photo = json.loads(conn.recv())['output']['data'][0]
|
148 |
-
# photo = photo.replace('data:image/jpeg;base64,', '').replace('data:image/png;base64,', '')
|
149 |
-
# photo = Image.open(io.BytesIO(base64.decodebytes(bytes(photo, "utf-8"))))
|
150 |
-
# return photo
|
151 |
|
152 |
#except:
|
153 |
# try:
|
|
|
97 |
photo = Image.open(io.BytesIO(base64.decodebytes(bytes(photo, "utf-8"))))
|
98 |
return photo
|
99 |
except:
|
100 |
+
with closing(create_connection(f"{url_sd4}")) as conn:
|
101 |
+
conn.send('{"fn_index":0,"session_hash":""}')
|
102 |
+
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":""}}')
|
103 |
+
conn.recv()
|
104 |
+
conn.recv()
|
105 |
+
conn.recv()
|
106 |
+
conn.recv()
|
107 |
+
photo = json.loads(conn.recv())['output']['data'][0]
|
108 |
+
photo = photo.replace('data:image/jpeg;base64,', '').replace('data:image/png;base64,', '')
|
109 |
+
photo = Image.open(io.BytesIO(base64.decodebytes(bytes(photo, "utf-8"))))
|
110 |
+
return photo
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
111 |
|
112 |
#except:
|
113 |
# try:
|