This commit is contained in:
parent
51f1edb28d
commit
a9b9eee182
@ -104,24 +104,36 @@ def run():
|
|||||||
else:
|
else:
|
||||||
prompt += arg + " "
|
prompt += arg + " "
|
||||||
|
|
||||||
imagine = Imagine()
|
|
||||||
|
|
||||||
filename = str(uuid.uuid4()) + ".png"
|
|
||||||
# style_enum = Style[style]
|
|
||||||
# ratio_enum = Ratio[ratio]
|
|
||||||
|
|
||||||
img_data = await imagine.sdprem(
|
|
||||||
prompt=prompt,
|
|
||||||
#style=style_enum,
|
async def generate_image(image_prompt, style_value, ratio_value, negative):
|
||||||
#ratio=ratio_enum,
|
if negative is None:
|
||||||
negative=negative,
|
negative = False
|
||||||
)
|
imagine = Imagine()
|
||||||
try:
|
filename = str(uuid.uuid4()) + ".png"
|
||||||
with open(filename, mode="wb") as img_file:
|
style_enum = Style[style_value]
|
||||||
img_file.write(img_data)
|
ratio_enum = Ratio[ratio_value]
|
||||||
except Exception as e:
|
img_data = await imagine.sdprem(
|
||||||
print(f"An error occurred while writing the image to file: {e}")
|
prompt=image_prompt,
|
||||||
return None
|
style=style_enum,
|
||||||
|
ratio=ratio_enum,
|
||||||
|
negative=negative
|
||||||
|
)
|
||||||
|
|
||||||
|
try:
|
||||||
|
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 image file: {e}")
|
||||||
|
return None
|
||||||
|
|
||||||
|
await imagine.close()
|
||||||
|
return img_file
|
||||||
|
|
||||||
|
filename = await generate_image(prompt, style, ratio, negative)
|
||||||
|
|
||||||
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
|
||||||
|
Loading…
Reference in New Issue
Block a user