BatSpot ONNX Models (call detector and search-call classifier)

ONNX conversions of two BatSpot models, both ResNet18 convolutional neural networks on true ultrasonic audio:

  • batspot_m09.onnx, the search-phase call classifier: classifies bat echolocation calls to species (or species complex) at 250 kHz.
  • batspot_m03.onnx, the call detector: decides whether a 20 ms window holds a bat call at all (noise or target) at 192 kHz. In the original pipeline it runs first and m09 classifies the calls it finds.

BatSpot is described in:

Smeele, S.Q., Hauer, C., Bergler, C., Dechmann, D.K., Dietzer, M.T., Elmeros, M., Fjederholt, E.T., Fogato, A., Kohles, J.E., Nöth, E. and Brinkløv, S.M. (2026). BatSpot: a retrainable neural network for automatic detection and classification of bat echolocation and detection of buzzes and social calls. Biological Conservation, 321, 111975.

It is built on ANIMAL-SPOT (Bergler et al.). These ONNX files are numerically verified conversions of the published PyTorch checkpoints. The models were not retrained or modified.

Purpose

This conversion exists so that BatSpot can run inside BirdNET-Go, a real-time acoustic monitoring application, next to the bird models and the other bat model there (BSG-BAT). It also works with any ONNX Runtime pipeline in Python, Go, C++ or other languages, without PyTorch.

Why BatSpot in addition to BSG-BAT:

  • It is a different, independently trained model: a ResNet18 on 20 ms linear-frequency spectrograms rather than a CNN on 1 s mel spectrograms. Agreement between the two is useful evidence when deciding whether a detection is real.
  • It covers species that BSG-BAT does not: Myotis dasycneme, Myotis nattereri and the Myotis brandtii/mystacinus complex.
  • It recognises feeding buzzes and social calls as their own classes rather than mislabelling them as a species.
  • The original pipeline is designed to be retrained with small amounts of local data (see the article).

The search-phase call classifier (models_call_classifier/m09) and the call detector (models_call_detector/m03) are converted here. The original release also contains a buzz detector and a social-call detector. Those are not included: they are binary detectors that add no species.

BirdNET-Go uses m03 to test the original two-stage pipeline (m03 finds calls, m09 names them) against its own energy gate in front of m09, first as a logged dry run that does not change detections.

How it works

mono audio, resampled to 250 kHz
   -> sliding window        5000 samples (20 ms), hop 1250 samples (5 ms) in the original predict.py
   -> pre-emphasis           y[n] = x[n] - 0.98 x[n-1]   (y[0] = x[0]), per window
   -> STFT                   n_fft 256, hop 128, periodic Hann, no centering, power = |X|^2 / 96
   -> frequency crop         bins 10..127 (~9.8-124 kHz), stretched to 256 bins (nearest, j*118//256)
   -> dB                     10*log10(max(P, 1e-10))
   -> min-max normalise      per window, to [0, 1] (a constant window becomes all zeros)
   -> ResNet18 [1,1,38,256] -> [1,15] logits
   -> softmax; argmax is a detection when its probability >= 0.5 (original default threshold)

reference_frontend.py is a standalone numpy implementation of this front end. It matches ANIMAL-SPOT's torch data pipeline to 5.6e-6 on real recordings, and every constant is documented in it.

Call detector (m03)

m03 uses the stock ANIMAL-SPOT front end (not the 250 kHz fork m09 uses), with the constants stored in its checkpoint:

mono audio, resampled to 192 kHz
   -> sliding window        3840 samples (20 ms), hop 1920 samples (10 ms) in the original config_predict
   -> pre-emphasis, STFT    as for m09 (n_fft 256, hop 128, periodic Hann, power / 96)
   -> frequency crop        bins 1..126 (~0.75-95 kHz), stretched to 256 bins (nearest, j*126//256)
   -> dB, min-max           as for m09
   -> ResNet18 [1,1,29,256] -> [1,2] logits (0 = noise, 1 = target)
   -> softmax; a window holds a call when P(target) >= 0.5 (original config_predict threshold)

reference_frontend.py computes this input when its constants are set to SR = 192000, F_MIN = 1000, F_MAX = 95000, SEQ_LEN = 3840 and WIN_HOP = 1920. The m03 training and prediction configs are in original_code/config_m03/.

Model architecture

  • Input: spectrogram [batch, 1, frames, 256] float32. frames = 38 for a full 20 ms m09 window and 29 for a full m03 window. Batch and frames are dynamic axes.
  • Output: logits [batch, 15] (m09) or [batch, 2] (m03) float32, raw logits. Apply softmax: the model is single-label and was trained with cross-entropy.
  • Backbone: ANIMAL-SPOT ResNet18 encoder (7x7 conv stem, no max-pool), global average pooling, Linear(512 -> 15). See original_code/models/.

Classes (output index order)

batspot_labels.txt lists the 15 classes in model index order, as Scientific name_Common name for species:

0  B   (feeding buzz / approach phase)  8  noise
1  Barbastella barbastellus             9  Plecotus auritus
2  Eptesicus serotinus                 10  Pipistrellus nathusii
3  Myotis brandtii/mystacinus          11  Pipistrellus pipistrellus
4  Myotis dasycneme                    12  Pipistrellus pygmaeus
5  Myotis daubentonii                  13  s   (social call)
6  Myotis nattereri                    14  Vespertilio murinus
7  Nyctalus noctula

noise, B and s are not species. Applications should report them separately or drop them. labels_map.md maps the original short codes (bbar, eser, mbramys, ...) to these names.

Files

File Description
batspot_m09.onnx The call classifier (FP32, opset 17, ~43 MB, weights inline)
batspot_m03.onnx The call detector (FP32, opset 17, ~43 MB, weights inline)
batspot_labels.txt 15 class labels in output index order
labels_map.md Original class codes -> labels
reference_frontend.py numpy reference implementation of the preprocessing
export_onnx.py The script used to convert the m09 checkpoint and verify parity
export_onnx_m03.py The same for the m03 checkpoint
original_code/ ANIMAL-SPOT model, data and predict code used by BatSpot (GPL-3.0, see original_code/LICENSE) and the m09 train/predict configs (m03 configs in original_code/config_m03/)
SHA256SUMS Checksums for all files

Usage with Python (ONNX Runtime)

import numpy as np, soundfile as sf, resampy, onnxruntime as ort
from reference_frontend import frontend          # see reference_frontend.py

y, sr = sf.read("bat_recording.wav", dtype="float32", always_2d=True)
y = resampy.resample(y.mean(axis=1), sr, 250000, filter="kaiser_best")

wins = [y[i:i + 5000] for i in range(0, len(y) - 5000 + 1, 1250)]
x = np.concatenate([frontend(w) for w in wins])          # [n, 1, 38, 256]

sess = ort.InferenceSession("batspot_m09.onnx", providers=["CPUExecutionProvider"])
logits = sess.run(["logits"], {"spectrogram": x})[0]
p = np.exp(logits - logits.max(1, keepdims=True)); p /= p.sum(1, keepdims=True)

labels = [l.strip() for l in open("batspot_labels.txt") if l.strip()]
for i in np.where(p.max(1) >= 0.5)[0]:
    k = p[i].argmax()
    if labels[k] not in ("noise", "B", "s"):
        print(f"{i * 0.005:.3f}s  {labels[k]}  {p[i, k]:.2f}")

Conversion details

  • Sources: BatSpot_article/batspot/models_call_classifier/m09/train/ANIMAL-SPOT.pk and BatSpot_article/batspot/models_call_detector/m03/train/ANIMAL-SPOT.pk from the Zenodo release.
  • Exported with torch.onnx.export (PyTorch 2.15, opset 17), dynamic batch and time axes, constant folding on.
  • Verified: PyTorch vs ONNX Runtime max absolute logit difference 2.1e-5 for m09 and 1.3e-5 for m03, each over 12 inputs (batch 1/2/4, full and 20-frame windows). End to end, the numpy front end plus ONNX differs from the full original torch path by 1.4e-4 in logits.
  • The original predict.py references an undefined num_classes and fails as shipped. The behaviour documented above (softmax, argmax, threshold) is the evident intent of that code.

Audio requirements and limitations

  • Sample rate: 250 kHz mono for m09, 192 kHz for m03 (it reads up to 95 kHz). Recordings at 256, 384 or 500 kHz can be resampled down. Lower rates lose part of the 10-125 kHz band the model reads.
  • Codec: lossless (WAV/FLAC) only. Lossy codecs discard ultrasonic content.
  • Level is discarded: min-max normalisation runs per 20 ms window, so faint background noise gets stretched to full range. Gate windows on signal energy before classifying, and skip digital silence: an all-zero window yields a meaningless low-confidence species guess.
  • Standalone use: in the original pipeline this classifier runs on calls already found by the call detector. Used alone, it relies on its noise class and on the application's own gating.
  • Cost: about 60 ms (m09) and 48 ms (m03) of CPU per 20 ms window on an Intel N150 core (single thread). Scoring every 5 ms hop in real time is not practical on small devices, so select candidate windows first.
  • Geographic scope: the classifier covers 12 European species or complexes; see the article for where its training data come from. It cannot recognise species outside this list.

License

  • Model weights and this ONNX conversion: CC-BY-4.0, following the original Zenodo release. You may use, share and adapt them, including commercially, with attribution.
  • original_code/: GPL-3.0, from Hauechri/BatSpot (ANIMAL-SPOT), redistributed unmodified with its licence.

Citation and attribution

If you use this model, please cite the original article and data release:

Smeele, S.Q., Hauer, C., Bergler, C., Dechmann, D.K., Dietzer, M.T., Elmeros, M., Fjederholt, E.T., Fogato, A., Kohles, J.E., Nöth, E. and Brinkløv, S.M. (2026). BatSpot: a retrainable neural network for automatic detection and classification of bat echolocation and detection of buzzes and social calls. Biological Conservation, 321, 111975.

Data, code and models: Zenodo, https://doi.org/10.5281/zenodo.18977979

and ANIMAL-SPOT:

Bergler, C. et al. (2022). ANIMAL-SPOT enables animal-independent signal detection and classification using deep learning. Scientific Reports, 12, 21966.

Acknowledgments

  • Simeon Q. Smeele, Christian Hauer, Christian Bergler and the BatSpot co-authors for the models, training data, code and open release (CC-BY-4.0).
  • Christian Bergler and the ANIMAL-SPOT team for the underlying framework.
  • tphakala for BirdNET-Go and the BSG-BAT conversion that this card follows.
  • Conversion to ONNX by alexbelgium for use with BirdNET-Go and other ONNX Runtime pipelines.
Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support