Manual:The detector
The live detector listens to incoming audio in tab 1 · Listen & record and scores each short analysis window for how much it resembles a boat engine. It runs in a background thread (app/detector.py) so the user interface and spectrogram stay responsive. Results appear in the Engine score graph, the Model output panel and drive the alarm logic.

Choosing and switching models¶
Pick the live model in Settings → Detector → Model (see Preferences). The dropdown lists built-in yamnet first, followed by every complete trained model folder in <data_dir>/models/ (folders containing both model.json and weights.npz; see Model files). To turn live detection off completely, uncheck Enabled on the same tab.
Whenever you change any setting in the Detector tab (model, engine classes, analysis step or enabled state) and press OK, the app stops the old detector thread cleanly, starts a new one with an empty buffer and updates the threshold line without needing a restart. Any late results from the replaced detector are ignored.
YAMNet and trained models¶
Two kinds of models can run as the live detector:
- YAMNet (
yamnet, default) - Google's pretrained general audio network covering 521 airborne sound classes, running internally at 16 kHz. On first load it downloads or loads TensorFlow Hub weights from
models/tfhub_cache, which takes roughly 5–50 seconds. Under Model output, YAMNet lists its top 3 most likely sound classes for the latest window. Its Engine score is the maximum score across the configured Engine classes (detector.target_classes, separated by;; 11 classes by default fromVehicleandBoat, Water vehicletoEngine starting). If any configured name is not among YAMNet's 521 classes, the app logs a warning. - Trained models
- Models trained in the Training suite use either 1024-dimensional YAMNet embeddings (at 16 kHz) or 32 frequency-band features (
bands: 30 one-third-octave bands from 18 Hz to 17.9 kHz, plus spectral flatness and crest factor at the stream's native sample rate). Under Model output, they always display all three classes ordered from highest to lowest probability: engine, interference and background (summing to 1.00). Engine score is the predicted probability of the engine class.
New models are saved in model.json v2 with a feature_spec block and a SHA-256 hash of weights.npz. Older v1 models still load in legacy mode with a log warning noting that their provenance cannot be verified.
What to expect from off-the-shelf YAMNet
YAMNet was trained on airborne YouTube clips and cuts off at 8 kHz. In our Wolfset tank tests (docs/yamnet_baseline.md), it responded reliably to four outboard motors (mean score 0.36–0.68), struggled with a small model-boat electric motor (0.19 slow, 0.005 fast), and triggered false positives on bubbling and water hoses (mean 0.23–0.36, max up to 0.84). Treat built-in YAMNet as a starting The baseline, not a finished underwater engine detector.
What the engine score means¶
The Engine score plot shows the last 60 seconds of scores on a 0 to 1 scale, with a red dashed horizontal line at the configured alarm threshold. Its exact interpretation depends on the model:
- For a trained model, it is a logistic-regression softmax probability across the three training classes (background, interference, engine). It reflects how similar the window is to training-set engines relative to training-set background and interference, not a calibrated real-world probability of a boat at sea.
- For built-in YAMNet, it is the highest independent class score among the configured engine classes (YAMNet's class scores do not sum to 1).
Sample-rate limit for bands models and channel handling¶
A bands model measures 30 one-third-octave bands up to an upper edge of 17,959.4 Hz. Because every band must lie below the Nyquist frequency (sr / 2), it requires a sample rate of at least 35,919 Hz (audit finding F05).
Lower sample rates are refused
If you feed audio below 35,919 Hz (such as 16 kHz or 32 kHz) to a bands model, the detector refuses it up front (UnsupportedSampleRate) instead of clamping upper bands. The detector label switches to error and the full reason is written to the log. Use 44.1 kHz or 48 kHz audio (the app's default recording rate is 48000 Hz).
When playing a multi-channel WAV file or listening to a multi-channel interface in tab 1, the live view reads one selected channel (audio.channel, default 0), whereas Training and Clip analysis mix multi-channel audio to mono using the shared channel policy (channel mean). Mono recordings made by Hydrofon are unaffected.
Detector label states¶
The status label in the top-right corner of the main window always reports the live detector's current state:
| Label | Meaning |
|---|---|
Detector: off |
Settings → Detector → Enabled is unchecked. |
Detector: loading <model>… |
The worker thread is loading weights (and warming up TensorFlow for YAMNet). |
Detector: <model> |
The model is ready and scoring incoming audio. |
Detector: error |
Loading failed or the incoming stream is incompatible (for instance sr < 35,919 Hz with a bands model). Check the Log panel at the bottom for the exact message. |
See also¶
- Alarms and events: how scores turn into alarms or events
- Streams and windows: how the audio stream is cut into windows
- Training a model: training your own model
- Model files:
model.jsonv2 andfeature_spec - The baseline: current results for YAMNet and trained models