Skip to content

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PETAL: Projection-based Episodic Training for Adaptive Learning in Fine-Grained Few-Shot Pollen Fossil Classification

Reference implementation accompanying the PETAL submission. It fine-tunes a light projection head on top of frozen DINOv2 features for few-shot pollen fossil recognition across PF40/PF80 benchmarks.

Repository Layout

  • PETAL(DINOv2-based).py — CLI entry point for training + evaluation.
  • pollen_fewshot/ — reusable components (config, data, models, training, evaluation, utilities).
  • Dataset/ — PF40 / PF80 JSON specifications and image folders (few-shot splits under OurMethod/few_shot).

Environment Setup

python -m venv .venv
source .venv/bin/activate
pip install --upgrade pip
pip install -r requirements.txt

The code automatically downloads the dinov2_vits14_reg backbone from the official Torch Hub repo on first use. Ensure outbound network access the first time you run the script.

Running the Pipeline

  1. Prepare specs
    JSON files describing the few-shot splits must live under Dataset/<benchmark>/OurMethod/few_shot/{train,val,test}.json and point to class-specific image directories (relative or absolute). The repo already includes PF40/PF80 specs; adjust or replace as needed.

  2. Train + evaluate

    python PETAL(DINOv2-based).py \
        --specs-dir Dataset/PF40/OurMethod/few_shot \
        --checkpoint-path checkpoints/pf40_dinov2.pth
    • Defaults target PF40; switch to PF80 by passing --specs-dir Dataset/PF80/OurMethod.
    • Runtime overrides exist for all hyper-parameters (--n-way, --n-shot, --epochs, etc.).
    • Use --skip-spec-check to skip the post-run inspection that verifies JSON/image consistency.
  3. Resume / Evaluate only
    Reuse --checkpoint-path to load the best projection head weights and re-run testing:

    python PETAL(DINOv2-based).py \
        --specs-dir Dataset/PF40/OurMethod/few_shot \
        --checkpoint-path checkpoints/pf40_dinov2.pth \
        --epochs 0 \
        --train-tasks 0

Environment variables POLLEN_FOSSIL_SPECS_DIR and POLLEN_FOSSIL_CHECKPOINT provide alternative defaults when CLI flags are not supplied.

Repro Notes

  • Training and evaluation automatically run on GPU when CUDA is available; CPU fallback is supported but slow.
  • Specs inspection prints the number of classes and a sample of image counts, helping catch broken paths before long experiments.
  • The code assumes RGB images; extend pollen_fewshot/data.py transforms for other modalities if needed.

Citation

Please cite the PETAL paper when referencing this implementation. (BibTeX placeholder)

About

Projection-based Episodic Training for Adaptive Learning

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages