[Paper Review] Your Diffusion Model is Secretly a Zero-Shot Classifier
This paper proposes Diffusion Classifier, a method to extract zero-shot and standard image classifiers from pre-trained conditional diffusion models—such as Stable Diffusion and DiT—without any additional training by leveraging the model's conditional likelihood estimates via the ELBO. It achieves strong zero-shot accuracy, outperforms contrastive baselines on compositional reasoning, and shows superior robustness to distribution shift.
The recent wave of large-scale text-to-image diffusion models has dramatically increased our text-based image generation abilities. These models can generate realistic images for a staggering variety of prompts and exhibit impressive compositional generalization abilities. Almost all use cases thus far have solely focused on sampling; however, diffusion models can also provide conditional density estimates, which are useful for tasks beyond image generation. In this paper, we show that the density estimates from large-scale text-to-image diffusion models like Stable Diffusion can be leveraged to perform zero-shot classification without any additional training. Our generative approach to classification, which we call Diffusion Classifier, attains strong results on a variety of benchmarks and outperforms alternative methods of extracting knowledge from diffusion models. Although a gap remains between generative and discriminative approaches on zero-shot recognition tasks, our diffusion-based approach has significantly stronger multimodal compositional reasoning ability than competing discriminative approaches. Finally, we use Diffusion Classifier to extract standard classifiers from class-conditional diffusion models trained on ImageNet. Our models achieve strong classification performance using only weak augmentations and exhibit qualitatively better "effective robustness" to distribution shift. Overall, our results are a step toward using generative over discriminative models for downstream tasks. Results and visualizations at https://diffusion-classifier.github.io/
Motivation & Objective
- To investigate whether pre-trained conditional diffusion models can serve as effective zero-shot classifiers without additional training.
- To bridge the performance gap between generative and discriminative models on image classification tasks.
- To evaluate the multimodal compositional reasoning and robustness of generative models in comparison to discriminative counterparts.
- To extract standard classifiers from class-conditional diffusion models like DiT using only weak augmentations.
- To demonstrate that generative modeling can be a viable alternative to discriminative learning for downstream tasks.
Proposed method
- The method uses the variational lower bound (ELBO) of the diffusion model to approximate the conditional log-likelihood $\log p_{\theta}(\mathbf{x} \mid \mathbf{c})$ for each class $\mathbf{c}$.
- For each input image $\mathbf{x}$, it computes a Monte Carlo estimate of the expected noise reconstruction loss (i.e., $\epsilon$-prediction loss) across multiple timesteps to estimate $p(\mathbf{x} \mid \mathbf{c})$.
- It applies Bayes’ theorem with a uniform prior to compute class probabilities $p(\mathbf{c} \mid \mathbf{x})$ from the estimated likelihoods.
- The approach uses uniformly weighted $\ell_2$ losses across timesteps to reduce variance and improve accuracy, outperforming weighted or variational-only objectives.
- It enables fast inference by using resolution reduction, class pruning via weak discriminative models, and parallelization of noise prediction steps.
- The method is applied to both text-to-image models (e.g., Stable Diffusion) and class-conditional models (e.g., DiT) to extract classifiers.
Experimental results
Research questions
- RQ1Can pre-trained diffusion models be used as zero-shot image classifiers without fine-tuning?
- RQ2How does the performance of a diffusion-based classifier compare to state-of-the-art discriminative models on zero-shot recognition tasks?
- RQ3To what extent do diffusion models exhibit stronger multimodal compositional reasoning than discriminative models?
- RQ4Can class-conditional diffusion models be used to extract robust, high-accuracy standard classifiers with minimal data augmentation?
- RQ5How does the design of the diffusion model (e.g., latent vs. pixel space, text encoder choice) affect the resulting classifier’s performance?
Key findings
- Diffusion Classifier achieves 77.5% zero-shot accuracy on ImageNet using Stable Diffusion, outperforming alternative knowledge-extraction methods.
- On the Winoground benchmark, it significantly outperforms the strongest contrastive baselines in multimodal compositional reasoning.
- For DiT, a class-conditional diffusion model trained on ImageNet, the method achieves 79.1% top-1 accuracy using only weak augmentations.
- The resulting classifier exhibits better 'effective robustness' to distribution shift than competing discriminative models trained on the same data.
- Uniformly weighting $\ell_2$ losses across timesteps yields the best performance, outperforming both variational lower bound and combined objectives.
- Inference can be accelerated by reducing resolution (e.g., $256^2$ or $128^2$) or using weak discriminative models to prune unlikely classes early.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.