Ben Evans
GitHub

Running MegaDetector and SpeciesNet without the fuss

Wednesday, 2 September 2026

MegaDetector detects animals, people, and vehicles in camera-trap images. SpeciesNet combines MegaDetector with a species classifier to produce an image-level prediction. By default, its command-line pipeline classifies the highest-confidence detection in each image. Setting up these models can be a bit of a hassle. The documentation suggests using Conda environments, but those aren't necessary here and can make switching between workflows cumbersome.

This post serves as a reference for me to quickly run them without the setup faff. The only software prerequisite is uv. uv creates an isolated environment and installs the required dependencies.

If you're not so comfortable with the command line, there are several simpler options, including Camtrap Detector for simplicity or AddaxAI.

Running MegaDetector (v5a) is as simple as:

uvx --from megadetector python -m megadetector.detection.run_detector_batch MDV5A ./data/assets ./data/detections.json

Or MegaDetector v1000-redwood with:

uvx --from megadetector python -m megadetector.detection.run_detector_batch MD1000-redwood ./data ./data/detections.json

Running SpeciesNet (also runs detection as part of the pipeline):

uvx --from speciesnet python -m speciesnet.scripts.run_model \
  --folders path/to/dataset \
  --predictions_json path/to/prediction_output.json \
  --country GBR # Optional Country (in ISO 3166-1 alpha-3 format, e.g. 'AUS') to enforce on all instances.

Visualising the output:

uvx --from megadetector-utils python -m megadetector.visualization.visualize_detector_output \
  path/to/prediction_output.json \
  path/to/preview_dir

Benchmarks

MDv5a on NVIDIA TITAN RTX

Finished inference for 21457 images in 40 minutes and 36.69 seconds (8.81 images per second)