Skip to content

MegaDetector is an AI model that helps conservation folks spend less time doing boring things with camera trap images.

License

Notifications You must be signed in to change notification settings

agentmorris/MegaDetector

Repository files navigation

MegaDetector

...helping conservation biologists spend less time doing boring things with camera trap images.

Table of contents

  1. What's MegaDetector all about?
  2. How do I get started with MegaDetector?
  3. Who is using MegaDetector?
  4. Repo contents
  5. Contact
  6. Gratuitous camera trap picture

What's MegaDetector all about?

MegaDetector is an AI model that identifies animals, people, and vehicles in camera trap images (which also makes it useful for eliminating blank images). This model is trained on several million images from a variety of ecosystems.

Here's a “teaser” image of what MegaDetector output looks like:

Red bounding box on fox
Image credit University of Washington.

How do I get started with MegaDetector?

  • If you are looking for a convenient tool to run MegaDetector, you don't need anything from this repository: check out EcoAssist.
  • If you're just considering the use of AI in your workflow, and you aren't even sure yet whether MegaDetector would be useful to you, we recommend reading the "getting started with MegaDetector" page.
  • If you're already familiar with MegaDetector and you're ready to run it on your data, see the MegaDetector User Guide for instructions on running MegaDetector.
  • If you're a programmer-type looking to use tools from this repo, check out the MegaDetector Python package that provides access to everything in this repo (yes, you guessed it, "pip install megadetector").
  • If you have any questions, or you want to tell us that MegaDetector was amazing/terrible on your images, email us!

MegaDetector is just one of many tools that aims to make conservation biologists more efficient with AI. If you want to learn about other ways to use AI to accelerate camera trap workflows, check out our of the field, affectionately titled “Everything I know about machine learning and camera traps”.

Who is using MegaDetector?

We work with ecologists all over the world to help them spend less time annotating images and more time thinking about conservation. You can read a little more about how this works on our getting started with MegaDetector page.

Here are a few of the organizations that have used MegaDetector... we're only listing organizations who (a) we know about and (b) have given us permission to refer to them here (or have posted publicly about their use of MegaDetector), so if you're using MegaDetector or other tools from this repo and would like to be added to this list, email us!

Also see:

Repo contents

Repo history

MegaDetector was initially developed by the Microsoft AI for Earth program; this repo was forked from the microsoft/cameratraps repo and is maintained by the original MegaDetector developers (who are no longer at Microsoft, but are absolutely fantastically eternally grateful to Microsoft for the investment and commitment that made MegaDetector happen). If you're interested in MD's history, see the downloading the model section in the MegaDetector User Guide to learn about the history of MegaDetector releases, and the can you share the training data? section to learn about the training data used in each of those releases.

What the code in this repo does

The core functionality provided in this repo is:

  • Tools for training and running MegaDetector.
  • Tools for working with MegaDetector output, e.g. for reviewing the results of a large processing batch.
  • Tools to convert among frequently-used camera trap metadata formats.

This repo does not host the data used to train MegaDetector, but we work with our collaborators to make data and annotations available whenever possible on lila.science. See the MegaDetector training data section to learn more about the data used to train MegaDetector.

Repo organization

This repo is organized into the following folders...

megadetector/detection

Code for running models, especially MegaDetector.

megadetector/postprocessing

Code for common operations one might do after running MegaDetector, e.g. generating preview pages to summarize your results, separating images into different folders based on AI results, or converting results to a different format.

megadetector/utils

Small utility functions for string manipulation, filename manipulation, downloading files from URLs, etc.

megadetector/visualization

Tools for visualizing images with ground truth and/or predicted bounding boxes.

megadetector/data_management

Code for:

  • Converting frequently-used metadata formats to COCO Camera Traps format
  • Converting the output of AI models (especially YOLOv5) to the format used for AI results throughout this repo
  • Creating, visualizing, and editing COCO Camera Traps .json databases

megadetector/api

Code for hosting our models as an API, either for synchronous operation (i.e., for real-time inference) or as a batch process (for large biodiversity surveys).

megadetector/classification

Experimental code for training species classifiers on new data sets, generally trained on MegaDetector crops. Currently the main pipeline described in this folder relies on a large database of labeled images that is not publicly available; therefore, this folder is not yet set up to facilitate training of your own classifiers. However, it is useful for users of the classifiers that we train, and contains some useful starting points if you are going to take a "DIY" approach to training classifiers on cropped images.

All that said, here's another "teaser image" of what you get at the end of training and running a classifier:


Image credit University of Minnesota, from the Snapshot Safari program.

megadetector/taxonomy_mapping

Code to facilitate mapping data-set-specific category names (e.g. "lion", which means very different things in Idaho vs. South Africa) to a standard taxonomy.

envs

Environment files... specifically .yml files for mamba/conda environments (these are what we recommend in our MegaDetector User Guide), and a requirements.txt for the pip-inclined.

images

Media used in documentation.

archive

Old code that we didn't quite want to delete, but is basically obsolete.

sandbox

Random things that don't fit in any other directory, but aren't quite deprecated. Mostly postprocessing scripts that were built for a single use case but could potentially be useful in the future.

test_images

A handful of images from LILA that facilitate testing and debugging.

Contact

For questions about this repo, contact [email protected].

You can also chat with us and the broader camera trap AI community on the AI for Conservation forum at WILDLABS or the AI for Conservation Slack group.

Gratuitous camera trap picture

Bird flying above water
Image credit USDA, from the NACTI data set.

You will find lots more gratuitous camera trap pictures sprinkled about this repo. It's like a scavenger hunt.

License

This repository is licensed with the MIT license.

Code written on or before April 28, 2023 is copyright Microsoft.

Contributing

This project welcomes contributions, as pull requests, issues, or suggestions by email. We have a list of issues that we're hoping to address, many of which would be good starting points for new contributors. We also depend on other open-source tools that help users run MegaDetector (e.g. EcoAssist and CamTrap Detector) and work with MegaDetector results (e.g. Timelapse); if you are looking to get involved in GUI development, reach out to the developers of those tools as well!

If you are interesting in getting involved in the conservation technology space, and MegaDetector just happens to be the first page you landed on, and none of our open issues are getting you fired up, don't fret! Head over to the WILDLABS discussion forums and let the community know you're a developer looking to get involved. Someone needs your help!