|
| 1 | + |
| 2 | +# Few-Shot Class-Incremental Learning by Sampling Multi-Phase Tasks (LIMIT) |
| 3 | + |
| 4 | +The code repository for ["Few-Shot Class-Incremental Learning by Sampling Multi-Phase Tasks"](https://arxiv.org/abs/2203.17030) (TPAMI 2022) in PyTorch. If you use any content of this repo for your work, please cite the following bib entry: |
| 5 | + |
| 6 | + @article{zhou2022few, |
| 7 | + title={Few-Shot Class-Incremental Learning by Sampling Multi-Phase Tasks}, |
| 8 | + author={Zhou, Da-Wei and Ye, Han-Jia and Zhan, De-Chuan}, |
| 9 | + journal={arXiv preprint arXiv:2203.17030}, |
| 10 | + year={2022} |
| 11 | + } |
| 12 | + |
| 13 | + |
| 14 | + |
| 15 | +## Few-Shot Class-Incremental Learning by Sampling Multi-Phase Tasks |
| 16 | + |
| 17 | + |
| 18 | +New classes arise frequently in our ever-changing world, e.g., emerging topics in social media and new types of products in e-commerce. A model should recognize new classes and meanwhile maintain discriminability over old classes. Under severe |
| 19 | +circumstances, only limited novel instances are available to incrementally update the model. The task of recognizing few-shot new classes without forgetting old classes is called few-shot class-incremental learning (FSCIL). In this work, we propose a new paradigm for FSCIL based on meta-learning by LearnIng Multi-phase Incremental Tasks (LIMIT), which synthesizes fake FSCIL tasks from the base dataset. The data format of fake tasks is consistent with the ‘real’ incremental tasks, and we can build a generalizable feature space for the unseen tasks through meta-learning. Besides, LIMIT also constructs a calibration module based on transformer, which calibrates the old class classifiers and new class prototypes into the same scale and fills in the semantic gap. The calibration module also adaptively |
| 20 | +contextualizes the instance-specific embedding with a set-to-set function. LIMIT efficiently adapts to new classes and meanwhile resists forgetting over old classes. Experiments on three benchmark datasets (CIFAR100, miniImageNet, and CUB200) and large-scale dataset, i.e., ImageNet ILSVRC2012 validate that LIMIT achieves state-of-the-art performance. |
| 21 | + |
| 22 | +<img src='imgs/teaser.png' width='1000' height='300'> |
| 23 | + |
| 24 | +## Results |
| 25 | +<img src='imgs/result.png' width='900' height='778'> |
| 26 | + |
| 27 | +Please refer to our [paper](https://arxiv.org/abs/2203.17030) for detailed values. |
| 28 | + |
| 29 | +## Prerequisites |
| 30 | + |
| 31 | +The following packages are required to run the scripts: |
| 32 | + |
| 33 | +- [PyTorch-1.4 and torchvision](https://pytorch.org) |
| 34 | + |
| 35 | +- tqdm |
| 36 | + |
| 37 | +- Download the [pretrained models](https://drive.google.com/drive/folders/11liacLA6F4uz_SWAPLYQshlzLMXMzDkB?usp=sharing) and put them in ./params |
| 38 | + |
| 39 | +## Dataset |
| 40 | +We provide the source code on three benchmark datasets, i.e., CIFAR100, CUB200 and miniImageNet. Please follow the guidelines in [CEC](https://github.com/icoz69/CEC-CVPR2021) to prepare them. |
| 41 | + |
| 42 | + |
| 43 | + |
| 44 | +## Code Structures |
| 45 | +There are four parts in the code. |
| 46 | + - `models`: It contains the backbone network and training protocols for the experiment. |
| 47 | + - `data`: Images and splits for the data sets. |
| 48 | +- `dataloader`: Dataloader of different datasets. |
| 49 | + - `checkpoint`: The weights and logs of the experiment. |
| 50 | + - `params`: Pretrained model weights. |
| 51 | + |
| 52 | +## Training scripts |
| 53 | + |
| 54 | +- Train CIFAR100 |
| 55 | + |
| 56 | + ``` |
| 57 | + python train.py -project limit -dataset cifar100 -epochs_base 20 -lr_base 0.0002 -lrg 0.0002 -gamma 0.3 -gpu 3 -model_dir ./params/pretrain_CIFAR.pth -temperature 16 -schedule Milestone -milestones 2 4 6 -num_tasks 32 >>cifar.txt |
| 58 | + ``` |
| 59 | + |
| 60 | +- Train CUB200 |
| 61 | + ``` |
| 62 | + python train.py -project limit -dataset cub200 -epochs_base 40 -lr_base 0.0002 -lrg 0.0002 -step 20 -gamma 0.5 -gpu 2 -model_dir ./params/pretrain_CUB.pth -dataroot YOURDATAROOT -num_tasks 32 >>cub.txt |
| 63 | + ``` |
| 64 | +
|
| 65 | +- Train miniImageNet |
| 66 | + ``` |
| 67 | + python train.py -project limit -dataset mini_imagenet -epochs_base 20 -lr_base 0.0002 -lrg 0.0002 -gamma 0.3 -gpu 3 -model_dir ./params/pretrain_MINI.pth -dataroot YOURDATAROOT -num_tasks 32 -temperature 0.5 -schedule Milestone -milestones 3 6 9 12 >>mini.txt |
| 68 | + ``` |
| 69 | +
|
| 70 | +Remember to change `YOURDATAROOT` into your own data root, or you will encounter errors. |
| 71 | +
|
| 72 | + |
| 73 | +
|
| 74 | + |
| 75 | +## Acknowledgment |
| 76 | +We thank the following repos providing helpful components/functions in our work. |
| 77 | +
|
| 78 | +- [Awesome Few-Shot Class-Incremental Learning](https://github.com/zhoudw-zdw/Awesome-Few-Shot-Class-Incremental-Learning) |
| 79 | +
|
| 80 | +- [PyCIL: A Python Toolbox for Class-Incremental Learning](https://github.com/G-U-N/PyCIL) |
| 81 | +
|
| 82 | +- [Fact](https://github.com/zhoudw-zdw/CVPR22-Fact) |
| 83 | +
|
| 84 | +- [FEAT](https://github.com/Sha-Lab/FEAT) |
| 85 | +
|
| 86 | +- [Castle](https://github.com/Sha-Lab/aCASTLE) |
| 87 | +
|
| 88 | +- [CEC](https://github.com/icoz69/CEC-CVPR2021) |
| 89 | +
|
| 90 | +
|
| 91 | +
|
| 92 | +## Contact |
| 93 | +If there are any questions, please feel free to contact with the author: Da-Wei Zhou (zhoudw@lamda.nju.edu.cn). Enjoy the code. |
0 commit comments