Git Product home page Git Product logo

easy-few-shot-learning's Introduction

Easy Few-Shot Learning

Python Versions CircleCI Code style: black License: MIT

Ready-to-use code and tutorial notebooks to boost your way into few-shot image classification. This repository is made for you if:

  • you're new to few-shot learning and want to learn;
  • or you're looking for reliable, clear and easily usable code that you can use for your projects.

Don't get lost in large repositories with hundreds of methods and no explanation on how to use them. Here, we want each line of code to be covered by a tutorial.

easyfsl-motto

What's in there?

Notebooks: learn and practice

You want to learn few-shot learning and don't know where to start? Start with our tutorial.

Code that you can use and understand

State-Of-The-Art Few-Shot Learning methods:

To reproduce their results, you can use the standard network architectures used in Few-Shot Learning research. They're also a feature of EasyFSL!

Tools for data loading:

Data loading in FSL is a bit different from standard classification because we sample batches of instances in the shape of few-shot classification tasks. No sweat! In EasyFSL you have:

  • TaskSampler: an extension of the standard PyTorch Sampler object, to sample batches in the shape of few-shot classification tasks
  • FewShotDataset: an abstract class to standardize the interface of any dataset you'd like to use
  • EasySet: a ready-to-use FewShotDataset object to handle datasets of images with a class-wise directory split

And also: some utilities that I felt I often used in my research, so I'm sharing with you.

Datasets to test your model

There are enough datasets used in Few-Shot Learning for anyone to get lost in them. They're all here, explicited, downloadable and easy-to-use, in EasyFSL.

CU-Birds

We provide a script to download and extract the dataset, along with the standard (train / val / test) split along classes. Once you've downloaded the dataset, you can instantiate the Dataset objects in your code with this super complicated process:

from easyfsl.datasets import CUB

train_set = CUB(split="train", training=True)
test_set = CUB(split="test", training=False)

tieredImageNet

To use it, you need the ILSVRC2015 dataset. Once you have downloaded and extracted the dataset, ensure that its localisation on disk is consistent with the class paths specified in the specification files. Then:

from easyfsl.datasets import TieredImageNet

train_set = TieredImageNet(split="train", training=True)
test_set = TieredImageNet(split="test", training=False)

miniImageNet

Same as tieredImageNet, we provide the specification files, but you need the ILSVRC2015 dataset. Once you have it:

from easyfsl.datasets import MiniImageNet

train_set = MiniImageNet(root="where/imagenet/is", split="train", training=True)
test_set = MiniImageNet(root="where/imagenet/is", split="test", training=False)

Since miniImageNet is relatively small, you can also load it on RAM directly at instantiation simply by adding load_on_ram=True to the constructor. It takes a few minutes but it can make your training significantly faster!

Danish Fungi

I've recently started using it as a Few-Shot Learning benchmarks, and I can tell you it's a great playing field. To use it, first download the data:

# Download the original dataset (/!\ 110GB)
wget http://ptak.felk.cvut.cz/plants/DanishFungiDataset/DF20-train_val.tar.gz
# Or alternatively the images reduced to 300px (6.5Gb)
wget http://ptak.felk.cvut.cz/plants/DanishFungiDataset/DF20-300px.tar.gz
# And finally download the metadata (83Mb) to data/fungi/
wget https://public-sicara.s3.eu-central-1.amazonaws.com/easy-fsl/DF20_metadata.csv  -O data/fungi/DF20_metadata.csv

And then instantiate the dataset with the same process as always:

from easyfsl.datasets import DanishFungi

dataset = DanishFungi(root="where/fungi/is")

Note that I didn't specify a train and test set because the CSV I gave you describes the whole dataset. I recommend to use it to test models with weights trained on an other dataset (like ImageNet). But if you want to propose a train/val/test split along classes, you're welcome to contribute!

QuickStart

  1. Install the package: pip install easyfsl
    Note: alternatively, you can clone the repository so that you can modify the code as you wish.

  2. Download your data.

  3. Design your training and evaluation scripts. You can use our example notebooks for episodic training or classical training

Contribute

This project is very open to contributions! You can help in various ways:

  • raise issues
  • resolve issues already opened
  • tackle new features from the roadmap
  • fix typos, improve code quality

easy-few-shot-learning's People

Contributors

ebennequin avatar antoinetoubhans 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.