fix?
Some checks failed
black-action / runner / black formatter (push) Failing after 0s

This commit is contained in:
0xMRTT 2023-06-21 11:01:48 +02:00
parent a88f6b3618
commit 910ffe99c0
Signed by: 0xMRTT
GPG Key ID: 910B287304120902

View File

@ -722,10 +722,9 @@ def run():
else: else:
prompt += arg + " " prompt += arg + " "
async def generate_image(image_prompt, style_value, ratio_value, negative, upscale): async def generate_image(image_prompt, style_value, ratio_value, negative):
if negative is None:
negative = False
imagine = AsyncImagine() imagine = AsyncImagine()
filename = str(uuid.uuid4()) + ".png"
style_enum = Style[style_value] style_enum = Style[style_value]
ratio_enum = Ratio[ratio_value] ratio_enum = Ratio[ratio_value]
img_data = await imagine.sdprem( img_data = await imagine.sdprem(
@ -735,21 +734,18 @@ def run():
priority="1", priority="1",
high_res_results="1", high_res_results="1",
steps="70", steps="70",
negative=negative negative=negative,
) )
if upscale:
img_data = await imagine.upscale(image=img_data)
try: try:
img_file = io.BytesIO(img_data) with open(filename, mode="wb") as img_file:
img_file.write(img_data)
except Exception as e: except Exception as e:
print( print(f"An error occurred while writing the image to file: {e}")
f"An error occurred while creating the in-memory image file: {e}")
return None return None
await imagine.close() await imagine.close()
return img_file
return filename
async def generate_dalle_image(prompt, size): async def generate_dalle_image(prompt, size):
base_urls = ['https://a.z-pt.com'] 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_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( await bot.api.send_image_message(
room_id=room.room_id, image_filepath=filename room_id=room.room_id, image_filepath=filename
) )