TeST: Test-time Self-Training under Distribution Shift

Samarth Sinha, Peter V. Gehler, Francesco Locatello, Bernt Schiele

TL;DR

TeST (Test-Time Self-Training) is a two-stage framework that allows deep learning models to adapt to new, unseen environments (like different weather or cities) during inference without needing the original training data. By using a student-teacher approach and consistency learning, it achieves state-of-the-art performance in object detection and segmentation, rivaling heavy-duty domain adaptation methods while using 10x less data.

What Problem Does This Paper Address?

Deep neural networks are notoriously "brittle." A model trained to detect cars in sunny California might fail miserably in a rainy London afternoon or a snowy morning in Munich. This is known as distribution shift.

Traditionally, researchers solve this using Domain Adaptation (DA), which requires a large collection of unlabeled data from the "target" environment during the initial training phase. However, in the real world, we often don't know where a model will be deployed until it's already there. Test-Time Adaptation (TTA) aims to fix the model "on the fly" using only the data it sees during inference. Current TTA methods often require special "pre-training" tricks (like teaching the model to predict image rotation) or struggle to learn truly robust features. TeST aims to bridge this gap without requiring any changes to how the original model was trained.

Methods

TeST introduces a two-stage Student-Teacher framework for adaptation:

  1. Stage 1: Training the Teacher (Consistency): The model is copied into a "Teacher" and a "Student." The Teacher is trained to produce invariant representations. It looks at two versions of the same unlabeled test image: a "weakly augmented" version (simple crop/rotate) and a "strongly augmented" version (using RandAugment). The goal is to minimize the distance between the features of both versions. This forces the teacher to ignore the "noise" of the new environment and focus on the core features of the objects.
  2. Stage 2: Training the Student (Distillation): Once the Teacher is adapted, it acts as a mentor. It generates "pseudo-labels" (predictions) for the test data. The Student model then learns from these pseudo-labels via Knowledge Distillation. To ensure the Student is confident, the authors also add an Entropy Minimization loss, which pushes the model to make "sharper" categorical choices.

Crucially, this process happens entirely at test time and requires zero access to the original source training data.

Datasets

The authors evaluated TeST on several challenging "Sim-to-Real" and "City-to-City" shifts:

  • Autonomous Driving (Detection): Cityscapes $\to$ BDD100k, Cityscapes $\to$ Foggy Cityscapes (weather shift), Cityscapes $\to$ KITTI, and Sim10k $\to$ Cityscapes (simulation to real).
  • General Objects: MS-COCO, where they used a ResNet-101 feature extractor and k-means clustering to create artificial "Out-of-Distribution" (OOD) splits.
  • Image Segmentation: GTA $\to$ Cityscapes and Synthia $\to$ Cityscapes.

Key Insights and Ideas

  • Invariance is Key: The "Aha!" moment is that by forcing the teacher to be consistent across massive augmentations (Stage 1), the model learns to discard the "style" of the new distribution (e.g., the "fogginess" or "graininess") and focus on the "content" (the car or pedestrian).
  • Data Efficiency: TeST is remarkably efficient. While standard Domain Adaptation methods use the entire target dataset, TeST achieves comparable results using only 256 to 512 unlabeled images.
  • "Do No Harm": One fear with test-time adaptation is "collapsing" the model if the data hasn't actually shifted. The authors found that TeST is robust; if there is no distribution shift, it actually slightly improves the original model's performance rather than degrading it.
  • Better Calibration: Beyond just being more accurate, the adapted models are better "calibrated"—meaning when the model says it is 90% sure about a bounding box, it is actually right about 90% of the time.

Key Results

  • Object Detection: On the Cityscapes to BDD100k task using a Deformable DeTR base, TeST improved the mean Average Precision (mAP) from ~40% (Source Only) to ~43%, significantly outperforming previous TTA methods like Tent and TTT.
  • Segmentation: In Sim-to-Real tasks (GTA $\to$ Cityscapes), TeST performed nearly as well as an "Oracle" model that was manually fine-tuned on ground-truth labels.
  • Comparison to DA: TeST achieved performance parity with modern Domain Adaptation algorithms (like those from Saito et al.) while requiring 5-10x less data at the time of adaptation.

Limitations and Future Work

  • Label Space Assumption: TeST assumes the "label space" is the same. If the model was trained to see cars and pedestrians, but the test environment contains "electric scooters" (a new class), TeST won't magically learn to identify them.
  • Computational Overhead: Because it involves a two-stage training process at test time, there is a computational cost before the model reaches peak performance in the new environment.
  • Future Directions: The authors suggest exploring how this framework could handle "open-set" scenarios where new classes of objects appear at test time.

Summary updated

BibTeX
@inproceedings{sinha2023test,
  author = {Samarth Sinha and Peter V. Gehler and Francesco Locatello and Bernt Schiele},
  title = {{TeST: Test-time Self-Training under Distribution Shift}},
  booktitle = {IEEE/CVF Winter Conference on Applications of Computer Vision},
  year = {2023},
  doi = {10.1109/wacv56688.2023.00278},
}
Figure