Git Product home page Git Product logo

bebe's Introduction

The Bio-logger Ethogram Benchmark (BEBE)

This repository contains code for model training and evaluation, presented in our forthcoming work:

B. Hoffman, M. Cusimano, V. Baglione, D. Canestrari, D. Chevallier, D. L. DeSantis, L. Jeantet, M. Ladds, T. Maekawa, V. Mata-Silva, V. Moreno-González, A. Pagano, E. Trapote, O. Vainio, A. Vehkaoja, K. Yoda, K. Zacarian, A. Friedlaender, and C. Rutz, "A benchmark for computational analysis of animal behavior, using animal-borne tags," 2023.

Please cite this paper if you use this code. The preprint is available at https://arxiv.org/abs/2305.10740. Code for producing our figures can be found at https://github.com/earthspecies/BEBE-figures.

For attributions of images used in this figure, see the file ATTRIBUTIONS.

Install necessary Python packages:

BEBE was developed in Python 3.8, with Pytorch version 1.12.1. To set up a conda environment for BEBE, follow these steps:

conda create -n BEBE python=3.8 pytorch cudatoolkit=11.3 torchvision torchaudio cudnn -c pytorch -c conda-forge
conda activate BEBE
pip install -r requirements.txt

Please note that the version of pytorch and the cudatoolkit that you can use may vary depending on your computational resources (e.g. whether you have a GPU and what kind). Therefore, to install PyTorch you should follow the instructions on their website, and potentially use a previous version if needed. To use your GPU with our HMM module (which uses jax and dynamax), please follow the instructions here to install jax for GPU.

Get data

All raw and formatted datasets for BEBE are available on our Zenodo repository.

Run a single experiment

The directory example_config contains example config files. To create configs for other models included in our paper, follow the format of the example config files, and check the default configs in BEBE/models/default_configs/ to see a list of parameters. If any parameters are not specified in your file, the default_configs will provide defaults values.

To run a single experiment using these hyperparameters, edit the output directory in a config file and run python single_experiment.py --config /path/to/CONFIG_NAME.yaml. Note that these config files specify that training is performed using folds 1, 2, 3, and 4, and testing is performed using fold 0. After training and evaluation, results and figures can be found at the output directory specified in config file.

To see the config files used for the experiments reported in the paper, please download the results on our Zenodo repository.

Run multiple experiments

To replicate the experiments in the paper, run python cross_val_experiment.py --experiment-dir-parent=/path/to/dir/where/experiment/should/go --experiment-name=EXPERIMENT NAME --dataset-dir=/path/to/formatted/dataset/ --model=MODEL TYPE --resume

Supported model types are CNN, CRNN, rf, kmeans, wavelet-kmeans, gmm, hmm, umapper, vame, iic, and random.

Once these experiments have been run, final results are saved in the file final_result_summary.yaml. These are scores averaged across all individuals from the four test sets not used for hyperparameter selection. The per-individual scores these are based on can be found in fold_$i/test_eval.yaml and fold_$i/train_eval.yaml, listed under individual scores.

Standalone evaluation

To evaluate model outputs without integrating model training into the BEBE codebase, you need to save your model predictions as .csv files. Predictions should be of shape [n_samples,], where each entry is an integer. Each file should have the same name as a file in the original dataset. Evaluation can then be performed using the generate_evaluations_standalone function in BEBE/evaluation/evaluation.py.

Implement a new model

  1. Inherit basic structure from BehaviorModel which can be found in BEBE/models/model_superclass.py.
  2. Include default model settings in a new model_type.yaml file, inside the directory BEBE/models/default_configs.
  3. Include new model class inside BEBE/training/train_model.py.
  4. To perform hyperparameter optimization as described in the paper, add your model to BEBE/utils/hyperparameters.py.

Process a new dataset

Example notebooks for processing a new dataset into the format used by BEBE can be found at https://github.com/earthspecies/BEBE-datasets/.

Enquiries

Please post an issue here on Github or contact us in any of the following situations:

  1. You have questions or issues with running this code.
  2. You are interested in including your data in a future expansion of BEBE.
  3. You test your model on BEBE and have something exciting to share.

bebe's People

Contributors

benjaminsshoffman avatar mcusi avatar

Stargazers

Nathãn Jaber avatar  avatar Matthew Pacey avatar Ștefan Istrate avatar  avatar  avatar  avatar Klaus Riede avatar David Robinson avatar Sumeyye Agac avatar Romain Fayat avatar Jake Graving avatar

Watchers

Britt Selvitelle avatar Aza Raskin avatar Jen-Yu Liu avatar  avatar Klaus Riede avatar Katie Zacarian avatar  avatar Nathãn Jaber avatar  avatar Matthew Pacey avatar

bebe's Issues

Use of `.split("/")` is (only?) blocker for Windows users

Some of the code uses .split("/") to split up file paths. For my students, running the code on Windows, this leads to failures when running evaluation.py -- it yields a KeyError because the paths do not actually get split.

The standard fix is to replace .split(".") with os.path.split(), but you could also use os.path.basename().

I'm not a Windows user myself so I wouldn't be able to test a patch.

requirements.txt has strict requirements, unsatisfiable on current Windows/conda

When my students tried to install BEBE code on Windows, the conda install fails on this requirement:

numba==0.34.1

simply because this version of numba is old and no longer available from the repository. If I change the requirement from "==" to ">=" then the error goes away and pip installation completes successfully. Is it a "safe" installation? Only you can judge!

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.