TL;DR
DreamBooth shows how to make a large text-to-image model draw one specific object, such as your dog or a particular handbag, in new scenes. It takes 3 to 5 photos of the subject, gives the subject a rare made-up word, and fine-tunes the model on those photos. A second training term, the prior preservation loss, stops the model from forgetting what the rest of its class looks like. The result is a model that keeps the subject's details while following new text prompts.
Builds on: Photorealistic Text-to-Image Diffusion Models with Deep Language Understanding, Prior Preservation Loss · Leads to: personalised image generation in general, where a single subject is added to a model that already knows the world
Why it mattered
Before this work, a text-to-image model could draw "a dog" but not your dog. Prompting harder did not help much, because words like "brown dog with a white chest" match thousands of animals. DreamBooth made a single subject a first-class thing the model can draw on request. The paper's examples include a vase in the snow, a vase on the beach, and a vase in the jungle.
The recipe spread quickly. Open-source toolkits, including the Hugging Face diffusers library, ship DreamBooth training scripts for Stable Diffusion, so people can personalise a model on a single consumer GPU with a few photos. The core idea, a rare identifier plus a class word plus a regularising loss, has been reused by later personalisation methods.
The problem
Three things were broken before this paper.
- Text cannot name a specific subject. A diffusion model maps a prompt to an image through a text encoder. Describing a particular clock in words is too lossy, so the model produces a clock that looks similar but not identical.
- Image-only methods lose the scene. Image-guided tools copy the look of the reference but cannot easily move the subject into a new context.
- Naive fine-tuning breaks the model. Training on 3 to 5 images for a long time makes the model overfit: every output looks like the training photos, and the general class (all dogs, all vases) drifts. The paper calls the second part language drift, a term borrowed from language models that lose general grammar when fine-tuned on a narrow task.
DreamBooth needs a method that adds a new subject to the model's vocabulary, lets the subject be combined with the words of any scene, and does not damage the class.
How it works
Take one tiny concrete case: a user has 4 photos of their dog, Rex. The model is a pretrained text-to-image diffusion model.
- Pick an identifier. Choose a rare token from the tokenizer's vocabulary, such as a short string that is rare in the training data. Call it [V]. The paper argues that common English words such as "unique" already carry meaning, so the model would have to unlearn that meaning first.
- Write the caption. Label every photo "a [V] dog". The word "dog" ties the new word to the class the model already understands. Without it, training is slower and language drift is worse.
- Make class images. Before training, ask the frozen original model to draw about 1000 images from the prompt "a dog", using random starting noise. These are the prior images. They show the model what dogs in general look like.
- Fine-tune on both sets. At each training step, compute a loss on a photo of Rex with the caption "a [V] dog", and a second loss on one of the model's own dog images with the caption "a dog". Add them with weight lambda. Update the weights of the model.
- Use it. Write a new prompt such as "a [V] dog on a beach at sunset". The model binds [V] to Rex, so the output shows Rex in the new scene.
Check: after step 2, the caption "a [V] dog" has 2 meaningful words in it, the identifier and the class. After step 4, a training step has two losses, so the total is their sum with the second one scaled by lambda.
flowchart LR A["3 to 5 subject photos"] --> C["Caption: a V dog"] B["Frozen model draws about 1000 a dog images"] --> D["Prior images"] C --> E["Subject loss"] D --> F["Prior preservation loss"] E --> G["Total loss = subject loss + lambda times prior loss"] F --> G G --> H["Update model weights"] H --> I["Prompt with V: new scenes of Rex"]
Worked examples
Take one photo of Rex and one class image. Suppose the model's squared error on the photo is 0.20 and on the class image is 0.10, with and weights .
- The subject term is .
- The prior term is .
- The total is .
Interpretation: the update that lowers this total improves both how Rex looks and how well the model still draws dogs in general.
The paper trains Imagen for about 1000 iterations with and learning rate . For Stable Diffusion it uses learning rate . It generates about 1000 class images, though fewer can be used. Training takes about 5 minutes on one TPUv4 for Imagen, and about 5 minutes on one NVIDIA A100 for Stable Diffusion.
- The 1000 prior images give the model a broad sample of the class at the start.
- The learning rate is small, so the weights move only a little per step, which limits overfitting to the 3 to 5 photos.
- The prior term runs at every step, so the model is pulled back toward the class even when the subject loss is still falling.
- Result: the subject is learned in about 1000 steps, and the model still generates varied dogs.
Interpretation: the paper's numbers show that DreamBooth is cheap to run, which is why it became practical.
A training run reports the subject term 0.15 and the prior term 0.30. You want the prior term to count for half as much as the current setting. What lambda should you use, and what is the new total?
Answer: the current lambda is 1. Half as much weight means lambda = 0.5. The new total is .
The math
Let be a photo of the subject and the embedding of its caption "a [V] dog". A diffusion model is trained to denoise: it is given a noisy version of the image, where is Gaussian noise, and it predicts the clean image . The usual denoising loss is a weighted squared error between that prediction and the clean image.
Step 2 in symbols. The caption embedding is . Here is the tokenizer that turns text into tokens, and is the text encoder. The class prompt for the prior images uses the same encoder: .
Step 3 in symbols. Each prior image comes from sampling the frozen model: , where is random noise drawn from a standard Gaussian, . The frozen model is never updated, so these images are a fixed record of its prior.
Step 4 in symbols. The full objective is
The first term is the subject loss. The second term is the prior preservation loss. Its weight is , and the paper uses . The weights and come from the noise schedule, and the two noise levels and are sampled independently.
In the tiny case, suppose the subject term is 0.20 and the prior term is 0.10 for one step. With the total is . With it would be , which gives the prior term less say in the update.
Rare identifier. The paper does not give a formula for the identifier, but for Imagen it samples tokens at random from those of at most 3 Unicode characters (without spaces) in the T5-XXL token range 5000 to 10000, so the model has little prior for them.
Results
The paper evaluates two things: subject fidelity, how much the generated subject looks like the real one, and prompt fidelity, how well the image follows the text. It uses DINO and CLIP-I for the first, and CLIP-T for the second. DINO is preferred because it is not trained to ignore differences between subjects of the same class, whereas CLIP-I can score two different subjects of one class as close.
| Method | DINO (higher is better) | CLIP-I (higher is better) | CLIP-T (higher is better) |
|---|---|---|---|
| Real images | 0.774 | 0.885 | not applicable |
| DreamBooth (Imagen) | 0.696 | 0.812 | 0.306 |
| DreamBooth (Stable Diffusion) | 0.668 | 0.803 | 0.305 |
| Textual Inversion (Stable Diffusion) | 0.569 | 0.780 | 0.255 |
In a user study with 72 participants (1800 answers in total), DreamBooth on Stable Diffusion was preferred over Textual Inversion for subject fidelity 68% of the time and for prompt fidelity 81% of the time.
The ablation on Imagen with 15 subjects isolates the prior term. With the prior preservation loss, the prior metric PRES (the DINO similarity between generated class images and the real subject, so lower means less of the subject leaks into the class) falls from 0.664 to 0.493, and the diversity metric DIV rises from 0.371 to 0.391. Subject fidelity drops slightly, DINO from 0.712 to 0.684. This is the trade the loss is designed to make: a little less snapping to the training photos for more variety and a class that survives.
Limits. The paper reports failure modes. For rare objects such as backpacks, the subject can clash with the class prior and come out misshapen. The context and the subject's appearance can become entangled, so a prompt can change the subject's colour. And with a few photos it can overfit and reproduce the training shots. Common subjects such as dogs and cats were easier to learn than rare objects. Two photos were enough for a common dog, while a backpack needed at least three.
Reading guide
- Introduction explains the goal: implant a subject under a unique identifier, using the class word to keep the prior. Read it with Diffusion Model and Language Model in mind.
- Related work compares with GAN editing, CLIP-based editing, and Textual Inversion. Learning Transferable Visual Models From Natural Language Supervision (CLIP) and Hierarchical Text-Conditional Image Generation with CLIP Latents are the background for the CLIP and image-guided parts.
- Method. Section 3.1 gives background on text-to-image diffusion, which needs Diffusion Model. Section 3.2, the fine-tuning technique, needs Fine-Tuning and Overfitting, and the identifier needs Subword Tokenization. Section 3.3, prior preservation, needs Prior Preservation Loss and Learning Rate.
- Experiments needs Emerging Properties in Self-Supervised Vision Transformers for the subject metric, and Cosine Similarity for every score.
- Background for the Stable Diffusion side: U-Net and Latent Diffusion Model.
Check yourself
QuestionWhy does the caption contain the class word 'dog' as well as the identifier?Show answer
QuestionWith lambda = 1, a subject term of 0.25 and a prior term of 0.05, what is the total loss?Show answer
QuestionWhy does the paper generate the class images with the frozen model instead of using a dataset of dogs?Show answer
QuestionA user fine-tunes on 4 photos for 20000 steps with no prior term and gets images that look just like the photos. Which failure is this and what does the paper suggest?Show answer
QuestionWhich metric would you use to check that a generated dog is your dog, and why not the other?Show answer
Sources
- Ruiz et al., "DreamBooth: Fine Tuning Text-to-Image Diffusion Models for Subject-Driven Generation," arXiv 2208.12242, 2022. https://arxiv.org/abs/2208.12242
- Ruiz et al., CVPR 2023. https://doi.org/10.1109/CVPR52729.2023.02155
- Project page: https://dreambooth.github.io/