Repository navigation
Add MobileNet ONNX species classification and modernize BatBot - #44
Conversation
24d6f2e to
e6fe8b0
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #44 +/- ##
========================================
+ Coverage 59.2% 96.6% +37.3%
========================================
Files 7 15 +8
Lines 1383 2065 +682
Branches 0 276 +276
========================================
+ Hits 820 1995 +1175
+ Misses 563 32 -531
- Partials 0 38 +38
... and 2 files with indirect coverage changes Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
|
Looks great to me! Only other features I'd like would be 1) integrating the batch spec preprocessing into the batch ML inference, and 2) visual progress indicators in batch inference. Also, made a fresh install following these instructions but was unable to get it to use my gpu ("Failed to create CUDAExecutionProvider. Require cuDNN 9.* and CUDA 13.* ..."). Was the install expecting separate, manual install of CUDA and cuDNN? It seems like that shouldn't be necessary (link) - it's also possible something in my setup is different from yours. |
Summary
This PR prepares BatBot 0.2.0 by adding end-to-end bat-species classification with a bundled 35-label MobileNet ONNX model. Users can classify existing spectrograms, generate and classify spectrograms from WAV recordings, or process directory trees with fault-tolerant summaries and ordered multi-worker inference.
The PR also restructures the package so importing
batbotis lightweight, consolidates project configuration inpyproject.toml, raises the minimum Python version to 3.11, modernizes testing and publishing workflows, and expands branch coverage to 82.7%.High-level changes
pre/predict/postONNX inference pipeline and reusableClassifierpoochdownload mirror--num-workerswithout loading one model per workerclassify,classify-wav, andclassify-bulk; completedfetchand the legacybatchpathNOISEdiagnosticsbatbot.apiand added lazy submodule loadingimport batbotno longer initializes scientific/ONNX stacks or creates a log filepyproject.tomlClassification and batch processing
batbot.classifieralongside the existing spectrogram component, following Scoutbot WIC’spre→predict→postpattern.WAV classification uses full, uncompressed spectrogram chunks from
fast_mode=False. Compressed, masked, and debug images remain available for inspection.Platform, runtime, and Docker support
batbot[cpu]andbatbot[gpu].Evaluation, notebooks, and collaboration
01_classify_your_files.ipynb: bring-your-own-file classification, charts, and exports.02_spectrogram_walkthrough.ipynb: waveform/STFT processing, debugging images, model windows, and final predictions.Packaging and CI
pyproject.toml.Model and inference behavior
batbot.mobilenet.9dc57ea3.onnxthrough Git LFS and package data.poochcache.224 × 224 × 3windows.num_workers > 1runs per-spectrogram ONNX calls concurrently, preserves input order, bounds in-flight work, and reuses one session.spectrogram_outputor--spectrogram-dir.CLI and API changes
CLI
batbot classifybatbot classify-wavbatbot classify-bulkbatbot batchbatbot fetchRelevant controls include
--batch-size,--num-workers,--preprocess-workers,--provider,--no-progress, and--spectrogram-dir, where applicable.Python API
classifier.Classifierand convenience functionsclassify,classify_wav, andclassify_bulk.pre,predict, andpostfunctions.path,label,confidence,window_count,top, andscores.resultsandsummary; failed inputs retain their path and error.species_countsexcludesNOISEand counts classified files—not calls or individual bats.batbot.pipeline.Performance plotting
examples/plot_classifier_performance.pynow accepts a folder hierarchy containing WAV, JPG, or JPEG inputs, including mixed datasets. The immediate parent directory remains the ground-truth label:The example supports reusable prediction caches and multi-worker inference. It produces count, true-normalized, and prediction-normalized confusion matrices; top-1/2/3/5 accuracy; Matthews correlation; and
NOISEprecision-recall, ROC, and operating-point diagnostics when applicable. Species are reordered by genus before plotting so the shaded error regions remain contiguous.Compatibility notes
Testing and validation
Audit and strengthen tests around functional behavior, adding 34 new test cases covering numerical transforms, real processing artifacts, all classification CLI routes, corrupt-file isolation, aggregation, and genus-order visualization.
Coverage increased from 84.0%, without reducing the measured package scope or adding exclusions. The full suite now enforces a 90% minimum.
Formatting, lint, and documentation checks pass. Targeted fault-injection probes confirm that tests detect incorrect batch averaging, BGR/RGB reversal, and omitted genus swaps.
Actual accelerator execution, hosted cloud interactions, and scientific model accuracy remain separate validation requirements; hosted GPU-install checks do not establish CUDA kernel execution.
Changelog
Added
Removed
setup.py,setup.cfg, and standalone.flake8configuration.requirements/.Updated
pytest==8.4.2.Reviewer notes
Kitware, repositorybatbot, workflowpython-publish.yaml, and environmentpypibefore the first tagged release.1; concurrency is opt-in throughnum_workersor--num-workers.