This project is a Stable Diffusion fine-tuning example designed to help users perform additional training on a pretrained Stable Diffusion model using a custom dataset, thereby generating images in a specific style or theme and reducing reliance on complex prompt engineering.
Main capabilities:
- Provides a complete fine-tuning workflow, including dataset preparation, image caption generation, training configuration, and model usage.
- Uses the BLIP image captioning model to automatically generate text descriptions for unlabeled datasets, reducing manual annotation costs.
- Provides a YAML-based configuration file for easily modifying parameters such as dataset paths and validation prompts.
- Supports multi-GPU training; the example uses 2 A6000 GPUs, trains for about 15,000 steps, takes about 6 hours, and costs about $10.
- The trained model is compatible with existing Stable Diffusion repositories or user interfaces and can be converted to the Huggingface Diffusers format.
Usage:
- Prepare the dataset: images must be accompanied by text descriptions; refer to the Pokémon dataset used in the example (already uploaded to Huggingface, containing BLIP-generated descriptions).
- Download the original model weights (sd-v1-4-full-ema.ckpt).
- Use the modified training code (justinpinkney/stable-diffusion) and a custom YAML configuration file.
- Run main.py with parameters, such as -t for training, --base to specify the configuration file, --gpus to specify GPUs, --finetune_from to specify the original weights path, etc.
- During training, logs and samples are saved in the logs folder, and model performance can be observed through validation prompts.
- When using the fine-tuned model, simply modify the checkpoint path in txt2img.py.
Applicable scenarios:
- Researchers or developers who want to generate images in a specific style (such as Pokémon style).
- Users who need to customize an image generation model to reduce prompt engineering work.
- Deep learning enthusiasts learning the Stable Diffusion fine-tuning workflow.
Limitations:
- Training requires a GPU with at least 24GB of VRAM; if VRAM is insufficient, batch size and gradient accumulation steps need to be adjusted.
- The dataset and model weights used in the example must be downloaded separately, and training costs (time, expense) vary depending on hardware and dataset size.
- Automatically generated image descriptions may not be completely accurate, but the example considers them sufficient for training.
- The project does not provide detailed fee or pricing information; it only mentions an estimated cost for the example training.