A simple, guided application for training LoRA models for Stable Diffusion 1.5 and SDXL.
cd lora_trainer
pip install -r requirements.txt
python main.pyThe app opens at http://localhost:7860.
One app. Open it, follow the steps, get a LoRA file ready for ComfyUI.
No command line. No scattered settings. No jargon.
1. System Check - Verify GPU and environment
2. Pick your base model (SD 1.5 or SDXL, local or HuggingFace)
3. Import your images with captions
4. Choose what you're training (Style / Subject / Concept)
5. Review and start
6. Watch it train with live loss graph
7. Get your .safetensors file → drop into ComfyUI
- Data Augmentation: Automatic flip, color jitter, and affine transforms to improve generalization with small datasets
- Shuffled Epochs: Each training epoch shuffles image order for better learning
- Presets: Pre-configured settings for Style, Subject, and Concept training
- Live Monitoring: Real-time loss graph during training
- ComfyUI Integration: Auto-copy LoRA to ComfyUI folder (if detected)
- Python 3.10+
- CUDA-capable GPU (6GB+ minimum, 8GB+ recommended for SD 1.5, 12GB+ for SDXL)
- ~10GB disk space for models
When you download a base model from HuggingFace, it is cached on your disk for future use.
| Source | What Happens |
|---|---|
| HuggingFace download | Model downloads once (~2-7GB), stored in cache at ~/.cache/huggingface/hub/. Future runs use cached version - no re-download. |
| Local file | Copied to a temp folder during loading, cleaned up after training. No persistent cache. |
Windows: C:\Users\YOUR_USER\.cache\huggingface\hub\
Mac/Linux: ~/.cache/huggingface/hub/
- Cache persists between sessions - speeds up future runs
- To free disk space: Delete the cache folder manually
- To force re-download: Delete the specific model folder from cache
⚠️ Important: HuggingFace downloads are not automatically deleted after training. If you download SDXL and multiple SD 1.5 models, they will all stay in your cache占用 disk space.
| Dataset Size | Recommended |
|---|---|
| 10-15 images | Use data augmentation, 2500-3000 steps |
| 15-30 images | Augmentation optional, 3000-4000 steps |
| 30+ images | No augmentation needed, 3500-5000 steps |
Rank recommendations:
- Style LoRA: 64-128
- Subject LoRA: 128-256
- Concept LoRA: 64-128
ddd_Lora_Creator/
├── 01_what_is_lora.md # LoRA basics for beginners
├── 02_lora_technology_and_architecture.md # Technical deep-dive
├── 03_training_loras_and_using_in_comfyui.md # Complete usage guide
└── lora_trainer/
├── main.py # Entry point
├── core/
│ ├── pipeline.py # Training loop
│ ├── dataset.py # Image loading + augmentation
│ └── model.py # Model loading + LoRA injection
├── ui/
│ └── wizard.py # Gradio interface
└── presets/
└── configurations.py # Training presets
Each image needs a .txt file with the same name:
dataset/
image_001.png
image_001.txt ← Include your trigger word, e.g.:
a woman with ddd_my_style, outdoor, natural lighting
image_002.png
image_002.txt ← ddd_my_style, portrait, studio lighting
- Copy
.safetensorstoComfyUI/models/loras/ - Add Load LoRA node after Load Checkpoint
- Set strength_model: 0.7-0.8
- Include trigger word in your prompt