- Updated `load_model` and `download_and_load_model` methods in `dsd_nodes.py` to include new parameters for CPU memory management and offloading options. - Introduced `DSDResizeSelector` class for flexible image resizing options, including methods for center cropping, padding, and fitting images. - Enhanced `center_crop_and_resize` and added new utility functions in `utils.py` for improved image processing. - Updated `README.md` to document the new resizing options available in the DSD Image Generator. These changes improve memory efficiency and provide users with more control over image processing during model inference.
ComfyUI-DSD
An Unofficial ComfyUI custom node package that integrates Diffusion Self-Distillation (DSD) for zero-shot customized image generation.
DSD is a model for subject-preserving image generation that allows you to create images of a specific subject in novel contexts without per-instance tuning.
Features
- Subject-preserving image generation using DSD model
- Gemini API prompt enhancement
- Direct model download from Hugging Face
- Fine-grained control over generation parameters
Installation
- Clone this repository into your ComfyUI custom_nodes folder:
cd ComfyUI/custom_nodes
git clone https://github.com/irreveloper/ComfyUI-DSD.git
- Install the required dependencies:
pip install -r requirements.txt
-
Get the model files (two options):
- Option 1: Use the
DSD Model Downloadernode in ComfyUI to automatically download the model - Option 2: Download manually from Hugging Face or Google Drive
The model files will be stored in:
ComfyUI/models/dsd_model/transformer/(for transformer files)ComfyUI/models/dsd_model/pytorch_lora_weights.safetensors(for LoRA file)
- Option 1: Use the
-
Restart ComfyUI
Available Nodes
-
DSD Model Downloader: Automatically downloads the model from Hugging Face
-
DSD Model Loader: Loads a pre-downloaded model
-
DSD Model Selector: Helps select models from local directories
-
DSD Gemini Prompt Enhancer: Uses Google's Gemini API to enhance prompts for better image generation results. The API key can be provided in two ways:
- As an input parameter to the node (not recommended for sharing workflows)
- Through the
GEMINI_API_KEYenvironment variable (strongly recommended)
Note: To use the enhanced prompts, make sure to enable the
use_gemini_promptoption on the DSD Image Generator node. If you don't enter a API Key it will be skipped automatically. -
DSD Image Generator: Generates images with the DSD model
-
DSD Resize Selector: Provides flexible image resizing options for the DSD Image Generator:
- center_crop: Center crops the image and resizes (default behavior)
- crop: Simple center crop and resize
- pad: Preserves aspect ratio and adds padding to reach target size
- fit: Resizes to target dimensions without preserving aspect ratio
- Additional options for interpolation method and padding color
Basic Workflow
Troubleshooting
- Memory Issues: Try reducing precision (use bfloat16), lower resolution, or fewer steps
- Gemini API: Ensure you have a valid API key (can be set via GEMINI_API_KEY environment variable)
- Model Loading: If you see errors, try using the Model Downloader node to re-download files
Examples
Check the examples directory for sample workflows.

