Skip to content

vdplasthijs/PECL

Repository files navigation

arXiv Dataset CI Issues Python PyTorch License

Predicting butterfly species presence from satellite imagery using soft contrastive regularisation

This repository contains all code of our 2025 CVPR FGVC paper, including:

  • PECL (Paired Embeddings Contrastive Loss) implementation in scripts/paired_embeddings_models.py.
  • Torch dataloader for the S2BMS dataset in scripts/DataSetImagePresence.py
  • Resnet-based model to predict species presence vectors from satellite images, using PECL.

Installation:

  • Use conda to install packages using pecl.yml or pip install from requirements.txt.
  • Add your user profile data paths in content/data_paths_pecl.json. (This step is not needed when just experimenting with the code and the example data provided in the repo).

Getting started:

  • A sample data set (of 16 locations) is provided in tests/data_tests/.
  • Go to notebooks/Getting started.ipynb to see examples of how to load the data and model.

Data:

  • The full S2-BMS data set is available on Zenodo.
  • Our Torch dataloader is available in scripts/DataSetImagePresence.py.

PECL implementation

  • For details please see our paper.
  • PyTorch implementation can be found in scripts/paired_embeddings_models.py (ImageEncoder.pecl_loss()).

Results

  • The training scripts used for the paper are scripts/train.py and scripts/train_randomsearch.py.
  • The figures and tables in the paper were created in notebooks/Results figs and tables.ipynb.

Please cite our paper if you use this method or data in a publication - thank you!!

About

Paired embeddings contrastive learning

Resources

License

Stars

Watchers

Forks