From 910ffe99c0a8589b3051519c04b05fdf8dd54926 Mon Sep 17 00:00:00 2001 From: 0xMRTT <0xMRTT@proton.me> Date: Wed, 21 Jun 2023 11:01:48 +0200 Subject: [PATCH] fix? --- matrixai/__init__.py | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/matrixai/__init__.py b/matrixai/__init__.py index 04ae3bc..dcc7d2e 100644 --- a/matrixai/__init__.py +++ b/matrixai/__init__.py @@ -722,10 +722,9 @@ def run(): else: prompt += arg + " " - async def generate_image(image_prompt, style_value, ratio_value, negative, upscale): - if negative is None: - negative = False + 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] img_data = await imagine.sdprem( @@ -735,21 +734,18 @@ def run(): priority="1", high_res_results="1", steps="70", - negative=negative + negative=negative, ) - - if upscale: - img_data = await imagine.upscale(image=img_data) - try: - img_file = io.BytesIO(img_data) + with open(filename, mode="wb") as img_file: + img_file.write(img_data) except Exception as e: - print( - f"An error occurred while creating the in-memory image file: {e}") + print(f"An error occurred while writing the image to file: {e}") return None await imagine.close() - return img_file + + return filename async def generate_dalle_image(prompt, size): base_urls = ['https://a.z-pt.com'] @@ -784,7 +780,7 @@ def run(): #filename = await generate_image(prompt, style, ratio, negative, upscale=False) - filename = await generate_dalle_image(prompt, 512) + filename = await generate_dalle_image(prompt, "1024x1024") await bot.api.send_image_message( room_id=room.room_id, image_filepath=filename )