Skip to content
UTokyo-FieldPhenomics-LabPublic

About

Automatic waggle dance translation using AI.

Resources

Stars

5 stars

Watchers

1 watching

Forks

Latest commit

 

History

40 Commits

Folders and files

Repository files navigation

alt text

This repository is the official implementation of DeepWDT (Deep Waggle Dance Translator), a deep learning framework to detect and decode honeybee waggle dances in videos recorded under natural conditions.

Paper · Pretrained models · Datasets · How to cite

Description

Requirements

We recommend using Anaconda to create a conda environment:

conda create -n deepwdt python=3.10
conda activate deepwdt

Install PyTorch for your CUDA version following https://pytorch.org, then install the other requirements from the repository folder:

cd path_to_DeepWDT
pip install -r requirements.txt

Pretrained models

Download the checkpoints from the v1.0.0 release and put them in the weights/ folder. Checkpoints for shorter clip lengths (K = 1, 2, 4, 8, 16) are available with the datasets through the data request form.

Checkpoint 2D backbone 3D backbone Clip length Training data Size Configuration
deepwdt_nano_K32_bengaluru.pth YOLO-Free nano ShuffleNetV2 1.0x 32 frames Bengaluru (Apis dorsata) 15 MB src/config/pretrained/infer_nano_K32.yaml
deepwdt_tiny_K32_bengaluru.pth YOLO-Free tiny ShuffleNetV2 2.0x 32 frames Bengaluru (Apis dorsata) 44 MB src/config/pretrained/infer_tiny_K32.yaml

SHA-256 checksums are listed in SHA256SUMS.txt in the release.

Notes:

  • Both models are YOWOv2 detectors trained for 20 epochs on the 224 x 224 Bengaluru training split (batch size 8, learning rate 1e-5).
  • They were trained on Apis dorsata only. On other species or hive setups (e.g. Apis mellifera observation hives), expect lower accuracy; fine-tuning on a small annotated set from your own setup is recommended.
  • The matching eval_*_K32.yaml files evaluate the checkpoints on the Bengaluru test split (31 clips). With this repository we obtain:
Checkpoint Detected runs Precision Recall Angle RMSE (rad) Duration RMSE (frames)
nano K32 100 % 0.94 1.00 0.31 3.23
tiny K32 100 % 0.91 1.00 0.19 2.15

Quick start: inference on your videos

  1. Download a checkpoint into weights/ (see above).
  2. Put your videos in data/my_videos/videos/.
  3. Run:
python main.py --mode infer --configuration src/config/pretrained/infer_nano_K32.yaml

The models were trained on 30 fps videos. For 1920 x 1080 recordings keep downscale_factor: 0.5, which matches the scale of the training data; for 224 x 224 clips use downscale_factor: 1. Set device: cpu if you have no GPU.

Results are saved to runs/infer/ as:

  • an annotated video
  • a table of the detections for each frame
  • a gpkg file containing the colony and the translated target positions
  • an html map to visualize the translated targets

Translation to geographic coordinates

To translate dances to geographic targets, name the videos following the template video-name_latitude_longitude_yyyy_mm_dd_hh_mm_ss.

The model used to translate waggle run durations to distances is from https://doi.org/10.1016/j.anbehav.2019.01.016.

Datasets

Dataset Species Content Download
Bengaluru Apis dorsata 187 clips (224 x 224 and 448 x 448), annotations.txt with train/val/test split request form
Ginza (processed) Apis mellifera 63 clips (224 x 224), annotations.txt with train/val split request form
Ginza (raw) Apis mellifera 32 full-resolution clips (1920 x 1080) ginza.zip

The datasets and all pretrained checkpoints are released under CC BY 4.0. After you fill in the data request form, the download link is sent to you automatically.

Preparing a dataset

Unzip the dataset into data/<dataset_name>/ so that it contains a videos/ folder (a videos_224/ folder is also accepted) and annotations.txt, then run:

python src/dataset/unpack.py --dataset <dataset_name>

This writes train.csv, val.csv and test.csv (for the splits present), extracts the frames to rgb-images/ and writes one label file per annotated frame to labels/. Add --check to also write videos with the annotations drawn on them.

Annotation format

One row per annotated frame:

Column Meaning
filename clip name (video file name without extension)
frame_id frame index in the clip, starting at 0
run_id waggle run index
instance_id dance index
x0, x1, y0, y1 bounding box of the dancing bee, in pixels of the 224 x 224 clip
angle waggle run angle, in radians
split train, val or test

Known issues

  • The annotations.txt in the raw ginza.zip is a superseded intermediate version. Its boxes do not match the full-resolution videos or the processed clips, and some frame IDs are negative. Use ginza_processed.zip for training and evaluation. The script and per-clip crop parameters used to cut the 224 x 224 clips from the raw videos were not preserved.
  • Versions of src/dataset/unpack.py before v1.0.0 numbered the extracted frames from 1 while labels start at 0, which shifted the labels by one frame. The data loader now detects both numberings and reads the correct frame, so data unpacked with the old script still works.

Custom data collection advice

Data Capture Data Capture

For Apis mellifera videos, we recommend pointing the camera directly and straight at the hive frame, with the whole frame inside the video. An observation hive is the optimal setup.

Training and evaluation

Training

Set the dataset name in the configuration file and run:

python main.py --mode train --configuration src/config/train_small_model.yaml

train_small_model.yaml uses the nano backbone and train_big_model.yaml the tiny backbone. Checkpoints are saved to runs/train/<run_name>/weights/.

We recommend MLflow to follow the training metrics. Set mlflow: true in the training configuration and start the MLflow interface with:

mlflow ui

Evaluation

Set the path to your checkpoint at eval: weights: in the configuration file, check that the model settings match the ones used for training, and run:

python main.py --mode eval --configuration src/config/eval.yaml

To evaluate the pretrained models on the Bengaluru test split, use src/config/pretrained/eval_nano_K32.yaml or eval_tiny_K32.yaml.

Results

See the paper for the published results.

How to cite

If you use DeepWDT, the pretrained models or the datasets, please cite:

@article{grison2025deepwdt,
  title   = {Video based deep learning deciphers honeybee waggle dances in natural conditions},
  author  = {Grison, Sylvain and Siddaganga, Rajath and Hedge, Shrihari and Burridge, James and Blok, Pieter M. and Krishnan, Smitha and Brockmann, Axel and Guo, Wei},
  journal = {Landscape Ecology},
  volume  = {40},
  number  = {11},
  pages   = {211},
  year    = {2025},
  doi     = {10.1007/s10980-025-02244-4}
}

License

The software is released under the MIT license.

Contact

Laboratory of Field Phenomics, The University of Tokyo. Please use GitHub Issues for questions and bug reports.

About

Automatic waggle dance translation using AI.

Resources

Stars

5 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages