Universal Arthropod Localization and Instance Segmentation
Project description
flatbug
A General Method for Detection and Segmentation of Terrestrial Arthropods in Images
| Find and cite the flatbug paper in Method in Ecology and Evolution | Send us new data through our data contribution form. |
flatbug is partly a high-performance pyramid tiling inference wrapper for YOLOv8 and partly a hybrid instance segmentation dataset of terrestrial arthropods accompanied by an appropriate training schedule for YOLOv8 segmentation models, built on top of the original YOLOv8 training schedule.
The goal of flatbug is to provide a single unified model for detection and segmentation of all terrestrial arthropods on arbitrarily large images, especially fine-tuned for the case of top-down images/scans - thus the name "flat"bug.
Installation
We recommend using uv (installation):
# Easy-install
uv pip install flat-bug --torch-backend=auto
# Add to a project permanently (recommended)
uv add flat-bug
[!TIP] If you have problems with PyTorch not being installed with CUDA enabled try:
uv pip install torch torchvision --torch-backend=auto --reinstallMore details: https://docs.astral.sh/uv/guides/integration/pytorch/#the-uv-pip-interface
or (not recommended):
pip install flat-bug
Source/development
Or a development version can be installed from source by cloning this repository:
Clone the repository
git clone https://github.com/darsa-group/flat-bug.git
cd flat-bug
Install flatbug
uv sync --all-extras --all-groups --upgrade
# (optional but recommended)
uv pip install torch torchvision --torch-backend=auto --reinstall
or (not recommended):
pip install -e .
[!WARNING] If you do decide to install with
pip, as with other packages built withPyTorchit is best to ensure thattorchis installed separately. See https://pytorch.org/ for details. We recommend usingtorch>=2.3.
CLI Usage
We provide a number of CLI scripts with flatbug. The main one of interest is fb_predict, which can be used to run inference on images or videos:
[uv run] fb_predict -i <DIR_WITH_IMGS> -o <OUTPUT_DIR> [-w <WEIGHT_PATH>] ...
Tutorials
We provide a number of tutorials on general and advanced usage, training, deployment and hyperparameters of flatbug in examples/tutorials or with Google Colab .
Documentation
Find our documentation at https://darsa.info/flat-bug/.
CUDA Issues
Working with cross-platform PyTorch code can be a bit confusing, so if you ever get stuck with some CUDA errors, here are some possible paths to resolve the issues.
uv and pip
If you installed flat-bug via a package manager but find that GPU acceleration is not working, your environment likely downloaded the default PyPI wheels which may not match your system's NVIDIA drivers.
If you are using uv, the easiest fix is to force a re-resolution of the PyTorch backend:
# Automatically detect hardware and reinstall PyTorch
uv pip install torch torchvision --torch-backend=auto --reinstall
# OR manually force a specific CUDA version (e.g., CUDA 11.8)
uv pip install torch torchvision --torch-backend=cu118 --reinstall
If you are using standard pip, you must manually point to the PyTorch index that matches your system:
# Uninstall the broken versions
pip uninstall torch torchvision
# Reinstall pointing explicitly to the CUDA 11.8 or 12.1 (cu121) index
pip install torch torchvision --index-url https://download.pytorch.org/whl/cu118
Verification:
[uv run] python -c "import torch; print(f'CUDA Available: {torch.cuda.is_available()}')"
Source
Rebuild the environment and lockfile from scratch:
# cd ~/flat-bug
# 1. Purge old state
rm uv.lock
rm -rf .venv
# 2. Generate the pure, cross-platform lockfile
uv lock
# 3. Create your local environment
uv sync --all-extras --all-groups
# 4. Patch your local environment with your specific hardware backend
uv pip install torch torchvision --torch-backend=auto --reinstall
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file flat_bug-1.1.1.tar.gz.
File metadata
- Download URL: flat_bug-1.1.1.tar.gz
- Upload date:
- Size: 106.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e5165e11daa09ccb8c16f1d13b38497d19d2b40be0be46586105544819b8f973
|
|
| MD5 |
8f8a6b75b8c4ff3ae5986652a9186c58
|
|
| BLAKE2b-256 |
518dc69b1c30e4e4abfd93580f527e54ad1c015ae34acd1dbf143beb9c3c0223
|
File details
Details for the file flat_bug-1.1.1-py3-none-any.whl.
File metadata
- Download URL: flat_bug-1.1.1-py3-none-any.whl
- Upload date:
- Size: 115.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
57e2187fae53a50ad18494e326aa9cff7c2fb44bfdc689edff671da590e65ba9
|
|
| MD5 |
2900a34ab72cdff61bf58d4a66fb763d
|
|
| BLAKE2b-256 |
61105c40d6a6db903a345d6b7ef04d1771ca9c3c019673aa7239736854df0b59
|