Introduction
Deep learning models often fail when encountering out-of-distribution (OOD) data, such as images affected by adverse weather, sensor noise, or artistic stylization. Traditional Test-Time Adaptation (TTA) methods typically update model weights on-the-fly, which is computationally expensive and leads to model versioning issues across different deployments. Generalized Diffusion Adaptation (GDA) offers a paradigm shift: instead of adapting the model, it adapts the input. By leveraging pre-trained diffusion models, GDA "purifies" OOD images, shifting them back toward the source training distribution before classification.
Methodology: Structural Guidance in Diffusion
The core of GDA is a novel Structural Guidance mechanism integrated into the reverse sampling process of a diffusion model. Unlike previous purification methods that focus on simple noise removal, GDA iteratively guides image generation using three distinct objectives:
- Marginal Entropy Minimization: GDA generates multiple augmented views of a denoised image and minimizes the average entropy of the classifier's predictions. This ensures the resulting image is one the classifier can identify with high confidence and consistency.
- Style Transfer via CLIP: To bridge the gap between stylized OOD samples (e.g., sketches) and the source domain (e.g., photos), GDA employs a CLIP-based loss with text prompts like "photo-realistic."
- Content Preservation: A patch-wise contrastive loss, utilizing internal UNet features, ensures that the spatial structure and semantic content of the original image are preserved during the transformation.
A final confidence filtering step acts as a safeguard, reverting to the original image if the adaptation process decreases the classifier's certainty.
Experimental Evaluation
GDA was rigorously tested on four ImageNet-based OOD benchmarks: ImageNet-C (synthetic corruptions), ImageNet-R (renditions), ImageNet-Sketch, and ImageNet-Stylized.
Performance and Visual Results
GDA consistently outperformed state-of-the-art diffusion-based methods like DDA and DiffPure. On ImageNet-C, it achieved accuracy improvements of 4.4% to 5.02%. On more challenging style-shift datasets, improvements ranged from 2.5% to 7.4%. Notably, GDA achieves these results with as few as 10 diffusion steps, making it significantly faster than previous purification techniques.
Qualitative analysis demonstrates GDA's ability to re-colorize sketches and remove distracting backgrounds from paintings, making them recognizable to standard classifiers like ResNet50.
Discussion and Future Work
GDA's "fix the data, not the model" approach makes it highly versatile and compatible with any classifier architecture (e.g., ResNet, ConvNext, Swin Transformer) without retraining. While it offers a robust solution for OOD shift, the computational cost of running diffusion at test time remains a challenge for low-latency edge devices. Future research will explore automated prompt engineering for style loss and extending GDA to tasks beyond classification, such as object detection and segmentation.
Summary updated