This code implements the IEEE Signal Process. Lett. paper Shaping Visual Representations with Attributes for Few-Shot Learning (ASL).
If you find our work useful, please consider citing our work using the bibtex:
@ARTICLE{asl2022spl,
author={Chen, Haoxing and Li, Huaxiong and Li, Yaohui and Chen, Chunlin},
journal={IEEE Signal Processing Letters},
title={Shaping Visual Representations With Attributes for Few-Shot Recognition},
year={2022},
volume={29},
pages={1397-1401},
doi={10.1109/LSP.2022.3180934}
}
- Linux
- Python 3.7
- Pytorch 1.2
- Torchvision 0.4
- GPU + CUDA CuDNN
You can download datasets automatically by adding --download
when running the program. However, here we give steps to manually download datasets to prevent problems such as poor network connection:
CUB:
- Create the dir
ASL/datasets/cub
; - Download
CUB_200_2011.tgz
from here, and put the archive intoASL/datasets/cub
; - Running the program with
--download
.
SUN:
- Create the dir
ASL/datasets/sun
; - Download the archive of images from here, and put the archive into
ASL/datasets/sun
; - Download the archive of attributes from here, and put the archive into
ASL/datasets/sun
; - Running the program with
--download
.
Download data and run on multiple GPUs with special settings:
python train.py --train-data [train_data] --test-data [test_data] --backbone [backbone] --num-shots [num_shots] --batch-tasks [batch_tasks] --train-tasks [train_tasks] --semantic-type [semantic_type] --multi-gpu --download
Run on CUB dataset, ResNet-12 backbone, 1-shot, single GPU
python train.py --train-data cub --test-data cub --backbone resnet12 --num-shots 1 --batch-tasks 4 --train-tasks 60000 --semantic-type class_attributes
Note that batch tasks are set to 1. Larger batchsize may damage the learning of the visual-attribute generator.
Our code is based on TorchMeta.
Please feel free to contact us if you have any problems.
Email: haoxingchen@smail.nju.edu.cn