Skip to content

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

2 watching

Forks

Repository files navigation

SporaScan: An Automated Pipeline for Precise Disc-Based Disease Severity Assessment in Grapevine Downy Mildew

The online Platform for leaf disc diagnosis

Input and Output

Overview

This repository provides a YOLO + Mobile SAM + U-Net pipeline for grapevine leaf disc disease severity estimation. The batch CLI processes a folder of plate photos and writes one annotated JPEG plus one CSV per image.

Environment

Use Python 3.10, 3.11, or 3.12. The supplied PyTorch 2.5.1 command is not available for Python 3.13.

Create and activate a fresh Python environment:

python -m venv .venv
.\.venv\Scripts\Activate.ps1
python -m pip install --upgrade pip

Install PyTorch first. Choose the command that matches your machine from https://pytorch.org/get-started/locally/. For a CPU-only Windows environment:

pip install torch==2.5.1 torchvision==0.20.1 --index-url https://download.pytorch.org/whl/cpu

Then install the pipeline dependencies:

pip install -r requirements.txt

segmentation-models-pytorch==0.5.0 is required for the supplied weights/UNet_best.pth checkpoint. Loading that checkpoint with a different major model-library version can fail or silently change model construction.

Model Files

The default CLI paths expect:

weights/yolon_best.pt
weights/mobile_sam.pt
weights/UNet_best.pth

Pass custom paths with --yolo-weights, --sam-weights, and --unet-weights if your files are stored elsewhere.

Batch Processing

Run the CLI on a folder of plate photos:

python grapevine_leaf_disc_severity_cli.py path\to\plate_photos --output-dir severity_outputs

For every supported image file (.jpg, .jpeg, .png, .bmp, .tif, .tiff), the CLI writes:

severity_outputs/<image_stem>_annotated.jpg
severity_outputs/<image_stem>.csv

Each CSV contains one row per detected disc:

disk_id,bbox,leaf_pixels,diseased_pixels,severity_percent

bbox is written as x,y,w,h in source-image pixel coordinates. Pixel counts are computed from the U-Net mask at 224 x 224 resolution, and severity_percent is:

diseased_pixels / (diseased_pixels + leaf_pixels) * 100

The CLI does not call cv2.imshow or cv2.waitKey, so it can run unattended on folders of images.

Tests

Run the lightweight test suite:

python -m unittest discover -s tests

These tests cover CLI path handling and CSV output without requiring OpenCV, PyTorch, Ultralytics, or the model weights. Full inference testing requires the environment and model files above.

Single-Image Legacy Script

grapevine_leaf_disc_severity.py still exposes LeafDownSegPipe for direct Python use. Its display-based get_results() method preserves the original interactive behavior and opens an OpenCV window when severity=True.

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages