Skip to content

SammyBolger/Bat-Detection-Using-Machine-Learning

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bat Detection Using Machine Learning

Independent Study — Data Science & Machine Learning Concordia College, Moorhead, Minnesota — Spring 2026

Automated bat echolocation call detection from AudioMoth ultrasonic recordings. Converts raw WAV files into spectrogram images, then trains a MobileNetV2 CNN (transfer learning) to classify bat calls vs. background noise.

Final validation accuracy: 96.4%


Results

Metric Value
Overall accuracy 96.4%
Bat recall 94.6%
No-bat recall 97.5%
Test set size 6,634 images
Training set size ~26,500 images

Full Dataset & Trained Model

The complete project — including all 33,167 labeled recordings, generated spectrograms, trained model weights, and output plots is available here, whats in this repo is a demo due to the size of all the audio recordings I wasn't able to upload to GitHub:

Download Full Project (Google Drive)

The dataset contains:

  • 12,985 confirmed bat echolocation recordings (echolocation_calls/)
  • 20,182 confirmed no-bat recordings (no_bat_noise/)
  • All spectrograms and diagnostic plots generated from training

How to Run

1. Install dependencies

pip install -r requirements.txt

  • Installs libraries

2. Add your data

Place .WAV recordings into the appropriate folders:

  • Bat recordings → data/echolocation_calls/
  • No-bat recordings → data/no_bat_noise/

3. Generate spectrograms

python make_spectrograms.py

  • Outputs 224×224 grayscale PNG spectrograms to output/spectrograms/.

4. Train the model

python train_cnn.py

  • Outputs 5 diagnostic plots to output/plots/ and saves the best model to models/bat_model.keras.

How It Works

Step 1 — Chunking: Each 20-second WAV is sliced into 0.5-second windows.

Step 2 — Spectrograms: Each chunk is converted to a 2D image via STFT. Only the 18–80 kHz band is kept (bat call range). Amplitude is converted to decibels and globally normalized to a fixed range so all images are comparable.

Step 3 — Transfer Learning: MobileNetV2 (pretrained on ImageNet by Google, Sandler et al. 2018) is used as a frozen feature extractor. A small classification head is trained on top to recognize bat call patterns.

Step 4 — Evaluation: The model is tested on a 80%/20% split. Output includes a confusion matrix and more.


About

Automated bat echolocation call detector built for the Concordia Bat Project. Converts AudioMoth WAV recordings (384 kHz) into spectrograms, then trains a MobileNetV2 CNN via transfer learning to classify bat vs. no-bat audio. Achieves 96.4% accuracy on 33,000+ labeled recordings.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages