Home

Awesome

LargeScaleIncrementalLearning

This is the implementation of CVPR 2019 paper "Large Scale Incremental Learning". If the paper and code helps you, we would appreciate your kindly citations of our paper.

@inproceedings{wu2019large,
  title={Large Scale Incremental Learning},
  author={Wu, Yue and Chen, Yinpeng and Wang, Lijuan and Ye, Yuancheng and Liu, Zicheng and Guo, Yandong and Fu, Yun},
  booktitle={Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition},
  pages={374--382},
  year={2019}
}

Abstract

In this paper, we proposed a new method to address the imbalance issue in incremental learning, which is critical when the number of classes becomes large. Firstly, we validated our hypothesis that the classifier layer (the last fully connected layer) has a strong bias towards the new classes, which has substantially more training data than the old classes. Secondly, we found that this bias can be effectively corrected by applying a linear model with a small validation set. Our method has excellent results on two large datasets with 1,000+ classes (ImageNet ILSVRC 2012 and MS-Celeb-1M), outperforming the state-of-the-art by a large margin (11.1% on ImageNet ILSVRC 2012 and 13.2% on MS-Celeb-1M).

Environment Setup

Words before the code: most codes and experiments are finished in late 2017 and earlier 2018. It is hard to retrieve exact the same environment for experiments, which I remember that the system was in Ubuntu 14. CUDA and tensorflow are all with earlier versions. I re-installed the system several times last year (2018) because some conficts in setting up environment for pytorch, which was original fit for caffe and tensorflow. And also, I upgraded the system form Ubuntu 14 to Ubuntu 16.

The resnet implementation is the official tensorflow official models at:

https://github.com/tensorflow/models

In the latest repo, the most similar implementaion is:

https://github.com/tensorflow/models/blob/master/official/r1/resnet/imagenet_main.py

Unfortunately, we were not able to run our code with the latest tensorflow-2.0 or tensorflow-1.14.

We understand that how important it is to reproduce the results of published papers. I find a compatible tensorflow-1.5 version that is able to run the code with my current CUDA settings. To not mess up with my current software enviroment for pytorch mostly, I use the virtualenv to set up a seperate environment for experiments. The dependency of the code is lite and should be able work in most cases if you get the tensorflow version set up correctly. I summarize my current environment for reference.

System Information<br/> Distributor ID: Ubuntu<br/> Description: Ubuntu 16.04.3 LTS<br/> Release: 16.04<br/> Codename: xenial<br/>

CUDA version: 9.0<br/> CUDNN version: 7.0.5<br/> GPU: TITAN X (Pascal) 12GB<br/>

Python version: 3.5.2<br/> Environemnt is setup using virtualenv.<br/>

virtualenv venv
pip install scipy
pip install tensorflow-gpu==1.5

To activate the environment:

source venv/bin/activate

To run the code

Dataset:<br/> We mainly clean the code for ImageNet dataset and leave the other two datasets (CIFAR and MS-Celeb-1M) in future work.

Data preparation:<br/> We have put essential files in the repo so that what you need to do is to download the ImageNet-1000 images. For the images, we used the ILSVRC2016_CLS-LOC.tar.gz file, which should be kept unchanged since 2012. <br/> Some links to handle the 50K validation images to split validation images in class folders.

https://github.com/facebook/fb.resnet.torch/blob/master/INSTALL.md#download-the-imagenet-dataset

After downloading and processing, the structure in the data forlder (dataImageNet100 and dataImageNet1000) should be like:

|--train
|  |--n01440764
|  |--n01443537
|  |.......
|--train.txt
|--val
|  |--n01440764
|  |--n01443537
|  |.......
|--val.txt

Experiments run command:

CUDA_VISIBLE_DEVICES=0 python imagenet_main.py 1>log 2>&1

Results

We run the code once and report the result here. Top-5 accuracy is reported on ImageNet dataset. We observe similar results on ImageNet-100 form this repo with new environment and what we reported in paper. On ImageNet-1000, we notice some performance drop in several first increments but the final results are even better than what we reported in our paper, which might be caused by different operation systems and software environments.

Training on ImageNet-100 takes around 15 hours. Results are:

102030405060708090100
In paper (%)98.4096.2094.0092.9091.1089.4088.1086.5085.4084.40
This Repo (%)98.7996.1095.0693.5090.9689.7389.0287.2285.9784.24
Before Bias Correction (%)-95.7093.0690.7586.6086.0683.6081.2578.2876.32
\beta1.00.59000.51400.47420.48390.46480.43890.42970.43350.3941
\gamma0.0-0.4416-0.5401-0.4701-0.5323-0.4672-0.4830-0.5349-0.5804-0.4609
Training Samples12800144171460014600146001444114600146201433114566
Val Samples200400300240250240210160180200
Test Samples500100015002000250030003500400045005000

Training on ImageNet-100 takes around 100 hours. Results are:

1002003004005006007008009001000
In paper (%)94.1092.5089.6089.1085.7083.2080.2077.5075.0073.20
This Repo (%)93.7291.4688.7086.6384.6483.0881.3779.8278.2276.76
Before Bias Correction (%)-89.6484.5080.8478.0774.8972.6670.3867.9363.34
\beta1.00.78730.73820.70530.68840.67040.66090.65150.62390.6334
\gamma0.0-0.5586-0.5759-0.5015-0.5505-0.5137-0.4677-0.4471-0.4118-0.4064
Training Samples126856144159144505144301143776145238143391144418143277143046
Val Samples2000400030002400250024002100160018002000
Test Samples5000100001500020000250003000035000400004500050000

Results are from one run of the model on ImageNet-100 and ImageNet-1000. Log files are located at

./logs/log-ImageNet100
./logs/log-ImageNet1000

Implementation notes

Class Order:<br/> To keep the same order with iCaRL (https://github.com/srebuffi/iCaRL), we use the same random seed (1993) from numpy to generate the order.

Distilling Loss:<br/> We store the previous network for distilling loss.

Bias Correction:<br/> After learning the Bias Correction parameters (\beta and \gamma), classifier after correction is used for the distilling loss in the next incremental training.

Validation Samples from exemplars:<br/> 10% selection is limited on exemplars (old classes). Samples from new classes will match the same number of validation samples.

Useful links

Awesome-Incremental-Learning: https://github.com/xialeiliu/Awesome-Incremental-Learning

Contact

If you found any issue of the code, please contact Yue Wu (@wuyuebupt, Email: yuewu@ece.neu.edu or wuyuebupt@gmail.com)