๐Ÿ“œLocal AI 18 min read

How to Use Stable Diffusion Locally

A guide to installing and using Stable Diffusion on your own computer, including models, LoRAs, ComfyUI, and Automatic1111.

Your Journey into Local AI Art with Stable Diffusion

Welcome to the exciting world of local AI art generation with Stable Diffusion! Unlike cloud-based services, running Stable Diffusion on your own computer gives you complete control, privacy, and freedom from subscriptions. This guide will walk you through the essentials: installing the necessary tools, understanding models and LoRAs, and getting started with popular interfaces like ComfyUI and Automatic1111.

System Requirements and Installation

Running Stable Diffusion locally requires a reasonably powerful computer, primarily a modern NVIDIA graphics card (GPU) with at least 6-8 GB of VRAM. While it's possible to run it on AMD cards or even just a CPU, the performance will be significantly slower. Hereโ€™s a general overview of the installation process:

  1. Install Python: Stable Diffusion relies on Python. Download and install the latest version of Python 3.10 from the official Python website. Make sure to check the box that says 'Add Python to PATH' during installation.
  2. Install Git: Git is a version control system used to download and update Stable Diffusion and its components. Download and install Git from the official website.
  3. Choose a User Interface: For a user-friendly experience, you'll want a graphical user interface (GUI). The two most popular options are Automatic1111 and ComfyUI. Automatic1111 is known for being feature-rich and relatively easy to set up, making it a great choice for beginners. ComfyUI uses a node-based system that is incredibly powerful and flexible, but has a steeper learning curve.
  4. Download and Run the UI:
    • For Automatic1111: Go to the Automatic1111 GitHub repository, download the project as a ZIP file, and extract it. Navigate to the extracted folder and run the webui-user.bat (on Windows) or webui.sh (on Linux/Mac) script. The first time you run it, it will download all the necessary dependencies and the base Stable Diffusion model. This can take a while.
    • For ComfyUI: Visit the ComfyUI GitHub repository and follow the installation instructions. It's a similar process of downloading and running a script.

Understanding Models and LoRAs

Stable Diffusion's power lies in its vast ecosystem of models and LoRAs (Low-Rank Adaptations). These are files that determine the style, characters, and overall look of your generated images.

  • Checkpoint Models: These are the main models that contain the core data for generating images. They come in various styles, from photorealistic to anime-inspired. You can find a massive collection of models on websites like Civitai and Hugging Face. To use a model, you download the .ckpt or .safetensors file and place it in the models/Stable-diffusion directory of your Automatic1111 or ComfyUI installation.
  • LoRAs: LoRAs are smaller files that are used to fine-tune a checkpoint model. They can be trained to replicate a specific art style, a character, or even a particular object. LoRAs are incredibly versatile and allow for a high degree of customization. To use a LoRA, you download the file and place it in the models/Lora directory. You then activate it within the UI, usually by adding a special tag to your prompt.

Getting Started with Automatic1111

Once you have Automatic1111 running, you'll be greeted with a web interface. Here's a quick rundown of the basic workflow:

  1. Select a Checkpoint Model: At the top left of the page, you'll see a dropdown menu where you can select the checkpoint model you want to use.
  2. Write Your Prompt: In the 'txt2img' (text-to-image) tab, you'll find two main text boxes: one for your positive prompt (what you want to see) and one for your negative prompt (what you want to avoid).
  3. Adjust Settings: Below the prompt boxes, you'll find various settings, such as sampling method, sampling steps, and image dimensions (width and height). For beginners, the default settings are a good starting point.
  4. Generate! Click the 'Generate' button and watch your first local AI art creation come to life!

Exploring the Power of ComfyUI

ComfyUI's node-based interface might seem intimidating at first, but it offers unparalleled control over the image generation pipeline. Each node represents a specific step in the process, such as loading a model, processing a prompt, or decoding an image. You connect these nodes together to create a workflow. While a detailed guide to ComfyUI is beyond the scope of this introduction, the key advantage is the ability to create complex, multi-step workflows that are not possible in simpler interfaces. For example, you can easily combine multiple LoRAs, use different models for different parts of an image, and create intricate inpainting and outpainting workflows.

The Journey Ahead

Running Stable Diffusion locally is a rewarding experience that opens up a world of creative possibilities. Start by experimenting with different models and LoRAs, and don't be afraid to dive into the advanced settings as you become more comfortable. The Stable Diffusion community is vast and supportive, with countless tutorials and resources available online. So go forth, explore, and create!