Compare commits

...

2 Commits

Author SHA1 Message Date
jordan
6ba5bf90cc Updoot 2022-12-10 22:45:15 +11:00
jordan
7c6d64bb0f Refactor 2022-12-10 22:44:39 +11:00

View File

@ -87,7 +87,7 @@ class DiffuseAPI():
"prompt": prompt, "prompt": prompt,
"styles": self.styles, "styles": self.styles,
"steps": self.num_steps, "steps": self.num_steps,
"seed": self.ai_seed, "seed": self.seed,
"n_iter": 1, "n_iter": 1,
"height": self.height, "height": self.height,
"width": self.width, "width": self.width,
@ -112,17 +112,10 @@ class DiffuseAPI():
alive.close() alive.close()
await sess.close() await sess.close()
return None return None
request = await sess.post("/sdapi/v1/txt2img", json=payload) async with aiohttp.ClientSession(self.url) as session:
try: async with session.head('/') as alive:
req_json = await request.json() if alive.status != 200:
request.close() return None
await sess.close() async with session.post("/sdapi/v1/txt2img", json=payload) as image_json:
return req_json["images", [0]] image_data = await image_json.json()
except: return image_data["images"][0]
return None