Supported models
- Stable Diffusion 1.4
- Stable Diffusion 2.x
Dreambooth training uses prior preservation to maintain model quality while learning the new concept.
Basic training
Dataset preparation
Prepare instance images
Create a directory with 3-5 images of your subject:Each image should clearly show the subject you want to train.
Prepare class images (optional)
Create or generate 100-200 images of the same class:MaxDiffusion can automatically generate class images using
num_class_images.Configuration
Dreambooth training extends the base Stable Diffusion configs with additional parameters.Dreambooth-specific parameters
| Parameter | Default | Description |
|---|---|---|
instance_data_dir | '' | Directory with instance images (your subject) |
class_data_dir | '' | Directory with class images (for prior preservation) |
instance_prompt | '' | Prompt describing instance (e.g., “a photo of ohwx dog”) |
class_prompt | '' | Prompt describing class (e.g., “a photo of a dog”) |
num_class_images | 100 | Number of class images to generate if missing |
prior_loss_weight | 1.0 | Weight for prior preservation loss |
cache_dreambooth_dataset | False | Cache preprocessed dataset |
Training parameters
Recommended settings for Dreambooth:Model configuration
Use Stable Diffusion 1.4 or 2 Base:Example: Training on a custom subject
Dog example
Person example
Prior preservation
Prior preservation prevents the model from overfitting to your instance images by training on both:- Instance images: Your specific subject (e.g., your dog)
- Class images: General examples of the class (e.g., random dogs)
Adjusting prior preservation
Increaseprior_loss_weight to preserve more of the original model:
Dataset caching
For faster training iterations, cache the preprocessed dataset:Hyperparameter tuning
Learning rate
- Too high (greater than 1e-5): Model forgets original capabilities, overfits to instances
- Too low (less than 1e-7): Slow learning, may not capture subject
- Recommended: 2e-6 to 5e-6
Training steps
- Too few (less than 100): Subject not learned well
- Too many (greater than 400): Overfitting, loss of diversity
- Recommended: 150-250 steps
Number of instance images
- Minimum: 3 images
- Recommended: 5-10 images
- Maximum: 20 images (beyond this, standard fine-tuning may be better)
Number of class images
- Recommended: 100-200 images
- More class images = better prior preservation
- Fewer class images = faster training but possible overfitting
Generate images after training
Use your Dreambooth model to generate images:Best practices
Image quality
- Use high-quality, well-lit images
- Show subject from multiple angles
- Vary backgrounds and contexts
- Avoid heavily edited or filtered images
Prompt engineering
- Use a rare identifier token (ohwx, sks, xyz123)
- Include the class name in prompts (“dog”, “person”, “style”)
- Keep instance and class prompts similar in structure
Training tips
- Start with default hyperparameters
- Monitor loss - should decrease steadily
- Test generation every 50 steps to check progress
- Use GCS buckets for output to prevent data loss
- Enable profiling for the first run to check performance
Troubleshooting
Model overfits to training images
- Decrease
max_train_steps(try 100 instead of 150) - Increase
prior_loss_weight(try 1.5 or 2.0) - Add more varied instance images
Subject not learned well
- Increase
max_train_steps(try 200 or 250) - Increase
learning_rate(try 5e-6) - Reduce
prior_loss_weight(try 0.5) - Use more instance images
Generated images lack diversity
- Increase
num_class_images(try 200) - Increase
prior_loss_weight - Use more diverse instance images
Out of memory
- Reduce
per_device_batch_sizeto 1 - Use
bfloat16for weights and activations - Disable
cache_dreambooth_dataset
Advanced configuration
Optimizer settings
Data preprocessing
Checkpointing
Monitoring
View training progress:- Training loss (should decrease)
- Learning rate (follows schedule)
- Step time (should stabilize after warmup)