TL;DR
Pretrained vision models frequently misclassify images that are rotated, scaled, or sheared. This paper introduces a zero-shot, training-free framework that reframes "canonicalization"—the act of geometrically undoing these transformations—as an out-of-distribution (OOD) detection problem. By minimizing distance-based OOD scores using a simple random search with local refinement, paired with a smart gating mechanism, they achieve massive robustness gains on transformed data without sacrificing in-distribution accuracy.
What Problem Does This Paper Address?
Deep learning models are notoriously sensitive to spatial transformations like rotation, scaling, and shearing. If a model only saw upright objects during training, a sideways or skewed object can completely break its predictions.
Traditional fixes involve data augmentation (retraining the model with transformed images) or designing specialized equivariant architectures. However, both approaches require modifying or completely retraining the model from scratch, which is impractical for already-deployed, black-box systems.
Test-time canonicalization offers an elegant alternative: leave the classifier untouched, and instead find a way to "undo" the transformation of the input before feeding it to the model. Unfortunately, existing canonicalizers rely on a very narrow set of logit-based confidence scores and complex, bespoke search procedures that often degrade performance on images that were already perfectly aligned.
Methods
The authors reframe test-time canonicalization as an Out-of-Distribution (OOD) detection problem. The core intuition is simple: an object in its standard, upright pose lies in a high-density region of the training distribution (In-Distribution, or ID). A transformed object (e.g., rotated 90 degrees) looks like an OOD sample. Therefore, finding the canonical pose means searching through possible transformations to minimize the input's OOD score.
The framework introduces two key components:
- OOD-based Energy Minimization: The authors systematically benchmark around 20 training-free OOD scoring functions across four families (logit-based, activation-rectification, prototype-based, and kNN-based) to serve as the energy function to minimize over the transformation group.
- Gated Canonicalization: Unconditionally transforming every image can distort features and hurt accuracy for already-aligned inputs. To fix this, the authors introduce a lightweight gating mechanism consisting of a selection gate (only canonicalize if the initial OOD score is above a threshold $\tau$) and an acceptance gate (only keep the transformed version if its OOD score actually improved).
For the optimization backend, they show that complex, bespoke search methods can be replaced by a simpler global optimizer: Random Search with Local Refinement (RS-LR), which samples the parameter space globally using Sobol sequences and then applies gradient descent to the best candidate.
Datasets
The authors evaluated their approach across a diverse set of benchmarks covering 2D images, sketches, and 3D data:
- MNIST & EMNIST Balanced: Standard handwritten digits and letters, augmented with random rotations, shearing, and scaling.
- SI-Score (Rotation): A large-scale robustness benchmark featuring ImageNet foreground objects randomly rotated onto different backgrounds.
- TU Berlin: A 2D sketch dataset drawn with single lines.
- ModelNet10: A 3D point cloud dataset used to test spatial robustness beyond 2D images.
Key Insights and Ideas
- Distance-Based Beats Logit-Based: While previous test-time canonicalization methods relied heavily on logit-based confidence scores, this paper reveals that feature-space distance-based methods (like kNN and prototype distances) perform significantly better. They capture the data manifold structure more accurately than final model outputs.
- Simpler Search Wins: Instead of complex Lie-algebra or tree-search methods, a combination of global uniform sampling followed by local gradient-based tweaking (RS-LR) yields the best balance of accuracy and optimization reliability.
- The Gating Necessity: Canonicalization should be treated as a conditional corrective mapping, not an unconditional preprocessing step. Gating decouples the task of preserving ID accuracy from restoring OOD robustness, turning a harsh trade-off into a controllable threshold parameter.
Key Results
- SI-Score (ImageNet objects): On the challenging SI-Score rotation benchmark using a ResNet-50 backbone, the proposed OOD-based canonicalization (OODC) using a per-class kNN score improved top-1 accuracy by over 12 percentage points compared to the vanilla model, vastly outperforming previous logit-energy baselines.
- Training-Free Superiority: Across MNIST, EMNIST, TU Berlin, and ModelNet10, OODC consistently achieved the highest accuracy on transformed test data among all training-free methods. For instance, on transformed ModelNet10, it boosted accuracy from 20.5% (vanilla) to 59.6%.
- ID Preservation: Thanks to the gating mechanism, the framework preserves almost all in-distribution accuracy on untransformed data while maintaining robust gains on transformed data.
Limitations and Future Work
- Inference Latency: The method requires a budget of around 60 sample evaluations per input to search for the optimal transformation. While lightweight, this search overhead might limit its applicability in strict real-time systems.
- Deep Feature Information Loss: Relying purely on deep features can sometimes discard critical spatial information needed for perfect geometric alignment.
- Future Directions: The authors suggest exploring more sample-efficient optimization strategies (like Bayesian Optimization or evolutionary algorithms) and combining OOD scores with foundation model energy scores to further improve zero-shot alignment.
Summary updated