Skip to main content

a PyTorch Collaborative Deep Learning Framework for Conservation.

Project description

PyTorch Wildlife: A Collaborative Deep Learning Framework for Conservation

Welcome to Version 0.0.1.1.2

The Pytorch-wildlife library allows users to directly load the MegadetectorV5 model weights for animal detection. We've fully refactored our codebase, prioritizing ease of use in model deployment and expansion. In addition to MegadetectorV5, Pytorch-wildlife also accommodates a range of classification weights, such as those derived from the Amazon Rainforest dataset and the Opossum classification dataset. Explore the codebase and functionalities of Pytorch-wildlife through our interactive Gradio web app and detailed Jupyter notebooks, designed to showcase the practical applications of our enhancements.

Table of Contents

  1. Prerequisites
  2. Installation
  3. Running the Demo
  4. License

Prerequisites

  1. Python 3.8
  2. NVIDIA GPU (for CUDA support, although the demo can run on CPU)

If you have conda/mamba installed, you can create a new environment with the following command:

conda create -n pytorch-wildlife python=3.8 -y
conda activate pytorch-wildlife

Installation

1. Install through pip:

pip install PytorchWildlife

Running the Demo

Here is a brief example on how to perform detection and classification on a single image using PyTorch-wildlife:

import torch
from PytorchWildlife.models import detection as pw_detection
from PytorchWildlife.models import classification as pw_classification
img = torch.randn((3, 1280, 1280))
# Detection
detection_model = pw_detection.MegaDetectorV5()
detection_result = detection_model.single_image_detection(img)
#Classification
classification_model = pw_classification.AI4GAmazonRainforest()
classification_results = classification_model.single_image_classification(img)

Version 0.0.1.1.2 does not currently have video detection support, you can use the Gradio app for single image and batch image detection & classification.

If you want to use our Gradio demo for a user-friendly interface. Please run the following code inside the current repo. You can also find Jupyter Notebooks with an image and video tutorial:

git clone -b PytorchWildlife_Dev --single-branch https://github.com/microsoft/CameraTraps.git
cd CameraTraps
cd demo
# For the image demo
python image_demo.py
# For the video demo
python video_demo.py
# For the gradio app
python demo_gradio.py

The demo_gradio.py will launch a Gradio interface where you can:

  • Perform Single Image Detection: Upload an image and set a confidence threshold to get detections.
  • Perform Batch Image Detection: Upload a zip file containing multiple images to get detections in a JSON format.
  • Perform Video Detection: Upload a video and get a processed video with detected animals (Not supported in version 0.0.1.1.2).

License

This project is licensed under the MIT License. Refer to the LICENSE file for more details.

Copyright

Copyright (c) Microsoft Corporation. All rights reserved.

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

PytorchWildlife-0.0.1.1.2.tar.gz (13.9 kB view hashes)

Uploaded Source

Built Distribution

PytorchWildlife-0.0.1.1.2-py3-none-any.whl (18.1 kB view hashes)

Uploaded Python 3

Supported by

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