Nemo (MAMBO_v3) deployment
Identify moths and butterflies from images, with species, genus and family predictions. V3 adds a standalone ONNX option alongside PyTorch: no training package or GPU is needed for ONNX/CPU. Both backends use the same API, regional lists and output format. The comparisons below show quality and speed against V2, including CPU, laptop GPU and server GPU measurements.
Weights: CC BY-NC-SA 4.0 (non-commercial, share-alike). Adapter code: MIT. Model notices explain attribution and scope.
Model files download automatically from public ERDA storage on first use and are verified and cached. Reuse one predictor across calls.
Package · Model card and weights · Try one image · Citation
Quick start
Python 3.12+ is required. Choose the portable API for ONNX or backend switching, or the native API for an existing PyTorch integration. Expand either quick start.
Portable API — ONNX/CPU, with optional PyTorch backend
uv venv --python 3.13 .venv
source .venv/bin/activate # Windows PowerShell: .venv\Scripts\Activate.ps1
uv pip install 'mambo-v3[onnx]==0.3.1'
Python:
from mambo_deploy import Predictor
predictor = Predictor() # Global species list, ONNX, CPU
result = predictor.predict(["moth.jpg", "butterfly.jpg"])
print(result[0].label) # (species_id, genus_id, family_id)
print(result[0].confidence) # confidence for each rank
records = result.to_dict() # JSON-serializable records
CLI:
mambo_predict -i ./images -o ./output --name predictions
This writes output/predictions/predictions.json and mini_metric.csv;
--embeddings also writes embeddings.npy. Choose a new output name for each run.
For one-off use, replace mambo_predict with
uvx --from 'mambo-v3[onnx]==0.3.1' mambo_predict.
Native PyTorch — mini_trainer only
uv venv --python 3.13 .venv
source .venv/bin/activate # Windows PowerShell: .venv\Scripts\Activate.ps1
uv pip install 'mt-trainer==0.3.1' --torch-backend=cpu
Python:
from mini_trainer.deploy import Predictor
predictor = Predictor(device="cpu", model="full") # Loads Nemo immediately
print(predictor.input_size)
result = predictor("moth.jpg")
print(result[0].label, result[0].confidence)
CLI:
python -m mini_trainer.deploy -i ./images -o ./output --name predictions \
--model full --device cpu --dtype float32
The native CLI downloads Nemo automatically and writes mini_metric.csv plus
its resolved configuration. The Python API returns Torch prediction containers.
Both examples explicitly select CPU/global scope; native defaults remain
CUDA/Europe for compatibility. For a CUDA installation use --torch-backend=auto,
then select device="cuda" or --device cuda --dtype float16.
No mambo-v3 installation is required. Generic mt_predict also supports local
checkpoints via --weights.
The following input/output table and options describe the portable API.
| Interface | Inputs | Outputs |
|---|---|---|
Python predict(images) |
A path, PIL image, CHW array/tensor, or collection of these; BCHW batches also work. Original pixels: uint8 or floats in [0,1]. | One result per image, in input order. label, confidence, index have species/genus/family order; labels are GBIF taxon IDs as strings. to_dict() produces ordinary Python records; save(path) writes JSON. |
Python predict_with_embeddings(images) |
Same inputs. | (result, vectors); vectors are a float32 NumPy array [N,1280] with unit-length rows. |
CLI -i |
One or more image files or directories, searched recursively. | JSON contains results, metadata and config; each result has label, confidence, index. CSV has one row per image/rank for evaluation. |
For an RGB HWC NumPy image, pass image.transpose(2, 0, 1); convert OpenCV BGR to
RGB first. Do not resize or normalize images yourself. Alpha is discarded and EXIF
orientation is not applied. topk cannot exceed the smallest retained rank; narrow custom lists may require topk=1.
Predictions at each rank are independent, so the three
IDs need not form one ancestral path. CSV truth labels are inferred from parent
folder names; arbitrary image folders do not supply evaluation ground truth.
Choose the configuration that matters
Start with the defaults; select a regional preset when your location is known. ONNX/CPU is the simplest dependency footprint and a useful starting point for CPU-only and edge applications. For NVIDIA GPU throughput, use PyTorch if it fits your environment, or ONNX/CUDA to keep the training package out of your application. Runtime installation and offline use covers these alternatives. Changing runtime does not change the input/output contract.
Enable tta=True / --tta for image crops from camera light traps when the quality gain below is
worth roughly 3× lower throughput. Keep the default recipe. Its benefit is
image-domain dependent; the general-photograph comparison below provides context.
Keep precision="auto". Increase batch_size only when processing enough images
to benefit; reduce it if memory is tight. Adjust CPU workers only if needed to meet
your application's throughput or CPU budget. Request embeddings or extra candidates
only when your workflow uses them. No server, dataset metadata or training setup is
required.
Pass API settings to Predictor(...), except the prediction methods shown below.
CLI flags apply to mambo_predict.
| Python API | CLI | Default | Role / main trade-off |
|---|---|---|---|
model=, class_list= |
--model, --class-list |
full / no override |
Eligible species; affects predictions and confidence. |
backend=, device= |
--backend, --device |
onnx, cpu |
Runtime and hardware: onnx or torch; cpu or cuda:0. |
tta=True |
--tta |
Off | Quality versus throughput; enabling uses the recommended three-view recipe. |
batch_size= |
--batch-size |
8 |
Images per model call: throughput versus memory. |
threads= |
--threads |
2 |
ONNX CPU threads and default image-preparation workers; does not set PyTorch's model threads. |
preprocess_workers= |
--preprocess-workers |
Follows threads |
Image-preparation CPU allocation. |
precision= |
--precision |
auto |
Runtime-selected compute precision; normally leave unchanged. |
predict_with_embeddings(images) |
--embeddings |
Off | Vectors for similarity/search or downstream features. |
predict(images, topk=k) |
--topk k |
1 |
Candidates per rank; Python returns a list of candidates per image when k > 1. |
| CLI only | --threshold |
0 |
Acceptance flag in the evaluation CSV; JSON predictions stay unfiltered. |
Geographic scope
Use predictor.available_presets() to list choices, or read the
preset catalogue for their exact scope and construction.
Presets include species that can occur in a region, including introduced
species; they are neither native-distribution maps nor exhaustive checklists.
Use model="full" if a regional restriction is inappropriate.
europe and north_europe preserve the V2 lists. Updated _v3 lists are also
available; legacy north_europe performed better on Flemming and is recommended
for comparable northern-European use. A custom class_list=["GBIF_SPECIES_ID", ...]
or UTF-8 file with one ID per line overrides the preset (--class-list species.txt
in the CLI). Unknown IDs and empty lists fail; duplicates are removed.
Large image collections
Use streaming for a large collection of paths, consuming results as they arrive:
from contextlib import closing
with closing(predictor.predict_stream(image_paths)) as batches:
for result in batches:
records = result.to_dict()
# Write records to your database, file or downstream service here.
Input order is preserved. Add embeddings=True to receive (result, vectors) pairs.
For in-memory inputs, split large collections into smaller predict() requests;
that method retains results for the whole request. The CLI writes results batch by
batch. batch_size limits model calls, not total request memory.
Streaming controls are available
if the defaults do not fit your workload.
Changes from Meghan (MAMBO_v2)
Native mini_trainer.deploy.Predictor preserves Europe/CUDA defaults and needs only
mt-trainer>=0.3.1. The portable mambo_deploy API defaults to global scope and
ONNX/CPU. Nemo changes scores and embedding width: recalibrate thresholds and
regenerate stored embeddings when migrating.
See migration details for calling conventions and loading and metadata for startup loading, input-size discovery and Hugging Face downloads.
Beyond Python
The ONNX assets also provide a path to local browser inference with ONNX Runtime Web, where images can be processed on the user's device. Existing browser work is recorded in the release roadmap. This Python release does not ship a browser SDK: preprocessing, external weights and browser/runtime support still need integration. The same local API or CLI can be embedded in desktop applications, batch jobs and services without a hosted prediction service.
Release comparison
These results help choose TTA and runtime; they do not establish accuracy in every
region. All models use legacy northern Europe on the same 52,788 reporting
image crops from Danish AMI camera light traps, expert-reviewed by Flemming Helsing
(the Flemming dataset), including out-of-vocabulary truth. mini_metrics selects calibrated
thresholds per pipeline/rank on 5,852 separate images. Recipe exploration used
Flemming too, so this is descriptive evidence, not independent validation.
The quality figure compares unthresholded and calibrated predictions, with
full-support and support >5 macro metrics alongside acceptance coverage. TTA uses
rotation30_pad25_3; its quality gain comes at the throughput cost shown below.
Support >5 requires more than five truth instances and accepted predictions in every compared pipeline. Truth classes outside that average account for 15.30% / 0.42% / 0.01% of images at species/genus/family without thresholds, and 18.95% / 11.21% / 0.03% after calibration. No evaluation rows are discarded; the averaging class sets differ between confidence settings. Full-support metrics retain rare and predicted-only classes, which can change model rankings.
Measured images/second, end to end, on an i7-12800H / RTX 3080 Ti Laptop with four preparation/runtime threads. V3 uses automatic precision; compare on your own hardware before choosing a batch size. These laptop measurements predate the latest pipeline improvements and remain a consumer-hardware baseline.
On this laptop, ONNX is faster on CPU; native PyTorch benefits more from larger GPU batches. TTA improves quality but reduces throughput, so enable it according to your accuracy and processing-budget requirements.
Flemming metrics, calibrated thresholds and laptop timing data retain the exact values.
Confidence trade-offs: precision–recall and accuracy–coverage
These historical curves use the previous padded_scale TTA recipe; single-view
results are unchanged. They illustrate threshold trade-offs, not recommended
thresholds for the current TTA recipe.
Complementary in-domain and HPC results
The original global-lepi test split adds a comparison on general photographs using
the global vocabulary. It complements the expert-reviewed Danish AMI image
crops; the image domains and class lists differ, so their absolute scores should
not be compared as a controlled domain-effect estimate. The same mini_metrics
calibration/support policy uses 568,939 reporting images and 63,974 separate
calibration images, with both confidence settings evaluated on the reporting split.
V3 improves in-domain performance over V2. The Flemming-selected TTA recipe reduces in-domain performance, illustrating that its benefit depends on the input domain; this does not override its benefit on the camera-light-trap image crops. Support >5 changes the class average, not the evaluation rows. Truth classes outside that average represent 1.70% / 0.34% / <0.01% of species/genus/family images without thresholds, and 1.88% / 0.38% / <0.01% after calibration. Thresholds and complete metrics are retained as thresholds and metric tables.
The server comparison retains CPU, GPU request and GPU streaming throughput in images/second. B200 batch-256 values are updated: PyTorch reaches 1,976 images/s and ONNX 997 images/s when streaming, or 624 and 396 with TTA. CPU, V2 and smaller-batch results retain their earlier measurements; new request points are shown separately rather than joined to older scaling curves. These are measured application rates, not a promise of GPU saturation.
Timing details and provenance record measurement settings, memory and repeat ranges. Keep the laptop comparison above when choosing for consumer devices. ONNX's CPU advantage and independence from the training package make it especially relevant when a GPU or the full PyTorch stack is not an option; PyTorch remains the faster GPU choice in these measurements.
Metadata
Release files for mambo-v3 0.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mambo_v3-0.3.1.tar.gz | 258.1 kB | Without provenance | Details for mambo_v3-0.3.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mambo_v3-0.3.1-py3-none-any.whl | Python 3 | none | any | Details for mambo_v3-0.3.1-py3-none-any.whl |
Total release size: 520.5 kB
Release files / mambo_v3-0.3.1.tar.gz
| Download URL | mambo_v3-0.3.1.tar.gz |
|---|---|
| Size | 258.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c3c878b279d482687f3942262257f1d11146a5955d3c0076940612971dfda915
|
|
BLAKE2b-256 checksum How to use checksums |
f6ae5d02309207721b7d3ef4b21e190674fb25e92a24231370e4b8603b490ffc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.22 {"installer":{"name":"uv","version":"0.12.22","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / mambo_v3-0.3.1-py3-none-any.whl
| Download URL | mambo_v3-0.3.1-py3-none-any.whl |
|---|---|
| Size | 262.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1447933d76cf532df12a42cb4dbcaaa1393bfa8bf1e714e6a9ebf2a7f5127f0b
|
|
BLAKE2b-256 checksum How to use checksums |
4bb7be98f448dfa69ca687323fb802313804a03258653397857040f6ae0e8585
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.22 {"installer":{"name":"uv","version":"0.12.22","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for mambo-v3 0.3.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.