Official codes for Learning Attention-Guided Pyramidal Features for Few-shot Fine-grained Recognition (Pattern Recognition, 2022)
By Hao Tang, Chengcheng Yuan, Zechao Li, and Jinhui Tang
Python3
Pytorch
>= 1.6.0CUDA
= 10.2json
- Change directory to
./filelists/CUB
- run
source ./download_CUB.sh
- Change directory to
./filelists/Aircrafts
- change variable data_dir in Aircrafts_prepare_csv.py
- run
python Aircrafts_prepare_csv.py
- Change directory to
./filelists/StanfordCars
- change variable data_dir in StanforCar_prepare_csv.py
- run
python StanforCar_prepare_csv.py
- Change directory to
./filelists/StanfordDogs
- change variable data_dir in StanfordDog_prepare_csv.py
- run
python StanfordDog_prepare_csv.py
- Require three data split json file:
base.json
,val.json
,novel.json
for each dataset - The format should follow
{"label_names":["class0","class1",...]
, "image_names":["filepath1","filepath2",...]
,"image_labels":[l1,l2,l3,...]
}
See test.json for reference - Put these file in the same folder and change data_dir
['DATASETNAME']
in configs.py to the folder path
Run
python ./train.py --train_n_way [TRAIN_N_WAY] --test_n_way [TEST_N_WAY] --n_shot [K_SHOT] --stop_epoch [EPOCHS] --dataset [DATASETNAME] --model [BACKBONENAME] --method [METHODNAME] --num_classes [NUM_CLASSES] --train_aug --apcnn [--OPTIONARG]
For example,
python ./train.py --train_n_way 5 --test_n_way 5 --n_shot 1 --stop_epoch 120 --dataset CUB --model Conv4 --method protonet --num_classes 200 --train_aug --apcnn
Commands below follow this example, and please refer to io_utils.py
for additional options.
Save the extracted feature before the classifaction layer to increase test speed.
python ./save_features.py --train_n_way 5 --test_n_way 5 --n_shot 1 --dataset CUB --model Conv4 --method protonet --train_aug --apcnn --num_classes 200
python ./test.py --train_n_way 5 --test_n_way 5 --n_shot 1 --dataset CUB --model Conv4 --method protonet --train_aug --apcnn --num_classes 200
- The test results will be recorded in
./record/results.txt
@inproceedings{TianTD21,
author = {Sheng Tian and Hao Tang and Longquan Dai},
title = {Coupled Patch Similarity Network FOR One-Shot Fine-Grained Image Recognition},
booktitle = {ICIP},
pages = {2478--2482},
year = {2021},
publisher = {{IEEE}}
}
@article{zha2023boosting,
title={Boosting Few-shot Fine-grained Recognition with Background Suppression and Foreground Alignment},
author={Zha, Zican and Tang, Hao and Sun, Yunlian and Tang, Jinhui},
journal={IEEE Transactions on Circuits and Systems for Video Technology},
year={2023},
publisher={IEEE},
doi={10.1109/TCSVT.2023.3236636}
}
If this work is useful in your research, please cite
@article{TangYLT22,
author = {Hao Tang and Chengcheng Yuan and Zechao Li and Jinhui Tang},
title = {Learning attention-guided pyramidal features for few-shot fine-grained recognition},
journal = {Pattern Recognit.},
volume = {130},
pages = {108792},
year = {2022}
}
This implementation builds upon several open-source codes. Specifically, we have modified and integrated the following codes into this repository: