Giter VIP home page Giter VIP logo

bml's Introduction

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.

BML framework diagram

Setup

1. Dependencies

  • Linux with Python >= 3.6
  • PyTorch >= 1.6 & torchvision that matches the PyTorch version.
  • GCC 7.5
  • CUDA 11.2

2. Build env

virtualenv BML_env --python=python3.6
cd /path/to/venv/BML_env
source ./bin/activate
pip install -r requirements.txt 
  • Install Apex (optional, to enable mixed precision training):
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

  • Data Preparation
    • we evaluate BML on five commonly used benchmarks, including miniImageNet, tieredImageNet, CUB, CIFAR-FS and FC100. We collated and summarized the data:

      Dataset DownloadPath Split
      miniImageNet path 64/16/20
      tieredImageNet path(code:123z) 351/97/160
      CUB path 100/50/50
      CIFAR-FS path 64/16/20
      FC100 path 60/20/20
    • unzip dataset to /data/few-shot/data/

  • pretraind weights for evaluation
    • we offer our released weights on five benchmarks:

      Dataset GoogleDriver BaiDuYun 5way-5shot 5way-1shot
      miniImageNet path path(code:123z) 83.69 67.21
      tieredImageNet path path(code:123z) 85.15 69.49
      CIFAR-FS path path(code:123z) 88.63 74.99
      CUB path path(code:123z) 89.80 74.42
      FC100 path path(code:123z) 62.62 44.62
    • The training and eval details can be found in log and eval_results.

    • download weights to pretrained_weights.

    • note: We give the latest evaluation results and models which are slightly different from the results reported in the paper.

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}
}

bml's People

Contributors

zzqzzq avatar

Stargazers

 avatar  avatar jwhao avatar Xinyu Zhang avatar zling avatar yunkai avatar Chaofei avatar Xiongkun Linghu avatar  avatar  avatar fikry102 avatar  avatar tf1997 avatar  avatar Mouxiao Huang avatar 王矶法 avatar  avatar  avatar

Watchers

James Cloos avatar  avatar Howard H. Tang avatar

Forkers

zoechoo

bml's Issues

the recurring result of this paper

Thanks for your work! I think this paper is perfect. But I don't know why I can't recur the result. And the dataset, tiredImageNet, can't be used. I utilized the weight data given in the project and I get the same result with you. I'm not sure whether the parameters in the project have changed during training.

Thank you very much!

DeepEMD resolution

Thank you very much for your work. I am very interested in your work and would like to quote your paper.
However, I would like to ask you about some details. I would like to know whether the test results of DeepEMD resolution from 84 to 224 that you mentioned in Table 6 were conducted directly on the pre-training model or the DeepEMD was re-trained with 224 resolution.
Thank you very much!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.