Shaping Visual Representations with Attributes for Few-Shot Learning
This code implements the Shaping Visual Representations with Attributes for Few-Shot Learning (ASL).
Citation
If you find our work useful, please consider citing our work using the bibtex:
@Article{chen2021asl,
author = {Chen, Haoxing and Li, Huaxiong and Li, Yaohui and Chen, Chunlin},
title = {Shaping Visual Representations with Attributes for Few-Shot Learning},
journal = {arXiv preprint arXiv:2112.06398},
year = {2021},
}
Prerequisites
- Linux
- Python 3.7
- Pytorch 1.2
- Torchvision 0.4
- GPU + CUDA CuDNN
Datasets
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
.
Few-shot Classification
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 4/1 when training 1-shot/5-shot tasks.
AGAM and TorchMeta.
Our code is based onContacts
Please feel free to contact us if you have any problems.
Email: [email protected]