Coder Social home page Coder Social logo

lp-dif's Introduction

LP-DiF

Official implementation of the paper "Learning Prompt with Distribution-Based Feature Replay for Few-Shot Class-Incremental Learning"

Overall

Our code is mainly based on CoOp and SHIP. Sincerely thanks for their contribution.

Requirements

Please refer to CoOp to install the requirements.

Prepare data

Download data

Please follow CEC to download mini-ImageNet, CUB-200 and CIFAR-100.

Please download SUN-397 dataset from SUN397.

Setup data

Create ./data folder under this projects

mkdir data

Move or link those unzip datasets folder into this ./data, and make folder to the structure below:

./data/
    CUB_200_2011/
        images/
            001.Black_footed_Albatross/
                Black_Footed_Albatross_0001_796111.jpg
                Black_Footed_Albatross_0002_55.jpg
                ...
            002.Laysan_Albatross/
            ...
        images.txt
        image_class_labels.txt
        train_test_split.txt
    miniimagenet/
        images/
            ._n0153282900000005.jpg
            ...
        index_list/
            mini_imagenet/
                session_1.txt
                session_2.txt
                ...
        split/
            train.csv
            test.csv
    SUN397/
        images/
            a/
                abbey/
                    sun_aaalbzqrimafwbiv.jpg
                    sun_aaaulhwrhqgejnyt.jpg
                    ...
                airplane_cabin/
                ...
            b/
            ...
        split/
            ClassName.txt
            Training_01.txt
            Testing_01.txt

Note that the CIFAR100 dataset is automatically downloaded by the torchvision's code, so there is no need to manually configure it.

Pre-compute Gaussian Distribution of Old Classes

The Gaussian Distribution of Old Classes of each dataset are release in https://drive.google.com/drive/folders/1w5tIVP0gKnOFBcHa-24HlJDBRtvTfZxD?usp=sharing.

Download these .pkl files in ./pre_calculate_GD/ in the root of this project:

./pre_calculate_GD/
    cifar100.pkl
    cub200.pkl
    miniImageNet.pkl
    cub200_wo_base.pkl
    sun397.pkl

In addition, you can use ./generate_GD.py to generate Gaussian Distribution for each class. The training images features can be easily extracted by image encoder of CLIP model, and the VAE, which is responsible to generate synthesized features, can be training by using SHIP.

Training Model

Simply run script file in ./scripts/

For example, for training LP_DiF on CUB-200 dataset, just execute:

bash scripts/script_cub200.sh

For training LP_DiF on mini-ImageNet dataset, execute:

bash scripts/script_miniImageNet.sh

For training LP_DiF on CIFAR-100 dataset, execute:

bash scripts/script_cifar100.sh

For training LP_DiF on SUN-397 dataset, execute:

bash scripts/script_sun397.sh

For training LP_DiF on CUB-200* (CUB-200 w/o base session) dataset, execute:

bash scripts/script_cub200_wo_base.sh

lp-dif's People

Contributors

1170300714 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

lp-dif's Issues

Training code for VAE.

Hi, Thanks for sharing the paper and code. It is a great work!
Can you provide your code about training VAE? I can just find the /pre_calculate_GD and generate_GD.py .But I can't find training code for VAE. I also learn the code about SHIP, but SHIP not provide the datasets.py for cifar100.
Can you help me? Thanks!

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.