Skip to content

Repository files navigation

Code for Revisiting Continual Ultra-fine-grained Visual Recognition with Pre-trained Models

Prerequest

  1. Main dependecies

        torch==2.5.0
        torchvision==0.20.0
        cuda==12.1
        numpy=2.1.2
        timm==1.0.12
  2. Preparing data

    • Download SoyGene, SoyAgeing and SoyGlobal UFG datasets.

    • Create folder Data/, unzip and place the data as

              Data
              ├── SoyAgeing
              │   └── ......
              ├── SoyGene
              │   └── ......
              └── SoyGlobal
                  └── ......
    • Formulate the raw data using

      python build_img_folder_structure.py Data/SoyAgeing/R1
      python build_img_folder_structure.py Data/SoyAgeing/R3
      python build_img_folder_structure.py Data/SoyAgeing/R4
      python build_img_folder_structure.py Data/SoyAgeing/R5
      python build_img_folder_structure.py Data/SoyAgeing/R6
      python build_img_folder_structure.py Data/SoyGene
      python build_img_folder_structure.py Data/SoyGlobal

Training and Inference

  • Train any model with the config

    # for SoyGene-C
    python train_net_seq.py --config-file configs/ufgvc/${model}/${model}_base21k224_gene.yaml --resume
    # for SoyAgeing-C
    python train_net_seq.py --config-file configs/ufgvc/${model}/${model}_base21k224_ageing.yaml --resume
    # for SoyGlobal-C
    python train_net_seq.py --config-file configs/ufgvc/${model}/${model}_base21k224_global.yaml --resume
    # for UniUFG-C
    python train_net_seq.py --config-file configs/ufgvc/${model}/${model}_base21k224_gamixhalf.yaml --resume
  • If a model is already trained, excecuting the above commands also performs full test of the model.

  • All models are evaluated periodically during training, we recommend to use Tensorboard to monitor the training process and evaluate results:

    tensorboard --logdir outputs/${model_output}$

Supported Models

  • Besides the proposed Unic, we also include the following previous continual learning models, making this repository a unified base framework for future research and development:

    • CODA-Prompt, DualPrompt, HiDE, L2P, LAE, S-Prompts, VQPrompt
  • We also integrate basic PEFT methods, including

    • Prompt tuning, Prefix tuning, Adapter, Lora

Code structure

  • The overall structure of the code is based on FastReID. This repository is organized as

    Unic
    ├── configs # Where model configuration files saved
    ├── Data # Where data saved 
    ├── fastclas # An extension of FastReID for classification tasks
    ├── fastreid # FastReID source code
    ├── outputs # Where training logs and checkpoints saved
    ├── ufgvc # The main code
    │   ├── config # Definition of the basic configuration for all models
    │   ├── data # Reading and augmenting data
    │   ├── engine # The main training loop
    │   ├── evaluation # Evaluators for testing the model 
    │   ├── __init__.py
    │   ├── modeling # Definition of models
    │   │   ├── meta_arch # Definition of continual learning models
    │   │   └── vits # Definition of ViTs with different PEFT methods
    │   └── utils # Commonly used tools, e.g. logging, visualization and distributed communication.
    ├── README.md # This file
    ├── build_img_folder_structure.py # data formulation tool
    ├── train_net_seq_mix.py # Training script for UniUFG-C
    └── train_net_seq_mix.py # Training script for other three datasets
    

Acknowledgement

This code is greatly inspired by FastReID and CODA-Prompt.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages