This is the official repository for the paper "Evaluating AI-Assisted Pollinator Detection in Agricultural Fields". Data is available here at our data repo.
- We introduced an AI-assisted annotation framework for pollinator detection datasets.
- Our annotation framework increased the number of annotations by 87% compared to manual labels.
- Training with our dataset increased model performance by 29 percentage points in mAP.
- With our dataset, we examined how different treatments impact model performance.
- We showed that increasing the number of annotated pollinators improves model performance.
For reproducibility, we also provide the annotations from each iteration. To reproduce the results of YOLOv5 used in our iterative computer vision pipeline, you will also need to download the model weights: Test using script from yolov5 repo (see below how to run evaluation script).
- iteration 1 checkpoint
- iteration 2 checkpoint
- iteration 3 checkpoint
- iteration 4 checkpoint
- iteration 5 checkpoint
- We also have the weights for YOLOv5 trained on the final dataset.
Our code was tested on a Linux machine, with Python 3.7.13.
Use pip to setup your favourite virtual environment (venv/conda/etc)
git clone --recurse-submodules https://github.com/PRBonn/bee_detection.git
cd bee_detection
pip install -r requirements.txtYou may need to install PyTorch separately if you have specific version requirements.
- The split used in Study 1 is given in our data repo.
- Randomly split training and validation data from 2022 with
cd scripts; python3 split_dataset.py - The test split is simply the annotations for the date July 20, 2022.
- To obtain the growing training split, use the script
cd scripts; python3 incremental.py --parent_dir <path to patches parent dir> --output_parent_dir <path to output dir> - The test split is the same as that of Study 2, i.e., using the annotations for the date July 20, 2022.
- Download the images
- Download the annotations for training and also the annotations around which to be patched (these are the uncorrected predictions from iteration x.5)
- Generate the patches
python3 crop_BBs.py \
--images_dir <path to image dir> \
--labels_dir <path to labels> \
--patching_labels_dir <path to annotations for location of patches (iteration x.5)> \
--output_dir <path to output dir> \
--num_repeats 1 \
--patch_size 1024- You may want to visualise the patches as a sanity check (see how to section on visualise)
- split patches into train-val set. We do not need a test set because we will predict on the full images for AI-assisted annotation and are not interested in the YOLOv5 test performance at this stage.
python scripts/split_dataset.py <path to parent dir of patches> --test_split 0.0 --val_split 0.15 - create a config file pointing to the patches dataset. See yolov5/data/roundx.yaml for an example
- Train using the patches
python -m torch.distributed.run --nproc_per_node <number of gpus> --master_port <pick an unused port> train.py --data <config yaml of dataset> --cfg yolov5m.yaml --batch-size 6 --workers 6 --epochs 600 --img 1024 --name <whatever name you would like to use to call this experiment> --project <path to output training logs> --save-period 20 --weights <pretrained weights pt> --cache ram --hyp data/hyps/hyp.scratch-high.yaml;
cd scripts;
python merge_yolo_hiwi.py \
--hiwi_labels_dir <dir of labels from previous iteration> \
--round_labels_dir <dir of predictions from current round> \
--out_dir <path to output dir> \
--imgs_dir <path to img dir> python val.py --data <config for test dataset yaml> --weights <weights to evaluate> --batch-size 8 --task "test" --workers 8 --name <experiment name> --img 5120 --project <path to output logs>;Feel free to contact me at linn.chong@uni-bonn.de or open an issue in this repo if you have any questions.