[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M71JC591MNTYSNTX0M9F9TZZ":3,"skill-same:01M71JC591MNTYSNTX0M9F9TZZ":93},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":22,"publishedAt":43,"linkOnly":44,"markdownContent":45,"markdownBody":46,"frontMatter":47,"refName":62,"commitSha":63,"skillDirectory":64,"forksCount":65,"repositoryHtmlUrl":66,"repositoryHomepageUrl":6,"ownerHtmlUrl":67,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":68,"install":69,"resources":82},"01M71JC591MNTYSNTX0M9F9TZZ","stable-diffusion-image-generation",null,"State-of-the-art text-to-image generation with Stable Diffusion models via HuggingFace Diffusers. Use when generating images from text prompts, performing image-to-image translation, inpainting, or building custom diffusion pipelines.","xuanxuan1983\u002Fhermes-skills-backup","xuanxuan1983","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F151701653?v=4","01M71HCZNB5H19QJ6YBF98W2WH","01M71HCZP14T0921BD0TC9EPD3",1,"MIT","https:\u002F\u002Fgithub.com\u002Fxuanxuan1983\u002Fhermes-skills-backup\u002Fblob\u002Fmain\u002Fskills\u002Fmlops\u002Fmodels\u002Fstable-diffusion\u002FSKILL.md",[17],{"categoryNo":18,"categoryName":19,"taxonomyType":20,"taxonomyTypeDesc":21},"01JBSEEDCAT000000000000016","图像与多媒体","SCENARIO","使用场景",[23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42],"Image Generation","Stable Diffusion","diffusion","generation","stable diffusion image generation","image","with","use","custom","orchestra","computer","vision","multimodal","Transformers","text","Accelerate","when","Art","translation","images","2026-11-10 10:12:30",false,"---\nname: stable-diffusion-image-generation\ndescription: State-of-the-art text-to-image generation with Stable Diffusion models via HuggingFace Diffusers. Use when generating images from text prompts, performing image-to-image translation, inpainting, or building custom diffusion pipelines.\nversion: 1.0.0\nauthor: Orchestra Research\nlicense: MIT\ndependencies: [diffusers>=0.30.0, transformers>=4.41.0, accelerate>=0.31.0, torch>=2.0.0]\nmetadata:\n  hermes:\n    tags: [Image Generation, Stable Diffusion, Diffusers, Text-to-Image, Multimodal, Computer Vision]\n\n---\n\n# Stable Diffusion Image Generation\n\nComprehensive guide to generating images with Stable Diffusion using the HuggingFace Diffusers library.\n\n## When to use Stable Diffusion\n\n**Use Stable Diffusion when:**\n- Generating images from text descriptions\n- Performing image-to-image translation (style transfer, enhancement)\n- Inpainting (filling in masked regions)\n- Outpainting (extending images beyond boundaries)\n- Creating variations of existing images\n- Building custom image generation workflows\n\n**Key features:**\n- **Text-to-Image**: Generate images from natural language prompts\n- **Image-to-Image**: Transform existing images with text guidance\n- **Inpainting**: Fill masked regions with context-aware content\n- **ControlNet**: Add spatial conditioning (edges, poses, depth)\n- **LoRA Support**: Efficient fine-tuning and style adaptation\n- **Multiple Models**: SD 1.5, SDXL, SD 3.0, Flux support\n\n**Use alternatives instead:**\n- **DALL-E 3**: For API-based generation without GPU\n- **Midjourney**: For artistic, stylized outputs\n- **Imagen**: For Google Cloud integration\n- **Leonardo.ai**: For web-based creative workflows\n\n## Quick start\n\n### Installation\n\n```bash\npip install diffusers transformers accelerate torch\npip install xformers  # Optional: memory-efficient attention\n```\n\n### Basic text-to-image\n\n```python\nfrom diffusers import DiffusionPipeline\nimport torch\n\n# Load pipeline (auto-detects model type)\npipe = DiffusionPipeline.from_pretrained(\n    \"stable-diffusion-v1-5\u002Fstable-diffusion-v1-5\",\n    torch_dtype=torch.float16\n)\npipe.to(\"cuda\")\n\n# Generate image\nimage = pipe(\n    \"A serene mountain landscape at sunset, highly detailed\",\n    num_inference_steps=50,\n    guidance_scale=7.5\n).images[0]\n\nimage.save(\"output.png\")\n```\n\n### Using SDXL (higher quality)\n\n```python\nfrom diffusers import AutoPipelineForText2Image\nimport torch\n\npipe = AutoPipelineForText2Image.from_pretrained(\n    \"stabilityai\u002Fstable-diffusion-xl-base-1.0\",\n    torch_dtype=torch.float16,\n    variant=\"fp16\"\n)\npipe.to(\"cuda\")\n\n# Enable memory optimization\npipe.enable_model_cpu_offload()\n\nimage = pipe(\n    prompt=\"A futuristic city with flying cars, cinematic lighting\",\n    height=1024,\n    width=1024,\n    num_inference_steps=30\n).images[0]\n```\n\n## Architecture overview\n\n### Three-pillar design\n\nDiffusers is built around three core components:\n\n```\nPipeline (orchestration)\n├── Model (neural networks)\n│   ├── UNet \u002F Transformer (noise prediction)\n│   ├── VAE (latent encoding\u002Fdecoding)\n│   └── Text Encoder (CLIP\u002FT5)\n└── Scheduler (denoising algorithm)\n```\n\n### Pipeline inference flow\n\n```\nText Prompt → Text Encoder → Text Embeddings\n                                    ↓\nRandom Noise → [Denoising Loop] ← Scheduler\n                      ↓\n               Predicted Noise\n                      ↓\n              VAE Decoder → Final Image\n```\n\n## Core concepts\n\n### Pipelines\n\nPipelines orchestrate complete workflows:\n\n| Pipeline | Purpose |\n|----------|---------|\n| `StableDiffusionPipeline` | Text-to-image (SD 1.x\u002F2.x) |\n| `StableDiffusionXLPipeline` | Text-to-image (SDXL) |\n| `StableDiffusion3Pipeline` | Text-to-image (SD 3.0) |\n| `FluxPipeline` | Text-to-image (Flux models) |\n| `StableDiffusionImg2ImgPipeline` | Image-to-image |\n| `StableDiffusionInpaintPipeline` | Inpainting |\n\n### Schedulers\n\nSchedulers control the denoising process:\n\n| Scheduler | Steps | Quality | Use Case |\n|-----------|-------|---------|----------|\n| `EulerDiscreteScheduler` | 20-50 | Good | Default choice |\n| `EulerAncestralDiscreteScheduler` | 20-50 | Good | More variation |\n| `DPMSolverMultistepScheduler` | 15-25 | Excellent | Fast, high quality |\n| `DDIMScheduler` | 50-100 | Good | Deterministic |\n| `LCMScheduler` | 4-8 | Good | Very fast |\n| `UniPCMultistepScheduler` | 15-25 | Excellent | Fast convergence |\n\n### Swapping schedulers\n\n```python\nfrom diffusers import DPMSolverMultistepScheduler\n\n# Swap for faster generation\npipe.scheduler = DPMSolverMultistepScheduler.from_config(\n    pipe.scheduler.config\n)\n\n# Now generate with fewer steps\nimage = pipe(prompt, num_inference_steps=20).images[0]\n```\n\n## Generation parameters\n\n### Key parameters\n\n| Parameter | Default | Description |\n|-----------|---------|-------------|\n| `prompt` | Required | Text description of desired image |\n| `negative_prompt` | None | What to avoid in the image |\n| `num_inference_steps` | 50 | Denoising steps (more = better quality) |\n| `guidance_scale` | 7.5 | Prompt adherence (7-12 typical) |\n| `height`, `width` | 512\u002F1024 | Output dimensions (multiples of 8) |\n| `generator` | None | Torch generator for reproducibility |\n| `num_images_per_prompt` | 1 | Batch size |\n\n### Reproducible generation\n\n```python\nimport torch\n\ngenerator = torch.Generator(device=\"cuda\").manual_seed(42)\n\nimage = pipe(\n    prompt=\"A cat wearing a top hat\",\n    generator=generator,\n    num_inference_steps=50\n).images[0]\n```\n\n### Negative prompts\n\n```python\nimage = pipe(\n    prompt=\"Professional photo of a dog in a garden\",\n    negative_prompt=\"blurry, low quality, distorted, ugly, bad anatomy\",\n    guidance_scale=7.5\n).images[0]\n```\n\n## Image-to-image\n\nTransform existing images with text guidance:\n\n```python\nfrom diffusers import AutoPipelineForImage2Image\nfrom PIL import Image\n\npipe = AutoPipelineForImage2Image.from_pretrained(\n    \"stable-diffusion-v1-5\u002Fstable-diffusion-v1-5\",\n    torch_dtype=torch.float16\n).to(\"cuda\")\n\ninit_image = Image.open(\"input.jpg\").resize((512, 512))\n\nimage = pipe(\n    prompt=\"A watercolor painting of the scene\",\n    image=init_image,\n    strength=0.75,  # How much to transform (0-1)\n    num_inference_steps=50\n).images[0]\n```\n\n## Inpainting\n\nFill masked regions:\n\n```python\nfrom diffusers import AutoPipelineForInpainting\nfrom PIL import Image\n\npipe = AutoPipelineForInpainting.from_pretrained(\n    \"runwayml\u002Fstable-diffusion-inpainting\",\n    torch_dtype=torch.float16\n).to(\"cuda\")\n\nimage = Image.open(\"photo.jpg\")\nmask = Image.open(\"mask.png\")  # White = inpaint region\n\nresult = pipe(\n    prompt=\"A red car parked on the street\",\n    image=image,\n    mask_image=mask,\n    num_inference_steps=50\n).images[0]\n```\n\n## ControlNet\n\nAdd spatial conditioning for precise control:\n\n```python\nfrom diffusers import StableDiffusionControlNetPipeline, ControlNetModel\nimport torch\n\n# Load ControlNet for edge conditioning\ncontrolnet = ControlNetModel.from_pretrained(\n    \"lllyasviel\u002Fcontrol_v11p_sd15_canny\",\n    torch_dtype=torch.float16\n)\n\npipe = StableDiffusionControlNetPipeline.from_pretrained(\n    \"stable-diffusion-v1-5\u002Fstable-diffusion-v1-5\",\n    controlnet=controlnet,\n    torch_dtype=torch.float16\n).to(\"cuda\")\n\n# Use Canny edge image as control\ncontrol_image = get_canny_image(input_image)\n\nimage = pipe(\n    prompt=\"A beautiful house in the style of Van Gogh\",\n    image=control_image,\n    num_inference_steps=30\n).images[0]\n```\n\n### Available ControlNets\n\n| ControlNet | Input Type | Use Case |\n|------------|------------|----------|\n| `canny` | Edge maps | Preserve structure |\n| `openpose` | Pose skeletons | Human poses |\n| `depth` | Depth maps | 3D-aware generation |\n| `normal` | Normal maps | Surface details |\n| `mlsd` | Line segments | Architectural lines |\n| `scribble` | Rough sketches | Sketch-to-image |\n\n## LoRA adapters\n\nLoad fine-tuned style adapters:\n\n```python\nfrom diffusers import DiffusionPipeline\n\npipe = DiffusionPipeline.from_pretrained(\n    \"stable-diffusion-v1-5\u002Fstable-diffusion-v1-5\",\n    torch_dtype=torch.float16\n).to(\"cuda\")\n\n# Load LoRA weights\npipe.load_lora_weights(\"path\u002Fto\u002Flora\", weight_name=\"style.safetensors\")\n\n# Generate with LoRA style\nimage = pipe(\"A portrait in the trained style\").images[0]\n\n# Adjust LoRA strength\npipe.fuse_lora(lora_scale=0.8)\n\n# Unload LoRA\npipe.unload_lora_weights()\n```\n\n### Multiple LoRAs\n\n```python\n# Load multiple LoRAs\npipe.load_lora_weights(\"lora1\", adapter_name=\"style\")\npipe.load_lora_weights(\"lora2\", adapter_name=\"character\")\n\n# Set weights for each\npipe.set_adapters([\"style\", \"character\"], adapter_weights=[0.7, 0.5])\n\nimage = pipe(\"A portrait\").images[0]\n```\n\n## Memory optimization\n\n### Enable CPU offloading\n\n```python\n# Model CPU offload - moves models to CPU when not in use\npipe.enable_model_cpu_offload()\n\n# Sequential CPU offload - more aggressive, slower\npipe.enable_sequential_cpu_offload()\n```\n\n### Attention slicing\n\n```python\n# Reduce memory by computing attention in chunks\npipe.enable_attention_slicing()\n\n# Or specific chunk size\npipe.enable_attention_slicing(\"max\")\n```\n\n### xFormers memory-efficient attention\n\n```python\n# Requires xformers package\npipe.enable_xformers_memory_efficient_attention()\n```\n\n### VAE slicing for large images\n\n```python\n# Decode latents in tiles for large images\npipe.enable_vae_slicing()\npipe.enable_vae_tiling()\n```\n\n## Model variants\n\n### Loading different precisions\n\n```python\n# FP16 (recommended for GPU)\npipe = DiffusionPipeline.from_pretrained(\n    \"model-id\",\n    torch_dtype=torch.float16,\n    variant=\"fp16\"\n)\n\n# BF16 (better precision, requires Ampere+ GPU)\npipe = DiffusionPipeline.from_pretrained(\n    \"model-id\",\n    torch_dtype=torch.bfloat16\n)\n```\n\n### Loading specific components\n\n```python\nfrom diffusers import UNet2DConditionModel, AutoencoderKL\n\n# Load custom VAE\nvae = AutoencoderKL.from_pretrained(\"stabilityai\u002Fsd-vae-ft-mse\")\n\n# Use with pipeline\npipe = DiffusionPipeline.from_pretrained(\n    \"stable-diffusion-v1-5\u002Fstable-diffusion-v1-5\",\n    vae=vae,\n    torch_dtype=torch.float16\n)\n```\n\n## Batch generation\n\nGenerate multiple images efficiently:\n\n```python\n# Multiple prompts\nprompts = [\n    \"A cat playing piano\",\n    \"A dog reading a book\",\n    \"A bird painting a picture\"\n]\n\nimages = pipe(prompts, num_inference_steps=30).images\n\n# Multiple images per prompt\nimages = pipe(\n    \"A beautiful sunset\",\n    num_images_per_prompt=4,\n    num_inference_steps=30\n).images\n```\n\n## Common workflows\n\n### Workflow 1: High-quality generation\n\n```python\nfrom diffusers import StableDiffusionXLPipeline, DPMSolverMultistepScheduler\nimport torch\n\n# 1. Load SDXL with optimizations\npipe = StableDiffusionXLPipeline.from_pretrained(\n    \"stabilityai\u002Fstable-diffusion-xl-base-1.0\",\n    torch_dtype=torch.float16,\n    variant=\"fp16\"\n)\npipe.to(\"cuda\")\npipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)\npipe.enable_model_cpu_offload()\n\n# 2. Generate with quality settings\nimage = pipe(\n    prompt=\"A majestic lion in the savanna, golden hour lighting, 8k, detailed fur\",\n    negative_prompt=\"blurry, low quality, cartoon, anime, sketch\",\n    num_inference_steps=30,\n    guidance_scale=7.5,\n    height=1024,\n    width=1024\n).images[0]\n```\n\n### Workflow 2: Fast prototyping\n\n```python\nfrom diffusers import AutoPipelineForText2Image, LCMScheduler\nimport torch\n\n# Use LCM for 4-8 step generation\npipe = AutoPipelineForText2Image.from_pretrained(\n    \"stabilityai\u002Fstable-diffusion-xl-base-1.0\",\n    torch_dtype=torch.float16\n).to(\"cuda\")\n\n# Load LCM LoRA for fast generation\npipe.load_lora_weights(\"latent-consistency\u002Flcm-lora-sdxl\")\npipe.scheduler = LCMScheduler.from_config(pipe.scheduler.config)\npipe.fuse_lora()\n\n# Generate in ~1 second\nimage = pipe(\n    \"A beautiful landscape\",\n    num_inference_steps=4,\n    guidance_scale=1.0\n).images[0]\n```\n\n## Common issues\n\n**CUDA out of memory:**\n```python\n# Enable memory optimizations\npipe.enable_model_cpu_offload()\npipe.enable_attention_slicing()\npipe.enable_vae_slicing()\n\n# Or use lower precision\npipe = DiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)\n```\n\n**Black\u002Fnoise images:**\n```python\n# Check VAE configuration\n# Use safety checker bypass if needed\npipe.safety_checker = None\n\n# Ensure proper dtype consistency\npipe = pipe.to(dtype=torch.float16)\n```\n\n**Slow generation:**\n```python\n# Use faster scheduler\nfrom diffusers import DPMSolverMultistepScheduler\npipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)\n\n# Reduce steps\nimage = pipe(prompt, num_inference_steps=20).images[0]\n```\n\n## References\n\n- **[Advanced Usage](references\u002Fadvanced-usage.md)** - Custom pipelines, fine-tuning, deployment\n- **[Troubleshooting](references\u002Ftroubleshooting.md)** - Common issues and solutions\n\n## Resources\n\n- **Documentation**: https:\u002F\u002Fhuggingface.co\u002Fdocs\u002Fdiffusers\n- **Repository**: https:\u002F\u002Fgithub.com\u002Fhuggingface\u002Fdiffusers\n- **Model Hub**: https:\u002F\u002Fhuggingface.co\u002Fmodels?library=diffusers\n- **Discord**: https:\u002F\u002Fdiscord.gg\u002Fdiffusers\n","# Stable Diffusion Image Generation\n\nComprehensive guide to generating images with Stable Diffusion using the HuggingFace Diffusers library.\n\n## When to use Stable Diffusion\n\n**Use Stable Diffusion when:**\n- Generating images from text descriptions\n- Performing image-to-image translation (style transfer, enhancement)\n- Inpainting (filling in masked regions)\n- Outpainting (extending images beyond boundaries)\n- Creating variations of existing images\n- Building custom image generation workflows\n\n**Key features:**\n- **Text-to-Image**: Generate images from natural language prompts\n- **Image-to-Image**: Transform existing images with text guidance\n- **Inpainting**: Fill masked regions with context-aware content\n- **ControlNet**: Add spatial conditioning (edges, poses, depth)\n- **LoRA Support**: Efficient fine-tuning and style adaptation\n- **Multiple Models**: SD 1.5, SDXL, SD 3.0, Flux support\n\n**Use alternatives instead:**\n- **DALL-E 3**: For API-based generation without GPU\n- **Midjourney**: For artistic, stylized outputs\n- **Imagen**: For Google Cloud integration\n- **Leonardo.ai**: For web-based creative workflows\n\n## Quick start\n\n### Installation\n\n```bash\npip install diffusers transformers accelerate torch\npip install xformers  # Optional: memory-efficient attention\n```\n\n### Basic text-to-image\n\n```python\nfrom diffusers import DiffusionPipeline\nimport torch\n\n# Load pipeline (auto-detects model type)\npipe = DiffusionPipeline.from_pretrained(\n    \"stable-diffusion-v1-5\u002Fstable-diffusion-v1-5\",\n    torch_dtype=torch.float16\n)\npipe.to(\"cuda\")\n\n# Generate image\nimage = pipe(\n    \"A serene mountain landscape at sunset, highly detailed\",\n    num_inference_steps=50,\n    guidance_scale=7.5\n).images[0]\n\nimage.save(\"output.png\")\n```\n\n### Using SDXL (higher quality)\n\n```python\nfrom diffusers import AutoPipelineForText2Image\nimport torch\n\npipe = AutoPipelineForText2Image.from_pretrained(\n    \"stabilityai\u002Fstable-diffusion-xl-base-1.0\",\n    torch_dtype=torch.float16,\n    variant=\"fp16\"\n)\npipe.to(\"cuda\")\n\n# Enable memory optimization\npipe.enable_model_cpu_offload()\n\nimage = pipe(\n    prompt=\"A futuristic city with flying cars, cinematic lighting\",\n    height=1024,\n    width=1024,\n    num_inference_steps=30\n).images[0]\n```\n\n## Architecture overview\n\n### Three-pillar design\n\nDiffusers is built around three core components:\n\n```\nPipeline (orchestration)\n├── Model (neural networks)\n│   ├── UNet \u002F Transformer (noise prediction)\n│   ├── VAE (latent encoding\u002Fdecoding)\n│   └── Text Encoder (CLIP\u002FT5)\n└── Scheduler (denoising algorithm)\n```\n\n### Pipeline inference flow\n\n```\nText Prompt → Text Encoder → Text Embeddings\n                                    ↓\nRandom Noise → [Denoising Loop] ← Scheduler\n                      ↓\n               Predicted Noise\n                      ↓\n              VAE Decoder → Final Image\n```\n\n## Core concepts\n\n### Pipelines\n\nPipelines orchestrate complete workflows:\n\n| Pipeline | Purpose |\n|----------|---------|\n| `StableDiffusionPipeline` | Text-to-image (SD 1.x\u002F2.x) |\n| `StableDiffusionXLPipeline` | Text-to-image (SDXL) |\n| `StableDiffusion3Pipeline` | Text-to-image (SD 3.0) |\n| `FluxPipeline` | Text-to-image (Flux models) |\n| `StableDiffusionImg2ImgPipeline` | Image-to-image |\n| `StableDiffusionInpaintPipeline` | Inpainting |\n\n### Schedulers\n\nSchedulers control the denoising process:\n\n| Scheduler | Steps | Quality | Use Case |\n|-----------|-------|---------|----------|\n| `EulerDiscreteScheduler` | 20-50 | Good | Default choice |\n| `EulerAncestralDiscreteScheduler` | 20-50 | Good | More variation |\n| `DPMSolverMultistepScheduler` | 15-25 | Excellent | Fast, high quality |\n| `DDIMScheduler` | 50-100 | Good | Deterministic |\n| `LCMScheduler` | 4-8 | Good | Very fast |\n| `UniPCMultistepScheduler` | 15-25 | Excellent | Fast convergence |\n\n### Swapping schedulers\n\n```python\nfrom diffusers import DPMSolverMultistepScheduler\n\n# Swap for faster generation\npipe.scheduler = DPMSolverMultistepScheduler.from_config(\n    pipe.scheduler.config\n)\n\n# Now generate with fewer steps\nimage = pipe(prompt, num_inference_steps=20).images[0]\n```\n\n## Generation parameters\n\n### Key parameters\n\n| Parameter | Default | Description |\n|-----------|---------|-------------|\n| `prompt` | Required | Text description of desired image |\n| `negative_prompt` | None | What to avoid in the image |\n| `num_inference_steps` | 50 | Denoising steps (more = better quality) |\n| `guidance_scale` | 7.5 | Prompt adherence (7-12 typical) |\n| `height`, `width` | 512\u002F1024 | Output dimensions (multiples of 8) |\n| `generator` | None | Torch generator for reproducibility |\n| `num_images_per_prompt` | 1 | Batch size |\n\n### Reproducible generation\n\n```python\nimport torch\n\ngenerator = torch.Generator(device=\"cuda\").manual_seed(42)\n\nimage = pipe(\n    prompt=\"A cat wearing a top hat\",\n    generator=generator,\n    num_inference_steps=50\n).images[0]\n```\n\n### Negative prompts\n\n```python\nimage = pipe(\n    prompt=\"Professional photo of a dog in a garden\",\n    negative_prompt=\"blurry, low quality, distorted, ugly, bad anatomy\",\n    guidance_scale=7.5\n).images[0]\n```\n\n## Image-to-image\n\nTransform existing images with text guidance:\n\n```python\nfrom diffusers import AutoPipelineForImage2Image\nfrom PIL import Image\n\npipe = AutoPipelineForImage2Image.from_pretrained(\n    \"stable-diffusion-v1-5\u002Fstable-diffusion-v1-5\",\n    torch_dtype=torch.float16\n).to(\"cuda\")\n\ninit_image = Image.open(\"input.jpg\").resize((512, 512))\n\nimage = pipe(\n    prompt=\"A watercolor painting of the scene\",\n    image=init_image,\n    strength=0.75,  # How much to transform (0-1)\n    num_inference_steps=50\n).images[0]\n```\n\n## Inpainting\n\nFill masked regions:\n\n```python\nfrom diffusers import AutoPipelineForInpainting\nfrom PIL import Image\n\npipe = AutoPipelineForInpainting.from_pretrained(\n    \"runwayml\u002Fstable-diffusion-inpainting\",\n    torch_dtype=torch.float16\n).to(\"cuda\")\n\nimage = Image.open(\"photo.jpg\")\nmask = Image.open(\"mask.png\")  # White = inpaint region\n\nresult = pipe(\n    prompt=\"A red car parked on the street\",\n    image=image,\n    mask_image=mask,\n    num_inference_steps=50\n).images[0]\n```\n\n## ControlNet\n\nAdd spatial conditioning for precise control:\n\n```python\nfrom diffusers import StableDiffusionControlNetPipeline, ControlNetModel\nimport torch\n\n# Load ControlNet for edge conditioning\ncontrolnet = ControlNetModel.from_pretrained(\n    \"lllyasviel\u002Fcontrol_v11p_sd15_canny\",\n    torch_dtype=torch.float16\n)\n\npipe = StableDiffusionControlNetPipeline.from_pretrained(\n    \"stable-diffusion-v1-5\u002Fstable-diffusion-v1-5\",\n    controlnet=controlnet,\n    torch_dtype=torch.float16\n).to(\"cuda\")\n\n# Use Canny edge image as control\ncontrol_image = get_canny_image(input_image)\n\nimage = pipe(\n    prompt=\"A beautiful house in the style of Van Gogh\",\n    image=control_image,\n    num_inference_steps=30\n).images[0]\n```\n\n### Available ControlNets\n\n| ControlNet | Input Type | Use Case |\n|------------|------------|----------|\n| `canny` | Edge maps | Preserve structure |\n| `openpose` | Pose skeletons | Human poses |\n| `depth` | Depth maps | 3D-aware generation |\n| `normal` | Normal maps | Surface details |\n| `mlsd` | Line segments | Architectural lines |\n| `scribble` | Rough sketches | Sketch-to-image |\n\n## LoRA adapters\n\nLoad fine-tuned style adapters:\n\n```python\nfrom diffusers import DiffusionPipeline\n\npipe = DiffusionPipeline.from_pretrained(\n    \"stable-diffusion-v1-5\u002Fstable-diffusion-v1-5\",\n    torch_dtype=torch.float16\n).to(\"cuda\")\n\n# Load LoRA weights\npipe.load_lora_weights(\"path\u002Fto\u002Flora\", weight_name=\"style.safetensors\")\n\n# Generate with LoRA style\nimage = pipe(\"A portrait in the trained style\").images[0]\n\n# Adjust LoRA strength\npipe.fuse_lora(lora_scale=0.8)\n\n# Unload LoRA\npipe.unload_lora_weights()\n```\n\n### Multiple LoRAs\n\n```python\n# Load multiple LoRAs\npipe.load_lora_weights(\"lora1\", adapter_name=\"style\")\npipe.load_lora_weights(\"lora2\", adapter_name=\"character\")\n\n# Set weights for each\npipe.set_adapters([\"style\", \"character\"], adapter_weights=[0.7, 0.5])\n\nimage = pipe(\"A portrait\").images[0]\n```\n\n## Memory optimization\n\n### Enable CPU offloading\n\n```python\n# Model CPU offload - moves models to CPU when not in use\npipe.enable_model_cpu_offload()\n\n# Sequential CPU offload - more aggressive, slower\npipe.enable_sequential_cpu_offload()\n```\n\n### Attention slicing\n\n```python\n# Reduce memory by computing attention in chunks\npipe.enable_attention_slicing()\n\n# Or specific chunk size\npipe.enable_attention_slicing(\"max\")\n```\n\n### xFormers memory-efficient attention\n\n```python\n# Requires xformers package\npipe.enable_xformers_memory_efficient_attention()\n```\n\n### VAE slicing for large images\n\n```python\n# Decode latents in tiles for large images\npipe.enable_vae_slicing()\npipe.enable_vae_tiling()\n```\n\n## Model variants\n\n### Loading different precisions\n\n```python\n# FP16 (recommended for GPU)\npipe = DiffusionPipeline.from_pretrained(\n    \"model-id\",\n    torch_dtype=torch.float16,\n    variant=\"fp16\"\n)\n\n# BF16 (better precision, requires Ampere+ GPU)\npipe = DiffusionPipeline.from_pretrained(\n    \"model-id\",\n    torch_dtype=torch.bfloat16\n)\n```\n\n### Loading specific components\n\n```python\nfrom diffusers import UNet2DConditionModel, AutoencoderKL\n\n# Load custom VAE\nvae = AutoencoderKL.from_pretrained(\"stabilityai\u002Fsd-vae-ft-mse\")\n\n# Use with pipeline\npipe = DiffusionPipeline.from_pretrained(\n    \"stable-diffusion-v1-5\u002Fstable-diffusion-v1-5\",\n    vae=vae,\n    torch_dtype=torch.float16\n)\n```\n\n## Batch generation\n\nGenerate multiple images efficiently:\n\n```python\n# Multiple prompts\nprompts = [\n    \"A cat playing piano\",\n    \"A dog reading a book\",\n    \"A bird painting a picture\"\n]\n\nimages = pipe(prompts, num_inference_steps=30).images\n\n# Multiple images per prompt\nimages = pipe(\n    \"A beautiful sunset\",\n    num_images_per_prompt=4,\n    num_inference_steps=30\n).images\n```\n\n## Common workflows\n\n### Workflow 1: High-quality generation\n\n```python\nfrom diffusers import StableDiffusionXLPipeline, DPMSolverMultistepScheduler\nimport torch\n\n# 1. Load SDXL with optimizations\npipe = StableDiffusionXLPipeline.from_pretrained(\n    \"stabilityai\u002Fstable-diffusion-xl-base-1.0\",\n    torch_dtype=torch.float16,\n    variant=\"fp16\"\n)\npipe.to(\"cuda\")\npipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)\npipe.enable_model_cpu_offload()\n\n# 2. Generate with quality settings\nimage = pipe(\n    prompt=\"A majestic lion in the savanna, golden hour lighting, 8k, detailed fur\",\n    negative_prompt=\"blurry, low quality, cartoon, anime, sketch\",\n    num_inference_steps=30,\n    guidance_scale=7.5,\n    height=1024,\n    width=1024\n).images[0]\n```\n\n### Workflow 2: Fast prototyping\n\n```python\nfrom diffusers import AutoPipelineForText2Image, LCMScheduler\nimport torch\n\n# Use LCM for 4-8 step generation\npipe = AutoPipelineForText2Image.from_pretrained(\n    \"stabilityai\u002Fstable-diffusion-xl-base-1.0\",\n    torch_dtype=torch.float16\n).to(\"cuda\")\n\n# Load LCM LoRA for fast generation\npipe.load_lora_weights(\"latent-consistency\u002Flcm-lora-sdxl\")\npipe.scheduler = LCMScheduler.from_config(pipe.scheduler.config)\npipe.fuse_lora()\n\n# Generate in ~1 second\nimage = pipe(\n    \"A beautiful landscape\",\n    num_inference_steps=4,\n    guidance_scale=1.0\n).images[0]\n```\n\n## Common issues\n\n**CUDA out of memory:**\n```python\n# Enable memory optimizations\npipe.enable_model_cpu_offload()\npipe.enable_attention_slicing()\npipe.enable_vae_slicing()\n\n# Or use lower precision\npipe = DiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)\n```\n\n**Black\u002Fnoise images:**\n```python\n# Check VAE configuration\n# Use safety checker bypass if needed\npipe.safety_checker = None\n\n# Ensure proper dtype consistency\npipe = pipe.to(dtype=torch.float16)\n```\n\n**Slow generation:**\n```python\n# Use faster scheduler\nfrom diffusers import DPMSolverMultistepScheduler\npipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)\n\n# Reduce steps\nimage = pipe(prompt, num_inference_steps=20).images[0]\n```\n\n## References\n\n- **[Advanced Usage](references\u002Fadvanced-usage.md)** - Custom pipelines, fine-tuning, deployment\n- **[Troubleshooting](references\u002Ftroubleshooting.md)** - Common issues and solutions\n\n## Resources\n\n- **Documentation**: https:\u002F\u002Fhuggingface.co\u002Fdocs\u002Fdiffusers\n- **Repository**: https:\u002F\u002Fgithub.com\u002Fhuggingface\u002Fdiffusers\n- **Model Hub**: https:\u002F\u002Fhuggingface.co\u002Fmodels?library=diffusers\n- **Discord**: https:\u002F\u002Fdiscord.gg\u002Fdiffusers\n",{"name":5,"author":48,"license":14,"version":49,"metadata":50,"description":7,"dependencies":57},"Orchestra Research","1.0.0",{"hermes":51},{"tags":52},[23,24,53,54,55,56],"Diffusers","Text-to-Image","Multimodal","Computer Vision",[58,59,60,61],"diffusers>=0.30.0","transformers>=4.41.0","accelerate>=0.31.0","torch>=2.0.0","main","17ee50c38aefa9426a89d7e8ee167fdc4c184fb7","skills\u002Fmlops\u002Fmodels\u002Fstable-diffusion",0,"https:\u002F\u002Fgithub.com\u002Fxuanxuan1983\u002Fhermes-skills-backup","https:\u002F\u002Fgithub.com\u002Fxuanxuan1983","2026-05-24 00:14:48",{"source":8,"skillName":5,"commands":70,"prompt":80,"zipAvailable":81},[71,74,77],{"tool":72,"command":73},"npx","npx skills add xuanxuan1983\u002Fhermes-skills-backup --skill stable-diffusion-image-generation",{"tool":75,"command":76},"bunx","bunx skills add xuanxuan1983\u002Fhermes-skills-backup --skill stable-diffusion-image-generation",{"tool":78,"command":79},"pnpm","pnpm dlx skills add xuanxuan1983\u002Fhermes-skills-backup --skill stable-diffusion-image-generation","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fxuanxuan1983\u002Fhermes-skills-backup\u002Fblob\u002Fmain\u002Fskills\u002Fmlops\u002Fmodels\u002Fstable-diffusion\u002FSKILL.md",true,[83,89],{"path":84,"resourceType":85,"resourceTypeDesc":86,"sizeBytes":87,"sourceHtmlUrl":88},"references\u002Fadvanced-usage.md","REFERENCE","参考文档",17690,"https:\u002F\u002Fgithub.com\u002Fxuanxuan1983\u002Fhermes-skills-backup\u002Fblob\u002Fmain\u002Fskills\u002Fmlops\u002Fmodels\u002Fstable-diffusion\u002Freferences\u002Fadvanced-usage.md",{"path":90,"resourceType":85,"resourceTypeDesc":86,"sizeBytes":91,"sourceHtmlUrl":92},"references\u002Ftroubleshooting.md",12401,"https:\u002F\u002Fgithub.com\u002Fxuanxuan1983\u002Fhermes-skills-backup\u002Fblob\u002Fmain\u002Fskills\u002Fmlops\u002Fmodels\u002Fstable-diffusion\u002Freferences\u002Ftroubleshooting.md",[94,134,162,177,199,220],{"skillNo":95,"name":96,"nameZh":6,"description":97,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":98,"categories":99,"keywords":114,"publishedAt":43},"01M71JFHVW1W4XE013TY9ZYN9P","writing-plans","Use when you have a spec or requirements for a multi-step task. Creates comprehensive implementation plans with bite-sized tasks, exact file paths, and complete code examples.","https:\u002F\u002Fgithub.com\u002Fxuanxuan1983\u002Fhermes-skills-backup\u002Fblob\u002Fmain\u002Fskills\u002Fsoftware-development\u002Fwriting-plans\u002FSKILL.md",[100,103,106,111],{"categoryNo":101,"categoryName":102,"taxonomyType":20,"taxonomyTypeDesc":21},"01JBSEEDCAT000000000000015","视觉设计",{"categoryNo":104,"categoryName":105,"taxonomyType":20,"taxonomyTypeDesc":21},"01JBSEEDCAT000000000000018","写作与文案",{"categoryNo":107,"categoryName":108,"taxonomyType":109,"taxonomyTypeDesc":110},"01JBSEEDCAT000000000000030","开发工程师","PROFESSION","适用职业",{"categoryNo":112,"categoryName":113,"taxonomyType":109,"taxonomyTypeDesc":110},"01JBSEEDCAT000000000000036","内容创作者",[115,116,117,118,119,120,121,39,122,123,124,125,126,127,128,129,130,131,132,133],"writing","writing plans","plans","test-driven","test-driven-development","superpowers","design","workflow","you","code","tasks","subagent","code-review","review","documentation","paths","planning","development","for",{"skillNo":135,"name":119,"nameZh":6,"description":136,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":137,"categories":138,"keywords":147,"publishedAt":43},"01M71JFF859RV0XGWS206X1TMB","Use when implementing any feature or bugfix, before writing implementation code. Enforces RED-GREEN-REFACTOR cycle with test-first approach.","https:\u002F\u002Fgithub.com\u002Fxuanxuan1983\u002Fhermes-skills-backup\u002Fblob\u002Fmain\u002Fskills\u002Fsoftware-development\u002Ftest-driven-development\u002FSKILL.md",[139,142,145,146],{"categoryNo":140,"categoryName":141,"taxonomyType":20,"taxonomyTypeDesc":21},"01JBSEEDCAT000000000000007","代码审查",{"categoryNo":143,"categoryName":144,"taxonomyType":20,"taxonomyTypeDesc":21},"01JBSEEDCAT000000000000008","测试与质量",{"categoryNo":104,"categoryName":105,"taxonomyType":20,"taxonomyTypeDesc":21},{"categoryNo":112,"categoryName":113,"taxonomyType":109,"taxonomyTypeDesc":110},[148,132,149,150,151,152,153,154,155,156,120,115,157,39,124,126,158,159,160,161],"test driven development","test","driven","test-first","green","cycle","red-green-refactor","testing","implementing","debugging","systematic","bugfix","refactor","systematic-debugging",{"skillNo":163,"name":161,"nameZh":6,"description":164,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":165,"categories":166,"keywords":168,"publishedAt":43},"01M71JFCA5S48PZ5M7DG31R8K5","Use when encountering any bug, test failure, or unexpected behavior. 4-phase root cause investigation — NO fixes without understanding the problem first.","https:\u002F\u002Fgithub.com\u002Fxuanxuan1983\u002Fhermes-skills-backup\u002Fblob\u002Fmain\u002Fskills\u002Fsoftware-development\u002Fsystematic-debugging\u002FSKILL.md",[167],{"categoryNo":143,"categoryName":144,"taxonomyType":20,"taxonomyTypeDesc":21},[169,157,158,118,170,171,119,120,115,39,126,172,173,132,174,175,117,30,176,149],"systematic debugging","problem","problem-solving","phase","bug","fixes","root cause","root-cause",{"skillNo":178,"name":179,"nameZh":6,"description":180,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":181,"categories":182,"keywords":192,"publishedAt":43},"01M71JF9RQ092KM5ZXCBBT6FS1","subagent-driven-development","Use when executing implementation plans with independent tasks. Dispatches fresh delegate_task per task with two-stage review (spec compliance then code quality).","https:\u002F\u002Fgithub.com\u002Fxuanxuan1983\u002Fhermes-skills-backup\u002Fblob\u002Fmain\u002Fskills\u002Fsoftware-development\u002Fsubagent-driven-development\u002FSKILL.md",[183,184,187,188,189],{"categoryNo":104,"categoryName":105,"taxonomyType":20,"taxonomyTypeDesc":21},{"categoryNo":185,"categoryName":186,"taxonomyType":20,"taxonomyTypeDesc":21},"01JBSEEDCAT000000000000023","Skill与智能体开发",{"categoryNo":107,"categoryName":108,"taxonomyType":109,"taxonomyTypeDesc":110},{"categoryNo":112,"categoryName":113,"taxonomyType":109,"taxonomyTypeDesc":110},{"categoryNo":190,"categoryName":191,"taxonomyType":109,"taxonomyTypeDesc":110},"01JBSEEDCAT000000000000037","律师与法务",[193,126,132,150,118,119,194,195,120,115,39,122,124,125,127,128,196,197,198,117],"subagent driven development","delegate","delegation","fresh","parallel","code quality",{"skillNo":200,"name":201,"nameZh":6,"description":202,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":203,"categories":204,"keywords":207,"publishedAt":43},"01M71JF76DA8ARZ4JRYR4VBRWM","requesting-code-review","Pre-commit verification pipeline — static security scan, baseline-aware quality gates, independent reviewer subagent, and auto-fix loop. Use after code changes and before committing, pushing, or opening a PR.","https:\u002F\u002Fgithub.com\u002Fxuanxuan1983\u002Fhermes-skills-backup\u002Fblob\u002Fmain\u002Fskills\u002Fsoftware-development\u002Frequesting-code-review\u002FSKILL.md",[205,206],{"categoryNo":140,"categoryName":141,"taxonomyType":20,"taxonomyTypeDesc":21},{"categoryNo":107,"categoryName":108,"taxonomyType":109,"taxonomyTypeDesc":110},[208,209,124,128,118,210,211,119,212,213,120,214,115,215,216,217,126,127,218,219],"code review","requesting code review","pipeline","static","fix","auto-fix","auto","loop","security scan","commit","reviewer","verification",{"skillNo":221,"name":222,"nameZh":6,"description":223,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":224,"categories":225,"keywords":226,"publishedAt":43},"01M71JF52HZT5VQXFVF9K2H76K","plan","Plan mode for Hermes — inspect context, write a markdown plan into the active workspace's `.hermes\u002Fplans\u002F` directory, and do not execute the work.","https:\u002F\u002Fgithub.com\u002Fxuanxuan1983\u002Fhermes-skills-backup\u002Fblob\u002Fmain\u002Fskills\u002Fsoftware-development\u002Fplan\u002FSKILL.md",[],[222,227,228,131,132,133,229,230,117,115,122,126,231,232,233,234,235,236,237,238],"plan-mode","do","inspect","mode","work","markdown","active","directory","workspace","plan mode","write","implementation"]