Skip to content

Noninvasive technologies to detect, identify and monitor bears, facilitating their conservation.

License

Notifications You must be signed in to change notification settings

earthtoolsmaker/bear-conservation

Repository files navigation

AI for Bears

It contains a collection of software packages to work with bears.

Detected bear face using the bear face detector Pose of a bear using the bearfacelandmarkdetector Segmented face of a bear

It provides bear detection, bear face detection, bear face segmentation, bear facial landmark detection and bear re-identification models.

Context

Bears, particularly brown bears, are not only charismatic but also serve as indicator and umbrella species. By understanding and protecting them, we contribute to the overall health of the environment. However, monitoring bears is difficult due to their elusive and wide-ranging nature. The toolbox of methods available to study bears in non-invasive ways is limited, leading to a reduced understanding of their population status and trends.

Human-bear conflicts can pose challenges to effective bear conservation and threats to people and property. Promoting coexistence and mitigating human-bear conflicts is key to the long-term conservation of brown bears, preserving the vital role they play in maintaining a balanced ecosystem.

Setup

git-lfs

Make sure git-lfs is installed on your system.

Run the following command to check:

git lfs install

If not installed, one can install it with the following:

Linux

sudo apt install git-lfs
git-lfs install

Mac

brew install git-lfs
git-lfs install

Windows

Download and run the latest windows installer.

Detect bears

Binary classifier to detect bears from camera trap frames (nighttime and daytime).

Normalized Confusion Matrix Training Metrics Precision/Recall
Normalized Confusion Matrix Training Precision/Recall curve

beardetection virtualenv

Create a virtualenv using your tool of choice (eg. conda, pyenv, regular python, ...) and activate it.

conda create -n beardetection python=3.9
conda activate beardetection

Install the beardetection dependencies

make beardetection_setup

Install the model

Run the following command to install the model:

make beardetection_install_model

Detect

Predictions

Use the dummy detection script to check that everything works as expected:

make beardetection_predict

You should be able to find the predictions in the folder ./data/07_model_output/beardetection/predictions/

Now you can start predicting on your own images using the following python script:

python ./scripts/beardetection/model/predict.py \
  --model-weights ./data/06_models/beardetection/model/weights/model.pt \
  --source-path ./data/09_external/detect/images/bears/image1.jpg \
  --save-path ./data/07_model_output/beardetection/predictions/ \
  --loglevel "info"

Identify bears

Pipeline Overview

Bear IDentification Pipeline

Performance

Precision at 1 Precision at 3 Precision at 5 Precision at 10
95.5 96.5 97.3 98.5

bearidentification virtualenv

Create a virtualenv using your tool of choice (eg. conda, pyenv, regular python, ...) and activate it.

conda create -n bearidentification python=3.9
conda activate bearidentification

Install the bearidentification dependencies

make bearidentification_setup

Install the packaged pipeline

Run the following command to install the pipeline:

make install_packaged_pipeline

Predict

Use the dummy prediction script to check that everyhing works as expected:

make identify_default

You should be able to find the predictions in the folder ./data/07_model_output/identify/default/.

Now you can start predicting on your own images using the following python script:

python ./scripts/identify.py \
  --source-path ./data/09_external/identify/P1250243.JPG \
  --output-dir ./data/07_model_output/identify/default/

Identification of a bear

Development

To contribute to this repository, one can follow the relevant documentation.

Partnerships

This project was hosted and made possible by the following organizations:

Literature