This repository contains a machine learning application for predicting the genus and sex of Diapriidae and Ismaridae images using the Vision Transformer Architecture BEiTV2 and outlier detection (predict whether an insect does not belong to any of the learned classes). The application provides a user-friendly web interface for both single-image and batch processing.
This repository is based on the work published in the following paper:
"Image-based recognition of parasitoid wasps using advanced neural networks"
You can access the full text of the paper here: Full Text.
The original repository for this project is hosted on GitLab. You can find it here:
Before running the application, you need to have the following prerequisites:
- Anaconda Package Manager (Download)
- If using Microsoft Windows OS: Microsoft Visual C++ Redistributable (In many cases already installed. You can install it here)
-
Open Windows PowerShell.
-
Create a new folder for this project at your desire path and navigate to it in Windows PowerShell:
mkdir <path/to/diapriidae_classification_app> cd <path/to/diapriidae_classification_app>
-
Clone the repository to your local machine:
git clone https://gitlab.kit.edu/kit/iai/ber/diapriidaeclassificationapp.git cd diapriidaeclassificationapp
-
Create a virtual environment using Anaconda and activate it:
conda create -n diapriidae_app python=3.10 anaconda --yes conda activate diapriidae_app
-
Install the required dependencies from
requirements.txt
:pip install -r requirements.txt
-
Download the GroundingDINO weights file. If the provided link does not work, check the GroundingDINO Installation Guide (Step 4: Download pre-trained model weights).
curl -O weights/groundingdino_swint_ogc.pth https://github.com/IDEA-Research/GroundingDINO/releases/download/v0.1.0-alpha/groundingdino_swint_ogc.pth
-
Start the application:
python src/app.py
As soon as the Application is running a browser window should open automatically. You can perform genus/sex classification and outlier detection on single images or perform batch inference on multiple images or alternatively on all images inside a directory.
-
You will see two tabs: "Single Image" and "Image Folder." Select the "Single Image" tab.
-
Drag and drop an image into the designated box.
-
Click the "Predict" button to initiate the inference process.
-
The classification and outlier detection results will be displayed on the screen based on the image.
-
Select the "Image Batch" tab.
-
Inside the "Image data type" box specify if multiple images or all Images inside a directory should be predicted.
-
Click the "Browse" button and specify the images or the image folder to serve as input.
-
The application will process the specified images and generate prediction results in Excel file inside the output folder. The path of the Excel file will be displayed on the screen as soon as it is created.