GithubHelp home page GithubHelp logo

leonardo-lyh / dn4 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from wenbinlee/dn4

0.0 0.0 0.0 3.6 MB

The Pytorch code of "Revisiting Local Descriptor based Image-to-Class Measure for Few-shot Learning", CVPR 2019.

License: Other

Python 100.00%

dn4's Introduction

DN4 in PyTorch

We provide a PyTorch implementation of DN4 for few-shot learning. If you use this code for your research, please cite:

Revisiting Local Descriptor based Image-to-Class Measure for Few-shot Learning.
Wenbin Li, Lei Wang, Jinglin Xu, Jing Huo, Yang Gao and Jiebo Luo. In CVPR 2019.

Prerequisites

  • Linux
  • Python 3
  • Pytorch 0.4 or 1.0
  • GPU + CUDA CuDNN
  • pillow, torchvision, scipy, numpy

Getting Started

Installation

  • Clone this repo:
git clone https://github.com/WenbinLee/DN4.git
cd DN4
  • Install PyTorch 1.0 and other dependencies.

Datasets

miniImageNet Few-shot Classification

  • Train a 5-way 1-shot model based on Conv64F or ResNet256F:
python DN4_Train_5way1shot.py --dataset_dir ./datasets/miniImageNet --data_name miniImageNet
or
python DN4_Train_5way1shot_Resnet.py --dataset_dir ./datasets/miniImageNet --data_name miniImageNet
  • Test the model (specify the dataset_dir, basemodel, and data_name first):
python DN4_Test_5way1shot.py --resume ./results/DN4_miniImageNet_Conv64F_5Way_1Shot_K3/model_best.pth.tar --basemodel Conv64F
or
python DN4_Test_5way1shot.py --resume ./results/DN4_miniImageNet_ResNet256F_5Way_1Shot_K3/model_best.pth.tar --basemodel ResNet256F
  • The results on the miniImageNet dataset (If you set neighbor_k as 1, you may get better results in some cases):

Fine-grained Few-shot Classification

  • Data prepocessing (e.g., StanfordDog)
  • Specify the path of the dataset and the saving path.
  • Run the preprocessing script.
#!./dataset/StanfordDog_prepare_csv.py
python ./dataset/StanfordDog_prepare_csv.py
  • Train a 5-way 1-shot model:
python DN4_Train_5way1shot.py --dataset_dir ./datasets/StanfordDog --data_name StanfordDog
  • Test the model (specify the dataset_dir and data_name first):
python DN4_Test_5way1shot.py --resume ./results/DN4_StanfordDog_Conv64F_5_Way_1_Shot/model_best.pth.tar --basemodel Conv64F
  • The results on the fine-grained datasets:

Citation

If you use this code for your research, please cite our paper.

@inproceedings{li2019DN4,
  title={Revisiting Local Descriptor based Image-to-Class Measure for Few-shot Learning},
  author={Li, Wenbin and Wang, Lei and Xu, Jinglin and Huo, Jing and Gao Yang and Luo, Jiebo},
  booktitle={CVPR},
  year={2019}
}

dn4's People

Contributors

wenbinlee avatar

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.