Decision-support system for live detection of Leishmania parasites from microscopic images with Deep Learning
Key Features:
- Real-time prediction of leishmania parasites
- Intuitive user interface for easy use
A complete step-by-step installation guide (Windows edition).
- Windows PC
- Internet connection and about 5β10 GB free disk space
- An NVIDIA GPU is optional (project will also run on CPU, just slower)
- A microscope camera connected to your PC (required for livestream)
- Download Miniconda for Windows here:
π https://docs.anaconda.com/miniconda/ - Run the installer and just click Next (default options are fine).
- After installation, close all windows and open the Anaconda Prompt (search for it in the Start menu).
Open the Anaconda Prompt and run:
cd %USERPROFILE%\Downloads
git clone https://github.com/ZKI-PH-ImageAnalysis/leishmania.gitThis will create a folder called Leishmania.
Inside it, you will find the MicroPredictor folder that contains all the code.
Now move into the project folder:
cd "%USERPROFILE%\Downloads\Leishmania\MicroPredictor"π‘ Tip: If you saved the project somewhere else, adjust the path.
Run this command inside the project folder:
conda env create -f environment.ymlThis installs everything needed. β³ It can take a few minutes.
If you already created the environment before and just want to update it:
conda env update -f environment.yml --pruneThe environment name is defined inside environment.yml.
For this project, it is usually leishmania.
Activate it with:
conda activate leishmaniaNow you should see (leishmania) at the beginning of the line in your Anaconda Prompt.
Check if everything works by running:
python -c "import torch; print('CUDA available:', torch.cuda.is_available())- If you see
CUDA available: Trueβ your NVIDIA GPU will be used. - If you see
Falseβ the project will still run, but only on CPU (slower).
Make sure you are still in the project folder:
cd "%USERPROFILE%\Downloads\Leishmania\MicroPredictor"-
Create the configuration file automatically (only needed once):
python create_config.py
-
Start the livestream:
python livestream.py
Whenever you want to use the project again:
conda activate leishmania
cd "%USERPROFILE%\Downloads\Leishmania\MicroPredictor"
python livestream.py-
condanot recognized
β You are not in the Anaconda Prompt. Close everything and open the Anaconda Prompt again. -
ModuleNotFoundError(e.g. torch, cv2, PyQt5)
β You forgot to activate the environment. Runconda activate leishmania. -
Wrong folder
β Make sure you are in the folder whereenvironment.ymlis located. Usedirto list files. -
CUDA available: Falsebut you have a GPU
β Update your NVIDIA drivers. Otherwise, the project will run on CPU. -
Camera not working
β Double-check that your microscope camera is plugged in before runningcreate_config.py. If not, close everything, connect the camera, and run the command again.
β
Done! You now have everything set up on Windows.
Remember: 1) Open Anaconda Prompt β 2) Activate environment β 3) Go to project folder β 4) Run livestream.
- Python 3.8
- PyTorch 2.1.0
- Torchaudio 2.1.0
- Torchvision 0.16.0
- Cuda 12.1
- PyQt5 5.15.10
- Ultralytics 8.2.76
- ruamel.yaml 0.18.6
- OpenCV 4.10.0
Below you can see what a configuration file should look like. If create_config.py does not work for you, you can create the file manually and fill it out with the help of cameratest.ipynb.
version: 1.0
# Camera Settings
camera_nr: 0
camera_resolutions:
- [648, 486]
- [1296, 972]
- [2592, 1944]
used_camera_resolution: 2
camera_brightness_min: -64
camera_brightness_max: 64
camera_brightness_standard: 0
camera_brightness_used: 0
camera_contrast_min: -100
camera_contrast_max: 100
camera_contrast_standard: 0
camera_contrast_used: 0
camera_saturation_min: 0
camera_saturation_max: 255
camera_saturation_standard: 128
camera_saturation_used: 128
camera_hue_min: -180
camera_hue_max: 180
camera_hue_standard: 0
camera_hue_used: 0
# Snap Image Settings
change_scaling: false
crop_or_resize: crop
scaling_width: 648
scaling_height: 486
save_path: 'd:\Downloads\Leishmania\MicroPredictor\snapped_images'
# Yolo Parameters
yolo_weights:
path\to\folder\weights\universal_model.ptDataset available at: Zenodo
This dataset consists of microscopic images of Giemsa-stained skin smears obtained from Libyan patients diagnosed with cutaneous leishmaniasis (CL).
It is organized into two main parts:
- Dataset 1 β Collected with a Keyence BZ9000E digital microscope (lab-based).
- Dataset 2 β Extended dataset including all images from Dataset 1, plus an additional set collected with a Bresser Erudit DLX microscope (portable, low-cost).
Both datasets contain paired Images (.png) and Labels (.txt), split into train, val, and test subsets.
- Patients: 244 Libyan CL patients (confirmed by PCR at Tripoli University Hospital).
- Samples: Skin lesion smears (slit-skin or touch smears).
- Preparation: Air-dried, methanol-fixed, Giemsa-stained slides.
- Imaging Setup:
- Microscope: Keyence BZ9000E (lab-grade)
- Magnification: 100Γ oil immersion objective
- Numerical Aperture (NA): 1.3
- Resolution: 0.21 ΞΌm
- Image Count:
- 350 positive images (parasite densities: 1β100 amastigotes per image)
- 220 negative images (no parasites, controls)
- Total: 570 images
- Patients: Additional cohort (6 patients).
- Samples: Same smear preparation method.
- Imaging Setup:
- Microscope: Bresser Erudit DLX (portable, battery-powered)
- Camera: BRESSER MikroCam SP 5.0
- Magnification: 100Γ oil immersion objective
- Numerical Aperture (NA): 1.25
- Resolution: 0.22 ΞΌm
- Image Count:
- 106 positive images
- 58 negative images
- Total: 164 images
π Dataset 2 folder = Dataset 1 images + Dataset 2 images (extended dataset).
Dataset_1/
β
βββ Images/
β βββ train/ # dataset_1_image_1.png ... dataset_1_image_398.png
β βββ val/ # continues numbering from train
β βββ test/
β
βββ Labels/
β βββ train/ # dataset_1_image_1.txt ...
β βββ val/
β βββ test/
β
Dataset_2/
β
βββ Images/
β βββ train/ # contains both dataset_1 and dataset_2 images
β βββ val/
β βββ test/
β
βββ Labels/
β βββ train/
β βββ val/
β βββ test/
-
Naming Convention:
dataset_1_image_X.pngfor Dataset 1 imagesdataset_2_image_X.pngfor Dataset 2 additional images- Labels follow the same numbering with
.txtextension
-
Splits:
- Train, validation, and test sets are sequential.
- Example: Train = images 1β398, Val = 399ββ¦, Test = continues onward.
- Image format:
.png - Label format:
.txt(YOLO-style bounding boxes). - Each line = one object (parasite body).
Format:
class_id:- 0 = parasite
- Coordinates are normalized by image width and height.
- After
class_id, the values are given in pairs:
(x1 y1 x2 y2 β¦ x4 y4) - Every
.pnghas a corresponding.txtfile in the same split (train/,val/,test/).
- Dataset 1 = base dataset (lab microscope, high-quality).
- Dataset 2 = superset (Dataset_1 + portable microscope data).
- Train/Val/Test subsets are disjoint (sequential indexing prevents data leakage).
