Skip to content

feat(megadetector): add MegaDetector v6 as a standalone model choice - #544

Merged
Chouffe merged 24 commits into
mainfrom
arthur/feat-add-megadetector
May 18, 2026
Merged

Chouffe merged 24 commits into
mainfrom
arthur/feat-add-megadetector

Conversation

@Chouffe

@Chouffe Chouffe commented May 18, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Adds MegaDetector v6 (MDV6-yolov10-e-1280) as a fourth model in Biowatch's AI Models tab. MD is a fast worldwide detector for animals / people / vehicles — no species classification — useful as a blank-filter before manual species annotation. The three MD labels flow through Biowatch's species-centric data model as pseudo-species (animal, homo sapiens for person, vehicle).

Architecture

  • New Python LitServe server run_megadetector_server.py modeled on run_deepfaune_server.py minus the classifier. Loads weights via ultralytics.YOLO.
  • New tarball hosted at huggingface.co/earthtoolsmaker/megadetector/main/6.0.tar.gz (117.8 MB), built by scripts/build-megadetector-tarball.py from the Zenodo-hosted upstream weights.
  • New detectionOnly: true flag in mlmodels.js that suppresses the species panel in ModelCard.jsx and the model-picker dropdown.
  • New megadetector branch added to parseScientificName, transformBboxToCamtrapDP, and detectModelType. Common-names resolver gets a megadetector source so animal/person/vehicle resolve cleanly; the person label is mapped to the binomial homo sapiens at the server so species tooltips and IUCN lookups fire.
  • Confidence threshold: 0.2 (MD's official default).

Bonus fixes (caught during manual smoke)

  • Corrupt-video false positive: get_video_metadata now sanity-checks fps/frame_count/duration so the entire-file error pipeline catches corrupt files instead of letting one garbage frame surface as "animal".
  • Per-bbox confidence in observations: for MD, each row's classificationProbability now mirrors its own detectionConfidence instead of the top-level prediction score being copied across every row.
  • Video winner selection for MD: new weightedVote mode in selectVideoClassificationWinner uses mean-confidence-primary voting (frame-count tiebreaker) for MD videos, so a short burst of high-confidence "person" detections isn't drowned out by a longer stream of weak "animal" detections. Classifier behavior (SpeciesNet/DeepFaune/Manas) is unchanged.

Design + plan docs

  • Spec: docs/specs/2026-05-16-megadetector-model-choice-design.md
  • Plan: docs/plans/2026-05-16-megadetector-model-choice-plan.md

Test plan

  • JS: `npm test` (1362/1362 pass, includes 9 new MD-specific tests across resolver, mlmodels, bbox, prediction, and video classification)
  • Python: `cd python-environments/common && make lint && make format && uv run pytest tests/test_megadetector_server.py tests/test_utils.py -v` — 8 e2e tests against real weights + 13 utils tests (incl. 6 new metadata sanity tests) all pass
  • Manual smoke: download MD from AI Models tab → import mixed image folder + videos → confirm: card shows "Detection only · 3 categories", boxes show per-detection conf, blanks land as blanks, person frames land as "Human (Homo sapiens)", corrupt videos are skipped, DSCF0028.MP4 picks person not animal
  • Regression check: import a folder under an existing SpeciesNet/DeepFaune study, confirm classifier model behavior unchanged

Notes

  • ~118 MB download, reuses the existing `common` Python env (no extra env install for users who already have SpeciesNet/DeepFaune/Manas)
  • License: MDv6 weights are AGPL-3.0; the upstream LICENSE is bundled in the tarball so attribution travels with the binary
  • The `logo` field in `mlmodels.js` is unused throughout the codebase, so no MD logo asset is required

Chouffe added 22 commits May 16, 2026 13:38
@netlify

netlify Bot commented May 18, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for lucent-yeot-0cb408 canceled.

Name Link
🔨 Latest commit 5ce050e
🔍 Latest deploy log https://app.netlify.com/projects/lucent-yeot-0cb408/deploys/6a0ad9497763410009f258d4

Chouffe added 2 commits May 18, 2026 11:01
Previously the early-return 'if (scientificName) return animal' in mapObservationType
shadowed MegaDetector's 'homo sapiens' and 'vehicle' scientificName labels, exporting
both as 'animal' instead of the correct Camtrap DP 'human' and 'vehicle' values.

Extract mapObservationType into a pure module so the MD-specific routing can be
unit-tested without transitively loading download.ts.
@Chouffe
Chouffe merged commit 2131e44 into main May 18, 2026
15 checks passed
@Chouffe
Chouffe deleted the arthur/feat-add-megadetector branch June 2, 2026 14:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant