Home

Awesome

<img src="https://cdnstatic.megvii.com/websiteFE/static/img/logo_hover.2bd68a45.png" width="16%" alt="megvii research"/>

Binocular Mutual Learning for Improving Few-shot Classification (BML)

License: MIT stars GitHub repo size

Installation

This repo contains the PyTorch implementation of our ICCV paper "Binocular Mutual Learning for Improving Few-shot Classification".

BML is a novel and effective solution for few-shot classification. Inspired by the mutual learning paradigm and binocular parallax, we propose this framework, which learn the global relationship between classes and the detailed differences between samples simultaneously. That means, BML has two complementary views, working like human —— they deepen and rectify their perception through two eyes.

<p style="width: 50%; display: block; margin-left: auto; margin-right: auto"> <img src="./assets/bml_framework.png" alt="BML framework diagram"/> </p>

Setup

1. Dependencies

2. Build env

virtualenv BML_env --python=python3.6
cd /path/to/venv/BML_env
source ./bin/activate
pip install -r requirements.txt 
git clone https://github.com/NVIDIA/apex
cd apex
pip install -v --disable-pip-version-check --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" ./

3. Download Data and Weights

Usage

1. training

We give a representative training example on miniImageNet, for other dataset, complete the training by specifying --dataset and --transform.

bash train_bml.sh

You need at least one nvidia tesla v100 or two GeForce RTX 2080ti.

If you want to train two baseline models baseline-global and baseline-local, we also provide corresponding training interfaces:

bash train_baseline.sh

2. evaluation

For fairness, we evaluate BML on 2,000 episodes with 10 random seeds.

bash eval_bml.sh miniImageNet A /path/to/weights 5
bash eval_bml.sh miniImageNet A /path/to/weights 1

Acknowlegements

Part of the code refers to rethinking and MCT, Please check them for more details and features.

Citation

When using code within this repository, please refer the following paper in your publications:

@inproceedings{zhou2021binocular,
  title={Binocular Mutual Learning for Improving Few-shot Classification},
  author={Zhou, Ziqi and Qiu, Xi and Xie, Jiangtao and Wu, Jianan and Zhang, Chi},
  booktitle={Proceedings of the IEEE/CVF International Conference on Computer Vision},
  pages={8402--8411},
  year={2021}
}