Spaces:
Running
Running
lalashechka
commited on
Commit
•
42923c8
1
Parent(s):
e1b69ff
Update app.py
Browse files
app.py
CHANGED
@@ -79,52 +79,32 @@ def flip_text(prompt, negative_prompt, task, steps, sampler, cfg_scale, seed):
|
|
79 |
photo = Image.open(io.BytesIO(base64.decodebytes(bytes(photo, "utf-8"))))
|
80 |
return photo
|
81 |
|
82 |
-
#try:
|
83 |
-
# with closing(create_connection(f"{url_sd3}")) as conn:
|
84 |
-
# conn.send('{"fn_index":3,"session_hash":""}')
|
85 |
-
# 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":""}}')
|
86 |
-
# c = 0
|
87 |
-
# while c < 60:
|
88 |
-
# status = json.loads(conn.recv())['msg']
|
89 |
-
# if status == 'estimation':
|
90 |
-
# c += 1
|
91 |
-
# time.sleep(1)
|
92 |
-
# continue
|
93 |
-
# if status == 'process_starts':
|
94 |
-
# break
|
95 |
-
# photo = json.loads(conn.recv())['output']['data'][0][0]
|
96 |
-
# photo = photo.replace('data:image/jpeg;base64,', '').replace('data:image/png;base64,', '')
|
97 |
-
# photo = Image.open(io.BytesIO(base64.decodebytes(bytes(photo, "utf-8"))))
|
98 |
-
# return photo
|
99 |
-
#except:
|
100 |
try:
|
101 |
-
|
102 |
-
|
103 |
-
'
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
'
|
114 |
-
'
|
115 |
-
|
116 |
-
|
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 |
try:
|
121 |
ua = UserAgent()
|
122 |
headers = {
|
123 |
-
'authority': '
|
124 |
'accept': 'text/event-stream',
|
125 |
'accept-language': 'ru,en;q=0.9,la;q=0.8,ja;q=0.7',
|
126 |
'cache-control': 'no-cache',
|
127 |
-
'referer': 'https://
|
128 |
'sec-ch-ua': '"Not_A Brand";v="8", "Chromium";v="120", "YaBrowser";v="24.1", "Yowser";v="2.5"',
|
129 |
'sec-ch-ua-mobile': '?0',
|
130 |
'sec-ch-ua-platform': '"Windows"',
|
@@ -133,28 +113,48 @@ def flip_text(prompt, negative_prompt, task, steps, sampler, cfg_scale, seed):
|
|
133 |
'sec-fetch-site': 'same-origin',
|
134 |
'user-agent': f'{ua.random}'
|
135 |
}
|
136 |
-
client = Client("
|
137 |
-
result = client.predict(prompt,
|
138 |
-
return result
|
139 |
except:
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
79 |
photo = Image.open(io.BytesIO(base64.decodebytes(bytes(photo, "utf-8"))))
|
80 |
return photo
|
81 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
try:
|
83 |
+
with closing(create_connection(f"{url_sd3}")) as conn:
|
84 |
+
conn.send('{"fn_index":3,"session_hash":""}')
|
85 |
+
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":""}}')
|
86 |
+
c = 0
|
87 |
+
while c < 60:
|
88 |
+
status = json.loads(conn.recv())['msg']
|
89 |
+
if status == 'estimation':
|
90 |
+
c += 1
|
91 |
+
time.sleep(1)
|
92 |
+
continue
|
93 |
+
if status == 'process_starts':
|
94 |
+
break
|
95 |
+
photo = json.loads(conn.recv())['output']['data'][0][0]
|
96 |
+
photo = photo.replace('data:image/jpeg;base64,', '').replace('data:image/png;base64,', '')
|
97 |
+
photo = Image.open(io.BytesIO(base64.decodebytes(bytes(photo, "utf-8"))))
|
98 |
+
return photo
|
|
|
|
|
99 |
except:
|
100 |
try:
|
101 |
ua = UserAgent()
|
102 |
headers = {
|
103 |
+
'authority': 'ehristoforu-dalle-3-xl-lora-v2.hf.space',
|
104 |
'accept': 'text/event-stream',
|
105 |
'accept-language': 'ru,en;q=0.9,la;q=0.8,ja;q=0.7',
|
106 |
'cache-control': 'no-cache',
|
107 |
+
'referer': 'https://ehristoforu-dalle-3-xl-lora-v2.hf.space/?__theme=light',
|
108 |
'sec-ch-ua': '"Not_A Brand";v="8", "Chromium";v="120", "YaBrowser";v="24.1", "Yowser";v="2.5"',
|
109 |
'sec-ch-ua-mobile': '?0',
|
110 |
'sec-ch-ua-platform': '"Windows"',
|
|
|
113 |
'sec-fetch-site': 'same-origin',
|
114 |
'user-agent': f'{ua.random}'
|
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 |
+
try:
|
121 |
+
ua = UserAgent()
|
122 |
+
headers = {
|
123 |
+
'authority': 'nymbo-sd-xl.hf.space',
|
124 |
+
'accept': 'text/event-stream',
|
125 |
+
'accept-language': 'ru,en;q=0.9,la;q=0.8,ja;q=0.7',
|
126 |
+
'cache-control': 'no-cache',
|
127 |
+
'referer': 'https://nymbo-sd-xl.hf.space/?__theme=light',
|
128 |
+
'sec-ch-ua': '"Not_A Brand";v="8", "Chromium";v="120", "YaBrowser";v="24.1", "Yowser";v="2.5"',
|
129 |
+
'sec-ch-ua-mobile': '?0',
|
130 |
+
'sec-ch-ua-platform': '"Windows"',
|
131 |
+
'sec-fetch-dest': 'empty',
|
132 |
+
'sec-fetch-mode': 'cors',
|
133 |
+
'sec-fetch-site': 'same-origin',
|
134 |
+
'user-agent': f'{ua.random}'
|
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)
|