Skip to content

Installation

MegaDetector is installed as part of the PyTorch-Wildlife framework. A single pip install PytorchWildlife pulls in the latest MegaDetector V6, and the model weights download automatically the first time you run a detection.

pip install PytorchWildlife

Requirements:

  • Python 3.8+ (3.10+ recommended)
  • Optional: NVIDIA GPU with CUDA for 10–50x speedup

Conda

conda create -n megadetector python=3.10 -y
conda activate megadetector
pip install PytorchWildlife

GPU Setup

If PyTorch installed without CUDA support, install the GPU-enabled build manually:

pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121

Then reinstall PyTorch-Wildlife:

pip install PytorchWildlife

Install from Source (CLI and Fine-Tuning)

To use the local megadetector command-line tool, or to fine-tune V6 weights on your own dataset, install this repository in editable mode:

git clone https://github.com/microsoft/MegaDetector
cd MegaDetector
pip install -e .

This installs the megadetector_core package and registers the megadetector command (detect, train, validate, inference). The pyproject.toml declares the full dependency set, so there is no separate requirements.txt.

Prefer conda for a source install? The repository ships an environment.yaml you can build from directly:

conda env create -f environment.yaml
conda activate megadetector
pip install -e .

Confirm the CLI is on your path:

megadetector --help

See the CLI reference for the full command surface, and the Repository Architecture for how the megadetector_core package is organized.

Verify Installation

from PytorchWildlife.models import detection as pw_detection

model = pw_detection.MegaDetectorV6()
print("MegaDetector loaded successfully.")

Weights are downloaded automatically on first use.

Try Without Installing

Next Steps