Spaces:
Running
Running
lalashechka
commited on
Commit
•
e626c73
1
Parent(s):
c7fa2d8
Update app.py
Browse files
app.py
CHANGED
@@ -37,42 +37,49 @@ def flip_text(prompt, negative_prompt, task, steps, sampler, cfg_scale, seed):
|
|
37 |
url_sd3 = os.getenv("url_sd3")
|
38 |
url_sd4 = os.getenv("url_sd4")
|
39 |
|
40 |
-
|
|
|
41 |
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
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 |
def flipp():
|
|
|
37 |
url_sd3 = os.getenv("url_sd3")
|
38 |
url_sd4 = os.getenv("url_sd4")
|
39 |
|
40 |
+
url_sd5 = os.getenv("url_sd5")
|
41 |
+
url_sd6 = os.getenv("url_sd6")
|
42 |
|
43 |
+
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}}
|
44 |
+
response = requests.post(f'{url_sd5}', json=data)
|
45 |
+
print(response.text)
|
46 |
+
print(response.json()['image']['file_name'])
|
47 |
+
file_name = response.json()['image']['file_name']
|
48 |
+
photo = f"{url_sd6}{file_name}.png"
|
49 |
+
return photo
|
50 |
+
|
51 |
+
#with closing(create_connection(f"{url_sd3}", timeout=60)) as conn:
|
52 |
+
# conn.send('{"fn_index":3,"session_hash":""}')
|
53 |
+
# 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":""}}')
|
54 |
+
# while True:
|
55 |
+
# status = json.loads(conn.recv())['msg']
|
56 |
+
# if status == 'estimation':
|
57 |
+
# continue
|
58 |
+
# if status == 'process_starts':
|
59 |
+
# break
|
60 |
+
# photo = json.loads(conn.recv())['output']['data'][0][0]
|
61 |
+
# photo = photo.replace('data:image/jpeg;base64,', '').replace('data:image/png;base64,', '')
|
62 |
+
# photo = Image.open(io.BytesIO(base64.decodebytes(bytes(photo, "utf-8"))))
|
63 |
+
# return photo
|
64 |
+
#except:
|
65 |
+
# try:
|
66 |
+
# client = Client("https://prodia-sdxl-stable-diffusion-xl.hf.space")
|
67 |
+
# 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)
|
68 |
+
# return result
|
69 |
+
# except:
|
70 |
+
# print("n_2")
|
71 |
+
# print(url_sd4)
|
72 |
+
# with closing(create_connection(f"{url_sd4}", timeout=60)) as conn:
|
73 |
+
# conn.send('{"fn_index":0,"session_hash":""}')
|
74 |
+
# 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":""}}')
|
75 |
+
# conn.recv()
|
76 |
+
# conn.recv()
|
77 |
+
# conn.recv()
|
78 |
+
# conn.recv()
|
79 |
+
# photo = json.loads(conn.recv())['output']['data'][0]
|
80 |
+
# photo = photo.replace('data:image/jpeg;base64,', '').replace('data:image/png;base64,', '')
|
81 |
+
# photo = Image.open(io.BytesIO(base64.decodebytes(bytes(photo, "utf-8"))))
|
82 |
+
# return photo
|
83 |
|
84 |
|
85 |
def flipp():
|