Stable Diffusion Web UI

AUTOMATIC1111's stable-diffusion-webui is a browser front end for running Stable Diffusion image-generation models on your own machine. It wraps model loading, text-to-image, image-to-image, inpainting and upscaling in a Gradio interface served on port 7860, and supports extensions such as ControlNet. The steps below get it running; the later sections explain what happens when you press Generate, which settings matter, the launch flags for different hardware, and common problems.

1. Clone the Web UI Repository

stable-diffusion-webui
git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
cd stable-diffusion-webui
    

2. Install Dependencies

pip install -r requirements.txt
    

If some dependencies fail, try installing them manually:

pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
    

3. Launch the Web UI

Run the following command to start the Web UI:

python launch.py
    

If you encounter the "Torch is not able to use GPU" error, use this command:

export COMMANDLINE_ARGS="--skip-torch-cuda-test"
python launch.py
    

4. Access the Web UI in Your Browser

Once the server is running, the terminal will display a message like:

Running on local URL: http://127.0.0.1:7860
    

Open your web browser and go to:

http://127.0.0.1:7860
    

5. Stopping the Server

To stop the Web UI, press Ctrl+C in the terminal where it's running.

6. Optional: Run with MPS (for Mac Users)

If you're using a Mac with an M1/M2 chip, run with MPS acceleration:

export PYTORCH_ENABLE_MPS_FALLBACK=1
python launch.py
    

7. How generation works

Text-to-image in Stable Diffusion Prompt text CLIP text encoder embeddings U-Net denoiser N sampler steps VAE decoder latent -> pixels Image 512 or 1024 px

Stable Diffusion is a latent diffusion model. The prompt is turned into embeddings by a CLIP text encoder. Generation starts from random noise in a compressed latent space (for SD 1.x, a 64x64x4 tensor for a 512x512 image), and a U-Net predicts and removes noise over a series of sampler steps, guided by the text embeddings. Classifier-free guidance compares a prompted and an unprompted prediction at every step and pushes the result toward the prompt by the CFG scale. Finally the VAE decoder expands the latent back into pixels. Working in latent space rather than pixel space is what makes the model small and fast enough for consumer GPUs.

8. Web UI components

What the Web UI runs locally Browser http://127.0.0.1:7860 Gradio app (webui.py) tabs: txt2img, img2img, extras Checkpoints models/Stable-diffusion LoRA / embeddings models/Lora Extensions extensions/ PyTorch on CUDA, MPS or CPU device backend

launch.py (or the webui.sh / webui-user.bat wrappers) creates or checks the Python environment, installs pinned dependencies, and starts the Gradio server. Model checkpoints in .safetensors or .ckpt format go in models/Stable-diffusion/ and are selectable from the dropdown at the top of the page; LoRA files go in models/Lora/ and are invoked from the prompt with <lora:name:0.8>. Prefer .safetensors: .ckpt files are Python pickles and can execute code when loaded. Generated images are saved under outputs/ with the generation parameters embedded in the PNG metadata, so the PNG Info tab can restore the exact settings later.

9. Key settings

SettingWhat it controlsTypical starting value
Sampling methodNumerical solver for the denoising stepsDPM++ 2M with Karras schedule, or Euler a
Sampling stepsNumber of denoising iterations20 to 30
CFG scaleHow strongly the prompt is followed5 to 7; high values oversaturate
Width / heightOutput size; should match the model's training resolution512 for SD 1.5, 1024 for SDXL
SeedInitial noise; same seed and settings reproduce an image-1 for random
Denoising strength (img2img)How much of the input image is replaced0.3 to 0.6

Change one setting at a time with a fixed seed when tuning: with the seed held constant, differences between images come only from the setting you changed. The X/Y/Z plot script in the Script dropdown automates this by rendering a grid across, for example, several CFG values and samplers in one run.

10. Launch flags by hardware

# webui-user.sh (Linux/macOS) - set flags once instead of exporting each time
export COMMANDLINE_ARGS="--xformers"                 # NVIDIA, faster attention
# export COMMANDLINE_ARGS="--medvram"                # 4-6 GB VRAM
# export COMMANDLINE_ARGS="--lowvram"                # under 4 GB VRAM, slow
# export COMMANDLINE_ARGS="--skip-torch-cuda-test --use-cpu all --no-half"   # CPU only
# export COMMANDLINE_ARGS="--listen --port 7860"     # reachable from the LAN
./webui.sh

# check that PyTorch sees the GPU before launching
python -c "import torch; print(torch.cuda.is_available(), torch.__version__)"

The CPU-only pip install torch ... /whl/cpu command in step 2 is a fallback; it produces a working install but generation takes minutes per image instead of seconds. On an NVIDIA machine install the CUDA build of PyTorch instead, or let webui.sh install it, and see the NVIDIA setup guide for drivers.

11. Troubleshooting