feat: use pyimagine
Some checks failed
black-action / runner / black formatter (push) Failing after 0s

This commit is contained in:
0xMRTT 2023-06-21 11:18:23 +02:00
parent 12e0603a8e
commit 2bd1181ba2
Signed by: 0xMRTT
GPG Key ID: 910B287304120902

View File

@ -656,6 +656,10 @@ class AsyncImagine:
) as resp:
return await resp.read()
from pyimagine import Imagine
from pyimagine.constants import Inspiration
def run():
if not USERNAME or not SERVER or not PASSWORD:
print(
@ -722,8 +726,9 @@ def run():
else:
prompt += arg + " "
imagine = Imagine()
async def generate_image(image_prompt, style_value, ratio_value, negative):
imagine = AsyncImagine()
filename = str(uuid.uuid4()) + ".png"
style_enum = Style[style_value]
ratio_enum = Ratio[ratio_value]
@ -731,12 +736,8 @@ def run():
prompt=image_prompt,
style=style_enum,
ratio=ratio_enum,
priority="1",
high_res_results="1",
steps="70",
negative=negative,
)
await bot.api.send_markdown_message(room.room_id, f"{img_data}")
try:
with open(filename, mode="wb") as img_file:
img_file.write(img_data)
@ -779,7 +780,10 @@ def run():
return None
filename = await generate_image(prompt, style, ratio, negative)
# Generate an inspired image
inspired_image = imagine.sdinsp(Inspiration.INSPIRATION_01)
#filename = await generate_dalle_image(prompt, "1024x1024")
await bot.api.send_image_message(