Add MobileNet ONNX species classification and modernize BatBot - #44
Open
bluemellophone wants to merge 9 commits into
Open
Add MobileNet ONNX species classification and modernize BatBot#44bluemellophone wants to merge 9 commits into
bluemellophone wants to merge 9 commits into
Conversation
This was referenced Aug 17, 2026
bluemellophone
force-pushed
the
jrp/ml-model
branch
from
August 17, 2026 22:56
24d6f2e to
e6fe8b0
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #44 +/- ##
========================================
+ Coverage 59.2% 80.2% +20.9%
========================================
Files 7 14 +7
Lines 1383 1874 +491
Branches 0 251 +251
========================================
+ Hits 820 1504 +684
+ Misses 563 300 -263
- Partials 0 70 +70
... and 2 files with indirect coverage changes Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.tomlModel 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 changes
batbot fetch--pull,--configbatbot classify--batch-size,--num-workers,--top-k,--outputbatbot classify-wav--spectrogram-dir,--batch-size,--num-workers,--top-k,--outputbatbot classify-bulk--input-type,--recursive/--no-recursive,--spectrogram-dir,--num-workersbatbot batch--config,--num-workers,--outputClassification commands emit JSON containing individual results and a summary. The summary includes total, classified and failed counts, label counts, species counts excluding
NOISE, the noise count, and mean confidence.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.API changes
New classifier API
batbot.classifier.Classifier(...)classifier.classify(inputs, ...)classifier.classify_wav(filepath, ...)classifier.classify_bulk(inputs, ...)classifier.fetch(pull=False, config=...)classifier.discover_inputs(...)classifier.summarize(results)classifier.pre,predict,postbatch_sizelimits the number of image windows sent in one ONNX call.num_workerscontrols the number of concurrent per-spectrogram inference jobs and defaults to1to avoid unexpected CPU oversubscription.Result contracts
pathlabelconfidencelabelwindow_counttopscoresspectrogram_pathsBulk failures use
{ "path": ..., "error": ... }and remain in input order alongside successful results.Existing top-level API
batbot.fetch()is now implemented and returns the resolved model path.batbot.batch()is now implemented, reuses a classifier session, and returns classification results. Itscleanargument remains accepted for compatibility; generated temporary spectrograms are always cleaned.batbot.pipeline(),pipeline_multi_wrapper(),parallel_pipeline(), andexample()moved tobatbot.apiand remain re-exported frombatbot.pipeline_multi_wrapper()andparallel_pipeline()now raiseValueErrorfor invalid lengths or worker counts instead of relying on assertions.VERSION,version, and__version__remain available, with_version.pyas the package metadata source.classifierandspectrogramare exposed lazily throughbatbot.__getattr__.Compatibility notes
requirements/*.txtbatbot,batbot[test],batbot[docs], orbatbot[performance]as appropriatebatbotlogger in the application or callbatbot.utils.init_logging()VERBOSE,CLASSIFIER_CONFIG, andCLASSIFIER_BATCH_SIZEremain supportedBATBOT_...-prefixed environment variablesbatchoutput is now real classifier outputChangelog
Added
NOISE.pooch.pull=True/--pull.pre/predict/postinference functions.Classifierwith ONNX session reuse and optional provider selection.classify,classify-wav, andclassify-bulkCLI commands.py.typedmarker.Removed
setup.py,setup.cfg,.flake8, and the three duplicatedrequirements/*.txtfiles.batbot.logside effect.BATBOT_PYPI_TOKENusage in the publishing workflow.Updated
0.2.0throughbatbot/_version.py.pyproject.toml.batbot.__init__to a small public facade with lazy computational submodules.batbot.apiwith explicit signatures and validation.fetchandbatchAPIs from placeholders to functional classifier entry points.docsextra.8.4.2, branch coverage configuration, random ordering, and focused classifier tests.Validation
twine check, installs the wheel outside the checkout, and performs model inferenceReviewer notes
Kitware, repositorybatbot, workflowpython-publish.yaml, and environmentpypibefore the first tagged release.1; concurrency is opt-in throughnum_workersor--num-workers.