batdetect2
Science Score: 59.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
✓DOI references
Found 1 DOI reference(s) in README -
✓Academic publication links
Links to: biorxiv.org -
✓Committers with academic emails
1 of 6 committers (16.7%) from academic institutions -
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (15.5%) to scientific vocabulary
Repository
Basic Info
- Host: GitHub
- Owner: macaodha
- License: other
- Language: Jupyter Notebook
- Default Branch: main
- Size: 27.1 MB
Statistics
- Stars: 71
- Watchers: 15
- Forks: 13
- Open Issues: 10
- Releases: 13
Metadata Files
README.md
BatDetect2
Code for detecting and classifying bat echolocation calls in high frequency audio recordings.
[!NOTE] We’re actively working to make it easier to train and fine-tune BatDetect2 models using custom data. A major update is coming soon to the main branch—stay tuned! In the meantime, you can follow our progress in the train branch.
Getting started
Python Environment
We recommend using an isolated Python environment to avoid dependency issues. Choose one of the following options:
- Install the Anaconda Python 3.10 distribution for your operating system from here. Create a new environment and activate it:
bash
conda create -y --name batdetect2 python==3.10
conda activate batdetect2
- If you already have Python installed (version >= 3.8,< 3.11) and prefer using virtual environments then:
bash
python -m venv .venv
source .venv/bin/activate
Installing BatDetect2
You can use pip to install batdetect2:
bash
pip install batdetect2
Alternatively, download this code from the repository (by clicking on the green button on top right) and unzip it. Once unzipped, run this from extracted folder.
bash
pip install .
Make sure you have the environment activated before installing batdetect2.
Try the model
1) You can try a demo of the model (for UK species) on huggingface.
2) Alternatively, click here to run the model using Google Colab. You can also run this notebook locally.
Running the model on your own data
After following the above steps to install the code you can run the model on your own data.
Using the command line
You can run the model by opening the command line and typing:
bash
batdetect2 detect AUDIO_DIR ANN_DIR DETECTION_THRESHOLD
e.g.
bash
batdetect2 detect example_data/audio/ example_data/anns/ 0.3
AUDIO_DIR is the path on your computer to the audio wav files of interest.
ANN_DIR is the path on your computer where the model predictions will be saved. The model will output both .csv and .json results for each audio file.
DETECTION_THRESHOLD is a number between 0 and 1 specifying the cut-off threshold applied to the calls. A smaller number will result in more calls detected, but with the chance of introducing more mistakes.
There are also optional arguments, e.g. you can request that the model outputs features (i.e. estimated call parameters) such as duration, maxfrequency, etc. by setting the flag `--specfeatures. These will be saved as*specfeatures.csvfiles:
batdetect2 detect exampledata/audio/ exampledata/anns/ 0.3 --spec_features`
You can also specify which model to use by setting the --model_path argument. If not specified, it will default to using a model trained on UK data e.g.
batdetect2 detect example_data/audio/ example_data/anns/ 0.3 --model_path models/Net2DFast_UK_same.pth.tar
Using the Python API
If you prefer to process your data within a Python script then you can use the batdetect2 Python API.
```python from batdetect2 import api
AUDIOFILE = "exampledata/audio/20170701213954-MYOMYS-LR0_0.5.wav"
Process a whole file
results = api.processfile(AUDIOFILE)
Or, load audio and compute spectrograms
audio = api.loadaudio(AUDIOFILE) spec = api.generate_spectrogram(audio)
And process the audio or the spectrogram with the model
detections, features, spec = api.processaudio(audio) detections, features = api.processspectrogram(spec)
Do something else ...
```
You can integrate the detections or the extracted features to your custom analysis pipeline.
Using the Python API with HTTP
```python from batdetect2 import api import io import requests
AUDIO_URL = "
Process a whole file from a url
results = api.processurl(AUDIOURL)
Or, load audio and compute spectrograms
'requests.get(AUDIO_URL).content' fetches the raw bytes. You are free to use other sources to fetch the raw bytes
audio = api.loadaudio(io.BytesIO(requests.get(AUDIOURL).content)) spec = api.generate_spectrogram(audio)
And process the audio or the spectrogram with the model
detections, features, spec = api.processaudio(audio) detections, features = api.processspectrogram(spec) ```
Training the model on your own data
Take a look at the steps outlined in finetuning readme here for a description of how to train your own model.
Data and annotations
The raw audio data and annotations used to train the models in the paper will be added soon. The audio interface used to annotate audio data for training and evaluation is available here.
Warning
The models developed and shared as part of this repository should be used with caution. While they have been evaluated on held out audio data, great care should be taken when using the model outputs for any form of biodiversity assessment. Your data may differ, and as a result it is very strongly recommended that you validate the model first using data with known species to ensure that the outputs can be trusted.
FAQ
For more information please consult our FAQ.
Reference
If you find our work useful in your research please consider citing our paper which you can find here:
@article{batdetect2_2022,
title = {Towards a General Approach for Bat Echolocation Detection and Classification},
author = {Mac Aodha, Oisin and Mart\'{i}nez Balvanera, Santiago and Damstra, Elise and Cooke, Martyn and Eichinski, Philip and Browning, Ella and Barataudm, Michel and Boughey, Katherine and Coles, Roger and Giacomini, Giada and MacSwiney G., M. Cristina and K. Obrist, Martin and Parsons, Stuart and Sattler, Thomas and Jones, Kate E.},
journal = {bioRxiv},
year = {2022}
}
Acknowledgements
Thanks to all the contributors who spent time collecting and annotating audio data.
TODOs
- [x] Release the code and pretrained model
- [ ] Release the datasets and annotations used the experiments in the paper
- [ ] Add the scripts used to generate the tables and figures from the paper
Owner
- Name: Oisin Mac Aodha
- Login: macaodha
- Kind: user
- Company: University of Edinburgh
- Website: https://homepages.inf.ed.ac.uk/omacaod/
- Repositories: 4
- Profile: https://github.com/macaodha
GitHub Events
Total
- Create event: 11
- Release event: 4
- Issues event: 15
- Watch event: 19
- Issue comment event: 48
- Push event: 53
- Pull request review comment event: 20
- Pull request review event: 7
- Pull request event: 18
- Fork event: 6
Last Year
- Create event: 11
- Release event: 4
- Issues event: 15
- Watch event: 19
- Issue comment event: 48
- Push event: 53
- Pull request review comment event: 20
- Pull request review event: 7
- Pull request event: 18
- Fork event: 6
Committers
Last synced: 8 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| Santiago Martinez | s****l@g****m | 107 |
| macaodha | m****a@g****m | 14 |
| Kavi | k****i@e****k | 13 |
| Oisin Mac Aodha | o****d@e****k | 5 |
| ccarrizosa | c****a@g****m | 3 |
| Arky | h****y@g****m | 1 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 7 months ago
All Time
- Total issues: 32
- Total pull requests: 21
- Average time to close issues: about 1 month
- Average time to close pull requests: 9 days
- Total issue authors: 21
- Total pull request authors: 5
- Average comments per issue: 3.09
- Average comments per pull request: 1.14
- Merged pull requests: 20
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 12
- Pull requests: 12
- Average time to close issues: about 1 month
- Average time to close pull requests: 13 days
- Issue authors: 8
- Pull request authors: 3
- Average comments per issue: 2.25
- Average comments per pull request: 1.33
- Merged pull requests: 12
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- Jeff37 (5)
- markgloverswaybtinternetcom (5)
- kdarras (3)
- chrmue44 (2)
- jenstangchristensen (1)
- kaviecos (1)
- arky (1)
- MatisPatel (1)
- NoxTheXelor (1)
- sergewich (1)
- niallel (1)
- fhaefele (1)
- RanelelSapo (1)
- ccharp (1)
- revilodarnoc (1)
Pull Request Authors
- mbsantiago (16)
- kaviecos (3)
- ccarrizosa (2)
- EvansMike (1)
- arky (1)
Top Labels
Issue Labels
Pull Request Labels
Dependencies
- actions/checkout v3 composite
- actions/setup-python v3 composite
- librosa ==0.9.2
- matplotlib ==3.6.2
- numpy ==1.23.4
- pandas ==1.5.2
- scikit_learn ==1.2.0
- scipy ==1.9.3
- torch ==1.13.0
- torchaudio ==0.13.0
- torchvision ==0.14.0
- actions/checkout v3 composite
- actions/setup-python v3 composite
- pypa/gh-action-pypi-publish 27b31702a0e7fc50959f5ad993c78deac1bdfc29 composite
- click *
- librosa *
- matplotlib *
- numpy *
- pandas *
- scikit-learn *
- scipy *
- torch >=1.13.1,<2
- torchaudio *
- torchvision *
- librosa
- matplotlib
- numpy
- pandas
- python 3.10
- pytorch
- scikit-learn
- scipy
- torchaudio
- torchvision
- attrs 24.2.0
- audioread 3.0.1
- batdetect2 1.1.0
- certifi 2024.8.30
- cffi 1.17.1
- charset-normalizer 3.4.0
- click 8.1.7
- colorama 0.4.6
- contourpy 1.3.0
- cycler 0.12.1
- debugpy 1.8.8
- decorator 5.1.1
- exceptiongroup 1.2.2
- filelock 3.16.1
- fonttools 4.54.1
- fsspec 2024.10.0
- hypothesis 6.118.7
- idna 3.10
- importlib-resources 6.4.5
- iniconfig 2.0.0
- jinja2 3.1.4
- joblib 1.4.2
- kiwisolver 1.4.7
- lazy-loader 0.4
- librosa 0.10.2.post1
- llvmlite 0.43.0
- markupsafe 3.0.2
- matplotlib 3.9.2
- mpmath 1.3.0
- msgpack 1.1.0
- networkx 3.2.1
- nodeenv 1.9.1
- numba 0.60.0
- numpy 2.0.2
- nvidia-cublas-cu12 12.1.3.1
- nvidia-cuda-cupti-cu12 12.1.105
- nvidia-cuda-nvrtc-cu12 12.1.105
- nvidia-cuda-runtime-cu12 12.1.105
- nvidia-cudnn-cu12 9.1.0.70
- nvidia-cufft-cu12 11.0.2.54
- nvidia-curand-cu12 10.3.2.106
- nvidia-cusolver-cu12 11.4.5.107
- nvidia-cusparse-cu12 12.1.0.106
- nvidia-nccl-cu12 2.20.5
- nvidia-nvjitlink-cu12 12.6.77
- nvidia-nvtx-cu12 12.1.105
- packaging 24.2
- pandas 2.2.3
- pillow 11.0.0
- platformdirs 4.3.6
- pluggy 1.5.0
- pooch 1.8.2
- pycparser 2.22
- pyparsing 3.2.0
- pyright 1.1.388
- pytest 8.3.3
- python-dateutil 2.9.0.post0
- pytz 2024.2
- requests 2.32.3
- ruff 0.7.3
- scikit-learn 1.5.2
- scipy 1.13.1
- six 1.16.0
- sortedcontainers 2.4.0
- soundfile 0.12.1
- soxr 0.5.0.post1
- sympy 1.13.3
- threadpoolctl 3.5.0
- tomli 2.0.2
- torch 2.4.1
- torchaudio 2.4.1
- torchvision 0.19.1
- triton 3.0.0
- typing-extensions 4.12.2
- tzdata 2024.2
- urllib3 2.2.3
- zipp 3.21.0