TL;DR
DIVE (Diffusion model InVErsion) repurposes frozen, pretrained generative diffusion models for discriminative tasks like object detection and classification without any fine-tuning. By inverting the generative process using Bayes' rule and a novel gradient-based optimization in the embedding space, DIVE achieves competitive performance with a 14x speedup over previous diffusion-based classification methods.
What Problem Does This Paper Address?
While diffusion models have revolutionized image generation, a fundamental question remains: do these models truly "understand" the visual world, or are they just high-end stochastic parrots? If a model can generate a perfect image of a "goldfinch," it should, in theory, be able to recognize one.
Previous attempts to use generative models for recognition (like the "Diffusion Classifier") relied on enumeration. To classify an image, the model would calculate the likelihood of that image belonging to every possible class (e.g., "is it a cat?", "is it a dog?"). This works for 1,000 ImageNet classes but fails completely for object detection, where the "label" is a complex layout of multiple bounding boxes and categories. The number of possible layouts is effectively infinite, making enumeration impossible. Furthermore, these earlier methods assumed all labels were equally likely, ignoring the natural "prior" distribution of how objects appear in the real world.
Methods
The authors propose DIVE, which treats discriminative tasks as an inversion problem based on Bayes' rule: $p(y|x) \propto p(x|y)p(y)$.
- Likelihood ($p(x|y)$): They use a frozen, pretrained layout-to-image Latent Diffusion Model (LDM). This model tells us how likely an image $x$ is, given a specific layout $y$.
- Prior Layout Model ($p(y)$): Unlike classification, object layouts aren't uniform. You're more likely to see a car on a road than a car on a cloud. The authors train a small, separate diffusion model specifically to learn the distribution of valid object layouts from the training data.
- Optimization-based Inversion: Instead of checking every possible layout, DIVE treats the layout $y$ as a set of learnable parameters. It starts with a "blank" layout and uses gradient descent to find the layout that maximizes the posterior probability (the "best fit" for the image).
- Discrete Optimization Trick: Since looking up embeddings in a vocabulary is non-differentiable, they use a "nearest neighbor" replacement trick (similar to VQ-VAE). They optimize in the continuous embedding space but "snap" the values to the nearest valid discrete embeddings during the forward pass, allowing gradients to flow back effectively.
Datasets
The researchers evaluated DIVE on two primary benchmarks:
- COCO 2017: Used for the complex object detection task (118k training images).
- ImageNet-1k: Used to benchmark the method against previous diffusion-based classification approaches.
Key Insights and Ideas
- Generative Models as Zero-Shot Detectors: The most striking insight is that a model trained only to create images already contains the necessary spatial and semantic knowledge to locate and identify objects, provided you have the right "key" to unlock it.
- The Prior Matters: The paper demonstrates that for complex tasks like detection, the prior $p(y)$ is essential. Without it, the inversion process often produces "illegal" layouts or redundant boxes that the generative model might technically accept but which don't represent real-world logic.
- Efficiency through Optimization: Moving from enumeration to gradient-based optimization is the "aha moment" for speed. By following the gradient of the loss function, the model converges on the correct label much faster than checking classes one by one.
Key Results
- Object Detection: DIVE is the first method to successfully invert a diffusion model for object detection. It achieved 7.1 AP on a COCO subset, outperforming basic generative-discriminative hybrids and staying competitive with a standard Faster R-CNN R50 (6.8 AP) in similar constrained settings.
- Classification Speedup: On ImageNet, DIVE reached 77.2% accuracy, nearly identical to the original Diffusion Classifier (77.3%). However, it reduced the inference time from ~1100 seconds per image to just 80 seconds—a 14x speedup.
- Evaluation Metric: The authors show that DIVE can be used as a new metric to evaluate generative models. Models that have better "discriminative" scores via DIVE often align better with human-perceived quality and diversity metrics like FID and Precision/Recall.
Limitations and Future Work
Despite the progress, DIVE is still significantly slower than dedicated discriminative models (which run in milliseconds). The authors acknowledge that the computational cost of backpropagating through a U-Net multiple times is high.
Future work suggests exploring adaptive optimization steps (stopping early for "easy" images) to further boost speed. Additionally, extending this to "dense" tasks like semantic segmentation remains a challenge, as the optimization space for every pixel in an image is massive compared to a sequence of object bounding boxes.
Summary updated