Home

Awesome

imprinted-weights

This is an unofficial pytorch implementation of Low-Shot Learning with Imprinted Weights.

Requirements

Major Difference

Paper: InceptionV1 + RMSProp

This implementation: ResNet-50 + SGD

Preparation

Download CUB_200_2011 Dataset.

Unzip and locate it in this directory.

The whole directory should be look like this:

imprinted-weights
│   README.md
│   pretrain.py
│   models.py
│   loader.py
│   imprint.py
│   imprint_ft.py
│   alljoint.py
|
└───utils
│   
└───CUB_200_2011
    │   images.txt
    │   image_class_labels.txt
    │   train_test_split.txt
    │
    └───images
        │   001.Black_footed_Albatross
        │   002.Laysan_Albatross
        │   ...

Usage

Pretrain models

Train the model on the first 100 classes of CUB_200_2011.

python pretrain.py

Trained models will be saved at pretrain_checkpoint.

Imprint weights

Use N novel exemplar from the training split to imprint weights.

python imprint.py --model pretrain_checkpoint/model_best.pth.tar --num-sample N

Trained models will be saved at imprint_checkpoint.

For more details and parameters, please refer to --help option.

All w/o FT results of Table 1 and Table 2 in the paper can be reproduced by this script.

Imprint weights + FT

Apply fine-tuning to the imprinting model.

python imprint_ft.py --model pretrain_checkpoint/model_best.pth.tar --num-sample N

Trained models will be saved at imprint_ft_checkpoint.

All w/ FT results of Table 1 and Table 2 in the paper can be reproduced by this script.

All class joint

Train model for base and novel classes jointly without a separate low-shot learning phase.

python alljoint.py --num-sample N

Trained models will be saved at alljoint_checkpoint.

Results

200-way top-1 accuracy for novel-class examples in CUB-200-2011

w/o FT

n =1251020
Rand-noFT (paper)0.170.170.170.170.17
Imprinting (paper)21.2628.6939.5245.7749.32
Imprinting + Aug (paper)21.4030.0339.3546.3549.80
Rand-noFT0.000.000.000.000.00
Imprinting28.7737.6150.2056.3160.58
Imprinting + Aug28.8138.0249.9056.1860.44

w/ FT

n =1251020
Rand + FT (paper)5.2513.4134.9554.3365.60
Imprinting + FT (paper)18.6730.1746.0859.3968.77
AllClassJoint (paper)3.8910.8233.0050.2464.88
Rand + FT2.3913.0036.1156.8369.90
Imprinting + FT26.1434.8154.4063.4173.41
AllClassJoint7.3418.0945.6760.5873.41

200-way top-1 accuracy measured across examples in all classes of CUB-200-2011

w/o FT

n =1251020
Rand-noFT (paper)37.3637.3637.3637.3637.36
Imprinting (paper)44.7548.2152.9555.9957.47
Imprinting + Aug (paper)44.6048.4852.7856.5157.84
Rand-noFT41.3941.3941.3941.3941.39
Imprinting53.5057.3562.6565.3867.09
Imprinting + Aug53.4057.4762.5665.2167.26

w/ FT

n =1251020
Rand + FT (paper)39.2643.3653.6963.1768.75
Imprinting + FT (paper)45.8150.4159.1564.6568.73
AllClassJoint (paper)38.0241.8952.2461.1168.31
Rand + FT41.2746.4157.7167.7974.72
Imprinting + FT53.0257.8267.2171.7376.25
AllClassJoint42.7348.4362.2069.9575.89

References