Stable Diffusion image maker

Share your image task and setup. Get local code, clear steps and help with errors while safety checks stay on.

This is taking longer than expected.

Try againBrowse the library
AI Blocks

AI Blocks › Make images and art

Stable Diffusion image maker

Share your image task and setup. Get local code, clear steps and help with errors while safety checks stay on.

Get code to make or edit images with Stable Diffusion on your own machine. Keep safety checks on.

Free · No account · MIT licence · Made by Orchestra Research · Thinking: low · Tested · Updated 28 Oct 2026

What you get

What goes in

  • A text description of the picture you want
  • A source photo (optional)
  • A mask image marking the area to change (optional)
  • A style or model preference, such as SDXL (optional)

Before you start

  • A computer with a graphics card (GPU) that can run Python
  • Python with the diffusers, transformers, accelerate and torch packages
  • An AI that can run code, or you run the code yourself

What comes out

  • Install steps: The pip commands to set up the packages, with an optional memory-saving add-on.
  • Text-to-image code: A Python script that turns your prompt into an image and saves it as output.png.
  • SDXL version: A higher quality script that makes 1024 by 1024 images and saves memory.
  • Image-to-image and inpainting code: Scripts to restyle a photo or refill a masked area.
  • ControlNet and LoRA options: Code to guide a picture by edges, pose or depth, and to add a style.
  • Fixes for common problems: Code to handle out-of-memory errors, black images and slow runs.

Is it for you?

Use it when

  • You want pictures from a text prompt on your own machine.
  • You need to change part of a photo and keep the rest.
  • You want to guide a picture using a pose or an outline.

Skip it when

  • You have no graphics card or Python: use a hosted tool like DALL-E 3 or Leonardo.ai, which run in a browser or by API.
  • You want artistic, stylized pictures with no setup: use Midjourney.
  • You need a quick edit of one photo with no code: use a simple photo editor.

Fill it in

Add what this task works from, then copy the request.

  • A text description or a source image
  • A mask for the area to change (optional)
  • A computer with a GPU and Python. Know your GPU model and Python version before you start.
  • A style or model preference (optional)

Run it

Download the complete instructions and supporting files. Add them to Claude, ChatGPT or Gemini once, then ask for it by name in any chat. Pasting the instructions into a chat works too.

Download all files

Before and after this skill

Choose the steps you need. Bring your own material when you have it.

Before

Bring the material listed under Fill it in.

This skill

Stable Diffusion image maker

Open builder

After

Source dates and checks · details need a check

Each record covers the named details. Review the full instructions and current sources before using changing rules or APIs.

  • Not independently checked

    Current details in the cited vendor or regulator documentation have no independent check recorded here.

    Source 1 · Source 2

Details

From Orchestra Research. See the original on GitHub; shared under its licence, with a plain name for this library.

What it does

Images made from a text description, edits to your own photos, or code for your own image pipeline. The skill uses the Hugging Face Diffusers library with Stable Diffusion models, including SDXL and Flux. It covers text-to-image, image-to-image for changing style or quality, inpainting to refill a masked area, and outpainting to extend a picture. It adds ControlNet for guiding by edges, pose or depth, and LoRA for style tuning. It writes the Python and install steps. You need a computer with a capable graphics card and some Python knowledge. If you want no GPU, it points to hosted options.

What goes in and out

You give it

  • A text description or a source image
  • A mask for the area to change (optional)
  • A computer with a GPU and Python. Know your GPU model and Python version before you start.
  • A style or model preference (optional)

You get

  • Python code that generates images
  • Install steps
  • Image-to-image and inpainting setups
  • ControlNet and style tuning options

Use it when

  • You want pictures from a text prompt on your own machine.
  • You need to change part of a photo and keep the rest.
  • You want to guide a picture using a pose or an outline.
  • You are building a custom image generation pipeline.

More for Make images and art

Every make images and art skill

Full instructions

  • Check that you have a computer with a graphics card and Python. If not, pick a hosted tool instead.
  • Open Claude, ChatGPT or Gemini and paste this skill. Then describe the picture you want, or attach your photo.
  • Install the packages your AI lists, starting with the pip install line for diffusers, transformers, accelerate and torch.
  • Run the text-to-image code your AI gives you. The image is saved as output.png in the folder where you run it.
  • If you see an out-of-memory error, ask your AI for the memory settings in this skill and run again.
  • Before you use an image for business, check the licence of the model you chose. Then try image-to-image, inpainting or ControlNet to refine it. Check output.png first, and make small changes to the prompt and run it again until it looks right.

Full instruction file

Stable Diffusion Image Generation

Comprehensive guide to generating images with Stable Diffusion using the HuggingFace Diffusers library.

Before you start

Use the material below to do this job. If facts or tool access are missing, explain what you can finish and what must wait.

What you need (use your own material or the linked skill):

  • Your question (yours): the decision or problem, and what a good outcome looks like.

How to start:

  1. Look first. Use what they've already attached, pasted or put in their about-me note. In a coding assistant with file access, look in the project too for these by name.
  2. Check what's missing. Look for your question. They can attach files, paste the details, or share a file path your assistant can read. Ask only for missing facts that change the result. If they ask you to start with what they have, complete the parts you can and mark the gaps.
  3. Do the job. Follow the skill below with the facts and tools you have. Mark each gap with MISSING: where it belongs and never invent a fact to fill it.
When to use Stable Diffusion

Use Stable Diffusion when:

  • Generating images from text descriptions
  • Performing image-to-image translation (style transfer, enhancement)
  • Inpainting (filling in masked regions)
  • Outpainting (extending images beyond boundaries)
  • Creating variations of existing images
  • Building custom image generation workflows

Key features:

  • Text-to-Image: Generate images from natural language prompts
  • Image-to-Image: Transform existing images with text guidance
  • Inpainting: Fill masked regions with context-aware content
  • ControlNet: Add spatial conditioning (edges, poses, depth)
  • LoRA Support: Efficient fine-tuning and style adaptation
  • Multiple Models: SD 1.5, SDXL, SD 3.0, Flux support

Use alternatives instead:

  • DALL-E 3: For API-based generation without GPU
  • Midjourney: For artistic, stylized outputs
  • Imagen: For Google Cloud integration
  • Leonardo.ai: For web-based creative workflows
Quick start
Installation
pip install diffusers transformers accelerate torch
pip install xformers  # Optional: memory-efficient attention
Basic text-to-image
from diffusers import DiffusionPipeline
import torch

# Load pipeline (auto-detects model type)
pipe = DiffusionPipeline.from_pretrained(
    "stable-diffusion-v1-5/stable-diffusion-v1-5",
    torch_dtype=torch.float16
)
pipe.to("cuda")

# Generate image
image = pipe(
    "A serene mountain landscape at sunset, highly detailed",
    num_inference_steps=50,
    guidance_scale=7.5
).images[0]

image.save("output.png")
Using SDXL (higher quality)
from diffusers import AutoPipelineForText2Image
import torch

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

# Enable memory optimization
pipe.enable_model_cpu_offload()

image = pipe(
    prompt="A futuristic city with flying cars, cinematic lighting",
    height=1024,
    width=1024,
    num_inference_steps=30
).images[0]
Architecture overview
Three-pillar design

Diffusers is built around three core components:

Pipeline (orchestration)
├── Model (neural networks)
│   ├── UNet / Transformer (noise prediction)
│   ├── VAE (latent encoding/decoding)
│   └── Text Encoder (CLIP/T5)
└── Scheduler (denoising algorithm)
Pipeline inference flow
Text Prompt → Text Encoder → Text Embeddings
                                    ↓
Random Noise → [Denoising Loop] ← Scheduler
                      ↓
               Predicted Noise
                      ↓
              VAE Decoder → Final Image
Core concepts
Pipelines

Pipelines orchestrate complete workflows:

Pipeline Purpose
StableDiffusionPipeline Text-to-image (SD 1.x/2.x)
StableDiffusionXLPipeline Text-to-image (SDXL)
StableDiffusion3Pipeline Text-to-image (SD 3.0)
FluxPipeline Text-to-image (Flux models)
StableDiffusionImg2ImgPipeline Image-to-image
StableDiffusionInpaintPipeline Inpainting
Schedulers

Schedulers control the denoising process:

Scheduler Steps Quality Use Case
EulerDiscreteScheduler 20-50 Good Default choice
EulerAncestralDiscreteScheduler 20-50 Good More variation
DPMSolverMultistepScheduler 15-25 Excellent Fast, high quality
DDIMScheduler 50-100 Good Deterministic
LCMScheduler 4-8 Good Very fast
UniPCMultistepScheduler 15-25 Excellent Fast convergence
Swapping schedulers
from diffusers import DPMSolverMultistepScheduler

# Swap for faster generation
pipe.scheduler = DPMSolverMultistepScheduler.from_config(
    pipe.scheduler.config
)

# Now generate with fewer steps
image = pipe(prompt, num_inference_steps=20).images[0]
Generation parameters
Key parameters
Parameter Default Description
prompt Required Text description of desired image
negative_prompt None What to avoid in the image
num_inference_steps 50 Denoising steps (more = better quality)
guidance_scale 7.5 Prompt adherence (7-12 typical)
height, width 512/1024 Output dimensions (multiples of 8)
generator None Torch generator for reproducibility
num_images_per_prompt 1 Batch size
Reproducible generation
import torch

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

image = pipe(
    prompt="A cat wearing a top hat",
    generator=generator,
    num_inference_steps=50
).images[0]
Negative prompts
image = pipe(
    prompt="Professional photo of a dog in a garden",
    negative_prompt="blurry, low quality, distorted, ugly, bad anatomy",
    guidance_scale=7.5
).images[0]
Image-to-image

Transform existing images with text guidance:

from diffusers import AutoPipelineForImage2Image
from PIL import Image

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

init_image = Image.open("input.jpg").resize((512, 512))

image = pipe(
    prompt="A watercolor painting of the scene",
    image=init_image,
    strength=0.75,  # How much to transform (0-1)
    num_inference_steps=50
).images[0]
Inpainting

Fill masked regions:

from diffusers import AutoPipelineForInpainting
from PIL import Image

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

image = Image.open("photo.jpg")
mask = Image.open("mask.png")  # White = inpaint region

result = pipe(
    prompt="A red car parked on the street",
    image=image,
    mask_image=mask,
    num_inference_steps=50
).images[0]
ControlNet

Add spatial conditioning for precise control:

from diffusers import StableDiffusionControlNetPipeline, ControlNetModel
import torch

# Load ControlNet for edge conditioning
controlnet = ControlNetModel.from_pretrained(
    "lllyasviel/control_v11p_sd15_canny",
    torch_dtype=torch.float16
)

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

# Use Canny edge image as control.
# get_canny_image is not a library function: you supply the edge-map step. A simple version:
import cv2, numpy as np
from PIL import Image
def get_canny_image(img):
    edges = cv2.Canny(np.array(img.convert("RGB")), 100, 200)
    return Image.fromarray(np.stack([edges] * 3, axis=-1))

control_image = get_canny_image(input_image)  # input_image is your PIL photo

image = pipe(
    prompt="A beautiful house in the style of Van Gogh",
    image=control_image,
    num_inference_steps=30
).images[0]
Available ControlNets
ControlNet Input Type Use Case
canny Edge maps Preserve structure
openpose Pose skeletons Human poses
depth Depth maps 3D-aware generation
normal Normal maps Surface details
mlsd Line segments Architectural lines
scribble Rough sketches Sketch-to-image
LoRA adapters

Load fine-tuned style adapters:

from diffusers import DiffusionPipeline

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

# Load LoRA weights
pipe.load_lora_weights("path/to/lora", weight_name="style.safetensors")

# Generate with LoRA style
image = pipe("A portrait in the trained style").images[0]

# Adjust LoRA strength
pipe.fuse_lora(lora_scale=0.8)

# Unload LoRA
pipe.unload_lora_weights()
Multiple LoRAs
# Load multiple LoRAs
pipe.load_lora_weights("lora1", adapter_name="style")
pipe.load_lora_weights("lora2", adapter_name="character")

# Set weights for each
pipe.set_adapters(["style", "character"], adapter_weights=[0.7, 0.5])

image = pipe("A portrait").images[0]
Memory optimization
Enable CPU offloading
# Model CPU offload - moves models to CPU when not in use
pipe.enable_model_cpu_offload()

# Sequential CPU offload - more aggressive, slower
pipe.enable_sequential_cpu_offload()
Attention slicing
# Reduce memory by computing attention in chunks
pipe.enable_attention_slicing()

# Or specific chunk size
pipe.enable_attention_slicing("max")
xFormers memory-efficient attention
# Requires xformers package
pipe.enable_xformers_memory_efficient_attention()
VAE slicing for large images
# Decode latents in tiles for large images
pipe.enable_vae_slicing()
pipe.enable_vae_tiling()
Model variants
Loading different precisions
# FP16 (recommended for GPU)
pipe = DiffusionPipeline.from_pretrained(
    "model-id",
    torch_dtype=torch.float16,
    variant="fp16"
)

# BF16 (better precision, requires Ampere+ GPU)
pipe = DiffusionPipeline.from_pretrained(
    "model-id",
    torch_dtype=torch.bfloat16
)
Loading specific components
from diffusers import UNet2DConditionModel, AutoencoderKL

# Load custom VAE
vae = AutoencoderKL.from_pretrained("stabilityai/sd-vae-ft-mse")

# Use with pipeline
pipe = DiffusionPipeline.from_pretrained(
    "stable-diffusion-v1-5/stable-diffusion-v1-5",
    vae=vae,
    torch_dtype=torch.float16
)
Batch generation

Generate multiple images efficiently:

# Multiple prompts
prompts = [
    "A cat playing piano",
    "A dog reading a book",
    "A bird painting a picture"
]

images = pipe(prompts, num_inference_steps=30).images

# Multiple images per prompt
images = pipe(
    "A beautiful sunset",
    num_images_per_prompt=4,
    num_inference_steps=30
).images
Common workflows
Workflow 1: High-quality generation
from diffusers import StableDiffusionXLPipeline, DPMSolverMultistepScheduler
import torch

# 1. Load SDXL with optimizations
pipe = StableDiffusionXLPipeline.from_pretrained(
    "stabilityai/stable-diffusion-xl-base-1.0",
    torch_dtype=torch.float16,
    variant="fp16"
)
pipe.to("cuda")
pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)
pipe.enable_model_cpu_offload()

# 2. Generate with quality settings
image = pipe(
    prompt="A majestic lion in the savanna, golden hour lighting, 8k, detailed fur",
    negative_prompt="blurry, low quality, cartoon, anime, sketch",
    num_inference_steps=30,
    guidance_scale=7.5,
    height=1024,
    width=1024
).images[0]
Workflow 2: Fast prototyping
from diffusers import AutoPipelineForText2Image, LCMScheduler
import torch

# Use LCM for 4-8 step generation
pipe = AutoPipelineForText2Image.from_pretrained(
    "stabilityai/stable-diffusion-xl-base-1.0",
    torch_dtype=torch.float16
).to("cuda")

# Load LCM LoRA for fast generation
pipe.load_lora_weights("latent-consistency/lcm-lora-sdxl")
pipe.scheduler = LCMScheduler.from_config(pipe.scheduler.config)
pipe.fuse_lora()

# Generate in ~1 second
image = pipe(
    "A beautiful landscape",
    num_inference_steps=4,
    guidance_scale=1.0
).images[0]
Common issues

CUDA out of memory:

# Enable memory optimizations
pipe.enable_model_cpu_offload()
pipe.enable_attention_slicing()
pipe.enable_vae_slicing()

# Or use lower precision
pipe = DiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)

Black/noise images:

# If the pipeline exposes a safety flag, inspect it without disabling the check.
result = pipe(prompt)
flags = getattr(result, "nsfw_content_detected", None)
print("Safety flag:", flags[0] if flags else "not exposed by this pipeline")

# A flag means review the prompt and follow the model or service policy.
# If there is no flag, check the VAE configuration and model compatibility.

# Ensure proper dtype consistency
pipe = pipe.to(dtype=torch.float16)

Slow generation:

# Use faster scheduler
from diffusers import DPMSolverMultistepScheduler
pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)

# Reduce steps
image = pipe(prompt, num_inference_steps=20).images[0]
References
Resources
After this

When you've handed it back, suggest what they could do next in one short question. It's a suggestion: if they're done, that's fine. Offer these, and say they can type their own:

  • The Image maker and editor. It takes the image. If they pick one and that skill is added here, carry straight on with what you just made. If not, give the link and say what to bring.