Spaces:
Running
Running
lalashechka
commited on
Commit
•
4f2e466
1
Parent(s):
42923c8
Update app.py
Browse files
app.py
CHANGED
@@ -98,64 +98,36 @@ def flip_text(prompt, negative_prompt, task, steps, sampler, cfg_scale, seed):
|
|
98 |
return photo
|
99 |
except:
|
100 |
try:
|
101 |
-
|
102 |
-
|
103 |
-
'
|
104 |
-
'
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
'
|
112 |
-
'
|
113 |
-
|
114 |
-
|
115 |
-
}
|
116 |
-
client = Client("ehristoforu/dalle-3-xl-lora-v2", headers=headers)
|
117 |
-
result = client.predict(prompt,"(deformed, distorted, disfigured:1.3), poorly drawn, bad anatomy, wrong anatomy, extra limb, missing limb, floating limbs, (mutated hands and fingers:1.4), disconnected limbs, mutation, mutated, ugly, disgusting, blurry, amputation",True,0,1024,1024,6,True, api_name='/run')
|
118 |
-
return result[0][0]['image']
|
119 |
except:
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
}
|
136 |
-
client = Client("Nymbo/SD-XL", headers=headers)
|
137 |
-
result = client.predict(prompt,negative_prompt,"","",True,False,False,0,1024,1024,7,1,25,25,False,api_name="/run")
|
138 |
-
return result
|
139 |
-
except:
|
140 |
-
ua = UserAgent()
|
141 |
-
headers = {
|
142 |
-
'authority': 'radames-real-time-text-to-image-sdxl-lightning.hf.space',
|
143 |
-
'accept': 'text/event-stream',
|
144 |
-
'accept-language': 'ru,en;q=0.9,la;q=0.8,ja;q=0.7',
|
145 |
-
'cache-control': 'no-cache',
|
146 |
-
'referer': 'https://radames-real-time-text-to-image-sdxl-lightning.hf.space/?__theme=light',
|
147 |
-
'sec-ch-ua': '"Not_A Brand";v="8", "Chromium";v="120", "YaBrowser";v="24.1", "Yowser";v="2.5"',
|
148 |
-
'sec-ch-ua-mobile': '?0',
|
149 |
-
'sec-ch-ua-platform': '"Windows"',
|
150 |
-
'sec-fetch-dest': 'empty',
|
151 |
-
'sec-fetch-mode': 'cors',
|
152 |
-
'sec-fetch-site': 'same-origin',
|
153 |
-
'user-agent': f'{ua.random}'
|
154 |
-
}
|
155 |
-
client = Client("radames/Real-Time-Text-to-Image-SDXL-Lightning", headers=headers)
|
156 |
-
result = client.predict(prompt, [], 0, random.randint(1, 999999), fn_index=0)
|
157 |
-
return result
|
158 |
-
|
159 |
#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}}
|
160 |
#response = requests.post(f'{url_sd5}', json=data)
|
161 |
#print(response.text)
|
|
|
98 |
return photo
|
99 |
except:
|
100 |
try:
|
101 |
+
playground = str(os.getenv("playground"))
|
102 |
+
with closing(create_connection("wss://ashrafb-arpr.hf.space/queue/join", timeout=60)) as conn:
|
103 |
+
conn.send('{"fn_index":0,"session_hash":""}')
|
104 |
+
conn.send(f'{{"fn_index":0,"data":["{prompt}"],"session_hash":""}}')
|
105 |
+
conn.recv()
|
106 |
+
conn.recv()
|
107 |
+
conn.recv()
|
108 |
+
conn.recv()
|
109 |
+
a = conn.recv()
|
110 |
+
print(">> A:", a)
|
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)
|