{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": "# Livestock detection (DeepForest)" }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Context\n", "### Purpose\n", "Implement and fine-tune a prebuilt Deep Learning model to detect livestock in airborne imagery. The model is implemented using PyTorch Lightning, which simplifies the training process and allows for easy checkpointing, enabling collaborative work by saving and sharing model progress.\n", "\n", "### Modelling Approach\n", "The [live-stock detection model](https://huggingface.co/weecology/deepforest-livestock) from the latest version (v1.4.0) of the [DeepForest](https://deepforest.readthedocs.io/en/latest/) {cite:p}`Weinstein2020_MEE` Deep Learning model is used to predict bounding boxes corresponding to cattle from airborn RGB images.\n", "\n", "As a PyTorch Lightning module, this model can be fine-tuned easily, and checkpoints can be saved as [.safetensors](https://huggingface.co/docs/safetensors/index), making it possible to upload the trained models to platforms like Hugging Face for open collaboration.\n", "\n", "The prebuilt model was trained on a [limited dataset](https://new.wildlabs.net/discussion/global-model-livestock-detection-airborne-imagery-data-applications-and-needs) {cite:p}`livestockdataset`. According to the package's documentation, \"the prebuilt models will always be improved by adding data from the target area\". As such, this notebook will explore the improvement in the model's performance in live-stock detection from fine-tuning on local data.\n", "\n", "### Description\n", "This notebook will explore the capabilities of the DeepForest package. In particular, it will demonstrate how to:\n", "\n", "- Detect livestock in airborne imagery using the prebuilt livestock detection model.\n", "- Fine-tune the model using a novel publicly-available dataset.\n", "- Evaluate the model's performance before and after fine-tuning.\n", "- Save and share model checkpoints throughout the process, allowing for reproducibility and collaboration on Hugging Face.\n", "\n", "