diff --git a/plugins/stable-diffusion.py b/plugins/stable-diffusion.py index d4c9506..b428f93 100644 --- a/plugins/stable-diffusion.py +++ b/plugins/stable-diffusion.py @@ -29,13 +29,13 @@ async def handle_command(room, message, bot, prefix, config): if match.prefix() and match.command("sd"): try: parser = argparse.ArgumentParser(description='Generate images using self hosted Stable Diffusion') - parser.add_argument('--steps', type=int, default=12, help='Number of steps, default=16') - parser.add_argument('--cfg', type=int, default=1, help='CFG scale, default=7') + parser.add_argument('--steps', type=int, default=4, help='Number of steps, default=16') + parser.add_argument('--cfg', type=int, default=1.25, help='CFG scale, default=7') parser.add_argument('--h', type=int, default=512, help='Height of the image, default=512') parser.add_argument('--w', type=int, default=512, help='Width of the image, default=512') parser.add_argument('--neg', type=str, default='((((ugly)))), (((duplicate))), ((morbid)), ((mutilated)), out of frame, extra fingers, mutated hands, ((poorly drawn hands)), ((poorly drawn face)), (((mutation))), (((deformed))), ((ugly)), blurry, ((bad anatomy)), (((bad proportions))), ((extra limbs)), cloned face, (((disfigured))), out of frame, ugly, extra limbs, (bad anatomy), gross proportions, (malformed limbs), ((missing arms)), ((missing legs)), (((extra arms))), (((extra legs))), mutated hands, (fused fingers), (too many fingers), (((long neck)))', nargs='+', help='Negative prompt, default=none') - parser.add_argument('--sampler', type=str, nargs='+', default=['Euler', 'a'], help='Sampler name, default=Euler a') - parser.add_argument('prompt', type=str, nargs='+', help='Prompt for the image') + parser.add_argument('--sampler', type=str, nargs='*', default=['DPM++', 'SDE', 'Karras'], help='Sampler name, default=Euler a') + parser.add_argument('prompt', type=str, nargs='*', help='Prompt for the image') args = parser.parse_args(message.body.split()[1:]) # Skip the command itself @@ -58,15 +58,51 @@ async def handle_command(room, message, bot, prefix, config): response = requests.post(url=url, json=payload) r = response.json() - with open("/tmp/output.png", 'wb') as f: + with open("/tmp/output.jpg", 'wb') as f: f.write(base64.b64decode(r['images'][0])) - await bot.api.send_image_message(room_id=room.room_id, image_filepath="/tmp/output.png") # Corrected argument name + await bot.api.send_image_message(room_id=room.room_id, image_filepath="/tmp/output.jpg") # Corrected argument name except argparse.ArgumentError as e: await bot.api.send_text_message(room.room_id, f"Error: {e}") - await bot.api.send_markdown_message(room.room_id, "
Stable Diffusion Help
" + markdown_to_html(parser.format_help()) + "
") + await bot.api.send_markdown_message(room.room_id, "
Stable Diffusion Help" + print_help() + "
") except Exception as e: await bot.api.send_text_message(room.room_id, f"Error processing the command: {str(e)}") finally: if not command_queue.empty(): next_command = await command_queue.get() await handle_command(*next_command) + +def print_help(): + return """ +

Generate images using self-hosted Stable Diffusion

+ +

Positional arguments:

+ + +

Optional arguments:

+ + +

LORA List:

+ + +

Load LORAs like this:

+ +"""