ActMAD: Activation Matching to Align Distributions for Test-Time Training (CVPR 2023)

June 27, 2023 · View on GitHub

This is the official repository for our CVPR 2023 paper: ActMAD

ActMAD proposes a task- and architecture-agnostic Test-Time Training methodology which relies on aligning distributions of the intermediate activation responses from the training data, and the out-of-distribution test data at test-time. Our main contribution lies in proposing a location aware feature alignment approach where we model a distribution over each pixel in an intermediate feature map.

Our experimental evaluation spans over 2 downstream tasks (image classification and object detection). In this repository we provide code to reproduce CIFAR-10/100C and KITTI experiments from our main paper.

Installation

  1. git clone this repository.
  2. pip install -r requirements.txt to install required packages

Running Experiments

Prepare the datasets through the instructions listed here and also set the directory structure as described here.

Then setup up user specific paths in the PATHS dictionary in config.py.

CIFAR-10/100C

For these experiments we use the pre-trained weights from AugMix, hosted here.

Also, add the PATH to these weights. After setting up PATHS dictionary for a user, ActMad CIFAR-10/100 experiments for the highest severity of corruptions can be run with the following command:

python main.py --usr <NAME_OF_USER> --dataset <NAME_OF_DATASET>

Replace <NAME_OF_DATASET> with cifar10 or cifar100.

Wide-ResNet-40-2 CIFAR-10/100C Results

Mean ErrorGauss NoiseShot NoiseImpulse NoiseDefocus BlurGlass BlurMotion BlurZoom BlurSnowFrostFogBrightnessContrastElastic TransformPixelateJpeg
Source C1018.328.822.926.29.520.610.69.314.215.317.57.620.914.741.314.7
ActMAD10.413.011.215.17.415.98.37.19.59.310.65.98.412.39.313.6
Source C10046.765.760.159.132.051.033.632.441.445.251.431.655.540.359.742.4
ActMAD34.639.638.439.529.141.530.029.134.033.240.226.431.536.431.438.9

KITTI

ActMad KITTI experiments for the highest weather severity can be run with the following command:

python main.py --usr <NAME_OF_USER> --dataset KITTI

First the network will be trained on the original Kitti dataset (KITTI-Clear), then this trained network will be adapted to each of the different weather conditions KITTI- (fog, rain, snow) in an online manner.

YOLOv3 KITTI Results

mAP@50 (%)CarVanTruckPedestrianPerson SittingCyclistTramMisc
Source Fog19.631.315.06.034.833.620.26.79.1
ActMAD47.767.041.225.562.268.750.930.535.7
Source Rain66.586.469.658.668.663.760.264.560.4
ActMAD81.494.289.287.374.165.677.982.580.1

To cite us:

@InProceedings{mirza2023actmad,
    author    = {Mirza, M. Jehanzeb and Soneira, Pol Jane and Lin, Wei and Kozinski, Mateusz and Possegger, Horst and Bischof, Horst},
    title     = {ActMAD: Activation Matching to Align Distributions for Test-Time Training},
    booktitle = {Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},
    year      = {2023}
}