This is the source code for our paper: Gradient-Aware Logit Adjustment Loss for Long-tailed Classifier based on Pytorch.
Requirements
- Python 3.8.10
- torchvision 0.12.0
- Pytorch 1.11.0
- yacs 0.1.8
- ...
More details can be seen in requirements.txt
Install GALA
git clone https://github.com/lt-project-repository/lt-project.git
cd lt-project
pip install -r requirements.txt
Note that the torch version should be compatible with your cuda version. In the configuration file (ending with '.yaml'), norm_logits
is equivalent to Prediction Re-balancing Strategy, and margin_cls
means GALA Loss.
Dataset Preparation
Change the dataset path in main.py
accordingly.
Cross Entropy(ce)
python main.py --cfg config/CIFAR100_LT/ce_imba100.yaml
Cross Entropy + Prediction Re-balancing Strategy
python main.py --cfg config/CIFAR100_LT/ce_pn_imba100.yaml
GALA loss
python main.py --cfg config/CIFAR100_LT/gala_imba100.yaml
GALA loss + Prediction Re-balancing Strategy
python main.py --cfg config/CIFAR100_LT/gala_pn_imba100.yaml
Imbalance Factor | GALA loss | GALA loss + Prediction Re-balancing Strategy | Log | Model |
---|---|---|---|---|
200 | 48.0% | 48.5% | link | link |
100 | 52.1% | 52.3% | link | link |
50 | 56.0% | 56.5% | link | link |
10 | 63.8% | 64.2% | link | link |
Dataset | GALA loss | GALA loss + Prediction Re-balancing Strategy(τ) | Log | Model |
---|---|---|---|---|
ImageNet-LT | 53.4% | 54.9%(τ=1.7) | train.log fine-tune-τ.log | link |
iNa'2018 | 71.2% | 73.3%(τ=1.5) | train.log fine-tune-τ.log | link |
Places-LT | 41.0% | 41.4%(τ=1.4) | train.log fine-tune-τ.log | link |
- Support CIFAR100-LT dataset
- Support ImageNet-LT
- Support iNaturalist2018
- Support Places365-LT
- More results and models
We refer to some codes from BalancedMetaSoftmax. Many thanks to the authors.