arrow_forwardGuides / Stable Diffusion
Updated April 2026 25 min read 100% free Open source

Stable Diffusion
The complete guide — ComfyUI, SDXL, Flux & LoRA

Free AI image generation, no subscription, with total control. What the Diffusion Process is, how to install ComfyUI, how to write Prompts, ControlNet, LoRA, and Flux.1 — it's all here.

6GB
Minimum VRAM
SDXL
Flux.1 & SDXL
Unlimited images

What is Stable Diffusion and why is it revolutionary?

Stable Diffusion is an Open Source model for generating images from text that you can run locally on your machine — no payment, no subscription, no content restrictions. Released in 2022 by Stability AI, it completely changed the world of AI image generation.

Unlike Midjourney (server, paid) or DALL-E (paid API), SD runs at home on your own machine. No one sees your prompts, there are no limits on the number of images, and you can change every aspect of the generation process.

How does the Diffusion Process work?

The Diffusion process works in two stages:

The diffusion process — visual
noise
Pure noise
memory
U-Net × 20 steps
image
Latent Space
photo
VAE Decode
landscape
Final image

The model learns to turn noise into an image, guided by the Prompt you wrote (CLIP Text Encoding)

A quick comparison — SD vs Midjourney

Criterion Stable Diffusion Midjourney DALL-E 3
CostCompletely free$10/month+ChatGPT Plus
Ease of useIntermediate–advancedVery easyEasy
Control over the imageCompletely fullLimitedLimited
ControlNet / LoRAYes — built inNoNo
PrivacyFull — localDiscord serverOpenAI servers
Model flexibilityThousands of modelsOne modelOne model

The bottom line: if you want professional control, LoRA for faces, ControlNet for poses, batch generation — SD is the choice. If you want beautiful images instantly in 2 seconds with no settings — Midjourney.

What can you do with Stable Diffusion?

Installation — ComfyUI & A1111

There are two main options: ComfyUI (recommended — based on a Node Graph, powerful, flexible) andAUTOMATIC1111 (A1111 — a classic interface, easier for beginners). We'll explain both.

ComfyUI — the recommended installation

# Step 1 — make sure Python 3.10–3.11 is installed
python3 --version

# Step 2 — clone the repo
git clone https://github.com/comfyanonymous/ComfyUI
cd ComfyUI

# Step 3 — install dependencies
pip install -r requirements.txt

# Step 4 — download an SDXL model (1.8GB)
# place in: models/checkpoints/dreamshaper_xl.safetensors

# Step 5 — run
python main.py --listen
# open in browser: http://localhost:8188
ComfyUI — localhost:8188
Load Checkpoint
ckpt_name:
dreamshaper_xl.safetensors
─→
CLIP Text Encode (+)
text:
masterpiece, portrait...
─→
KSampler
steps: 25
cfg: 7.5
sampler: dpmpp_2m
─→
VAE Decode
tile: false
─→
Save Image
prefix: ComfyUI
Queue Prompt [Space] • Run [Enter] • Clear [Ctrl+D]

AUTOMATIC1111 — the classic interface

# Mac / Linux:
git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui
cd stable-diffusion-webui
./webui.sh

# Windows:
git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui
cd stable-diffusion-webui
webui-user.bat

# open at: http://127.0.0.1:7860
AUTOMATIC1111 — localhost:7860
txt2img img2img Extras PNG Info Settings
Prompt
masterpiece, best quality, portrait of woman, studio lighting, 8k
Negative prompt
(worst quality:1.4), deformed, extra fingers, blurry, watermark
Steps
25
CFG
7
Width
1024
Height
1024
play_circle
Stable Diffusion ComfyUI — a full guide
YouTube • search for tutorials
open_in_new
lightbulb
No GPU? 3 options
  • Google Colab — search "ComfyUI Colab" on GitHub. Free, T4 GPU, no local installation.
  • Replicate.com — API + interface, ~$0.002 per image. Excellent for ControlNet.
  • RunPod.io — a cloud GPU by the hour, ~$0.2/hour. The most flexible for experiments.

Models, Checkpoints and VAE

The heart of Stable Diffusion is theCheckpoint model — a .safetensors file that contains the neural network weights. Each checkpoint gives a different style and quality. Download them fromCivitai.com and HuggingFace.co.

Checkpoint Models — a full comparison

Model Base Size Style VRAM
SDXL Base 1.0SDXL6.5GBGeneral8GB
DreamShaper XLSDXL6.5GBArtistic / realistic8GB
Juggernaut XLSDXL6.5GBPhotorealistic8GB
RealVisXL v4SDXL6.5GBVery realistic8GB
Flux.1 DevFlux24GB (FP8: 12GB)Stunning16GB+
Flux.1 SchnellFlux24GB (GGUF: 8GB)Fast (4 steps)8GB GGUF

VAE — what it is and why it matters

The VAE (Variational Autoencoder) is the "translator" between Latent Space (the model's internal latent space) and pixel images. When the VAE is poor — images come out with oversaturated colors, blurry faces, and strange eyes.

ControlNet Models

LoRA Models

LoRA files (.safetensors, 50–200MB) add specific styles on top of the main Checkpoint. Save inmodels/loras/.

civitai.com/models
Search models... (juggernaut xl)
portrait
Juggernaut XL v9
Checkpoint • SDXL
star 4.9 • 2.1M downloads
brush
DreamShaper XL
Checkpoint • SDXL
star 4.8 • 1.4M downloads

Writing Prompts for images

A Prompt for an image works differently from a Prompt for text. It's a descriptive structure, not a question. The basic formula:

[quality] + [main subject] + [style] + [lighting] + [photographer/artist] + [additional details]

A full Prompt — an example with explanation

POSITIVE PROMPT:
(masterpiece, best quality:1.2), ohwx woman,
portrait photography, studio lighting, sharp focus,
bokeh background, wearing elegant suit, confident pose,
Canon EOS R5, f/1.8, 8k, skin texture, photorealistic

NEGATIVE PROMPT:
(worst quality, low quality:1.4), deformed hands,
extra fingers, blurry, watermark, text, jpeg artifacts,
bad anatomy, disfigured, ugly, mutation

Word weighting — Prompt Weighting

(beautiful:1.3)     # stronger emphasis — 30% more influence
(beautiful:0.7)     # weaker emphasis
[fade out]          # a fade-out effect
(red:1.2) dress     # emphasizing the color only
((very important))  # doubling = maximum emphasis

Critical parameters

Parameter Range Recommended Explanation
CFG Scale1–206–8How much the model "listens" to the prompt. Too high = oversaturated
Steps5–15020–30How many Denoising steps. More = higher quality, slower
Seed0–∞-1 (random)The seed number determines the starting point. Fixed = a fixed result
SamplerManyDPM++ 2M KarrasThe denoising algorithm. Dictates quality vs speed
Resolution512–20481024×1024 (SDXL)SDXL is trained on 1024. SD1.5 — 512×512

Quality Tags — a quick list

# high quality:
masterpiece, best quality, ultra detailed, 8k, RAW photo

# realistic style:
photorealistic, hyperrealistic, photography, DSLR, film grain

# lighting:
studio lighting, golden hour, cinematic lighting,
soft diffused light, dramatic shadows, rim lighting

# artistic style:
oil painting, watercolor, digital art, concept art,
anime style, illustration, artstation

ComfyUI Workflows

ComfyUI works with a Node Graph — each step in creating the image is represented by a Node, and the Nodes are connected by Wires. This gives full transparency and control over every aspect of the process.

The basic Nodes

Workflow — img2img

# instead of EmptyLatentImage:
Load Image → VAEEncode → KSampler (with denoise: 0.5–0.8)

# denoise 0.3 = a slight change (keeps 70% of the original image)
# denoise 0.8 = a large change (only 20% of the original)
ComfyUI — LoRA Workflow
Load Checkpoint
dreamshaper_xl
MODEL CLIP
─→
Load LoRA
my_character.safetensors
strength: 0.8
─→
CLIP Text Encode
"ohwx woman, portrait,
studio lighting"
─→
KSampler
steps: 25
cfg: 7
─→
VAE Decode
→ Save Image

Sharing Workflows — JSON

Every workflow in ComfyUI can be saved/loaded as a JSON file. You'll find thousands of workflows atcomfyworkflows.com and openart.ai/workflows. Just drag it into the interface.

extension
ComfyUI Manager — a must-install

ComfyUI-Manager adds a store of Custom Nodes — ControlNet, IP-Adapter, FaceSwap and more. Install from GitHub: ComfyUI-Manager ← save incustom_nodes/

ControlNet — precise control over the image structure

ControlNet is one of the most significant innovations in SD. It lets you control the structure, pose, depth and contour of the image — while keeping the flexibility of the prompt. This is what sets SD apart from Midjourney.

Types of ControlNet and when to use them

Python code — ControlNet with Diffusers

from diffusers import StableDiffusionXLControlNetPipeline, ControlNetModel
import torch, cv2, numpy as np
from PIL import Image

# loading ControlNet Canny
controlnet = ControlNetModel.from_pretrained(
    "diffusers/controlnet-canny-sdxl-1.0",
    torch_dtype=torch.float16
)

# loading the Pipeline
pipe = StableDiffusionXLControlNetPipeline.from_pretrained(
    "stabilityai/stable-diffusion-xl-base-1.0",
    controlnet=controlnet,
    torch_dtype=torch.float16
).to("cuda")

# preparing the Canny Edge
image = Image.open("input.jpg")
img_array = np.array(image)
canny = cv2.Canny(img_array, 100, 200)
canny_rgb = np.stack([canny] * 3, axis=-1)
canny_pil = Image.fromarray(canny_rgb)

# generating an image with ControlNet
result = pipe(
    prompt="portrait of woman, studio lighting, photorealistic, 8k",
    negative_prompt="blurry, deformed, worst quality",
    image=canny_pil,
    controlnet_conditioning_scale=0.8,   # ControlNet strength
    num_inference_steps=25,
    guidance_scale=7.5
).images[0]

result.save("output_controlnet.png")
ComfyUI — ControlNet Workflow
ControlNet Pipeline — Canny Edge
Load Image
input.jpg
Canny Preprocessor
low: 100
high: 200
Apply ControlNet
strength: 0.8
start: 0.0
end: 1.0
→ KSampler → VAE Decode → Save Image

IP-Adapter — Style Transfer and Face Transfer

IP-Adapter is a special ControlNet that takes a "reference" image and uses it to guide style or face. Excellent for creating images of the same person in different styles.

from diffusers import StableDiffusionXLPipeline
from ip_adapter import IPAdapterPlusXL

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

ip_adapter = IPAdapterPlusXL(
    pipe,
    image_encoder_path="h94/IP-Adapter/models/image_encoder",
    ip_ckpt="ip-adapter-plus_sdxl_vit-h.bin",
    device="cuda"
)

ref_image = Image.open("face_reference.jpg")

images = ip_adapter.generate(
    pil_image=ref_image,
    prompt="portrait, oil painting style, Van Gogh",
    negative_prompt="worst quality, blurry",
    scale=0.6,       # IP-Adapter strength
    num_samples=1,
    num_inference_steps=30,
    seed=42
)

Flux.1 — the best model of 2025

Flux.1 was released in 2024 by Black Forest Labs (the original founders of Stable Diffusion) and represents a significant leap in quality. 12 billion parameters, a Transformer architecture (not U-Net), and realistic images at a level not seen before.

Flux.1 Dev vs Schnell vs Pro

Version Steps Speed Quality License VRAM
Flux.1 Dev20–50SlowExcellentNon-Commercial16GB+ (FP8: 12GB)
Flux.1 Schnell4Very fastGoodApache 2.08GB (GGUF)
Flux.1 ProAPI onlyThe bestCommercial APIAPI

GGUF Quantization — Flux on 8GB VRAM

GGUF quantization lets you run Flux.1 even on cards with 8GB VRAM by compressing the weights from BF16 to Q4_K_S (4-bit). Slightly lower quality, but accessible to most users.

# download Flux.1 Schnell GGUF (8GB):
# https://huggingface.co/city96/FLUX.1-schnell-gguf
# choose: flux1-schnell-Q4_K_S.gguf (~8.3GB)

# ComfyUI — use UNETLoader instead of CheckpointLoader:
# models/unet/flux1-schnell-Q4_K_S.gguf

# recommended settings for Flux Schnell:
# Steps: 4  |  CFG: 1  |  Sampler: euler  |  Scheduler: simple
info
Flux vs SDXL — which to choose?
  • Flux.1 Dev/Schnell — higher image quality, text inside images, less support for LoRA/ControlNet (still in development)
  • SDXL — a mature ecosystem, thousands of LoRAs, full ControlNet, faster
  • For general creation in 2025 — Flux.1 Dev if you have 16GB VRAM, otherwise SDXL
play_circle
Flux.1 in ComfyUI — a full 2025 guide
YouTube • search for tutorials
open_in_new

5 practical projects

The projects are ordered by difficulty — beginner to advanced. Each project includes what you need, the Workflow, and where to start.

1
Beginner

Portrait Generator — a professional portrait from text

Creating professional portraits with studio lighting. Excellent for LinkedIn, profiles, business cards.

Model: DreamShaper XL | Steps: 25 | CFG: 7
Prompt: (masterpiece:1.2), professional headshot, business portrait,
studio lighting, sharp focus, bokeh, clean background, 8k
2
Intermediate

Product Photography — AI product photography

Photograph a product on a white background, then use img2img to replace the background with an interesting environment. Saves thousands on photography.

Step 1: photograph the product on a white background (a phone is enough)
Step 2: ComfyUI img2img, denoise: 0.4
Prompt: product on wooden table, coffee shop background,
warm lighting, professional photography, bokeh
3
Intermediate

Face Swap with IP-Adapter

Transfer a person's face to a different visual style — oil painting, Japanese animation, photorealism. With IP-Adapter.

Tools: ComfyUI + ComfyUI-IPAdapter-plus
Model: SDXL + ip-adapter-plus_sdxl_vit-h.bin
IP Scale: 0.5–0.7 (low = more flexible, high = more similar)
4
Advanced

Batch Generation API — 100 images automatically

A Python script for mass-producing images through the ComfyUI API. Excellent for Datasets, Stock Images, A/B Testing.

import requests, json, random

COMFY_URL = "http://127.0.0.1:8188"

def generate_image(prompt, seed=None):
    seed = seed or random.randint(0, 2**32)
    workflow = {
        "3": {"class_type": "KSampler",
              "inputs": {"seed": seed, "steps": 25, "cfg": 7,
                         "sampler_name": "dpmpp_2m", "scheduler": "karras",
                         "denoise": 1.0, "model": ["4", 0],
                         "positive": ["6", 0], "negative": ["7", 0],
                         "latent_image": ["5", 0]}},
        "4": {"class_type": "CheckpointLoaderSimple",
              "inputs": {"ckpt_name": "dreamshaper_xl.safetensors"}},
        "5": {"class_type": "EmptyLatentImage",
              "inputs": {"width": 1024, "height": 1024, "batch_size": 1}},
        "6": {"class_type": "CLIPTextEncode",
              "inputs": {"text": prompt, "clip": ["4", 1]}},
        "7": {"class_type": "CLIPTextEncode",
              "inputs": {"text": "worst quality, blurry", "clip": ["4", 1]}},
        "8": {"class_type": "VAEDecode",
              "inputs": {"samples": ["3", 0], "vae": ["4", 2]}},
        "9": {"class_type": "SaveImage",
              "inputs": {"images": ["8", 0], "filename_prefix": "batch"}}
    }
    r = requests.post(f"{COMFY_URL}/prompt",
                      json={"prompt": workflow})
    return r.json()

prompts = [f"portrait of person {i}, studio lighting" for i in range(100)]
for i, p in enumerate(prompts):
    generate_image(p, seed=i)
    print(f"Generated {i+1}/100")
5
Advanced

ComfyUI Custom Workflow — a consistent style

A full Pipeline for a consistent character: LoRA + IP-Adapter + ControlNet Pose. Every image is the same character, different poses.

Pipeline: Load Checkpoint → Load LoRA (character:0.8) →
IP-Adapter (face ref, scale:0.5) → ControlNet OpenPose →
CLIP Text Encode → KSampler (steps:30, cfg:6.5) →
VAE Decode → Save Image

Result: the same character, 20 different poses, a completely consistent style

Cheat sheet — a full Cheat Sheet

Sampler Comparison — which Sampler to choose?

Sampler Speed Quality Ideal use
DPM++ 2M KarrasFastExcellentThe recommended default for most needs
DPM++ 3M SDE KarrasIntermediateExcellentRealistic portraits, fine details
Euler aVery fastGoodQuick experiments, high variation
DDIMIntermediateGoodInpainting, img2img — consistent results
LCMFast × 10BasicReal-time preview, a quick draft

CFG Scale Guide

1–3
Too creative, "dreamy"
4–5
Flexible, not rigid
6–8
Recommended
9–12
Faithful to the prompt
13+
oversaturated

Resolution Best Practices

Model Recommended resolution Portrait (9:16) Landscape (16:9)
SD 1.5512×512512×768768×512
SDXL1024×1024832×12161216×832
Flux.11024×1024832×12161344×768

Common Errors — fixing common errors

CUDA out of memory
Add to the launch command: --lowvram (4GB) or --medvram (6–8GB). You can also download an FP8 checkpoint instead of FP16.
Blurry images / low quality
Check that the VAE is fine. Add to negative: (blurry:1.3), (soft focus:1.2). Try raising Steps to 30–35.
Deformed hands / wrong fingers
Add to negative: (deformed hands:1.4), (extra fingers:1.4), bad anatomy. Or use ControlNet OpenPose for a precise Pose.
ComfyUI can't find a Node
Install ComfyUI-Manager ← "Install Missing Custom Nodes" ← it will automatically install all the missing Nodes.
Checkpoint-not-loaded error
Make sure the file .safetensors is in the correct path: ComfyUI/models/checkpoints/. Restart ComfyUI after adding files.

Quality Tags — a quick list

# Positive — always add at the start of the Prompt:
(masterpiece, best quality:1.2), ultra detailed, 8k

# Photography:
RAW photo, DSLR, sharp focus, f/1.8, Canon EOS R5

# Lighting:
studio lighting, golden hour, cinematic, rim light

# Faces:
detailed eyes, perfect skin, natural makeup

# Negative — always add:
(worst quality, low quality:1.4), deformed,
extra fingers, bad anatomy, watermark, text,
blurry, duplicate, mutation, ugly
rocket_launch

The next steps

After you understand SD — the next step is LoRA Training. Train a model on your own images and always get images with the same person, style, or product.