How johri-lab/automatic-leaf-infection-identifier works
1. This repository is a local, Python-based desktop application for classifying leaf images as healthy or infected. The core architecture is a simple image-processing pipeline feeding a machine-learning classifier.
2. The main user entry point is GUIdriver.py. It launches the application UI and lets the user browse for an image file to analyze. The GUI layer is separate from the image-processing logic, so the interface is thin and the actual work happens in backend scripts.
3. The UI is defined by design.ui and mirrored in design.py, which strongly suggests a Qt/Qt Designer-style desktop front end. This layer handles file selection and result display, but does not contain the detection logic itself.
4. The primary processing pipeline lives in main.py. According to the README, it performs:
- RGB image acquisition
- RGB-to-HSI color conversion
- green-pixel masking
- removal of healthy leaf regions
- segmentation of candidate diseased regions
- extraction of numerical features for classification
5. classifier.py is the model boundary. main.py calls into it after feature extraction, and the README says the classifier is an SVM used to decide whether the leaf is infected or healthy. In architecture terms, this is the inference layer that consumes extracted features and returns the final label.
6. The repository includes a dataset artifact, Datasetinfectedhealthy.csv, which likely stores the extracted feature vectors and class labels used to train or validate the classifier. This CSV is the structured data boundary between image processing and machine learning.
7. The leaf sampler/ directory is a separate dataset-generation subsystem. It contains:
- leafdetectionALLmix.py
- leafdetectionALLsametype.py
These scripts scan image directories and generate dataset entries from source images. The README indicates one script is for mixed healthy/infected collections, and the other is for a single category.
8. The image assets are packaged separately from the code in Image Dataset/ as zip files, and there is also a testimage/ directory for sample inputs. This shows the project is organized around offline local files rather than networked data sources.
9. The system’s data flow is essentially:
selected leaf image → preprocessing/segmentation in main.py → numeric features → SVM classification in classifier.py → healthy/infected result shown in GUI.
10. Packaging and environment setup are lightweight: requirements.txt defines Python dependencies, and setup.py supports installation. The repo is self-contained and does not depend on external services or a backend server.
11. In architectural terms, the important boundaries are:
- Presentation layer: GUI files
- Image-processing layer: main.py
- ML inference layer: classifier.py
- Dataset preparation layer: leaf sampler/
- Static data layer: CSV and image archives
12. For a diagram, the key interaction to show is that the GUI is only a front end; the real computation is a local pipeline that transforms leaf imagery into features and then into a binary disease decision.
Main entry points: GUIdriver.py GUI driver · main.py Image pipeline · classifier.py SVM model · Datasetinfectedhealthy.csv Feature data
Components 15
Presentation
Desktop UI and user entry point
- GUI driver · Launches the app and handles image selection/result display
GUIdriver.py - UI form · Qt Designer interface definition
design.ui - UI code · Python mirror of the desktop form
design.py - Package setup · Project installation and dependency wiring
setup.py - Dependencies · Pinned runtime requirements
requirements.txt
Processing
Image preprocessing and feature extraction
- Image pipeline · Loads leaf images and prepares them for analysis
main.py - Color convert · RGB acquisition and RGB-to-HSI conversion
main.py - Mask & segment · Green masking, healthy-region removal, and diseased-region segmentation
main.py - Feature vector · Produces numeric descriptors for classification
main.py
Classifier
Machine-learning inference boundary
- SVM model · Consumes features and returns healthy or infected label
classifier.py
Dataset Prep
Scripts that build feature datasets
- Mix sampler · Generates dataset entries from mixed healthy/infected image collections
leaf sampler/leafdetectionALLmix.py - Single sampler · Generates dataset entries from one category at a time
leaf sampler/leafdetectionALLsametype.py
Data
Static datasets and sample inputs
- Feature data · Stored feature vectors and labels
Datasetinfectedhealthy.csv - Image archives · Packaged source image datasets
Image Dataset - Sample inputs · Local example images for trial runs
testimage
Connections 15
- GUI driver → UI code: boots UI · The desktop entry point initializes the generated Qt interface
- UI form → UI code: mirrors · The UI form is mirrored into Python code
- GUI driver → Image pipeline: send image · Selected leaf images are handed to the processing pipeline
- Image pipeline → Color convert: convert · Pipeline first normalizes color space for analysis
- Color convert → Mask & segment: mask · Converted image is used for healthy-region masking and diseased-region isolation
- Mask & segment → Feature vector: extract · Segmented candidate regions are transformed into numeric features
- Feature vector → SVM model: infer · Feature vectors are classified by the SVM boundary
- SVM model → GUI driver: result · Final healthy/infected decision is returned to the UI
- Feature data → SVM model: train/validate · Structured feature data underpins the classifier model
- Mix sampler → Feature data: builds · Mixed-collection sampler writes dataset rows
- Single sampler → Feature data: builds · Single-category sampler contributes dataset rows
- Image archives → Mix sampler: source · Packaged archives provide input images for dataset generation
- Image archives → Single sampler: source · Packaged archives provide input images for dataset generation
- Sample inputs → Image pipeline: input · Local sample images can be analyzed through the main pipeline
- Package setup → Dependencies: installs · Package setup depends on project requirements