Skip to content

The code for "SCL: Self-supervised contrastive learning for few-shot image classification"

License

Notifications You must be signed in to change notification settings

Jityan/SCLfewshot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SCL: Self-supervised contrastive learning for few-shot image classification

This repository contains the pytorch code for the paper: "SCL: Self-supervised contrastive learning for few-shot image classification" Jit Yan Lim, Kian Ming Lim, Chin Poo Lee, Yong Xuan Tan

*Please note that we did not apply data augmentation to increase the support sample during the evaluation stage in this repository.

Environment

The code is tested on Windows 10 with Anaconda3 and following packages:

  • python 3.7.4
  • pytorch 1.3.1

Preparation

  1. Change the ROOT_PATH value in the following files to yours:

    • datasets/miniimagenet.py
    • datasets/tiered_imagenet.py
    • datasets/cifarfs.py
    • datasets/fc100.py
  2. Download the datasets and put them into corresponding folders that mentioned in the ROOT_PATH:

    • miniImageNet: download from CSS and put in data/miniImageNet folder.

    • tieredImageNet: download from RFS and put in data/tieredImageNet folder.

    • CIFARFS: download from MetaOptNet and put in data/cifarfs folder.

    • FC100: download from MTL, extract them into train, val, and test folders and put in data/fc100 folder.

Pre-trained Models

[Optional] The pre-trained models can be downloaded from here. Extract and put the content in the save folder. To evaluate the model, run the test.py file with the proper save path as in the next section.

Experiments

To train on miniImageNet:

python train.py --dataset mini --gamma-rot 1.5 --gamma-dist 0.02 --save-path ./save/mini-exp1

To evaluate on 5-way 1-shot and 5-way 5-shot miniImageNet:

python test.py --dataset mini --shot 1 --save-path ./save/mini-exp1
python test.py --dataset mini --shot 5 --save-path ./save/mini-exp1

Citation

If you find this repo useful for your research, please consider citing the paper:

@article{LIM2023,
  title = {SCL: Self-supervised contrastive learning for few-shot image classification},
  journal = {Neural Networks},
  year = {2023},
  issn = {0893-6080},
  doi = {https://doi.org/10.1016/j.neunet.2023.05.037},
  url = {https://www.sciencedirect.com/science/article/pii/S0893608023002812},
  author = {Jit Yan Lim and Kian Ming Lim and Chin Poo Lee and Yong Xuan Tan}
}

Contacts

For any questions, please contact:

Jit Yan Lim (jityan95@gmail.com)
Kian Ming Lim (Kian-Ming.Lim@nottingham.edu.cn)

Acknowlegements

This repo is based on Prototypical Networks, RFS, and SKD.

About

The code for "SCL: Self-supervised contrastive learning for few-shot image classification"

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages