Welcome to dgenerate’s documentation!
This is the command line manual and library documentation for dgenerate.
dgenerate is a scriptable command line tool for generating images and animation sequences
using stable diffusion and related techniques, with an accompanying UI scripting environment.
For library usage examples see the Library Usage Examples folder under the examples folder in the github repository.
For command line usage documentation see the Usage Manual or the Examples Folder in the github repository.
Library Documentation
- dgenerate module
BatchProcessErrorDgenerateHelpExceptionDgenerateUsageErrorFrameStartOutOfBoundsImageProcessorArgumentErrorImageProcessorErrorImageProcessorImageModeErrorImageProcessorNotFoundErrorImageSeedErrorInvalidModelFileErrorInvalidModelUriErrorInvalidSchedulerNameErrorLatentsProcessorArgumentErrorLatentsProcessorErrorLatentsProcessorNotFoundErrorMediaIdentificationErrorModelNotFoundErrorModelUriLoadErrorModuleFileNotFoundErrorNonHFConfigDownloadErrorNonHFDownloadErrorNonHFModelDownloadErrorOutOfMemoryErrorPluginArgumentErrorPluginNotFoundErrorPromptEmbeddedArgumentErrorPromptUpscalerProcessingErrorPromptWeightingUnsupportedRenderLoopConfigErrorSchedulerArgumentErrorSchedulerLoadErrorSpacyModelNotFoundErrorUnknownMimetypeErrorUnsupportedPipelineConfigErrorWebFileCacheOfflineModeExceptionAnimationETAEventAnimationFileFinishedEventAnimationFinishedEventConfigRunnerConfigRunnerPluginConfigRunnerPluginLoaderDataTypeDgenerateArgumentsDiffusionArgumentsDiffusionPipelineWrapperImageFileSavedEventImageGeneratedEventModelTypePipelineTypePromptRenderLoopRenderLoopConfigStartingAnimationEventStartingAnimationFileEventStartingGenerationStepEventclear_device_cache()default_device()disable_offline_mode()enable_offline_mode()format_image_seed_uri()gen_seeds()invoke_dgenerate()invoke_dgenerate_events()is_offline_mode()main()offline_mode_context()parse_args()
- dgenerate submodules
- dgenerate.arguments module
- dgenerate.auto1111_metadata module
- dgenerate.batchprocess module
- dgenerate.devicecache module
- dgenerate.eval module
- dgenerate.filecache module
- dgenerate.filelock module
- dgenerate.files module
- dgenerate.globalconfig module
- dgenerate.hfhub module
- dgenerate.image module
- dgenerate.image_process module
- dgenerate.imageprocessors module
- dgenerate.imageprocessors.constants module
- dgenerate.invoker module
- dgenerate.mediainput module
- dgenerate.mediaoutput module
- dgenerate.memoize module
- dgenerate.memory module
- dgenerate.messages module
- dgenerate.pipelinewrapper module
- dgenerate.pipelinewrapper.constants module
- dgenerate.plugin module
- dgenerate.prompt module
- dgenerate.promptupscalers module
- dgenerate.promptupscalers.constants module
- dgenerate.promptweighters module
- dgenerate.promptweighters.constants module
- dgenerate.pygments module
- dgenerate.spacycache module
- dgenerate.resources module
- dgenerate.renderloop module
- dgenerate.textprocessing module
- dgenerate.torchutil module
- dgenerate.translators module
- dgenerate.types module
- dgenerate.webcache module
Diffusion Model Feature Support Tables
--model-type sd(SD 1.5 - SD 2.*)
--model-type pix2pix(SD 1.5 - SD 2.* - Pix2Pix)
--model-type sdxl(Stable Diffusion XL)
--model-type kolors(Kolors)
--model-type if(Deep Floyd Stage 1)
--model-type ifs(Deep Floyd Stage 2)
--model-type ifs-img2img(Deep Floyd Stage 2 - Img2Img)
--model-type sdxl-pix2pix(Stable Diffusion XL - Pix2Pix)
--model-type upscaler-x2(Stable Diffusion x2 Upscaler)
--model-type upscaler-x4(Stable Diffusion x4 Upscaler)
--model-type s-cascade(Stable Cascade)
--model-type sd3(Stable Diffusion 3 and 3.5)
--model-type sd3-pix2pix(Stable Diffusion 3 - Pix2Pix [UltraEdit])
--model-type flux(Flux.1)
--model-type flux-fill(Flux.1 - Infill / Outfill)
--model-type flux-kontext(Flux.1 - Pix2Pix like editing)
--model-type flux2(Flux.2 and Flux.2 Klein)
--model-type flux2-klein-kv(Flux.2 Klein KV)
--model-type z-image(Z-Image)
--model-type z-image-omni(Z-Image Omni)
--model-type qwen-image(Qwen-Image)
--model-type qwen-image-edit(Qwen-Image Edit and Edit-Plus)
--model-type qwen-image-layered(Qwen-Image Layered)
--model-type ltx(LTX-2.5 and LTX-Video, see Video Model Feature Support)
--model-type wan(Wan 2.1 / 2.2 T2V, I2V, FLF2V, V2V, VACE)
--model-type wan-animate(Wan-Animate)
--model-type wan-animate-2(Wan-Animate-2)
Model Type |
Txt2Img |
Img2Img |
Inpainting |
|---|---|---|---|
|
✅ |
✅ |
✅ |
|
❌ |
✅ |
🚧 |
|
✅ |
✅ |
✅ |
|
✅ |
✅ |
✅ |
|
✅ |
✅ |
✅ |
|
❌ |
✅ |
✅ |
|
❌ |
✅ |
✅ |
|
❌ |
✅ |
🚧 |
|
❌ |
✅ |
❌ |
|
❌ |
✅ |
❌ |
|
✅ |
✅ |
❌ |
|
✅ |
✅ |
✅ |
|
❌ |
✅ |
✅ |
|
✅ |
✅ |
✅ |
|
❌ |
❌ |
✅ |
|
❌ |
✅ |
✅ |
|
✅ |
❌ |
🚧 |
|
✅ |
❌ |
❌ |
|
✅ |
✅ |
✅ |
|
✅ |
❌ |
❌ |
|
✅ |
✅ |
✅ |
|
✅ |
❌ |
🚧 |
|
✅ |
❌ |
❌ |
Model Type |
LoRA |
Textual Inversions |
ControlNet |
Perturbed Attention Guidance (PAG) |
|---|---|---|---|---|
|
✅ |
✅ |
✅ |
✅ |
|
✅ |
✅ |
❌ |
❌ |
|
✅ |
✅ |
✅ |
✅ |
|
✅ |
❌ |
✅ |
✅ |
|
❌ |
❌ |
❌ |
❌ |
|
❌ |
❌ |
❌ |
❌ |
|
❌ |
❌ |
❌ |
❌ |
|
✅ |
✅ |
❌ |
❌ |
|
❌ |
❌ |
❌ |
❌ |
|
❌ |
✅ |
❌ |
❌ |
|
❌ |
❌ |
❌ |
❌ |
|
✅ |
❌ |
✅ |
✅ |
|
✅ |
❌ |
❌ |
❌ |
|
✅ |
✅ |
✅ |
❌ |
|
✅ |
✅ |
❌ |
❌ |
|
✅ |
✅ |
❌ |
❌ |
|
✅ |
❌ |
❌ |
❌ |
|
✅ |
❌ |
❌ |
❌ |
|
✅ |
❌ |
✅ |
❌ |
|
✅ |
❌ |
❌ |
❌ |
|
✅ |
❌ |
✅ |
❌ |
|
✅ |
❌ |
❌ |
❌ |
|
✅ |
❌ |
❌ |
❌ |
Model Type |
T2I Adapter |
IP Adapter |
|---|---|---|
|
✅ |
✅ |
|
❌ |
✅ |
|
✅ |
✅ |
|
❌ |
✅ |
|
❌ |
❌ |
|
❌ |
❌ |
|
❌ |
❌ |
|
❌ |
❌ |
|
❌ |
❌ |
|
❌ |
❌ |
|
❌ |
❌ |
|
❌ |
❌ |
|
❌ |
❌ |
|
❌ |
✅ |
|
❌ |
❌ |
|
❌ |
✅ |
|
❌ |
❌ |
|
❌ |
❌ |
|
❌ |
❌ |
|
❌ |
❌ |
|
❌ |
❌ |
|
❌ |
❌ |
|
❌ |
❌ |
Model Type |
sd-embed Prompt Weighting |
compel Prompt Weighting |
llm4gen Prompt Weighting |
|---|---|---|---|
|
✅ |
✅ |
✅ |
|
✅ |
✅ |
✅ |
|
✅ |
✅ |
❌ |
|
❌ |
❌ |
❌ |
|
❌ |
❌ |
❌ |
|
❌ |
❌ |
❌ |
|
❌ |
❌ |
❌ |
|
✅ |
✅ |
❌ |
|
❌ |
❌ |
❌ |
|
✅ |
✅ |
✅ |
|
✅ |
✅ |
❌ |
|
✅ |
❌ |
❌ |
|
✅ |
❌ |
❌ |
|
✅ |
❌ |
❌ |
|
✅ |
❌ |
❌ |
|
✅ |
❌ |
❌ |
|
❌ |
❌ |
❌ |
|
❌ |
❌ |
❌ |
|
❌ |
❌ |
❌ |
|
❌ |
❌ |
❌ |
|
❌ |
❌ |
❌ |
|
❌ |
❌ |
❌ |
|
❌ |
❌ |
❌ |
Model Type |
DyPE |
Cache-DiT |
ADetailer |
FreeU |
Hi-Diffusion |
DeepCache |
Microsoft RAS |
SADA |
TeaCache |
Spectrum |
|---|---|---|---|---|---|---|---|---|---|---|
|
❌ |
❌ |
✅ |
✅ |
✅ |
✅ |
❌ |
✅ |
❌ |
❌ |
|
❌ |
❌ |
❌ |
✅ |
❌ |
✅ |
❌ |
❌ |
❌ |
❌ |
|
❌ |
❌ |
✅ |
✅ |
✅ |
✅ |
❌ |
✅ |
❌ |
✅ |
|
❌ |
❌ |
✅ |
✅ |
✅ |
✅ |
❌ |
✅ |
❌ |
✅ |
|
❌ |
❌ |
❌ |
❌ |
❌ |
❌ |
❌ |
❌ |
❌ |
❌ |
|
❌ |
❌ |
❌ |
❌ |
❌ |
❌ |
❌ |
❌ |
❌ |
❌ |
|
❌ |
❌ |
❌ |
❌ |
❌ |
❌ |
❌ |
❌ |
❌ |
❌ |
|
❌ |
❌ |
❌ |
✅ |
❌ |
✅ |
❌ |
❌ |
❌ |
✅ |
|
❌ |
❌ |
❌ |
✅ |
❌ |
❌ |
❌ |
❌ |
❌ |
❌ |
|
❌ |
❌ |
❌ |
✅ |
❌ |
✅ |
❌ |
❌ |
❌ |
❌ |
|
❌ |
❌ |
❌ |
❌ |
❌ |
❌ |
❌ |
❌ |
❌ |
❌ |
|
❌ |
✅ |
✅ |
❌ |
❌ |
❌ |
✅ |
❌ |
❌ |
✅ |
|
❌ |
✅ |
❌ |
❌ |
❌ |
❌ |
✅ |
❌ |
❌ |
✅ |
|
✅ |
✅ |
✅ |
❌ |
❌ |
❌ |
❌ |
✅ |
✅ |
✅ |
|
✅ |
✅ |
✅ |
❌ |
❌ |
❌ |
❌ |
✅ |
✅ |
✅ |
|
✅ |
✅ |
❌ |
❌ |
❌ |
❌ |
❌ |
✅ |
✅ |
✅ |
|
✅ |
✅ |
✅ |
❌ |
❌ |
❌ |
❌ |
❌ |
❌ |
✅ |
|
✅ |
✅ |
❌ |
❌ |
❌ |
❌ |
❌ |
❌ |
❌ |
✅ |
|
✅ |
✅ |
✅ |
❌ |
❌ |
❌ |
❌ |
❌ |
❌ |
✅ |
|
✅ |
✅ |
❌ |
❌ |
❌ |
❌ |
❌ |
❌ |
❌ |
✅ |
|
✅ |
✅ |
✅ |
❌ |
❌ |
❌ |
❌ |
❌ |
❌ |
✅ |
|
✅ |
✅ |
✅ |
❌ |
❌ |
❌ |
❌ |
❌ |
❌ |
✅ |
|
✅ |
✅ |
❌ |
❌ |
❌ |
❌ |
❌ |
❌ |
❌ |
✅ |
Video Model Feature Support
--model-type ltx generates a whole clip in one pipeline call. The checkpoint’s
model_index.json selects LTX-2.5 (LTX2Pipeline) or the earlier LTX-Video (LTXPipeline).
Feature |
LTX-2.5 |
LTX-Video |
|---|---|---|
Text to video |
✅ |
✅ |
First / last frame images |
✅ |
✅ |
Video conditioning |
✅ |
✅ |
Separate first / last frame processors |
✅ |
✅ |
IC-LoRA control |
✅ |
❌ |
LoRA with IC-LoRA |
✅ |
❌ |
Length predicted from prompt |
✅ |
❌ |
Audio |
✅ |
❌ |
Sigmas and audio guidance |
✅ |
❌ |
LoRA |
✅ |
✅ |
Quantization |
✅ |
✅ |
Replacement transformer |
✅ |
✅ |
Cache-DiT |
✅ |
✅ |
LTX does not support ControlNets, adapters, textual inversions, prompt weighters, or inpainting. Cache-DiT is supported; other acceleration features in the tables above are not. GGUF transformers are tested with LTX-Video. See the video generation section in the manual for LTX-2.5 and the earlier LTX-Video checkpoint.
--model-type wan, --model-type wan-animate, and --model-type wan-animate-2
also generate a whole clip in one pipeline call. Clip length and frame rate are the
shared --video-lengths and --video-fps options.
Feature |
wan |
wan-animate |
wan-animate-2 |
|---|---|---|---|
Text to video |
✅ |
❌ |
❌ |
Image to video |
✅ |
❌ |
❌ |
First / last frame ( |
✅ |
❌ |
❌ |
Video to video |
✅ |
❌ |
❌ |
VACE ( |
✅ |
❌ |
❌ |
Character animation ( |
❌ |
✅ |
❌ |
|
❌ |
❌ |
✅ |
|
❌ |
✅ |
❌ |
Cache-DiT |
✅ |
✅ |
✅ |
MoE second transformer |
✅ |
❌ |
❌ |
LoRA |
✅ |
✅ |
✅ |
Quantization / GGUF |
✅ |
✅ |
✅ |
Spectrum |
✅ |
✅ |
✅ |
DyPE |
✅ |
✅ |
✅ |
Flow Image Model Notes
flux2, flux2-klein-kv, z-image-omni, qwen-image-edit, and
qwen-image-layered take an --image-seeds value with no mask as a
condition image. That is the text-to-image column above. There is no img2img
strength.
flux2 inpainting is Flux.2 Klein only. Full Flux.2 has no inpaint pipeline.
qwen-image-edit inpainting is the edit pipeline with a mask. Edit-plus has
no inpaint pipeline.
ControlNet on z-image and qwen-image is text-to-image and inpaint.
z-image accepts one union model. qwen-image can take more than one.
These model types support LoRA, Cache-DiT, DyPE, and Spectrum. They do not support textual inversions, IP adapters, T2I adapters, prompt weighters, PAG, DeepCache, TeaCache, SADA, RAS, or HiDiffusion.
PAG Support Caveats
PAG is supported for txt2img in all cases, but there are some edge cases in which PAG is not supported.
There is no support for using T2I Adapters with PAG.
Stable Diffusion 3 does not currently support PAG with ControlNets at all.
Stable Diffusion XL does not support PAG in (inpaint + ControlNets) mode.
Stable Diffusion 1.5 - 2.* does not support PAG in img2img, inpaint, or (img2img + ControlNets) mode. It does however support PAG in (inpaint + ControlNets) mode.
Kolors only supports PAG in txt2img mode.
Generation Feature Notes
FreeU parameters differ by model type and can be specified using the --freeu-params option. The recommended parameters for SD1.4, SD1.5, SD2.1, and SDXL can be reviewed here. Kolors is compatible with FreeU’s SDXL settings.
--torch-compile compiles repeated denoiser, ControlNet, and VAE decoder blocks. The first use of each waits while the graph builds. A later change of resolution or frame count compiles once more, then reuses that graph. CUDA and XPU need Triton. On macOS, PyTorch 2.13 and newer compile these blocks to a Metal kernel. CPU and quantized weights stay eager, and dgenerate warns. Text encoders, image encoders, and the LTX diffusion decoder stay eager. Wan-Animate-2 compiles its transformer and VAE blocks on every load. DGENERATE_TORCH_COMPILE=0 leaves every model eager, including Wan-Animate-2.
Faster generation speeds can be achieved by using Cache-DiT, DyPE, DeepCache, Microsoft RAS, SADA, TeaCache, or Spectrum, but may lead to reduced image quality. The default values for each of these features are conservative, providing some speed increases without major impacts on quality.
The DeepCache branch ID and interval can be specified with the --deep-cache-branch-ids and --deep-cache-intervals options. Benchmarks for different parameters can be reviewed here.
Microsoft Region-Adaptive Sampling (RAS) has numerous configurable options that can be reviewed here. Note that the --ras-index-fusion parameter is not compatible with SD3.5.
The TeaCache threshold can be specified with the --tea-cache-rel-l1-thresholds parameter. Information about this parameter can be reviewed here.
SADA cannot be combined with Hi-Diffusion, DeepCache, or TeaCache.
DyPE (--dype) adapts spatial RoPE frequencies during denoising. Use
--dype-methods to try yarn (default), ntk, or the base RoPE
baseline as combinatoric values. The Flux.1 and Qwen-Image adapters follow the upstream architecture; Flux
Fill/Kontext, Qwen Edit/Layered, Flux.2, Z-Image, and Wan are experimental
adapters. Reference long-side defaults are 1024 pixels for Flux/Flux.2/Z-Image,
1328 for Qwen-Image, and 832 for Wan. --dype-mscales controls the yarn
method’s attention magnitude scale: constant (default), decay, or
off. Use decay or off if yarn produces a fine repeating texture,
as it does with FLUX.1-dev. --dype-axis-scalings controls non-square
images: shared (default) applies the long side’s scaling to both axes, as
ComfyUI-DyPE does; independent scales each axis separately, as upstream
DyPE does. DyPE cannot be combined with Cache-DiT,
TeaCache, Spectrum, or SADA, because those features reuse or skip denoiser work
from an earlier step. See the DyPE source and the vendored adapter notes under
dgenerate/extras/dype.
Spectrum (--spectrum) forecasts denoiser block outputs and skips those blocks on later steps. Transformers skip their blocks. SDXL and Kolors skip the UNet down, mid, and up blocks and still run the output convolution. It is supported on SD3, SDXL, Kolors, Flux, Flux.2, Z-Image, Qwen-Image, and Wan. The moderate schedule is the default (window 2, flex 0.75). --spectrum-flex-windows 3 is the paper’s aggressive schedule. Details are at Spectrum.
Usage Manual
- Help Output
- Network Installer
- Windows Install
- Linux or WSL Install
- Linux with ROCm (AMD Cards)
- Linux with opencv-python-headless (libGL.so.1 issues)
- MacOS Install (Apple Silicon Only)
- Google Colab Install
- Install with XPU support
- Installing From Development Branches
- Basic Usage
- Negative Prompt
- Multiple Prompts
- Image Seeds
- Inpainting
- Inpainting With Auto Crop
- Per Image Seed Resizing
- Animated Output
- Video Generation
- Animation Slicing
- Inpainting Animations
- Latents Interchange
- Deterministic Output
- Specifying a specific GPU for CUDA
- Specifying a Scheduler (sampler)
- Specifying Sigmas (denoising schedule)
- Specifying a VAE
- VAE Tiling and Slicing
- Specifying a UNet
- Specifying a Transformer (SD3, Flux, and later flow models)
- Specifying an SDXL Refiner
- Specifying a Stable Cascade Decoder
- Specifying LoRAs
- Specifying Textual Inversions (embeddings)
- Specifying ControlNets
- Flux.2, Z-Image, and Qwen-Image
- Specifying T2I Adapters
- Specifying IP Adapters
- Specifying Text Encoders
- Prompt Upscaling
- The dynamicprompts prompt upscaler
- The magicprompt prompt upscaler
- The llama prompt upscaler
- The attention prompt upscaler
- The translate prompt upscaler
- Basic prompt upscaling example
- Prompt upscaling with LLMs (transformers)
- Prompt upscaling with LLMs (llama)
- Writing prompts from an image
- Customizing LLM output cleanup
- Prompt Weighting
- Embedded Prompt Arguments
- Utilizing CivitAI links and Other Hosted Models
- Specifying Generation Batch Size
- Batching Input Images and Inpaint Masks
- Image Processors
- Latents Processors
- Sub Commands
- Upscaling Images
- Adetailer (YOLO based inpainting)
- Segment Anything Mask Generation
- YOLO + SAM Automated Segmentation
- Quantization
- Cache-DiT Configuration
- Writing and Running Configs
- Basic config syntax
- Built in template variables
- Built in template functions
- Directives, and applying templating
- Setting template variables, in depth
- Setting environmental variables, in depth
- Globbing and path manipulation
- Importing arbitrary python modules
- String and text escaping behavior
- The \print and \echo directive
- The \image_process directive
- The \exec directive
- The \download directive
- The download() template function
- The \exit directive
- Running configs from the command line
- Config argument injection
- Setting template variables from the CLI
- Console UI
- Writing Plugins
- Utilizing the Python Environment for Training
- Auth Tokens
- File Cache Control
- Torch Compile
- Startup Configuration