Overview
sd-scripts ships two layers of inference tooling:gen_img.py— a full-featured CLI for SD 1.x, SD 2.x, and SDXL. It supports interactive prompting, file-driven batch generation, img2img, inpainting, ControlNet, LoRA, Highres fix, and more.- Minimal inference scripts — lightweight, model-specific scripts for FLUX, SD3, Lumina, and SDXL that load the model in its native format without requiring a Diffusers pipeline.
- SD 1.x / 2.x / SDXL
- FLUX
- SD3
- Lumina
gen_img.py
Modes of operation
gen_img.py supports three modes depending on how you supply prompts.- Interactive
- Anima
Type prompts one at a time. The script generates an image after each entry and displays a preview window.When
Type prompt: appears, enter your prompt and press Enter. Select the preview window and press any key to close it and enter the next prompt. Press Ctrl+Z then Enter to exit.If the preview window fails with an OpenCV error, install a display-capable build with
pip install opencv-python, or suppress the window entirely with --no_preview.Required and common options
Model specification
Output
Available samplers:
ddim, pndm, lms, euler, euler_a, heun, dpm_2, dpm_2_a, dpmsolver, dpmsolver++, dpmsingle, k_lms, k_euler, k_euler_a, k_dpm_2, k_dpm_2_aPrecision and memory
Prompt syntax
Write negative prompts inline using--n:--max_embeddings_multiples. For example, --max_embeddings_multiples 3 allows prompts up to 225 tokens.Dynamic prompts (wildcards)
Prompt options
You can override per-image settings directly inside the prompt text using--x flags. These work in interactive mode, command-line prompts, and prompt files.Example from a prompt file:
LoRA support
Apply one or more LoRA networks at inference time. The number of--network_module, --network_weights, and --network_mul entries must match.img2img
Pass an image with--image_path and a denoise strength with --strength.--image_path at a folder, images are processed in filename order. Pad filenames with leading zeros (001.jpg, 002.jpg) to ensure the correct sort order.Inpainting
Supply a grayscale mask image with--mask_image. White regions are repainted; black regions are preserved. Gradients in the mask produce soft transitions.Highres fix
Generate a small image first, then upscale and refine it with img2img to produce a high-resolution output without the compositional problems that come from denoising at large latent sizes.--highres_fix_scale 0.5 means the first stage generates at 512×512 (half of 1024×1024). The second stage upscales and refines to the full size.