Skip to main content

animl-py 3.3.3

AniML comprises a variety of machine learning tools for analyzing ecological data. This Python package includes a set of functions to classify subjects within camera trap field data and can handle both images and videos. This package is also available in R: animl

Table of Contents

  1. Installation
  2. Usage
  3. Models

Installation Instructions

It is recommended that you set up a conda environment for using animl. See Dependencies below for more detail. You will have to activate the conda environment first each time you want to run AniML from a new terminal.

From GitHub

git clone https://github.com/conservationtechlab/animl-py.git
cd animl-py
pip install -e .

From PyPi

pip install animl

Dependencies

We recommend running AniML on GPU-enabled hardware. **If using an NVIDIA GPU, ensure driviers, cuda-toolkit and cudnn are installed.

Python >= 3.12 <3.14

Onnx
Animl currently depends on onnxruntime-gpu == 1.20.0.

Python Package Dependencies

  • numpy>=2.0.2
  • pandas>=2.2.2,<3.0.0
  • pillow>=11.0.0
  • opencv-python>=4.12.0.88
  • tqdm>=4.66.5

Verify Install

We recommend you download the examples folder within this repository. Download and unarchive the zip folder. Then with the conda environment active:

python -m animl /path/to/example/folder

This should create an Animl-Directory subfolder within the example folder.

Or, if using your own data/models, animl can be given the paths to those files: Download and unarchive the zip folder. Then with the conda environment active:

python -m animl /example/folder --detector /path/to/megadetector --classifier /path/to/classifier --classlist /path/to/classlist.txt

You can use animl in this fashion on any image directory.

Finally you can use the animl.yml config file to specify parameters:

python -m animl /path/to/animl.yml

Usage

Inference

The functionality of animl can be parcelated into its individual functions to suit your data and scripting needs. The sandbox.ipynb notebook has all of these steps available for further exploration.

  1. It is recommended that you use the animl working directory for storing intermediate steps.
import animl
workingdir = animl.WorkingDirectory('/path/to/save/data')
  1. Build the file manifest of your given directory. This will find both images and videos.
files = animl.build_file_manifest('/path/to/images', out_file=workingdir.filemanifest, exif=True)
  1. If there are videos, extract individual frames for processing. Select either the number of frames or fps using the argumments. The other option can be set to None or removed.
allframes = animl.extract_frames(files, frames=3, out_file=workingdir.imageframes, parallel=True)
  1. Pass all images into MegaDetector. We recommend MDv5a. The function parse_MD will convert the json to a pandas DataFrame and merge detections with the original file manifest, if provided.
detector = animl.load_detector('/path/to/mdmodel.pt', model_type="mdv5", device='cuda:0')
mdresults = animl.detect(detector, allframes, resize_width=animl.MEGADETECTORv5_SIZE, resize_height=animl.MEGADETECTORv5_SIZE, 
                         letterbox=True, file_col="frame", device='cuda:0', checkpoint_path=working_dir.mdraw, quiet=True)
detections = animl.parse_detections(mdresults, manifest=allframes, out_file=workingdir.detections)
  1. For speed and efficiency, extract the empty/human/vehicle detections before classification.
animals = animl.get_animals(detections)
empty = animl.get_empty(detections)
  1. Classify using the appropriate species model. Merge the output with the rest of the detections if desired.
classifier, class_list = animl.load_classifier('/path/to/model', '/path/to/classlist.txt', device='cuda:0')
raw_predictions = animl.classify(classifier, animals, resize_width=480, resize_height=480, 
                                 file_col="filepath", batch_size=4, out_file=working_dir.predictions)
  1. Apply labels from class list with or without utilizing timestamp-based sequences.
manifest = animl.single_classification(animals, empty, raw_predictions, class_list['class'])

or, after defining a station column,

manifest = animl.sequence_classification(animals,
                                         empty, 
                                         raw_predictions,
                                         class_list['class'],
                                         station_col='station',
                                         empty_class="",
                                         sort_columns=None,
                                         file_col="filepath",
                                         maxdiff=60)
  1. (OPTIONAL) Save the Pandas DataFrame's required columns to csv and then use it to create json for TimeLapse compatibility
csv_loc = animl.export_timelapse(manifest, imagedir, only_animal = True)
animl.export_megadetector(manifest, out_file ="final_result.json", detector = 'MegaDetector v5a')
  1. (OPTIONAL) Create symlinks within a given directory for file browser access.
manifest = animl.export_folders(manifest, out_dir=working_dir.linkdir, out_file=working_dir.results)

Metadata

Release files for animl-lite 3.3.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for animl-lite 3.3.3
File Size Uploaded
animl_lite-3.3.3.tar.gz 54.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for animl-lite 3.3.3
File Interpreter ABI Platform
animl_lite-3.3.3-py3-none-any.whl Python 3 none any Details

Total release size: 102.1 kB

Release files / animl_lite-3.3.3.tar.gz

Download URL animl_lite-3.3.3.tar.gz
Size 54.3 kB
Tags Source
SHA-256 checksum
How to use checksums
14e9d9c079c25c89fb41434078890a04e98b81840d50205d03b83da1181e0b61
BLAKE2b-256 checksum
How to use checksums
e245e5fa080ba2c716d64cf84f092f8bcf88e06225f1c192d6665df7392d6bc6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 8, 2026.

Transparency log

Release files / animl_lite-3.3.3-py3-none-any.whl

Download URL animl_lite-3.3.3-py3-none-any.whl
Size 47.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8a134d1f9839e7e76e3c5e5bbb5b6ef30aeaedac6d5e8b1a1314448ef221ade3
BLAKE2b-256 checksum
How to use checksums
234dbbb0e5b8ec1d5ff156f7aa3a3a5c260ad04ad2a58758900e04eb6e371cf9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 8, 2026.

Transparency log

Release history Release notifications | RSS feed

3.3.4

2 release files

This release

3.3.3 This release

2 release files

3.3.2

2 release files

3.3.1

2 release files

3.3.0

2 release files

3.2.1

2 release files

3.2.0

2 release files

3.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page