|
1 |
| -# A General Single-Stage Solution for Long-Tailed Problems |
| 1 | +# A Strong Single-Stage Baseline for Long-Tailed Problems |
| 2 | + |
| 3 | +[](https://github.com/KaihuaTang/Scene-Graph-Benchmark.pytorch/blob/master/LICENSE) |
| 4 | +[](https://www.python.org/) |
| 5 | + |
| 6 | + |
| 7 | +This project provides a strong single-stage baseline for Long-Tailed Classification (under ImageNet-LT, Long-Tailed CIFAR-10/-100 datasets), Detection, and Instance Segmentation (under LVIS dataset). It is also a PyTorch implementation of the paper [Long-Tailed Classification by Keeping the Good and Removing the Bad Momentum Causal Effect](), which proposes a general solution to remove the bad momentum causal effect for a variety of Long-Tailed Recognition tasks. The codes are organized into three folders: |
| 8 | +1. The [classification folder](classification) supports long-tailed classification on ImageNet-LT, Long-Tailed CIFAR-10/CIFAR-100 datasets. |
| 9 | +2. The [lvis_old folder (deprecated)](lvis_old) supports long-tailed object detection and instance segmentation on LVIS V0.5 dataset, which is built on top of mmdet V1.1. |
| 10 | +3. The latest version of long-tailed detection and instance segmentation is under [lvis1.0 folder](lvis1.0). Since both LVIS V0.5 and mmdet V1.1 are no longer available on their homepages, we have to re-implement our method on [mmdet V2.4](https://github.com/open-mmlab/mmdetection) using [LVIS V1.0 annotations](https://www.lvisdataset.org/dataset). |
| 11 | + |
| 12 | + |
| 13 | +# Installation |
| 14 | +The classification part allows the lower version of the following requirements. However, in detection and instance segmentation (mmdet V2.4), I tested some lower versions of python and pytorch, which are all failed. If you want to try other environments, please check the updates of [mmdetection](https://github.com/open-mmlab/mmdetection). |
| 15 | + |
| 16 | +### Requirements: |
| 17 | +- PyTorch >= 1.6.0 |
| 18 | +- Python >= 3.7.0 |
| 19 | +- CUDA >= 10.1 |
| 20 | +- torchvision >= 0.7.0 |
| 21 | +- gcc version >= 5.4.0 |
| 22 | + |
| 23 | +### Step-by-step installation |
| 24 | +```bash |
| 25 | +conda create -n longtail pip python=3.7 -y |
| 26 | +source activate longtail |
| 27 | +conda install pytorch torchvision cudatoolkit=10.1 -c pytorch |
| 28 | +pip install pyyaml |
| 29 | + |
| 30 | +# download the project |
| 31 | +git clone https://github.com/KaihuaTang/Long-Tail-Classification.private.git |
| 32 | +cd Long-Tail-Classification.private.git |
| 33 | + |
| 34 | +# the following part is only used to build mmdetection |
| 35 | +cd lvis1.0 |
| 36 | +pip install mmcv-full |
| 37 | +pip install mmlvis |
| 38 | +pip install -r requirements/build.txt |
| 39 | +pip install -v -e . # or "python setup.py develop" |
| 40 | +``` |
| 41 | +### Additional Notes |
| 42 | +When we wrote the paper, we are using lvis V0.5 and mmdet V1.1 for our long-tailed instance segmentation experiments, but they've been deprecated by now. If you want to reproduce our results on lvis V0.5, you have to find a way to build mmdet V1.1 environments and use the code in lvis_old folder. |
| 43 | + |
| 44 | + |
| 45 | +# Datasets |
| 46 | +### ImageNet-LT |
| 47 | +ImageNet-LT is a long-tailed subset of original ImageNet, you can download the dataset from its [homepage](http://image-net.org/index). After you download the dataset, you need to change the data_root of 'ImageNet' in [./classification/main.py](classification/main.py) file. |
| 48 | + |
| 49 | +### CIFAR-10/-100 |
| 50 | +When you run the code for the first time, our dataloader will automatically download the CIFAR-10/-100. You need to set the data_root in [./classification/main.py](classification/main.py) to the path where you want to put all CIFAR data. |
| 51 | + |
| 52 | +### LVIS |
| 53 | +[Large Vocabulary Instance Segmentation (LVIS)](https://www.lvisdataset.org/) dataset uses the COCO 2017 train, validation, and test image sets. If you have already downloaded the COCO images, you only need to download the LVIS annotations. LVIS val set contains images from COCO 2017 train in addition to the COCO 2017 val split. |
| 54 | + |
| 55 | +You need to put all the annotations and images under ./data/LVIS like this: |
| 56 | +```bash |
| 57 | +data |
| 58 | + |-- LVIS |
| 59 | + |--lvis_v1_train.json |
| 60 | + |--lvis_v1_val.json |
| 61 | + |--images |
| 62 | + |--train2017 |
| 63 | + |--.... (images) |
| 64 | + |--test2017 |
| 65 | + |--.... (images) |
| 66 | + |--val2017 |
| 67 | + |--.... (images) |
| 68 | +``` |
| 69 | + |
| 70 | +# Getting Started |
| 71 | +For long-tailed classification, please go to [\[link\]](classification) |
| 72 | + |
| 73 | +For long-tailed object detection and instance segmentation, please go to [\[link\]](lvis1.0) |
| 74 | + |
| 75 | + |
| 76 | +# Advantages of the Proposed Method |
| 77 | +- Compared with previous state-of-the-art [Decoupling](https://github.com/facebookresearch/classifier-balancing), our method only requires one-stage training. |
| 78 | +- Most of the existing methods for long-tailed problems are using data distribution to conduct re-sampling or re-weighting during training, which is based on an inappropriate assumption that you can know the future distribution before you start to learn. Meanwhile, the proposed method doesn't need to know the data distribution during training, we only need to use an average feature for inference after we train the model. |
| 79 | +- Our method can be easily transferred to any tasks. We outperform the previous state-of-the-arts [Decoupling](https://arxiv.org/abs/1910.09217), [BBN](https://arxiv.org/abs/1912.02413), [OLTR](https://arxiv.org/abs/1904.05160) in image classification, and we achieve better results than 2019 Winner of LVIS challenge [EQL](https://arxiv.org/abs/2003.05176) in long-tailed object detection and instance segmentation (under the same settings with even fewer GPUs). |
| 80 | + |
| 81 | + |
| 82 | + |
| 83 | + |
2 | 84 |
|
3 |
| -Release Soon |
|
0 commit comments