Insect Detect Post - Post-processing of camera trap data

August 7, 2026 · View on GitHub

Insect Detect logo

License: AGPL v3 Python DOI Zenodo

This repository contains GUI-based software for post-processing of data captured with the Insect Detect camera trap. It turns the images and metadata captured by the camera trap into cropped, classified and filtered results ready for analysis, by combining image processing, AI-based classification and metadata aggregation into a single configurable pipeline.

Contents

Features

  • Image processing - crop individual detections from full frames (square or original aspect ratio) and/or draw bounding box + metadata overlays.
  • Classification - classify cropped detections with either the BioCLIP 2 foundation model or a custom Ultralytics YOLO classification model.
  • Crop sorting - automatically move cropped detections into subdirectories, either by each individual prediction or by the final prediction of the whole track.
  • Metadata processing - aggregate image-level predictions into per-track results with weighted probabilities. Filter tracks by detection confidence, duration, and prediction probability.
  • Config profiles - save, switch between and reuse multiple named configuration files (.yaml) for different processing setups.
  • Desktop GUI - configure and run the pipeline with a PySide6-based interface that inspects the source dataset, reports live progress and supports cancelling a running pipeline at any time.

Installation

Prerequisites

Note

Python does not need to be installed separately - uv automatically downloads and manages the required Python version for you when running uv sync.

Install uv:

Windows:

powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"

Linux and macOS:

curl -LsSf https://astral.sh/uv/install.sh | sh

Install git:

Windows:

winget install --id Git.Git -e --source winget

Linux (Debian/Ubuntu):

apt-get install git

macOS:

brew install git

Install post-processing software

Clone the insect-detect-post repository:

git clone https://github.com/maxsitt/insect-detect-post

Open a Terminal in your insect-detect-post directory or change directory (use full path after cd):

cd insect-detect-post

There are three installation options:

  1. CPU-only version:

    uv sync --extra cpu
    
  2. GPU with CUDA 13 support:

    uv sync --extra cuda132
    
  3. Legacy GPU with CUDA 12 support:

    uv sync --extra cuda126
    

Note

The cuda132/cuda126 options require a matching NVIDIA GPU driver. Run nvidia-smi and check the reported CUDA Version (top right) to see the maximum CUDA version your installed driver supports.


Usage

Start the GUI by running:

uv run --no-sync gui

Important

Always include --no-sync. Running uv run gui without it re-syncs the environment without your chosen extra, which uninstalls PyTorch and the ONNX runtime.

  1. Select a source directory - select a directory that contains images and metadata captured with the insect-detect software. Subdirectories are scanned recursively, so per-device/per-session folder structures are supported.
  2. Select an output directory - all processed results are written here.
  3. Configure the pipeline - enable/adjust the settings described in Settings below.
  4. Run the pipeline - progress and log messages are shown live, and a run can be cancelled at any time.

Models and supporting files referenced in the configuration (e.g. classification models, the BioCLIP Tree of Life Arthropoda-to-GBIF taxon key mapping used to build per-country species filters) are downloaded automatically on first use from the release assets.

Configuration profiles

Configuration files are stored as .yaml files in the configs/ directory. The active profile is tracked in configs/config_selector.yaml and can be switched, created or updated from the GUI, so different processing setups (e.g. per project or per classifier) can be saved and reused without editing YAML by hand.


Source structure

For data from a single camera trap, select the insect-detect/data folder as source directory. For data from multiple devices, the following source structure is recommended:

<source_path>/
├── insdet-cam01/
│   └── data/
├── insdet-cam02/
│   └── data/
├── insdet-cam03/
│   └── data/
└── ...

Output structure

Each run creates a timestamped directory under data_processed/ in your output directory:

<output_path>/
└── data_processed/
    └── 2026-08-05_14-30-12_<source>_processed/
        ├── 2026-08-05_14-30-12_<config>.json  # config snapshot for this run
        ├── 2026-08-05_14-30-12_run.log        # full log output
        ├── 2026-08-05_14-30-12_stats.json     # per-step durations
        ├── metadata/
        │   ├── <source>_metadata_merged.csv               # all source metadata, harmonized
        │   ├── <source>_metadata_merged_classified.csv    # + per-image predictions
        │   ├── ..._classified_candidates.csv              # per-track candidate predictions
        │   └── ..._classified_final.csv                   # one row per track (best prediction)
        └── images/
            ├── crops/      # cropped detections, optionally sorted into prediction subdirectories
            └── overlays/   # copies of full frames with bounding boxes + metadata drawn on

..._classified_final.csv is the file to use for analysis - one row per tracking ID with its final prediction, weighted probability, duration and (optionally) estimated size.


Settings

All settings are validated with Pydantic - out-of-range numeric values are automatically clamped to their allowed bounds and a warning is logged. bioclip and ultralytics are mutually exclusive (enable only one classifier), as are sort_crops and sort_tracks. Crop sorting and metadata processing both require classification results, so one of the two classifiers must be enabled. metadata.filter_tracks.min_dur_s must be less than max_dur_s.

General

SettingType / OptionsDefaultDescription
source_pathstring | nullnullFull path to the source directory containing images and metadata.
output_pathstring | nullnullFull path to the output directory where all results will be saved.
devicecpu, cudacpuDevice used for model inference. cuda requires a GPU with CUDA support.

Image Processing

Post-processing settings applied to full-frame images.

SettingType / OptionsDefaultDescription
processing.crop.enabledbooltrueSave individual detections as separate crop files. Detections without a full image (crop-only datasets) are copied as-is.
processing.crop.methodsquare, originalsquareCrop method: square crops to a square bounding box, which can improve classification; original keeps the original bounding box aspect ratio.
processing.overlay.enabledboolfalseDraw bounding boxes and metadata overlays on full images and save them as copies.

Classification

Classification settings applied to cropped detections.

SettingType / OptionsDefaultDescription
classification.bioclip.enabledbooltrueEnable classification with the BioCLIP 2 model (via pybioclip package).
classification.bioclip.batch_sizeint (1-256)16Batch size used for BioCLIP inference.
classification.bioclip.rankkingdom, phylum, class, order, family, genus, speciesspeciesPredict to selected taxonomic level. For ranks above species, species-level probabilities are summed up to the target rank.
classification.bioclip.filter_arthropods.enabledbooltrueRestrict BioCLIP predictions to Arthropoda (or subtaxa) and/or GBIF occurrence in selected country.
classification.bioclip.filter_arthropods.taxonArthropoda, InsectaArthropodaTaxon that BioCLIP predictions are restricted to (currently only Arthropoda and Insecta are supported).
classification.bioclip.filter_arthropods.countrycountry code, or allallCountry that BioCLIP Arthropoda predictions are restricted to (based on GBIF occurrence records). all for no restriction.
classification.ultralytics.enabledboolfalseEnable classification with a custom Ultralytics YOLO classification model.
classification.ultralytics.batch_sizeint (1-256)16Batch size used for Ultralytics inference.
classification.ultralytics.modelstringplatform_insect-detect_yolo26s-cls_v1-0-0.onnxFilename of the Ultralytics classification model, downloaded automatically from the models registry on first use.
classification.sort_crops.enabledboolfalseMove cropped detections into subdirectories based on the individual prediction.
classification.sort_tracks.enabledbooltrueMove all crops belonging to a track into one subdirectory based on the track's final prediction.

Filter files

Country filters are built on first use by querying the GBIF occurrence API (this can take a few minutes) and are then cached in filters/. The scripts that regenerate the underlying reference data (filters/resolve_gbif_country_codes.py, filters/resolve_tol_gbif_species.py) only need to be re-run when GBIF's country enumeration or the BioCLIP Tree of Life version changes.

Metadata Processing

Metadata processing settings applied to the final results.

SettingType / OptionsDefaultDescription
metadata.filter_tracks.enabledboolfalseFilter tracking IDs based on mean detection confidence and total tracking duration.
metadata.filter_tracks.min_det_conffloat (0-1)0.2Minimum mean detection confidence required to keep a tracking ID.
metadata.filter_tracks.min_dur_sint (0-600)2Minimum total tracking duration (seconds) required to keep a tracking ID.
metadata.filter_tracks.max_dur_sint (1-21600)3600Maximum total tracking duration (seconds) allowed to keep a tracking ID.
metadata.filter_predictions.enabledboolfalseFilter tracking IDs based on the weighted mean probability of the final prediction.
metadata.filter_predictions.min_prob_weightedfloat (0-1)0.2Minimum weighted mean probability required to keep a tracking ID.
metadata.estimate_size.enabledboolfalseEstimate physical size based on bounding box dimensions and frame size (millimeters).
metadata.estimate_size.frame_width_mmint (10-1000)230Physical width of the camera frame (millimeters).
metadata.estimate_size.frame_height_mmint (10-1000)130Physical height of the camera frame (millimeters).

License

This repository is licensed under the terms of the GNU Affero General Public License v3.0 (GNU AGPLv3).


Citation

If you use resources from this repository, please cite it as:

Sittinger, M. (2026). Software for post-processing of data captured with the Insect Detect camera trap (v1.0.0). Zenodo. https://doi.org/10.5281/zenodo.21822140