MegaDetector

repository·main·Indexed 43 days ago

https://github.com/agentmorris/megadetector

An AI-powered tool for conservation biologists to identify animals, people, and vehicles in camera trap imagery, primarily used to automate the filtering of blank images. Version 10.0.25 includes tools for batch processing, XMP metadata integration with digiKam, and the MegaClassifier for detailed species classification and feature extraction.

Tokens
42.3K
Snippets
90
Records
213
Agent score
54%

What's inside MegaDetector

  1. Overview of the megadetector.utils package

    main
    The megadetector.utils package provides a collection of utility functions designed for common camera trap workflows that are not directly part of the core MegaDetector detection logic. This includes tasks such as string and filename manipulation, downloading files from URLs, directory management, and data splitting.
  2. Overview of megadetector utility modules

    main

    The megadetector/utils directory provides miscellaneous utility modules designed for common data processing tasks. These include:

    • URL manipulation: Tools for handling and transforming web addresses.
    • Filename filtering: Logic for identifying and filtering specific file types, such as images and videos, from datasets.

    Many of these scripts are derived from the microsoft/ai4eutils repository.

  3. Overview of MegaDetector repository functionality

    main

    MegaDetector provides a suite of tools for camera trap image analysis. The core capabilities include:

    • Model Execution: Tools for training and running MegaDetector models.
    • Post-processing: Utilities to manage and review large batches of detection results.
    • Metadata Management: Tools to convert between common camera trap metadata formats.
    • Data Management: Support for the COCO Camera Traps format, converting AI model outputs (like YOLOv5) to internal formats, and managing .json databases.
    • Visualization: Tools for overlaying predicted or ground-truth bounding boxes on images.
    • Taxonomy Mapping: Utilities to map local dataset category names to a standardized taxonomy.
  4. What is MegaDetector?

    main

    MegaDetector is an AI model designed to identify animals, people, and vehicles in camera trap images. It is also commonly used to identify and eliminate 'blank' images (images containing no subjects of interest) from camera trap datasets.

    Key Limitations:

    • It identifies the presence of a subject but does not perform species-level classification.
    • For species identification, it is recommended to use SpeciesNet in conjunction with MegaDetector.
  5. Overview of MegaDetector visualization utilities

    main

    The megadetector/visualization directory provides several tools for inspecting ground truth annotations and model predictions:

    • visualize_db.py: Generates an HTML preview page of annotations from a COCO Camera Traps .json file.
    • visualize_detector_output.py: Renders images with bounding boxes to a folder based on MegaDetector output .json files.
    • visualization_utils.py: A shared utility module containing functions for drawing boxes and labels on images.
    • plot_utils.py: Graphing utilities used by the post-processing pipeline (postprocess_batch_results.py).
  6. Overview of the data_management package

    main

    The megadetector.data_management package provides a suite of tools for handling metadata and AI model outputs. Key capabilities include:

    • Format Conversion: Converting metadata to the COCO Camera Traps format and converting various AI model outputs (like YOLOv5) into the standard format used throughout the MegaDetector repository.
    • Database Management: Tools for creating, visualizing, and editing COCO Camera Traps .json databases.
    • Annotation Conversion: Converting between common annotation formats such as COCO, LabelMe, and YOLO.
    • Image Processing: Utilities for renaming images, generating crops, reading/removing EXIF data, and resizing datasets.
  7. Use the Repeat Detection Elimination (RDE) process

    main

    The Repeat Detection Elimination (RDE) process is used to quickly remove false positives that are frequently detected as objects of interest. This is achieved through a multi-step workflow involving finding repeat detections and then removing them from your dataset.

    The process is split into two primary CLI-accessible modules:

    1. find_repeat_detections: Identifies detections that are likely repeats.
    2. remove_repeat_detections: Removes those identified repeat detections from the results.

    For detailed implementation logic and advanced usage, refer to the RDE documentation on GitHub.

  8. Understanding MegaDetector limitations and best practices

    main

    While MegaDetector is highly effective for the majority of camera trap datasets, it is not infallible. Users should be aware of several categories of failure cases to manage expectations and ensure data quality.

    Key Recommendations for Users

    • Validate with your own data: Never rely solely on published accuracy percentages. Always run MegaDetector on a subset of your specific dataset to understand its performance characteristics before full deployment.
    • Use sample visualization pages: To quickly assess model performance, it is recommended to create sample result pages (similar to the Snapshot Safari examples) to visually inspect detections and errors.

    Known Failure Categories

    1. Under-represented species: Reptiles and other animals that fall within the model's domain but were not sufficiently represented in the training data.
    2. Unusual camera angles or environments: Scenarios unlike the training data, such as upside-down cameras (e.g., inside a den) or aquatic mammals in water.
    3. Random AI failures: Unpredictable errors where the model fails on standard cases.
    4. Borderline object sizes: Objects that are at the very edge of the detection threshold (too small to be easily discernible but not entirely out-of-domain).

    Out-of-Domain Scenarios

    MegaDetector is not intended to work for:

    • Underwater video (fish).
    • Drone imagery.
    • Extremely small objects in the distance that are not discernible even to humans.
  9. MegaDetector Overview

    main

    MegaDetector is an AI model designed to detect animals, people, and vehicles in camera trap images. Its primary purpose is to accelerate the workflow of conservation biologists by filtering out 'noise' (such as empty images, people, or vehicles) so they can focus on reviewing images containing animals.

    Key Capabilities:

    • Detection, not Classification: MegaDetector identifies the presence of animals, people, or vehicles but does not identify animals to the species level.
    • Workflow Acceleration: It automates the initial review process of large image datasets.

    Choosing your interface:

    • GUI Users: If you prefer a graphical user interface, use AddaxAI (formerly EcoAssist). This is the most common way users interact with MegaDetector.
    • Programmers: If you want to integrate MegaDetector into your own code, use the megadetector Python package via pip.
  10. Available detection submodules and CLI tools

    main

    The detection package provides several specialized modules for different inference workflows. Many of these modules include a main function that can be invoked via the command line (CLI).

    Core Detection Modules

    • run_detector_batch: For batch processing of images.
    • run_detector: General purpose detector execution.
    • pytorch_detector: PyTorch-based detector implementation.
    • rfdetr_detector: RF-DETR specific detector.
    • tf_detector: TensorFlow-based detector.

    Specialized Inference Modules

    • process_video: Tools for processing video files.
    • run_inference_with_yolov5_val: Inference specifically using YOLOv5 validation workflows.
    • run_tiled_inference: Performs inference on image tiles (useful for high-resolution images).
    • run_md_and_speciesnet: A combined workflow running both MegaDetector and SpeciesNet.

    Utilities

    • video_utils: Helper functions for video manipulation and processing.
  11. Use the data_management.lila package to manage LILA datasets

    main
    The data_management.lila package provides tools for interacting with and updating datasets hosted on lila.science. While the package contains a core lila_common module, much of the functionality is exposed through specialized scripts designed for common data management tasks like downloading subsets, creating test sets, or auditing image counts.