Conservation AI · Kenya · June–July 2025

Automating wildlife
detection in the field

A camera trap review process that consumed up to a week of staff time — reduced to minutes. Built during a research placement at Lewa Wildlife Conservancy, northern Kenya.

99.5%
mAP@50 validation score
100%
Recall on validation set
13
Species classes
5,000+
Total annotations

A bottleneck at the heart of conservation monitoring

The wildlife corridor linking Lewa Wildlife Conservancy to Mount Kenya is one of northern Kenya's most ecologically significant landscape features — enabling seasonal migration, genetic diversity, and habitat access for elephants, Grevy's zebra, giraffe, and buffalo. In 2022 alone, over 50,000 wildlife crossing events were recorded across the corridor.

Monitoring this movement relies on camera traps positioned along the 14 km corridor. But the volume of imagery created a persistent problem: reviewing a single week's footage could take up to a week of staff time. Consistent, timely analysis was nearly impossible to sustain.

Lewa's 2022 Annual Report identified AI-assisted image processing as a strategic priority. The detection model built during this placement was a direct response to that need.

The goal: replace manual review with an automated pipeline that processes large batches of camera trap images, classifies species, determines direction of movement, and exports structured data — in a fraction of the time.

Ranger surveying the Lewa landscape

Field survey at Lewa — the conservancy spans over 62,000 acres of savannah and highland terrain.

From raw images to structured movement data

01

Data collection & annotation

Over 5,000 annotations were compiled from raw camera trap footage across three corridor sites (Underpass, Mariana mid-section, Mt Kenya Exit) and supplementary images. Each image was manually annotated in Roboflow using bounding boxes across 13 species classes. The hardest task was differentiating Grevy's zebra from plains zebra — two species with near-identical stripe patterns.

02

Model training — Roboflow 3.0 Object Detection (XL)

A custom object-detection model — lewa-elephants/6 — was trained on the annotated dataset within Roboflow. Version 6 is the final production model, trained July 16 2025, using Roboflow 3.0 Object Detection Extra Large architecture. The platform handled preprocessing, augmentation, and API deployment.

03

Python batch processing pipeline

A local Python script connected to the Roboflow API to process images in batches. Images were loaded and resized to 1280px max width using Pillow, maintaining aspect ratio. Each image was passed to the model, returning predictions with species labels, confidence scores, and bounding box coordinates. Images with no detections were skipped automatically.

04

Directional movement classification

For each detected animal, the horizontal centre of its bounding box (x-position) was tracked across sequential frames. Left-to-right was classified as INTO Lewa, right-to-left as OUT OF Lewa. Without this directional anchoring, the same animal across consecutive frames would be counted multiple times — significantly inflating totals.

05

Structured CSV export

Final species counts (IN and OUT) were exported to formatted_results.csv. This enables longitudinal species-level tracking, seasonal movement pattern identification, and integration with broader ecological datasets — giving Lewa's team a scalable foundation for data-driven habitat management.

The model detecting in the field

A real camera trap image from the corridor — the model returns bounding boxes and confidence scores as structured JSON. The elephant here was detected at 100% confidence.

Model detecting elephant at 100% confidence

Camera CAMERA1 — 4 objects detected including elephant and bush classifications. Timestamp 01/02/2020 08:04PM.

"predictions": [
  {
    "class": "Elephant",
    "confidence": 1.0,
    "x": 1248.75,
    "y": 1237.5,
    "width": 2596.5,
    "height": 2490.75,
    "class_id": 1
  },
  {
    "class": "Bush",
    "confidence": 0.97,
    "x": 617.06,
    "y": 1346.63
  },
  // 2 more detections...
]

Raw JSON from the Roboflow API — each prediction includes class, confidence, and bounding box coordinates used for directional movement tracking.

13 species classes — annotation breakdown

293 images from one week of camera trap footage were processed in the final assessment. Across the full training process, 5,000+ annotations were made covering 13 classes. The distribution below shows why plain zebra and elephant dominate — and why Grevy's zebra differentiation remains the hardest classification challenge.

Grevy's Zebra (29 annotations) vs Plain Zebra (212) — visually similar stripe patterns make this the most challenging classification pair in the dataset. Highlighted in red.

Validation metrics

mAP@50
99.5%
Validation set — Roboflow 3.0 XL
Precision
85.5%
Of detections made, correct ones
Recall
100%
All true animals detected

A comparative test pitted the model against a manual count of elephant crossings over one week. The model was within +3 animals on inbound and -10 animals on outbound crossings — a strong margin for a field model given the volume and situational challenges involved.

What this changes for the conservation team

Speed

A full week's footage — previously requiring up to a week of manual staff review — now processed in minutes in a single session.

📈

Longitudinal data

Structured CSV output enables species-level IN/OUT tracking over time, seasonal movement pattern identification, and integration with wider ecological datasets.

🔁

Scalability

The pipeline accommodates new camera placements or additional species classes as monitoring needs evolve — no rebuild required.

🌍

Conservation context

Lewa/Borana host 317 of Kenya's ~3,000 remaining Grevy's zebra. Reliable movement data directly supports habitat management for an endangered species.

Known constraints

Juvenile occlusion

Juvenile elephants are frequently obscured behind adults, making them difficult to detect within the camera's field of view.

Camera placement

Cameras positioned too close to crossing points lack the breadth of view needed to capture full herd compositions.

Environmental false positives

Clouds and dense bush occasionally trigger detections. A dedicated bounding box category was added but flagged entries still require manual CSV cleanup.

Zebra differentiation

Grevy's and plains zebra remain the most challenging pair. More targeted training data is the clearest path to improvement.

Motion-triggered noise

Birds, people, and non-target subjects frequently trigger captures, adding dataset noise that additional training data would reduce.

CSV automation

False positive entries are appended to the output and must be manually removed — automating this step is the next identified priority.

Also from this placement → Predator Scat Analysis — Lewa Lab ← All Projects