Elephant rumble isolation toolkit for noisy wildlife recordings.
- CSV-driven segmentation with 5-second windows.
- Butterworth bandpass preprocessing (10 Hz to 250 Hz).
- Log-Mel spectrogram feature generation.
- 2D U-Net mask estimator in PyTorch with skip connections.
- Hybrid training loss: spectrogram MSE + SDR loss term.
- Inference pipeline that reconstructs waveform using Griffin-Lim.
Required columns:
SelectionSound_fileStart_timeEnd_timeCall_type
pip install -r requirements.txtpython main.py train --metadata_csv data/metadata.csv --audio_dir data/audio --output_dir checkpoints --epochs 40 --batch_size 8 --sr 2000 --call_type_filter contains_rumbleExample with Dice loss enabled/tuned:
python main.py train --metadata_csv data/metadata.csv --audio_dir data/audio --output_dir checkpoints --epochs 100 --batch_size 8 --sr 2000 --dice_weight 0.3 --call_type_filter contains_rumbleNotes:
- The default sample rate is 2000 Hz (sufficient to model energy up to 250 Hz).
- Ground-truth masks are derived from timestamp overlap inside each 5-second segment.
- Training objective can mix MSE, SDR, and Dice loss using
--mse_weight,--sdr_weight, and--dice_weight. - Training writes metrics to
checkpoints/metrics.csvand plots tocheckpoints/training_curves.png. - Metrics include train/validation loss, MSE, SDR loss, mask precision, recall, F1, and IoU.
python main.py infer --metadata_csv data/metadata.csv --audio_dir data/audio --checkpoint checkpoints/best.pt --output_dir outputs --sr 2000 --call_type_filter contains_rumbleOutput files are written as:
isolated_[Selection]_[Original_Filename].wav
Each output clip is trimmed to the exact annotation interval defined by Start_time and End_time.
utils.py: data loading, filtering, segmentation, spectrogram conversion, mask generation, reconstruction.model.py: compact 2D U-Net for soft mask prediction.train.py: dataset and optimization loop.infer.py: batch inference over metadata selections.main.py: CLI entrypoint withtrainandinfercommands.
You can host the web UI on GitHub Pages.
Important limitation:
- GitHub Pages is static hosting only. Python scripts such as training/inference (
main.py,train.py,infer.py) do not run on Pages.
This repository now includes a workflow at .github/workflows/pages.yml that:
- Converts
trimmed_raw/*.wavandoutputs/*.wavinto MP3 files. - Publishes a static site artifact containing:
index.htmldata/metadata.csvtrimmed_raw/*.mp3outputs/*.mp3
To enable Pages deployment:
- Push this repository to GitHub.
- In GitHub, open Settings -> Pages.
- Set Source to GitHub Actions.
- Push to
main(or run the workflow manually from Actions).
After deployment, your app will be available at:
https://<your-username>.github.io/<your-repo-name>/
Notes:
- Keep audio files reasonably small; GitHub Pages is best for demos, not large-scale audio hosting.
- If no MP3 files exist in
trimmed_raworoutputs, the UI will load but audio tracks will be missing.