subnet and encoder plugins added. stable diffusion fix. updated requirements.txt
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Plugin for generating images using self-hosted Stable Diffusion and sending them to a Matrix chat room.
|
||||
|
||||
Now supports a `--seed` parameter to control deterministic generation.
|
||||
"""
|
||||
|
||||
import requests
|
||||
@@ -90,8 +93,13 @@ async def handle_command(room, message, bot, prefix, config):
|
||||
parser.add_argument('--cfg', type=int, default=2, help='CFG scale, default=2')
|
||||
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, nargs='+', 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)))'], help='Negative prompt')
|
||||
parser.add_argument('--sampler', type=str, nargs='*', default=['DPM++', 'SDE'], help='Sampler name, default=DPM++ SDE')
|
||||
parser.add_argument('--neg', type=str, nargs='+',
|
||||
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)))'],
|
||||
help='Negative prompt')
|
||||
parser.add_argument('--sampler', type=str, nargs='*', default=['DPM++', 'SDE Karras'],
|
||||
help='Sampler name, default=DPM++ SDE')
|
||||
parser.add_argument('--seed', type=int, default=None,
|
||||
help='Seed for deterministic generation (omit for random)')
|
||||
parser.add_argument('prompt', type=str, nargs='*', help='Prompt for the image')
|
||||
|
||||
args = parser.parse_args(message.body.split()[1:]) # skip command prefix
|
||||
@@ -112,6 +120,9 @@ async def handle_command(room, message, bot, prefix, config):
|
||||
"width": args.w,
|
||||
"height": args.h,
|
||||
}
|
||||
# Add seed only if explicitly provided
|
||||
if args.seed is not None:
|
||||
payload["seed"] = args.seed
|
||||
|
||||
url = "http://127.0.0.1:7860/sdapi/v1/txt2img"
|
||||
response = requests.post(url=url, json=payload, timeout=600)
|
||||
@@ -127,7 +138,14 @@ async def handle_command(room, message, bot, prefix, config):
|
||||
|
||||
# Optional: send info about generated image
|
||||
neg_prompt_clean = neg_prompt.replace(" ", "")
|
||||
info_msg = f"""<details><summary>🔍 Image Info</summary><strong>Prompt:</strong> {prompt[:100]}<br><strong>Steps:</strong> {args.steps}<br><strong>Dimensions:</strong> {args.h}x{args.w}<br><strong>Sampler:</strong> {sampler_name}<br><strong>CFG Scale:</strong> {args.cfg}<br><strong>Negative Prompt:</strong> {neg_prompt_clean}</details>"""
|
||||
seed_info = f"<br><strong>Seed:</strong> {args.seed}" if args.seed is not None else ""
|
||||
info_msg = f"""<details><summary>🔍 Image Info</summary>
|
||||
<strong>Prompt:</strong> {prompt[:100]}<br>
|
||||
<strong>Steps:</strong> {args.steps}<br>
|
||||
<strong>Dimensions:</strong> {args.h}x{args.w}<br>
|
||||
<strong>Sampler:</strong> {sampler_name}<br>
|
||||
<strong>CFG Scale:</strong> {args.cfg}{seed_info}<br>
|
||||
<strong>Negative Prompt:</strong> {neg_prompt_clean}</details>"""
|
||||
# await bot.api.send_markdown_message(room.room_id, info_msg)
|
||||
|
||||
# Clean up temp file
|
||||
@@ -167,6 +185,7 @@ def print_help():
|
||||
<li>--w W - Width of the image, default=512</li>
|
||||
<li>--neg NEG - Negative prompt, 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)))</li>
|
||||
<li>--sampler SAMPLER - Sampler name, default=DPM++ SDE</li>
|
||||
<li>--seed SEED - Seed for deterministic generation (omit for random)</li>
|
||||
</ul>
|
||||
|
||||
<p>LORA List:</p>
|
||||
@@ -191,9 +210,9 @@ def print_help():
|
||||
# Plugin Metadata
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
__version__ = "1.0.0"
|
||||
__version__ = "1.1.0"
|
||||
__author__ = "Funguy Bot"
|
||||
__description__ = "Stable Diffusion image generation"
|
||||
__description__ = "Stable Diffusion image generation (supports --seed)"
|
||||
__help__ = """
|
||||
<details>
|
||||
<summary><strong>!sd</strong> – Generate images via Stable Diffusion</summary>
|
||||
@@ -204,6 +223,7 @@ __help__ = """
|
||||
<li><code>--h H --w W</code> – Image dimensions (default 512)</li>
|
||||
<li><code>--neg <negative prompt></code></li>
|
||||
<li><code>--sampler SAMPLER</code> – Sampler name (default DPM++ SDE)</li>
|
||||
<li><code>--seed SEED</code> – Deterministic seed (optional)</li>
|
||||
</ul>
|
||||
<p>Requires a locally running Stable Diffusion API.</p>
|
||||
</details>
|
||||
|
||||
Reference in New Issue
Block a user