Skip to content

leesb7426/CVPR2022-Task-Discrepancy-Maximization-for-Fine-grained-Few-Shot-Classification

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

60 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Task-Discrepancy-Maximization-for-Fine-grained-Few-Shot-Classification

Official PyTorch Repository of "Task Discrepancy Maximization for Fine-grained Few-Shot Classification (CVPR 2022 Oral Paper)"

Update

[2023/11/21] We released an extended version of TDM (called IAM). It is currently under review, and the code will be released after that.

Bug Fix

[2023/01/03] We omitted the random loss, which prevents overfitting, in training. Please add "--noise" to the training code. Sorry for the confusion.

Data Preparation

The following datasets are used in our paper:

CUB_200_2011: Dataset Page

FGVC-Aircraft: Dataset Page

iNaturalist2017 : Dataset Page

Stanford-Cars : Dataset Page

Stanford-Dogs : Dataset Page

Oxford-Pets : Dataset Page

Please proceed with the setting up data by referring to FRN Github.

Pretrained Weights

Here, all the pretrained weights with ProtoNet and FRN are publicized. Pretrained weights

Usage

Requirement

All the requirements to run the code are in requirements.txt You can download requirements by running below script.

pip install -r requirements.txt

Evaluation

To evaluate the code with pretrained weights, we provide an example script below.

Test the ProtoNet 1-shot in CUB_cropped with Conv-4.
(pretrained_weight: /Proto/CUB_fewshot_cropped/TDM/Conv4-1shot/model_Conv-4.pth)

python3 test.py --train_way 5 --train_shot 1 --gpu_num 1 --model Proto --dataset cub_cropped --TDM

Test the ProtoNet 5-shot in CUB_cropped with Conv-4.
(pretrained_weight: /Proto/CUB_fewshot_cropped/TDM/Conv4-5shot/model_Conv-4.pth)

python3 test.py --train_way 5 --train_shot 5 --gpu_num 1 --model Proto --dataset cub_cropped --TDM

Test the FRN 1-shot and 5-shot in CUB_cropped with Conv-4.
(pretrained_weight: /FRN/CUB_fewshot_cropped/TDM/Conv4-5shot/model_Conv-4.pth)

python3 test.py --train_way 5 --train_shot 5 --gpu_num 1 --model FRN --dataset cub_cropped --TDM

Train

We provide scripts for training. Other shell scripts are in the scripts directory.

python3 train.py --model Proto --dataset aircraft --opt sgd --lr 1e-1 --gamma 1e-1 --epoch 400 --stage 3 --val_epoch 20 --weight_decay 5e-4 --nesterov --train_way 30 --train_shot 1 --train_transform_type 0 --test_shot 1 --pre --gpu_num 1

Results

As we mentioned in our supplementary, we found that CTX and DSN show better performances in 1-shot when they are evaluated by models trained with 5-shot episodes. Therefore, we trained all models with 5-shot episodes except ProtoNet because it shows performance degradation.

CUB_cropped

CUB_raw

Aircraft

meta-iNat & tiered meta-iNat

Citation

If you find TDM helpful for your works, please consider citing:

@InProceedings{Lee_2022_CVPR,
    author    = {Lee, SuBeen and Moon, WonJun and Heo, Jae-Pil},
    title     = {Task Discrepancy Maximization for Fine-Grained Few-Shot Classification},
    booktitle = {Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},
    month     = {June},
    year      = {2022},
    pages     = {5331-5340}
}

Contact

If there are any questions, please feel free to contact with the authors: SuBeen Lee (leesb7426@gmail.com) WonJun Moon (wjun0830@gmail.com). Thank you.

About

Official PyTorch Repository of "Task Discrepancy Maximization for Fine-grained Few-Shot Classification" (TDM, CVPR 2022 Oral Paper)

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published