Logo vun Stable Diffusion

Stable Diffusion

Communautéit
AlexAI-MCP
stable-diffusion

Run Stable Diffusion locally with diffusers — text-to-image, img2img, inpainting, ControlNet, and SDXL.

Iwwersiicht

EditeurAlexAI-MCP
Repositoryhermes-CCC
Skill-Nummstable-diffusion
Stären
134
Forks
22
Matgeliwwert Fichieren
Nëmmen Instruktiounen
LizenzMIT
Linken
  • Instruktiounen am Markdown-Format

    Eng SKILL.md-Datei, déi de Modell bei Bedarf luet, soudatt nëmmen Token ufalen, wann eng Ufro tatsächlech dozou passt.

  • Funktionéiert mat all LLM

    KI-Skills si reng Markdown, keen ubidderspezifesche Code. Dofir funktionéiert dëse Skill mat GPT, Claude, Gemini, Grok oder engem lokale Modell.

  • Alles an den Instruktiounen

    Alles, wat de Modell brauch, steet an den Instruktiounen — keng zousätzlech Dateien ze synchroniséieren.

  • Open Source

    Vum AlexAI-MCP op GitHub verëffentlecht. Liest de Quelltext, ier Dir de Skill installéiert.

Installatioun

Installéiert de KI-Skill Stable Diffusion an TypingMind, fir e mat all LLM ze benotzen, oder füügt en an en anere KI-Agent an, deen SKILL.md liest.

1

An TypingMind installéieren

TypingMind installéiert e Skill direkt aus sengem GitHub-Dossier — dobäi gëtt SKILL.md gelies, d'Ressourcedateie gi gebëndelt an d'Resultat gëtt lokal gespäichert.

  1. Maacht d'App op a gitt op Plugins → Skills.
  2. Wielt „Vun GitHub installéieren“.
  3. Pecht d'URL vum Skill-Dossier hei drënner an a bestätegt.
    https://github.com/AlexAI-MCP/hermes-CCC/tree/master/skills/stable-diffusion
  4. Aktivéiert de Skill an all Chat, an deem Dir e benotze wëllt.
Plugins → Skills → Skill afügen → Vu GitHub-URL, pecht dann d'URL vum Dossier an a klickt op Weider.
2

An engem anere KI-Agent installéieren

All KI-Agent, deen d'Format Agent Skills liest, kann dëse Skill benotzen — kopéiert den Dossier an de Skill-Verzeechnes vun deem KI-Agent.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/AlexAI-MCP/hermes-CCC.git /tmp/hermes-CCC
mkdir -p .claude/skills
cp -r /tmp/hermes-CCC/skills/stable-diffusion .claude/skills/stable-diffusion
Start Claude Code nom Kopéieren nei, fir datt den neie Skill erkannt gëtt.

An TypingMind benotzen

Aktivéiert Stable Diffusion an engem Chat vun TypingMind, an de Modell iwwerhëlt de Rescht. Den Numm an d'Beschreiwung stinn am System-Prompt. Soubal eng Ufro dozou passt, luet de Modell déi komplett Instruktioune selwer — Dir musst de Skill ni manuell opruffen, an et fale keng Token un, bis en tatsächlech benotzt gëtt.

De Modell luet Stable Diffusion automatesch, soubal eng Ufro dozou passt.

Funktionéiert mat all KI-Modell

KI-Skills si reng Markdown-Instruktiounen amplaz vun ubidderspezifeschem Code. Dofir ass Stable Diffusion net un de Modell gebonnen, fir deen de Skill geschriwwe gouf. Installéiert en eemol an TypingMind a benotzt e mat GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama oder engem lokale Modell, deen Dir selwer bedreift — alles mat Ären eegenen API-Keys.

  • Gëtt nëmme gelueden, wann et néideg ass

    De System-Prompt enthält nëmmen den Numm an d'Beschreiwung. D'Instruktioune gi bei der éischter passender Ufro gelueden, soudatt en onbenotzte Skill näischt kascht.

  • De Modell am lafende Chat wiesselen

    Well de Skill aus Instruktiounen amplaz vu Code besteet, funktionéiert en och no engem Modellwiessel — den nächste Modell liest déi selwecht SKILL.md-Datei.

Skill-Instruktiounen

Dëst ass den Inhalt vu SKILL.md, deen de Modell luet. Liest e virun der Installatioun — e Skill besteet aus Instruktiounen, déi Äre Modell befollegt.

Stable Diffusion

Purpose

  • Use this skill to generate or edit images locally with Hugging Face diffusers.
  • Prefer it for text-to-image, img2img, inpainting, and model composition workflows.
  • This skill covers both classic Stable Diffusion models and SDXL.
  • It is useful for scripted generation, reproducible experiments, and GPU-backed image pipelines.

Install

bash
pip install diffusers transformers accelerate torch
  • You typically also need a compatible CUDA-enabled PyTorch build for GPU inference.
  • Confirm the install in Python before pulling large checkpoints.

Core Libraries

  • diffusers for pipeline abstractions
  • transformers for text encoders and related model components
  • accelerate for efficient device loading and memory movement
  • torch for runtime execution

Text-to-Image With SD 1.5

  • Classic Stable Diffusion 1.5 uses StableDiffusionPipeline.
python
import torch
from diffusers import StableDiffusionPipeline

pipe = StableDiffusionPipeline.from_pretrained(
    "runwayml/stable-diffusion-v1-5",
    torch_dtype=torch.float16,
)
pipe = pipe.to("cuda")

image = pipe(
    prompt="a cinematic photo of a mountain observatory at sunrise",
    negative_prompt="blurry, low quality, distorted",
    num_inference_steps=30,
    guidance_scale=7.5,
).images[0]

image.save("output.png")

SDXL

  • SDXL typically uses StableDiffusionXLPipeline.
python
import torch
from diffusers import StableDiffusionXLPipeline

pipe = StableDiffusionXLPipeline.from_pretrained(
    "stabilityai/stable-diffusion-xl-base-1.0",
    torch_dtype=torch.float16,
)
pipe = pipe.to("cuda")

image = pipe(
    prompt="a highly detailed editorial photo of a futuristic library interior",
    negative_prompt="low resolution, deformed, extra limbs",
    num_inference_steps=35,
    guidance_scale=6.5,
).images[0]

image.save("sdxl-output.png")
  • SDXL generally produces stronger prompt fidelity and image quality than SD 1.5, but it also requires more VRAM.

Key Parameters

  • prompt: the main text instruction
  • negative_prompt: what to suppress
  • num_inference_steps: denoising step count
  • guidance_scale: classifier-free guidance strength
  • seed: random seed for reproducibility

Seeded Generation

  • Use a seed when you need repeatable outputs:
python
import torch
from diffusers import StableDiffusionPipeline

pipe = StableDiffusionPipeline.from_pretrained(
    "runwayml/stable-diffusion-v1-5",
    torch_dtype=torch.float16,
).to("cuda")

generator = torch.Generator(device="cuda").manual_seed(42)

image = pipe(
    prompt="a clean product photo of a ceramic mug on a wood table",
    negative_prompt="blurry, noisy, warped",
    num_inference_steps=28,
    guidance_scale=7.0,
    generator=generator,
).images[0]

image.save("seeded-output.png")
  • The same seed and settings help with debugging prompt and LoRA changes.

Save Output

  • Save the generated image with PIL:
python
image.save("output.png")
  • Always save prompt metadata separately if you need auditability or experiment tracking.

Img2Img

  • Use StableDiffusionImg2ImgPipeline to transform an existing image while preserving composition.
python
import torch
from diffusers import StableDiffusionImg2ImgPipeline
from PIL import Image

pipe = StableDiffusionImg2ImgPipeline.from_pretrained(
    "runwayml/stable-diffusion-v1-5",
    torch_dtype=torch.float16,
).to("cuda")

init_image = Image.open("input.png").convert("RGB").resize((768, 768))

image = pipe(
    prompt="turn this concept sketch into a polished sci-fi matte painting",
    negative_prompt="blurry, low contrast, artifacts",
    image=init_image,
    strength=0.65,
    num_inference_steps=30,
    guidance_scale=7.5,
).images[0]

image.save("img2img-output.png")
  • Lower strength preserves more of the input image.
  • Higher strength pushes the result further away from the source.

Inpainting

  • Use StableDiffusionInpaintPipeline to replace or repair masked regions.
python
import torch
from diffusers import StableDiffusionInpaintPipeline
from PIL import Image

pipe = StableDiffusionInpaintPipeline.from_pretrained(
    "runwayml/stable-diffusion-inpainting",
    torch_dtype=torch.float16,
).to("cuda")

image = Image.open("scene.png").convert("RGB").resize((512, 512))
mask = Image.open("mask.png").convert("RGB").resize((512, 512))

result = pipe(
    prompt="replace the missing area with a wooden chair",
    negative_prompt="blurry, malformed, duplicate objects",
    image=image,
    mask_image=mask,
    num_inference_steps=30,
    guidance_scale=7.5,
).images[0]

result.save("inpaint-output.png")
  • White mask regions are typically where edits are applied.
  • Good masks matter as much as prompts for reliable inpainting.

ControlNet

  • ControlNet is useful when you want stronger control over pose, depth, edges, or composition.
  • Typical uses include pose-guided character generation, depth-aware edits, and line-art conditioning.
  • Pair ControlNet with SD 1.5 or SDXL depending on the model combination you are using.

Memory Optimization

  • Reduce memory pressure with built-in helpers:
python
pipe.enable_model_cpu_offload()
pipe.enable_attention_slicing()
  • pipe.enable_model_cpu_offload() is often helpful on constrained GPUs.
  • pipe.enable_attention_slicing() can reduce peak memory at some performance cost.
  • These settings are practical for laptops and single-GPU consumer machines.

LoRA Loading

  • Load LoRA adapters to specialize style, subject, or composition behavior:
python
pipe.load_lora_weights("./lora.safetensors")
  • Keep the base model and LoRA pairing compatible.
  • Track LoRA names, weights, and prompts in experiment logs.

Negative Prompts

  • Common negative prompts include:

  • blurry

  • low quality

  • worst quality

  • deformed

  • extra limbs

  • bad anatomy

  • artifact

  • text

  • watermark

  • Use concise negative prompts first.

  • Overly long negative prompts can produce unstable or muddled outputs.

Prompting Guidance

  • Be concrete about subject, style, lighting, framing, and medium.
  • Use short prompt iterations during tuning rather than changing many variables at once.
  • Record prompt, negative prompt, seed, and model version together.

SDXL vs SD 1.5

  • Use SDXL when:

  • prompt fidelity matters

  • you need stronger detail and composition

  • you have enough VRAM

  • Use SD 1.5 when:

  • you need a lighter model

  • you rely on mature community tooling

  • you need broad LoRA and ControlNet ecosystem support

Common Workflows

  • Text-to-image concept generation
  • Product mockups and ideation
  • Img2img refinement from sketches
  • Inpainting object replacement
  • Style transfer through LoRAs

ComfyUI Alternative

  • diffusers is strong for code-driven workflows.
  • ComfyUI is a strong GUI alternative when you want node-based visual workflows.
  • Use ComfyUI for rapid experimentation, complex graph composition, or collaborative prompt workflows.

Practical GPU Guidance

  • SD 1.5 is easier on smaller GPUs.
  • SDXL generally needs more VRAM and benefits from float16.
  • CPU generation is possible, but it is much slower and rarely ideal for interactive use.

Common Failure Modes

  • Out-of-memory:

  • enable CPU offload

  • enable attention slicing

  • reduce image size

  • use SD 1.5 instead of SDXL

  • Muddy or low-quality images:

  • increase num_inference_steps

  • refine the prompt

  • simplify the negative prompt

  • verify you are using the intended model

  • Unreliable edits in img2img:

  • lower or raise strength depending on whether the source is being ignored or over-preserved

  • use clearer prompts

  • start from a cleaner input image

  • Inpainting artifacts:

  • improve the mask

  • widen the masked area slightly

  • use a prompt that matches the surrounding scene

Recommended Workflow

  • Start with a baseline text-to-image run.
  • Lock a seed when comparing prompt or LoRA changes.
  • Move to img2img or inpainting only after the base model behavior looks correct.
  • Add memory optimizations before assuming you need larger hardware.

When To Use This Skill

  • You need local image generation from Python.
  • You want reproducible scripted generation for experiments or pipelines.
  • You need SDXL, img2img, inpainting, or LoRA-based customization.
  • You prefer code-first workflows over GUI-only tools.

Quick Reference

  • Install: pip install diffusers transformers accelerate torch
  • SDXL pipeline: StableDiffusionXLPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0")
  • SD 1.5 pipeline: StableDiffusionPipeline
  • Save image: image.save("output.png")
  • Img2img: StableDiffusionImg2ImgPipeline
  • Inpainting: StableDiffusionInpaintPipeline
  • Memory helpers: pipe.enable_model_cpu_offload() and pipe.enable_attention_slicing()
  • LoRA: pipe.load_lora_weights("./lora.safetensors")

Heefeg gestallte Froen

Wat mécht de KI-Skill Stable Diffusion?

Run Stable Diffusion locally with diffusers — text-to-image, img2img, inpainting, ControlNet, and SDXL.

Firwat Stable Diffusion op TypingMind benotzen?

Well Dir en eemol installéiert a mat all Modell benotze kënnt. Stable Diffusion besteet aus einfachem Markdown amplaz vun ubidderspezifeschem Code. Dee selwechte Skill funktionéiert also mat GPT-5, Claude, Gemini, Grok oder engem lokale Modell – an Dir kënnt de Modell matzen am Chat wiesselen, ouni datt de Skill ophält ze funktionéieren. TypingMind benotzt Är eegen API-Schlësselen, sou datt Dir d'Ubidder direkt bezuelt amplaz vun engem Abonnement pro Benotzerplaz. Är Skills a Chats bleiwen an Ärem eegene Späicher.

Wéi installéieren ech Stable Diffusion an TypingMind?

Maacht an TypingMind Plugins → Skills → Vu GitHub installéieren op a setzt https://github.com/AlexAI-MCP/hermes-CCC/tree/master/skills/stable-diffusion an. TypingMind liest d'Datei SKILL.md an installéiert de Skill, deen Dir pro Chat aktivéiere kënnt.

Wéi eng KI-Modeller kënnen Stable Diffusion benotzen?

All Modell, deen Dir an TypingMind verbënnt. KI-Skills sinn einfach Markdown-Instruktiounen an net ubidderspezifesche Code. Dofir kënne GPT, Claude, Gemini, Grok a lokal Modeller dëse Skill lueden, wann eng Ufro dozou passt.

Wéi vill KI-Modeller kann ech mat Stable Diffusion benotzen?

Esou vill Dir wëllt. Soulaang e Modell Skills ënnerstëtzt, kënnt Dir Stable Diffusion domat benotzen – GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama a méi – alles op TypingMind mat Ären eegenen API-Schlësselen.

Ass de KI-Skill Stable Diffusion gratis?

Jo. De Skill gëtt vum AlexAI-MCP ënner der Lizenz MIT op GitHub publizéiert. Dir bezuelt nëmmen Ären eegene KI-Ubidder fir d'Token, déi Dir benotzt.

Wat si KI-Skills?

E KI-Skill ass e weiderverwendbaart Pak vun Instruktiounen, dat engem KI-Modell bäibréngt, wéi en eng bestëmmt Aufgab erfëllt. E follegt dem oppenen Agent Skills-Format: eng Datei SKILL.md mat engem Numm an enger Beschreiwung, plus all Scripten, Virlagen oder Referenzdateien, déi de Modell eventuell brauch. De Modell liest d'Instruktiounen eréischt, wann Är Ufro zum Skill passt. En installéierte Skill kascht also näischt, bis e benotzt gëtt.

Wéi ënnerscheede sech KI-Skills vu Plugins oder MCP-Serveren?

E Plugin oder MCP-Server gëtt engem Modell nei Tools, déi en opruffe kann – Code, deen iergendwou leeft an e Resultat zeréckgëtt. E KI-Skill gëtt dem Modell dogéint Wëssen an eng Virgoensweis: wéi en eng Aufgab ugeet, wéi eng Schrëtt en nokënnt a wéi eng gutt Ausgab ausgesäit. Skills bestinn aus einfachem Markdown, brauche kee Server, keen API-Schlëssel a keng Lafzäitëmfeld a funktionéiere mat all Modell.

All weisen

Elo Ären eegene KI-Workspace ariichten

Abonnéiert Iech op eisen Newsletter, fir iwwer nei Funktiounen an zukünfteg Gewënnspiller informéiert ze ginn 👇