Skip to main content

Zamba

Docs Status tests codecov

https://user-images.githubusercontent.com/46792169/138346340-98ee196a-5ecd-4753-b9df-380528091f9e.mp4

Zamba means "forest" in Lingala, a Bantu language spoken throughout the Democratic Republic of the Congo and the Republic of the Congo.

zamba is a tool built in Python that uses machine learning and computer vision to automatically detect and classify animals in camera trap images and videos. You can use zamba to:

  • Identify which species appear in each image or video
  • Filter out blank images or videos
  • Create your own custom models that identify your species in your habitats
  • Estimate the distance between animals in the frame and the video camera
  • And more! 🙈 🙉 🙊

The official video models in zamba can identify blank videos (where no animal is present) along with 32 species common to Africa and 11 species common to Europe. The official image models identify species from throughout the world: lila.science covers 178 global species and groups, and speciesnet (a conversion of Google's SpeciesNet) covers a much larger taxonomy of over 2,000 classes. Users can also finetune models using their own labeled images and videos to then make predictions for new species and/or new ecologies.

zamba can be used both as a command-line tool and as a Python package. It is also available as a user-friendly website application, Zamba Cloud.

We encourage people to share their custom models trained with Zamba. If you train a model and want to make it available, please add it to the Model Zoo Wiki for others to be able to use!

Visit https://zamba.drivendata.org/docs/ for full documentation and tutorials.

Installing zamba

We recommend uv for installing Python packages and managing environments. Install uv, then ensure you have:

  • Python >= 3.11
  • FFmpeg > 4.3 and < 5 (only needed for video workflows)

Then install the extras you need with uv. We recommend only installing one or the other depending on your use case. Pass --torch-backend=auto so uv installs a PyTorch build matched to your GPU (or CPU):

# For video workflows
uv pip install zamba[video] --torch-backend=auto

# For image workflows
uv pip install zamba[image] --torch-backend=auto

# For both (requires protobuf/setuptools overrides — see Installation docs)
uv pip install zamba[video,image] --torch-backend=auto --overrides zamba-overrides.txt

See the Installation page for the overrides file and full details.

You can also use pip: pip install zamba[video], pip install zamba[image], or pip install zamba[video,image].

Getting started

Once you have zamba installed, some good starting points are:

Example usage

Once zamba is installed, you can see the basic command options with:

$ zamba --help

 Usage: zamba [OPTIONS] COMMAND [ARGS]...

 Zamba is a tool built in Python to automatically identify the species seen in camera trap
 videos from sites in Africa and Europe. Visit https://zamba.drivendata.org/docs for more
 in-depth documentation.

╭─ Options ─────────────────────────────────────────────────────────────────────────────────╮
│ --version                     Show zamba version and exit.                                │
│ --install-completion          Install completion for the current shell.                   │
│ --show-completion             Show completion for the current shell, to copy it or        │
│                               customize the installation.                                 │
│ --help                        Show this message and exit.                                 │
╰───────────────────────────────────────────────────────────────────────────────────────────╯
╭─ Commands ────────────────────────────────────────────────────────────────────────────────╮
│ densepose      Run densepose algorithm on videos.                                         │
│ depth          Estimate animal distance at each second in the video.                      │
│ predict        Identify species in a video.                                               │
│ train          Train a model on your labeled data.                                        │
| image          Tools for working with images instead of videos.                           |
╰───────────────────────────────────────────────────────────────────────────────────────────╯

zamba can be used "out of the box" to generate predictions or train a model using your own images and videos. zamba supports the same image formats as pillow and the same video formats as FFmpeg, which are listed here. Any images or videos that fail a set of validation checks will be skipped during inference or training.

Classifying unlabeled images and videos

Zamba classifies videos by default, but can easily be set to classify images instead. To get classifications for videos:

$ zamba predict --data-dir path/to/videos

and for images:

$ zamba image predict --data-dir path/to/videos

By default, predictions will be saved to zamba_predictions.csv. Run zamba predict --help or zamba image predict --help to list all possible options to pass to predict.

See the Quickstart page or the user tutorial on classifying images or classifying videos for more details.

Training a model

Zamba defaults to training a model for classifying videos:

$ zamba train --data-dir path/to/videos --labels path_to_labels.csv --save_dir my_trained_model

Training a model for images is similar:

$ zamba image train --data-dir path/to/images --labels path_to_labels.csv --save_dir my_trained_model

The newly trained model will be saved to the specified save directory. The folder will contain a model checkpoint as well as training configuration, model hyperparameters, and validation and test metrics. Run zamba train --help or zamba image train --help to list all possible options to pass to train.

You can use your trained model on new images or videos by editing the train_configuration.yaml that is generated by zamba. Add a predict_config section to the yaml that points to the checkpoint file that is generated:

...
# generated train_config
...

predict_config:
  checkpoint: PATH_TO_YOUR_CHECKPOINT_FILE

Now you can pass this configuration to the command line. See the Quickstart page or the user tutorial on training a model for more details.

You can then share your model with others by adding it to the Model Zoo Wiki.

Estimating distance between animals and the camera

Depth-estimation models are also supported, but only for video files. For example:

$ zamba depth --data-dir path/to/videos

By default, predictions will be saved to depth_predictions.csv. Run zamba depth --help to list all possible options to pass to depth.

See the depth estimation page for more details.

Contributing

We would love your contributions of code fixes, new models, additional training data, docs revisions, and anything else you can bring to the project!

See the docs page on contributing to zamba for details.

Reference paper

Dorne, E., Qi, J., Bull, P., Stephens, C., Bessone, M., Debetencourt, B., Fruth, B., Morgan, D., Palmer, M. S., Sanz, C., Wendefeuer, J., Crockford, C., Deschner, T., Langergraber, K. E., Piel, A. K., Robbins, M., Sommer, V., Stewart, F. A., Wittig, R. M., . . . Arandjelovic, M. (2025). Zamba: Computer vision for wildlife conservation. Proceedings of the Python in Science Conferences, 85–111. https://doi.org/10.25080/crcw9835

Metadata

Release files for zamba 2.7.2

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

Source distribution (sdist)

Source distribution for zamba 2.7.2
File Size Uploaded
zamba-2.7.2.tar.gz 40.8 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for zamba 2.7.2
File Interpreter ABI Platform
zamba-2.7.2-py3-none-any.whl Python 3 none any Details

Total release size: 81.6 MB

Release files / zamba-2.7.2.tar.gz

Download URL zamba-2.7.2.tar.gz
Size 40.8 MB
Tags Source
SHA-256 checksum
How to use checksums
b9172d5c38e4e6b4767cae11ac85c9b54bb3a15a8e4d9e20be32495884740e6c
BLAKE2b-256 checksum
How to use checksums
61ceb3b6375125e2ab39e4097795d12c7510c7f5f4bfd1d4e3e80e2d8ee645cb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release files / zamba-2.7.2-py3-none-any.whl

Download URL zamba-2.7.2-py3-none-any.whl
Size 40.8 MB
Tags Python 3
SHA-256 checksum
How to use checksums
9683e004af3219635937d2a854b4443fe51527e242b2f3602267159a039571c6
BLAKE2b-256 checksum
How to use checksums
6d02e7abffcda7b6e141f89c837a9c87b47afab3b8a68328a09d2d53f7c0e1b1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release history Release notifications | RSS feed

This release

2.7.2 This release

2 release files

2.7.1

2 release files

2.7.0

2 release files

0.1.6

1 release file

0.1.5

1 release file

0.1.4

1 release file

0.1.3

1 release file

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