[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M71PR780EE0FEWT6FP0X7G3H":3,"skill-same:01M71PR780EE0FEWT6FP0X7G3H":92},{"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":13,"repositoryHtmlUrl":65,"repositoryHomepageUrl":6,"ownerHtmlUrl":66,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":67,"install":68,"resources":81},"01M71PR780EE0FEWT6FP0X7G3H","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.","gjbvsjjvgm-sketch\u002FWORM_V2_SOVEREIGN","gjbvsjjvgm-sketch","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F278511911?v=4","01M71F3JXKZQ70H2KCHHTXKZDA","01M71PENEVFN19DBZFNHJPCHQ7",0,"MIT","https:\u002F\u002Fgithub.com\u002Fgjbvsjjvgm-sketch\u002FWORM_V2_SOVEREIGN\u002Fblob\u002Fmain\u002Fcore\u002Fhermes-agent\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 13:02:02",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","6746276ba18cb774853eb61b3b9399658bc9bc5c","core\u002Fhermes-agent\u002Fskills\u002Fmlops\u002Fmodels\u002Fstable-diffusion","https:\u002F\u002Fgithub.com\u002Fgjbvsjjvgm-sketch\u002FWORM_V2_SOVEREIGN","https:\u002F\u002Fgithub.com\u002Fgjbvsjjvgm-sketch","2026-04-28 17:01:03",{"source":8,"skillName":5,"commands":69,"prompt":79,"zipAvailable":80},[70,73,76],{"tool":71,"command":72},"npx","npx skills add gjbvsjjvgm-sketch\u002FWORM_V2_SOVEREIGN --skill stable-diffusion-image-generation",{"tool":74,"command":75},"bunx","bunx skills add gjbvsjjvgm-sketch\u002FWORM_V2_SOVEREIGN --skill stable-diffusion-image-generation",{"tool":77,"command":78},"pnpm","pnpm dlx skills add gjbvsjjvgm-sketch\u002FWORM_V2_SOVEREIGN --skill stable-diffusion-image-generation","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fgjbvsjjvgm-sketch\u002FWORM_V2_SOVEREIGN\u002Fblob\u002Fmain\u002Fcore\u002Fhermes-agent\u002Fskills\u002Fmlops\u002Fmodels\u002Fstable-diffusion\u002FSKILL.md",true,[82,88],{"path":83,"resourceType":84,"resourceTypeDesc":85,"sizeBytes":86,"sourceHtmlUrl":87},"references\u002Fadvanced-usage.md","REFERENCE","参考文档",17690,"https:\u002F\u002Fgithub.com\u002Fgjbvsjjvgm-sketch\u002FWORM_V2_SOVEREIGN\u002Fblob\u002Fmain\u002Fcore\u002Fhermes-agent\u002Fskills\u002Fmlops\u002Fmodels\u002Fstable-diffusion\u002Freferences\u002Fadvanced-usage.md",{"path":89,"resourceType":84,"resourceTypeDesc":85,"sizeBytes":90,"sourceHtmlUrl":91},"references\u002Ftroubleshooting.md",12401,"https:\u002F\u002Fgithub.com\u002Fgjbvsjjvgm-sketch\u002FWORM_V2_SOVEREIGN\u002Fblob\u002Fmain\u002Fcore\u002Fhermes-agent\u002Fskills\u002Fmlops\u002Fmodels\u002Fstable-diffusion\u002Freferences\u002Ftroubleshooting.md",[93,134,159,176,195,214],{"skillNo":94,"name":95,"nameZh":6,"description":96,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":97,"categories":98,"keywords":113,"publishedAt":43},"01M71QG27G1R2H2ZWEG4S0WTZT","writing-plans","Write implementation plans: bite-sized tasks, paths, code.","https:\u002F\u002Fgithub.com\u002Fgjbvsjjvgm-sketch\u002FWORM_V2_SOVEREIGN\u002Fblob\u002Fmain\u002Fcore\u002Fskills\u002Fsoftware-development\u002Fwriting-plans\u002FSKILL.md",[99,102,105,110],{"categoryNo":100,"categoryName":101,"taxonomyType":20,"taxonomyTypeDesc":21},"01JBSEEDCAT000000000000015","视觉设计",{"categoryNo":103,"categoryName":104,"taxonomyType":20,"taxonomyTypeDesc":21},"01JBSEEDCAT000000000000018","写作与文案",{"categoryNo":106,"categoryName":107,"taxonomyType":108,"taxonomyTypeDesc":109},"01JBSEEDCAT000000000000030","开发工程师","PROFESSION","适用职业",{"categoryNo":111,"categoryName":112,"taxonomyType":108,"taxonomyTypeDesc":109},"01JBSEEDCAT000000000000036","内容创作者",[114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133],"writing","writing plans","plans","test-driven","test-driven-development","superpowers","design","workflow","code","tasks","subagent","code-review","review","documentation","write","paths","planning","development","test","implementation",{"skillNo":135,"name":118,"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":145,"publishedAt":43},"01M71QFZYRTJXMAE551MRAKZ14","TDD: enforce RED-GREEN-REFACTOR, tests before code.","https:\u002F\u002Fgithub.com\u002Fgjbvsjjvgm-sketch\u002FWORM_V2_SOVEREIGN\u002Fblob\u002Fmain\u002Fcore\u002Fskills\u002Fsoftware-development\u002Ftest-driven-development\u002FSKILL.md",[139,142],{"categoryNo":140,"categoryName":141,"taxonomyType":20,"taxonomyTypeDesc":21},"01JBSEEDCAT000000000000007","代码审查",{"categoryNo":143,"categoryName":144,"taxonomyType":20,"taxonomyTypeDesc":21},"01JBSEEDCAT000000000000008","测试与质量",[146,131,132,147,148,149,150,119,114,151,122,124,152,153,154,155,156,116,157,158],"test driven development","driven","green","red-green-refactor","testing","debugging","systematic","refactor","systematic-debugging","enforce","tests","tdd","quality",{"skillNo":160,"name":154,"nameZh":6,"description":161,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":162,"categories":163,"keywords":165,"publishedAt":43},"01M71QFWR5Q8EYEQ6MCS3SM6MC","4-phase root cause debugging: understand bugs before fixing.","https:\u002F\u002Fgithub.com\u002Fgjbvsjjvgm-sketch\u002FWORM_V2_SOVEREIGN\u002Fblob\u002Fmain\u002Fcore\u002Fskills\u002Fsoftware-development\u002Fsystematic-debugging\u002FSKILL.md",[164],{"categoryNo":143,"categoryName":144,"taxonomyType":20,"taxonomyTypeDesc":21},[166,151,152,117,167,168,118,119,114,124,169,170,131,171,116,172,132,173,174,175],"systematic debugging","problem","problem-solving","phase","bugs","root cause","root-cause","investigation","understand","hermes",{"skillNo":177,"name":178,"nameZh":6,"description":179,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":180,"categories":181,"keywords":187,"publishedAt":43},"01M71QFS9S04MD8JP747W5WM0N","subagent-driven-development","Execute plans via delegate_task subagents (2-stage review).","https:\u002F\u002Fgithub.com\u002Fgjbvsjjvgm-sketch\u002FWORM_V2_SOVEREIGN\u002Fblob\u002Fmain\u002Fcore\u002Fskills\u002Fsoftware-development\u002Fsubagent-driven-development\u002FSKILL.md",[182,183,186],{"categoryNo":103,"categoryName":104,"taxonomyType":20,"taxonomyTypeDesc":21},{"categoryNo":184,"categoryName":185,"taxonomyType":20,"taxonomyTypeDesc":21},"01JBSEEDCAT000000000000023","Skill与智能体开发",{"categoryNo":111,"categoryName":112,"taxonomyType":108,"taxonomyTypeDesc":109},[188,124,131,147,117,118,189,190,119,114,121,122,125,126,191,192,116,193,194,132],"subagent driven development","delegate","delegation","subagents","parallel","stage","task",{"skillNo":196,"name":197,"nameZh":6,"description":198,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":199,"categories":200,"keywords":203,"publishedAt":43},"01M71QFQ1DBCVAZ511MXFE6T2V","requesting-code-review","Pre-commit review: security scan, quality gates, auto-fix.","https:\u002F\u002Fgithub.com\u002Fgjbvsjjvgm-sketch\u002FWORM_V2_SOVEREIGN\u002Fblob\u002Fmain\u002Fcore\u002Fskills\u002Fsoftware-development\u002Frequesting-code-review\u002FSKILL.md",[201,202],{"categoryNo":140,"categoryName":141,"taxonomyType":20,"taxonomyTypeDesc":21},{"categoryNo":106,"categoryName":107,"taxonomyType":108,"taxonomyTypeDesc":109},[204,205,122,126,117,118,206,207,119,208,114,209,210,124,125,211,212,131,213,116],"code review","requesting code review","fix","auto-fix","auto","security scan","commit","verification","security","scan",{"skillNo":215,"name":216,"nameZh":6,"description":217,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":218,"categories":219,"keywords":221,"publishedAt":43},"01M71QFM7KWM540YR67FRN807Q","python-debugpy","Debug Python: pdb REPL + debugpy remote (DAP).","https:\u002F\u002Fgithub.com\u002Fgjbvsjjvgm-sketch\u002FWORM_V2_SOVEREIGN\u002Fblob\u002Fmain\u002Fcore\u002Fskills\u002Fsoftware-development\u002Fpython-debugpy\u002FSKILL.md",[220],{"categoryNo":106,"categoryName":107,"taxonomyType":108,"taxonomyTypeDesc":109},[222,223,224,225,226,227,228,229,151,152,230,231,232,154,233,234,235,236,175,237],"debugpy","python debugpy","python","dap","inspect","post-mortem","pdb","remote","debugger","node","commands","debug","post","breakpoints","node-inspect","tui"]