Home

Awesome

Test-Agnostic Long-Tailed Recognition

This repository is the official Pytorch implementation of Self-Supervised Aggregation of Diverse Experts for Test-Agnostic Long-Tailed Recognition (NeurIPS 2022).

<p align="center"> <img src="figure.png" weight=800> </p>

1. Results

(1) ImageNet-LT (ResNeXt-50)

Long-tailed recognition with uniform test class distribution:

MethodsMACs(G)Top-1 acc.Model
Softmax4.2648.0
RIDE6.0856.3
SADE (ours)6.0858.8Download

Test-agnostic long-tailed recognition:

MethodsMACs(G)Forward-50Forward-10UniformBackward-10Backward-50
Softmax4.2666.160.348.034.927.6
RIDE6.0867.664.056.348.744.0
SADE (ours)6.0869.465.458.854.553.1

(2) CIFAR100-Imbalance ratio 100 (ResNet-32)

Long-tailed recognition with uniform test class distribution:

MethodsMACs(G)Top-1 acc.
Softmax0.0741.4
RIDE0.1148.0
SADE (ours)0.1149.8

Test-agnostic long-tailed recognition:

MethodsMACs(G)Forward-50Forward-10UniformBackward-10Backward-50
Softmax0.0762.356.241.425.817.5
RIDE0.1163.057.048.035.429.3
SADE (ours)0.1165.958.349.843.942.4

(3) Places-LT (ResNet-152)

Long-tailed recognition with uniform test class distribution:

MethodsMACs(G)Top-1 acc.
Softmax11.5631.4
RIDE13.1840.3
SADE (ours)13.1840.9

Test-agnostic long-tailed recognition:

MethodsMACs(G)Forward-50Forward-10UniformBackward-10Backward-50
Softmax11.5645.640.231.423.419.4
RIDE13.1843.141.640.338.236.9
SADE (ours)13.1846.443.340.941.441.6

(4) iNaturalist 2018 (ResNet-50)

Long-tailed recognition with uniform test class distribution:

MethodsMACs(G)Top-1 acc.
Softmax4.1464.7
RIDE5.8071.8
SADE (ours)5.8072.9

Test-agnostic long-tailed recognition:

MethodsMACs(G)Forward-3Forward-2UniformBackward-2Backward-3
Softmax4.1465.465.564.764.063.4
RIDE5.8071.571.971.871.971.8
SADE (ours)5.8072.372.572.973.573.3

2. Requirements

pip install -r requirements.txt

3. Datasets

(1) Four bechmark datasets

data
├── ImageNet_LT
│   ├── test
│   ├── train
│   └── val
├── CIFAR100
│   └── cifar-100-python
├── Place365
│   ├── data_256
│   ├── test_256
│   └── val_256
└── iNaturalist 
    ├── test2018
    └── train_val2018

(2) Txt files

data_txt
├── ImageNet_LT
│   ├── ImageNet_LT_backward2.txt
│   ├── ImageNet_LT_backward5.txt
│   ├── ImageNet_LT_backward10.txt
│   ├── ImageNet_LT_backward25.txt
│   ├── ImageNet_LT_backward50.txt
│   ├── ImageNet_LT_forward2.txt
│   ├── ImageNet_LT_forward5.txt
│   ├── ImageNet_LT_forward10.txt
│   ├── ImageNet_LT_forward25.txt
│   ├── ImageNet_LT_forward50.txt
│   ├── ImageNet_LT_test.txt
│   ├── ImageNet_LT_train.txt
│   ├── ImageNet_LT_uniform.txt
│   └── ImageNet_LT_val.txt
├── Places_LT_v2
│   ├── Places_LT_backward2.txt
│   ├── Places_LT_backward5.txt
│   ├── Places_LT_backward10.txt
│   ├── Places_LT_backward25.txt
│   ├── Places_LT_backward50.txt
│   ├── Places_LT_forward2.txt
│   ├── Places_LT_forward5.txt
│   ├── Places_LT_forward10.txt
│   ├── Places_LT_forward25.txt
│   ├── Places_LT_forward50.txt
│   ├── Places_LT_test.txt
│   ├── Places_LT_train.txt
│   ├── Places_LT_uniform.txt
│   └── Places_LT_val.txt
└── iNaturalist18
    ├── iNaturalist18_backward2.txt
    ├── iNaturalist18_backward3.txt
    ├── iNaturalist18_forward2.txt
    ├── iNaturalist18_forward3.txt
    ├── iNaturalist18_train.txt
    ├── iNaturalist18_uniform.txt
    └── iNaturalist18_val.txt 

4. Pretrained models

5. Script

(1) ImageNet-LT

Training

python train.py -c configs/config_imagenet_lt_resnext50_sade.json

Evaluate

python test.py -r checkpoint_path
python test_all_imagenet.py -r checkpoint_path

Test-time training

python test_train_imagenet.py -c configs/test_time_imagenet_lt_resnext50_sade.json -r checkpoint_path

(2) CIFAR100-LT

Training

python train.py -c configs/config_cifar100_ir100_sade.json

Evaluate

python test.py -r checkpoint_path
python test_all_cifar.py -r checkpoint_path

Test-time training

python test_train_cifar.py -c configs/test_time_cifar100_ir100_sade.json -r checkpoint_path

(3) Places-LT

Training

python train.py -c configs/config_places_lt_resnet152_sade.json

Evaluate

python test_places.py -r checkpoint_path
python test_all_places.py -r checkpoint_path

Test-time training

python test_train_places.py -c configs/test_time_places_lt_resnet152_sade.json -r checkpoint_path

(4) iNaturalist 2018

Training

python train.py -c configs/config_iNaturalist_resnet50_sade.json

Evaluate

python test.py -r checkpoint_path
python test_all_inat.py -r checkpoint_path

Test-time training

python test_train_inat.py -c configs/test_time_iNaturalist_resnet50_sade.json -r checkpoint_path

6. Citation

If you find our work inspiring or use our codebase in your research, please cite our work.

@inproceedings{zhang2022Self,
  title={Self-Supervised Aggregation of Diverse Experts for Test-Agnostic Long-Tailed Recognition},
  author={Zhang, Yifan and Hooi, Bryan and Hong, Lanqing and Feng, Jiashi},
  booktitle={Advances in Neural Information Processing Systems},
  year={2022}
}

7. Acknowledgements

This is a project based on this pytorch template.

The mutli-expert framework are based on RIDE. The data generation of agnostic test class distributions takes references from LADE.