Code release for the paper BSNet: Bi-Similarity Network for Few-shot Fine-grained Image Classification. (TIP2020)
- python=3.6
- PyTorch=1.2
- torchvision=0.4.2
- pillow=6.2.1
- numpy=1.18.1
- h5py=1.10.2
- Change directory to
./filelists/CUB
- run
source ./download_CUB.sh
- method: relationnet|CosineBatch|OurNet.
- n_shot: number of labeled data in each class (1|5).
- train_aug: perform data augmentation or not during training.
- gpu: gpu id.
python ./train.py --dataset CUB --model Conv4 --method relationnet --n_shot 5 --train_aug --gpu 0
python ./train.py --dataset CUB --model Conv4 --method CosineBatch --n_shot 5 --train_aug --gpu 0
python ./train.py --dataset CUB --model Conv4 --method OurNet --n_shot 5 --train_aug --gpu 0
python ./save_features.py --dataset CUB --model Conv4 --method relationnet --n_shot 5 --train_aug --gpu 0
python ./save_features.py --dataset CUB --model Conv4 --method CosineBatch --n_shot 5 --train_aug --gpu 0
python ./save_features.py --dataset CUB --model Conv4 --method OurNet --n_shot 5 --train_aug --gpu 0
python ./test.py --dataset CUB --model Conv4 --method relationnet --n_shot 5 --train_aug --gpu 0
python ./test.py --dataset CUB --model Conv4 --method CosineBatch --n_shot 5 --train_aug --gpu 0
python ./test.py --dataset CUB --model Conv4 --method OurNet --n_shot 5 --train_aug --gpu 0
CUB-200-2011 | ||
5-way 5-shot Accuracy (%) | 5-way 1-shot Accuracy (%) | |
Relation Network | 77.87 ± 0.64 | 63.94 ± 0.92 |
Cosine Network | 77.86 ± 0.68 | 65.04 ± 0.97 |
BSNet (R&C) | 80.99 ± 0.63 | 65.89 ± 1.00 |
If you find this paper useful in your research, please consider citing:
@ARTICLE{9293172,
author={X. {Li} and J. {Wu} and Z. {Sun} and Z. {Ma} and J. {Cao} and J. -H. {Xue}},
journal={IEEE Transactions on Image Processing},
title={BSNet: Bi-Similarity Network for Few-shot Fine-grained Image Classification},
year={2021},
volume={30},
number={},
pages={1318-1331},
doi={10.1109/TIP.2020.3043128}}
Our code is based on Chen's contribution. Specifically, except for our core design, cosine network and BSNet, everything else (e.g. backbone, dataset, relation network, evaluation standards, hyper-parameters)are built on and integrated in https://github.com/wyharveychen/CloserLookFewShot.
Thanks for your attention! If you have any suggestion or question, you can leave a message here or contact us directly: