Home

Awesome

Improved Few-Shot Visual Classification

**This code base is an implicit fork of https://github.com/plai-group/simple-cnaps. Please refer to that repository for the most up-to-date code. We will try to sync that repository with the one here as much as possible, but there will be latencies as the PLAI-Group repository is directly maintained, and my personal copy here is not. Also, if you would like to ask any questions or reach out regarding any of the papers, please email me directly at peyman.bateni@hotmail.com (my cs.ubc.ca may have expired by the time you are emailing as I have graduated!).

This repository contains source codes for the following papers and thesis:

The code base has been authored by Peyman Bateni, Jarred Barber, Raghav Goyal, Vaden Masrani, Dr. Jan-Willemn van de Meent, Dr. Leonid Sigal and Dr. Frank Wood. The source codes build on the original code base for CNAPS authored by Dr. John Bronskill, Jonathan Gordon, James Reqeima, Dr. Sebastian Nowozin, and Dr. Richard E. Turner. We would like to thank them for their help, support and early sharing of their work. To see the original CNAPS repository, visit https://github.com/cambridge-mlg/cnaps.

Simple CNAPS

Simple CNAPS proposes the use of hierarchically regularized cluster means and covariance estimates within a Mahalanobis-distance based classifer for improved few-shot classification accuracy. This method incorporates said classifier within the same neural adaptive feature extractor as CNAPS. For more details, please refer to our paper on Simple CNAPS: Improved Few-Shot Visual Classification. The source code for this paper has been provided in the simple-cnaps-src directory. To reproduce our results, please refer to the README.md file within that folder.

Global Meta-Dataset Rank (Simple CNAPS): https://github.com/google-research/meta-dataset#training-on-all-datasets

Global Mini-ImageNet Rank (Simple CNAPS):

PWC PWC PWC PWC

Global Tiered-ImageNet Rank (Simple CNAPS):

PWC PWC PWC PWC

Transductive CNAPS

Transductive CNAPS extends the Simple CNAPS framework to the transductive few-shot learning setting where all query examples are provided at once. This method uses a two-step transductive task-encoder for adapting the feature extractor as well as a soft k-means cluster refinement procedure, resulting in better test-time accuracy. For additional details, please refer to our paper on Transductive CNAPS: Enhancing Few-Shot Image Classification with Unlabelled Examples. The source code for this work is provided under the transductive-cnaps-src directory. To reproduce our results, please refer to the README.md file within this folder.

Global Meta-Dataset Rank (Transductive CNAPS): https://github.com/google-research/meta-dataset#training-on-all-datasets

Global Mini-ImageNet Rank (Transductive CNAPS):

PWC PWC PWC PWC

Global Tiered-ImageNet Rank (Transductive CNAPS):

PWC PWC PWC PWC

Active and Continual Learning

We additionally evaluate both methods within the paradigms of "out of the box" active and continual learning. These settings were first proposed by Requeima et al., and studies how well few-shot classifiers, trained for few-shot learning, can be deployed for active and continual learning without any problem-specific finetuning or training. For additional details on our active and continual learning experiments and algorithms, please refer to our latest paper: Beyond Simple Meta-Learning: Multi-Purpose Models for Multi-Domain, Active and Continual Few-Shot Learning. For code and instructions to reproduce the experiments reported, please refer to the active-learning and continual-learning folders.

Meta-Dataset Results

DatasetSimple CNAPSSimple CNAPSTransductive CNAPSTransductive CNAPS
--shuffle_datasetFalseTrueFalseTrue
In-Domain Datasets------------
ILSVRC58.6±1.156.5±1.158.8±1.157.9±1.1
Omniglot91.7±0.691.9±0.693.9±0.494.3±0.4
Aircraft82.4±0.783.8±0.684.1±0.684.7±0.5
Birds74.9±0.876.1±0.976.8±0.878.8±0.7
Textures67.8±0.870.0±0.869.0±0.866.2±0.8
Quick Draw77.7±0.778.3±0.778.6±0.777.9±0.6
Fungi46.9±1.049.1±1.248.8±1.148.9±1.2
VGG Flower90.7±0.591.3±0.691.6±0.492.3±0.4
Out-of-Domain Datasets------------
Traffic Signs73.5±0.759.2±1.076.1±0.759.7±1.1
MSCOCO46.2±1.142.4±1.148.7±1.042.5±1.1
MNIST93.9±0.494.3±0.495.7±0.394.7±0.3
CIFAR1074.3±0.772.0±0.875.7±0.773.6±0.7
CIFAR10060.5±1.060.9±1.162.9±1.061.8±1.0
---------------
In-Domain Average Accuracy73.8±0.874.6±0.875.2±0.875.1±0.8
Out-of-Domain Average Accuracy69.7±0.865.8±0.871.8±0.866.5±0.8
Overall Average Accuracy72.2±0.871.2±0.873.9±0.871.8±0.8

Mini-ImageNet Results

Setup5-way 1-shot5-way 5-shot10-way 1-shot10-way 5-shot
Simple CNAPS53.2±0.970.8±0.737.1±0.556.7±0.5
Transductive CNAPS55.6±0.973.1±0.742.8±0.759.6±0.5
---------------
Simple CNAPS + FETI77.4±0.890.3±0.463.5±0.683.1±0.4
Transductive CNAPS + FETI79.9±0.891.5±0.468.5±0.685.9±0.3

Tiered-ImageNet Results

Setup5-way 1-shot5-way 5-shot10-way 1-shot10-way 5-shot
Simple CNAPS63.0±1.080.0±0.848.1±0.770.2±0.6
Transductive CNAPS65.9±1.081.8±0.754.6±0.872.5±0.6
---------------
Simple CNAPS + FETI71.4±1.086.0±0.657.1±0.778.5±0.5
Transductive CNAPS + FETI73.8±1.087.7±0.665.1±0.880.6±0.5

Citation

We hope you have found our code base helpful! If you use this repository, please cite our papers:

@InProceedings{Bateni2020_SimpleCNAPS,
    author = {Bateni, Peyman and Goyal, Raghav and Masrani, Vaden and Wood, Frank and Sigal, Leonid},
    title = {Improved Few-Shot Visual Classification},
    booktitle = {Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},
    month = {June},
    year = {2020}
}

@InProceedings{Bateni2022_TransductiveCNAPS,
    author    = {Bateni, Peyman and Barber, Jarred and van de Meent, Jan-Willem and Wood, Frank},
    title     = {Enhancing Few-Shot Image Classification With Unlabelled Examples},
    booktitle = {Proceedings of the IEEE/CVF Winter Conference on Applications of Computer Vision (WACV)},
    month     = {January},
    year      = {2022},
    pages     = {2796-2805}
}

@misc{Bateni2022_BeyondSimpleMetaLearning,
    title={Beyond Simple Meta-Learning: Multi-Purpose Models for Multi-Domain, Active and Continual Few-Shot Learning}, 
    author={Peyman Bateni and Jarred Barber and Raghav Goyal and Vaden Masrani and Jan-Willem van de Meent and Leonid Sigal and Frank Wood},
    year={2022},
    eprint={2201.05151},
    archivePrefix={arXiv},
    primaryClass={cs.CV}
}

@phdthesis{Bateni2021_Thesis, 
    series      = {Electronic Theses and Dissertations (ETDs) 2008+}, 
    title       = {On label-efficient computer vision : building fast and effective few-shot image classifiers}, 
    url         = {https://open.library.ubc.ca/collections/ubctheses/24/items/1.0402554}, 
    DOI         = {http://dx.doi.org/10.14288/1.0402554}, 
    school      = {University of British Columbia}, 
    author      = {Bateni, Peyman}, 
    year        = {2021}, 
    collection  = {Electronic Theses and Dissertations (ETDs) 2008+}
}

**If you would like to ask any questions or reach out regarding any of the papers, please email me directly at peyman.bateni@hotmail.com (my cs.ubc.ca email may have expired by the time you are emailing as I have graduated!).