[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6QNJBHTF31MTYG49JBWTC1T":3,"skill-same:01M6QNJBHTF31MTYG49JBWTC1T":95},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":23,"publishedAt":44,"linkOnly":45,"markdownContent":46,"markdownBody":47,"frontMatter":48,"refName":62,"commitSha":63,"skillDirectory":64,"forksCount":14,"repositoryHtmlUrl":65,"repositoryHomepageUrl":66,"ownerHtmlUrl":67,"ownerBlogUrl":68,"ownerDescription":69,"updatedAt":70,"install":71,"resources":84},"01M6QNJBHTF31MTYG49JBWTC1T","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.","Tashima-Tarsh\u002FDisha6.6","Tashima-Tarsh","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F269906498?v=4","01M6PBH98X03XERH0HFT4PFB1P","NITISH KUMAR","01M6PBH9DA0M6KM3Z12P848F0K",0,"MIT","https:\u002F\u002Fgithub.com\u002FTashima-Tarsh\u002FDisha6.6\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fqc-stable-diffusion\u002FSKILL.md",[18],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000016","图像与多媒体","SCENARIO","使用场景",[24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43],"diffusion","generation","Image Generation","Stable Diffusion","stable diffusion image generation","image","pipelines","custom","Accelerate","translation","models","Art","images","use","text","Transformers","HuggingFace","multimodal","state","research","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\ntags: [Image Generation, Stable Diffusion, Diffusers, Text-to-Image, Multimodal, Computer Vision]\ndependencies: [diffusers>=0.30.0, transformers>=4.41.0, accelerate>=0.31.0, torch>=2.0.0]\ncategory: \"ai-research\"\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,"tags":49,"author":54,"license":15,"version":55,"category":56,"description":7,"dependencies":57},[26,27,50,51,52,53],"Diffusers","Text-to-Image","Multimodal","Computer Vision","Orchestra Research","1.0.0","ai-research",[58,59,60,61],"diffusers>=0.30.0","transformers>=4.41.0","accelerate>=0.31.0","torch>=2.0.0","main","0da4485785ee599388900be50db1635489d53056",".agents\u002Fskills\u002Fqc-stable-diffusion","https:\u002F\u002Fgithub.com\u002FTashima-Tarsh\u002FDisha6.6","https:\u002F\u002Fdisha6.6.thenitishkr.in\u002F","https:\u002F\u002Fgithub.com\u002FTashima-Tarsh","www.thenitishkr","thenitishkr | AI • Cyber-security • Research\r\n","2026-11-08 03:33:25",{"source":8,"skillName":5,"commands":72,"prompt":82,"zipAvailable":83},[73,76,79],{"tool":74,"command":75},"npx","npx skills add Tashima-Tarsh\u002FDisha6.6 --skill stable-diffusion-image-generation",{"tool":77,"command":78},"bunx","bunx skills add Tashima-Tarsh\u002FDisha6.6 --skill stable-diffusion-image-generation",{"tool":80,"command":81},"pnpm","pnpm dlx skills add Tashima-Tarsh\u002FDisha6.6 --skill stable-diffusion-image-generation","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FTashima-Tarsh\u002FDisha6.6\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fqc-stable-diffusion\u002FSKILL.md",true,[85,91],{"path":86,"resourceType":87,"resourceTypeDesc":88,"sizeBytes":89,"sourceHtmlUrl":90},"references\u002Fadvanced-usage.md","REFERENCE","参考文档",17690,"https:\u002F\u002Fgithub.com\u002FTashima-Tarsh\u002FDisha6.6\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fqc-stable-diffusion\u002Freferences\u002Fadvanced-usage.md",{"path":92,"resourceType":87,"resourceTypeDesc":88,"sizeBytes":93,"sourceHtmlUrl":94},"references\u002Ftroubleshooting.md",12401,"https:\u002F\u002Fgithub.com\u002FTashima-Tarsh\u002FDisha6.6\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fqc-stable-diffusion\u002Freferences\u002Ftroubleshooting.md",[96,124,147,174,199,223],{"skillNo":97,"name":98,"nameZh":6,"description":99,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":100,"categories":101,"keywords":103,"publishedAt":44},"01M6QRD07D4TGNDK6VJ4EHF8BV","youtube-full","Use when the user needs YouTube transcripts, video search, channel browsing, playlist extraction, or content monitoring. Trigger phrases: 'get the transcript for', 'search YouTube for', 'what are the latest videos on', 'list this playlist', 'monitor this channel', or any request involving a YouTube URL, video ID, or @handle. Do NOT use for downloading video or audio files, YouTube engagement data (likes, comments), or private\u002Fage-restricted videos.","https:\u002F\u002Fgithub.com\u002FTashima-Tarsh\u002FDisha6.6\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fyoutube-full\u002FSKILL.md",[102],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},[104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123],"youtube full","youtube","full","transcript","search","monitoring","data","Video","Audio","list","files","do","get","age","trigger","URL","for","browsing","request","youtube transcripts",{"skillNo":125,"name":126,"nameZh":6,"description":127,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":128,"categories":129,"keywords":130,"publishedAt":44},"01M6QRCJ3112VYPA97YG7KGMC2","x-twitter-growth","X\u002FTwitter growth engine for building audience, crafting viral content, and analyzing engagement. Use when the user wants to grow on X\u002FTwitter, write tweets or threads, analyze their X profile, research competitors on X, plan a posting strategy, or optimize engagement. Complements social-content (generic multi-platform) with X-specific depth: algorithm mechanics, thread engineering, reply strategy, profile optimization, and competitive intelligence via web search.","https:\u002F\u002Fgithub.com\u002FTashima-Tarsh\u002FDisha6.6\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fx-twitter-growth\u002FSKILL.md",[],[131,132,133,43,108,134,135,136,137,138,139,140,141,142,37,143,144,145,146,120],"twitter","x twitter growth","growth","content","engineering","plan","web search","competitors","analyze","engine","write","strategy","platform","grow","posting","competitive",{"skillNo":148,"name":149,"nameZh":6,"description":150,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":151,"categories":152,"keywords":156,"publishedAt":44},"01M6QRBN3EHQNJY42RERP7A149","write-a-skill","Create new agent skills with proper structure, progressive disclosure, and bundled resources. Use when user wants to create, write, build, or author a new skill.","https:\u002F\u002Fgithub.com\u002FTashima-Tarsh\u002FDisha6.6\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fwrite-a-skill\u002FSKILL.md",[153],{"categoryNo":154,"categoryName":155,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000023","Skill与智能体开发",[157,141,158,159,160,161,162,163,37,164,165,62,166,167,168,169,170,171,172,173],"write a skill","github","create","https","productivity","matt pocock","direct","example","build","new skill","structure","new agent","resources","with","tree","progressive disclosure","author",{"skillNo":175,"name":176,"nameZh":6,"description":177,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":178,"categories":179,"keywords":180,"publishedAt":44},"01M6QRB6G8P33PNGAF9Y69EJ9T","wrap-up","Close out a launched Claude Managed Agent — recap every primitive the founder now owns, regenerate the single-file overview page, and suggest the next 1-2 upgrades. Use when the user says \"wrap up\", \"close this out\", \"what do I own now\", \"give me the summary\", \"recap the agent\", or when the orchestrator routes phase=wrap-up. primitives_inventory.py tables everything owned (agent, environment, session, memory, outcome, deployment); overview_page.py regenerates a self-contained .\u002Fmy-agent\u002Fagent-overview.html; upgrade_suggester.py ranks the next moves from recorded deferrals plus standing hardening steps. Companion to run-without-you; the last stop before phase=done.","https:\u002F\u002Fgithub.com\u002FTashima-Tarsh\u002FDisha6.6\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fwrap-up\u002FSKILL.md",[],[181,182,183,184,185,186,187,188,189,37,190,115,191,192,193,194,195,196,197,198],"wrap up","up","wrap","gemini","deployment","run","file","hardening","closeout","stop","upgrade","founder","close","companion","you","tables","directions","phase",{"skillNo":200,"name":201,"nameZh":6,"description":202,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":203,"categories":204,"keywords":206,"publishedAt":44},"01M6QRA5AYC1RBFZ39GTWGS3N8","workflow-builder","Design and write deterministic multi-agent workflow scripts (.js files in .claude\u002Fworkflows\u002F) for Claude Code's Workflow tool. Use when a user wants to build, create, author, scaffold, or run a custom Claude Code workflow, orchestrate sub-agents (fan-out, pipeline, loop, judge-panel), or automate a repeatable multi-step task across fresh-context agents.","https:\u002F\u002Fgithub.com\u002FTashima-Tarsh\u002FDisha6.6\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fworkflow-builder\u002FSKILL.md",[205],{"categoryNo":154,"categoryName":155,"taxonomyType":21,"taxonomyTypeDesc":22},[207,208,209,210,211,159,186,212,213,214,215,216,141,217,114,218,219,220,221,222],"workflow","workflow builder","builder","design","workflows","code","orchestrate","pipeline","loop","multi-agent","context","across","fresh","scripts","judge","claude code workflow",{"skillNo":224,"name":225,"nameZh":6,"description":226,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":227,"categories":228,"keywords":229,"publishedAt":44},"01M6QR7QMCZESKQA0ERW1E657M","weekly-review","Use when someone wants to run a weekly review, close open loops, audit stalled projects and commitments, get their system back to trusted, restart a lapsed review habit, or says \"\u002Fcs:weekly-review\". Walks David Allen's three-phase loop — GET CLEAR, GET CURRENT, GET CREATIVE — with deterministic scripts that inventory open loops, gate the checklist with named gaps, and score commitment health 0-100.","https:\u002F\u002Fgithub.com\u002FTashima-Tarsh\u002FDisha6.6\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fweekly-review\u002FSKILL.md",[],[230,231,232,233,234,235,236,237,238,215,239,240,241,242,243,244,116,245,246,198],"review","weekly review","weekly","deterministic scripts","reflect","feeds","inventory","open","team","projects","project-management","scanner","conversation","back","project","sprint","cadence"]