RolnickLab / ami-data-companion

Desktop app for analyzing images from autonomous insect monitoring stations using deep learning models
MIT License
9 stars 3 forks source link

AMI Data Companion

Desktop app for analyzing images from autonomous insect monitoring stations using deep learning models

Monitoring station deployment in field Screenshot of desktop application Emerald moths detected in processed images

Dependencies

Install (or upgrade) the package with the following command

pip install https://github.com/RolnickLab/ami-data-companion/archive/main.zip

Optionally test the installation with the following command

ami test pipeline

Installation (for developers)

Create an environment just for AMI and the data companion using conda (or virtualenv)

conda create -n ami python=3.10 anaconda

Clone the repository using the command line or the GitHub desktop app.

git clone git@github.com:RolnickLab/ami-data-companion.git

Install as an editable package. This will install the dependencies and install the trapdata console command

cd ami-data-companion
pip install -e .

Test the whole backend pipeline without the GUI using this command

python trapdata/tests/test_pipeline.py

GUI Usage

A short video of the application in use can be seen here: https://www.youtube.com/watch?v=DCPkxM_PvdQ

CLI Usage

Configure models and the image_base_path for the deployment images you want to process, then see the example workflow below. Help can be viewed for any of the subcommands with ami export --help.

Settings

There are two ways to configure settings

  1. Using the graphic interface:
    • Run ami gui and click Settings. This will write settings to the file trapdata.ini
  2. Using environment variables
    • Copy .env.example to .env and edit the values, or
    • Export the env variables to your shell environment

The CLI will read settings from either source, but will prioritize environment variables. The GUI only reads from trapdata.ini.

Example workflow

ami --help
ami test pipeline
ami show settings
ami import --no-queue
ami show sessions
ami queue sample --sample-size 10
ami queue status
ami run
ami show occurrences
ami queue all
ami run
ami queue status --watch  # Run in a 2nd shell or on another server connected to the same DB
ami show occurrences
ami export occurrences --format json --outfile denmark_sample.json --collect-images

Database

By default both the GUI and CLI will automatically create a local sqlite database by default. It is recommended to use a PostgreSQL database to increase performance for large datasets and to process data from multiple server nodes.

You can test using PostgreSQL using Docker:

docker run -d -i --name ami-db -p 5432:5432 -e POSTGRES_HOST_AUTH_METHOD=trust -e POSTGRES_DB=ami postgres:14
docker logs ami-db --tail 100

Change the database connection string in the GUI Settings to postgresql://postgres@localhost:5432/ami (or set it in the environment settings if only using the CLI)

Stop and remove the database container:

docker stop ami-db && docker remove ami-db

A script is available in the repo source to run the commands above. ./scrips/start_db_container.sh

KG Notes for adding new models