stable-diffusion-image-generation

Generate images from text prompts using Stable Diffusion models via HuggingFace Diffusers.

Updated Oct 7, 2022
One-click install
npx skills add https://github.com/tamagusko/linux-cfg --skill stable-diffusion-image-generation-tamagusko
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: stable-diffusion-image-generation
Source: https://github.com/tamagusko/linux-cfg/tree/main/dotfiles/claude/skills/stable-diffusion
Command: npx skills add https://github.com/tamagusko/linux-cfg --skill stable-diffusion-image-generation-tamagusko

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires diffusers, transformers, accelerate, torch, and includes references (resource) components.

What problem does it solve? Running Stable Diffusion locally involves many moving parts—pipelines, schedulers, VAEs, ControlNets, LoRA adapters, and GPU memory constraints. This Skill provides working code patterns and troubleshooting guidance so you can generate, transform, and deploy diffusion-based images without piecing together documentation from scratch. ## Core Features & Use Cases - Text-to-Image Generation: Produce images from prompts with SD 1.5, SDXL, SD 3.0, or Flux, with control over steps, guidance scale, seeds, and negative prompts. - Image Transformation: Perform image-to-image translation, inpainting of masked regions, and ControlNet-conditioned generation using edges, poses, or depth maps. - Optimization & Deployment: Apply LoRA adapters, memory optimizations (CPU offload, attention slicing, xFormers), and deploy generation as a FastAPI service with Docker and Kubernetes. - Use Case: A researcher needs to generate 50 variations of a product concept image. Using the batch generation and reproducible seed patterns, they produce consistent outputs on a single GPU with memory offloading enabled. ## Quick Start Ask the AI to write a Python script using Diffusers that loads stable-diffusion-v1-5 in float16 and generates an image from your prompt saved as output.png.

Frequently Asked Questions about stable-diffusion-image-generation

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I generate images with Stable Diffusion in Python?

Load a DiffusionPipeline from a pretrained model like stable-diffusion-v1-5 with torch_dtype float16, move it to CUDA, then call it with a prompt, num_inference_steps, and guidance_scale. The returned images list contains PIL images you can save directly.

What is the difference between SD 1.5, SDXL, and Flux pipelines?

SD 1.5 generates 512x512 images with lower VRAM needs, SDXL produces higher-quality 1024x1024 images, and Flux is a newer transformer-based model. Diffusers auto-detects the model type when loading with DiffusionPipeline.from_pretrained.

How do I fix CUDA out of memory errors in Diffusers?

Enable model CPU offloading with pipe.enable_model_cpu_offload(), add attention slicing and VAE slicing, or load the model in float16 precision. Reducing image resolution and batch size also lowers VRAM consumption.

Does Stable Diffusion support LoRA fine-tuning adapters?

Yes, load LoRA weights with pipe.load_lora_weights() and adjust strength via fuse_lora or set_adapters. Multiple LoRAs can be combined by assigning adapter names and weights, and unloaded with unload_lora_weights.

Why are my Stable Diffusion images black or noisy?

Black images often come from the safety checker or VAE dtype mismatches—try disabling the safety checker or keeping the VAE in float32. Noisy outputs usually mean too few inference steps or a misconfigured scheduler.

How do I use ControlNet for pose or edge conditioning?

Load a ControlNetModel such as control_v11p_sd15_canny alongside a StableDiffusionControlNetPipeline, then pass a preprocessed control image (canny edges, poses, or depth maps) with your prompt. Adjust controlnet_conditioning_scale to control influence strength.