Skip to main content

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

Project description

MegaDetector

This package is a pip-installable version of the support/inference code for MegaDetector, an object detection model that helps conservation biologists spend less time doing boring things with camera trap images. Complete documentation for this Python package is available at megadetector.readthedocs.io.

If you aren't looking for the Python package specifically, and you just want to learn more about what MegaDetector is all about, head over to the MegaDetector repo.

If you don't want to run MegaDetector, and you just want to use the utilities in this package - postprocessing, manipulating large volumes of camera trap images, etc. - you may want to check out the megadetector-utils package, which is identical to this one, but excludes all of the PyTorch/YOLO dependencies, and is thus approximately one zillion times smaller.

Installation

Install with:

pip install megadetector

MegaDetector model weights aren't downloaded at the time you install the package, but they will be (optionally) automatically downloaded the first time you run the model.

Package reference

See megadetector.readthedocs.io.

Examples of things you can do with this package

Run MegaDetector on one image and count the number of detections

from megadetector.utils import url_utils
from megadetector.visualization import visualization_utils as vis_utils
from megadetector.detection import run_detector

# This is the image at the bottom of this page, it has one animal in it
image_url = 'https://github.com/agentmorris/MegaDetector/raw/main/images/orinoquia-thumb-web.jpg'
temporary_filename = url_utils.download_url(image_url)

image = vis_utils.load_image(temporary_filename)

# This will automatically download MDv5a; you can also specify a filename.
model = run_detector.load_detector('MDV5A')

result = model.generate_detections_one_image(image)

detections_above_threshold = [d for d in result['detections'] if d['conf'] > 0.2]
print('Found {} detections above threshold'.format(len(detections_above_threshold)))

Run MegaDetector on a folder of images

from megadetector.detection.run_detector_batch import \
    load_and_run_detector_batch, write_results_to_file

# Choose a folder to run MD on recursively, and an output file
image_folder = '/path/to/megadetector_test_images'
output_file = '/path/to/output/file.json'

# The package will automatically download whichever model you request; you 
# can also specify a filename.
model_name = 'MDV5A'

# Run the model on all images in the folder
results = load_and_run_detector_batch(model_name, image_folder)

# Write results to a format that Timelapse and other downstream tools like
write_results_to_file(results,
                      output_file,
                      relative_path_base=image_folder,
                      detector_file=model_name)

Contact

Contact cameratraps@lila.science with questions.

Gratuitous animal picture


Image credit University of Minnesota, from the Orinoquía Camera Traps data set.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

megadetector-10.0.18.tar.gz (608.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

megadetector-10.0.18-py3-none-any.whl (688.2 kB view details)

Uploaded Python 3

File details

Details for the file megadetector-10.0.18.tar.gz.

File metadata

  • Download URL: megadetector-10.0.18.tar.gz
  • Upload date:
  • Size: 608.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for megadetector-10.0.18.tar.gz
Algorithm Hash digest
SHA256 149bd958a1484a1c4ef8618b9a2b3eb1ab206f9141e8c79ad3b7825be49f53c7
MD5 5f6fe61a8d6a6caec26ee2b0c4d836d1
BLAKE2b-256 cb19c2a1e3197826ff2f87a7a8de60bafa06ba59c3a892aeed2269775d6fd3f4

See more details on using hashes here.

File details

Details for the file megadetector-10.0.18-py3-none-any.whl.

File metadata

  • Download URL: megadetector-10.0.18-py3-none-any.whl
  • Upload date:
  • Size: 688.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for megadetector-10.0.18-py3-none-any.whl
Algorithm Hash digest
SHA256 1ff1deb486cb89fd90b84201de24d358a934f115ada9bd3beba8dde3854fac36
MD5 5ee4e7b9599896f3c99a5a162d04575c
BLAKE2b-256 7e278dcca062e9c6050b8000f1943068acd9c5a6d427c6326c0a9b40ab792a09

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page