0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Automatically Generate Images with Stable Diffusion

Posted at

Are you just starting with Stable Diffusion and thinking, "I want to create lots of images at once, but manually changing settings each time is such a hassle"? Actually, there's a tool that can automatically generate large quantities of images just by creating simple configuration files, even without programming experience. Today, I'll explain how to use this convenient tool in a way that's easy to understand for beginners.

Demonstration

CLI Interface in Action

CLI Interface

The actual execution screen in the terminal. You can see the colorful progress bars and real-time progress display.

Project Repository

Complete source code, documentation, configuration examples, and contribution guidelines are included.

Why Automation is Necessary

When using Stable Diffusion manually, don't you encounter these frustrations?

Common Challenges

  • Want to create 10 images of the same character in different outfits, but changing prompts each time is tedious
  • Want to compare multiple sampling methods, but changing settings one by one takes too much time
  • Want to automatically generate images overnight and wake up to lots of completed images
  • Want to create images with the same settings repeatedly, but can't remember the configuration

The automation tool introduced today solves these problems. Once you create a configuration file, everything else is fully automated with just one button press.

What You Need

What you need to use this tool is surprisingly simple:

Essential Requirements

  1. Stable Diffusion WebUI (AUTOMATIC1111 version) running environment
  2. Node.js (software for running JavaScript)
  3. Basic text file editing skills

Recommended Environment

  • Windows 10/11, macOS, or Linux
  • 8GB+ memory
  • Adequate storage space (for generated images)

No programming knowledge is required. Being able to edit text files is sufficient.

Step 1: Installing Node.js

First, install Node.js. This is free software downloadable from the official website (https://nodejs.org/).

Installation Steps

  1. Access the Node.js official website
  2. Download the "LTS" version (recommended)
  3. Run the downloaded file to install
  4. After installation, run the following in Command Prompt (Windows) or Terminal (Mac/Linux):
node --version

If a version number appears, installation was successful.

Step 2: Tool Setup

Next, set up the automation tool.

Download and Initial Setup

  1. Download or clone the tool
  2. Open the folder and run the following in command prompt:
npm install
  1. Copy the configuration file:
cp .env.example .env
  1. Open the .env file and configure the WebUI address:
SD_WEBUI_URL=http://localhost:7860

For local environments, no changes needed. If running WebUI on another computer, change to that IP address.

Step 3: Preparing Stable Diffusion WebUI

The important point is starting WebUI with the correct options.

Correct Startup Method

Windows environment:

webui.bat --listen --api

Mac/Linux environment:

webui.sh --listen --api

The --listen --api option is crucial. Without this, the automation tool cannot access WebUI.

Verification Method
Once WebUI starts correctly, access http://localhost:7860 in your browser to confirm the normal WebUI interface appears.

Step 4: Creating Your First Configuration File

Now let's create the file that describes image generation settings. While it might look like programming, it's actually very simple.

Basic Configuration File Example

Open the file prompts/configs.jsonl and write content like this:

{"prompt": "1girl, solo, school uniform, black hair, brown eyes, happy smile", "negative_prompt": "worst quality, bad quality", "width": 512, "height": 768, "sampler_name": "Euler a", "steps": 20, "cfg_scale": 7, "seed": -1, "batch_size": 1, "n_iter": 1, "hires_fix": false}

Explaining Setting Meanings

Let me briefly explain what each item means:

  • prompt: Content of the image you want to generate (your usual prompt)
  • negative_prompt: Elements to avoid (your usual negative prompt)
  • width, height: Image size (pixels)
  • sampler_name: Sampling method (same as what you select in WebUI)
  • steps: Number of generation steps (20-30 is common)
  • cfg_scale: CFG scale (7 is standard)
  • seed: Random seed (-1 for automatic)
  • batch_size: Number of images to create at once
  • n_iter: Number of repetitions
  • hires_fix: High-resolution fix (true or false)

Step 5: Actually Running It

Once the configuration file is ready, let's actually run it.

Execution Command

npm start

You'll see a screen like this:

🚀 Starting Stable Diffusion automation...
📸 [████████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░] 30.0% Config 1/3
🔄 [████████████████░░░░░░░░░░░░░░] 57.1% Step 16/28 ETA: 25.1s

Understanding the Display

  • Top line: Overall progress
  • Middle: Current image generation progress
  • Numbers: Which step, estimated seconds to completion

Creating Multiple Images at Once

Once you can create one image, let's try automatically creating multiple images.

Multiple Configuration Example

Add multiple lines to the configuration file like this:

{"prompt": "1girl, solo, school uniform, black hair, brown eyes, happy smile", "negative_prompt": "worst quality, bad quality", "width": 512, "height": 768, "sampler_name": "Euler a", "steps": 20, "cfg_scale": 7, "seed": -1, "batch_size": 1, "n_iter": 2, "hires_fix": false}
{"prompt": "1girl, solo, casual clothes, blonde hair, blue eyes, gentle smile", "negative_prompt": "worst quality, bad quality", "width": 512, "height": 768, "sampler_name": "Euler a", "steps": 20, "cfg_scale": 7, "seed": -1, "batch_size": 1, "n_iter": 2, "hires_fix": false}
{"prompt": "1girl, solo, summer dress, red hair, green eyes, mischievous smile", "negative_prompt": "worst quality, bad quality", "width": 512, "height": 768, "sampler_name": "Euler a", "steps": 20, "cfg_scale": 7, "seed": -1, "batch_size": 1, "n_iter": 2, "hires_fix": false}

This automatically generates images of 3 different characters, 2 each, for a total of 6 images.

Checking Generated Images

Images are automatically organized and saved.

File Location

out/
└── 2025-08-14/  (today's date)
    ├── 1723648392847-2605429855.png
    ├── 1723648394123-2605429856.png
    └── 1723648396234-2605429857.png

Filenames follow the format "generation_time-seed_value.png", so you can see at a glance when it was created and which seed was used.

Common Failures and Solutions

Here are problems beginners often encounter and their solutions.

Problem 1: "fetch failed" Error

Cause: WebUI not started correctly or API not enabled

Solution:

  1. Restart WebUI with --listen --api options
  2. Confirm you can access http://localhost:7860 in browser

Problem 2: Configuration File Errors

Cause: Incorrect JSON format

Solution:

  1. Check that each line is proper JSON format
  2. Check for missing commas or quotation marks
  3. Verify with online JSON checker

Problem 3: Images Don't Generate as Expected

Cause: Inappropriate prompts or settings

Solution:

  1. First try the same settings manually in WebUI
  2. Try increasing steps (20→30 etc.)
  3. Try adjusting CFG scale (7→10 etc.)

Problem 4: Slow Processing

Cause: Settings too heavy or hardware issues

Solution:

  1. Reduce image size (768→512 etc.)
  2. Reduce steps (30→20 etc.)
  3. Set batch_size to 1

Useful Tips

Overnight Automatic Generation

Using it to set up before sleep and have images ready in the morning:

  1. Write many settings in configuration file
  2. Start with npm start before sleep
  3. Check out/ folder in the morning

Saving Settings

Save successful settings in separate files:

# Backup successful settings
cp prompts/configs.jsonl prompts/good-configs-backup.jsonl

Gradual Testing

Don't generate in bulk immediately; test gradually:

  1. Generate 1 image with 1 setting
  2. If no problems, multiple images with same setting
  3. Finally, bulk generation with multiple settings

Safe Exit Methods

If you want to stop midway:

  1. Press z key on keyboard (recommended)
  2. Safely exits after current image completes
  3. For emergencies, force exit with Ctrl+C

Summary

Using this tool, you can dramatically improve Stable Diffusion image generation efficiency even without programming knowledge. While it might seem difficult at first, once you learn it, you'll find it so convenient you can't go back to manual work.

Success Points

  1. Start with simple settings
  2. Don't panic with errors; check one by one
  3. Always save successful settings
  4. Gradually challenge more complex settings

Future Applications

  • Character design variation creation
  • Large-scale art production
  • Commercial material creation
  • Hobby creative activities

Why not start your efficient Stable Diffusion life today? While you might be confused initially, you'll surely be amazed by its convenience.


Project Repository

You can find the complete source code, detailed documentation, practical configuration examples, and contribution guidelines for the tool introduced in this article.

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?