# gioaprilino/grape-leaf-disesase-detection architecture

> Architecture diagram of the GitHub repository gioaprilino/grape-leaf-disesase-detection, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/gioaprilino/grape-leaf-disesase-detection
- Repository: https://github.com/gioaprilino/grape-leaf-disesase-detection

## Overview

This repository is a grape-leaf disease classifier with two main workflows: users upload an image for preprocessing, feature extraction, validation and KNN prediction; researchers build a labeled feature dataset, tune the classifier and evaluate results. The UI also presents confidence, class probabilities, feature plots and contour-related information. The graph includes the documented training and validation capabilities, but some app internals are omitted from the excerpts, so those links rely on README statements rather than claims about unseen calls.

Main entry points: [`app.py`](https://github.com/gioaprilino/grape-leaf-disesase-detection/blob/main/app.py) (Streamlit App), [`run_pipeline.py`](https://github.com/gioaprilino/grape-leaf-disesase-detection/blob/main/run_pipeline.py) (Training Pipeline), [`src/train.py`](https://github.com/gioaprilino/grape-leaf-disesase-detection/blob/main/src/train.py) (Feature Dataset Builder), [`src/features.py`](https://github.com/gioaprilino/grape-leaf-disesase-detection/blob/main/src/features.py) (Feature Extraction)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_inference["Image Detection"]
  node_app["Streamlit App<br/>[app.py]"]
  node_preprocess["Image Preprocessing<br/>[preprocess.py]"]
  node_features["Feature Extraction<br/>[features.py]"]
  node_validation["Leaf Validation<br/>[app.py]"]
  node_classifier[("Trained KNN<br/>[knn_td_model.pkl]")]
  node_results_ui["Prediction Results<br/>[app.py]"]
end

subgraph group_modeling["Model Training"]
  node_pipeline["Training Pipeline<br/>[run_pipeline.py]"]
  node_dataset_builder["Feature Dataset Builder<br/>[train.py]"]
  node_knn_training["KNN Tuning<br/>[train.py]"]
  node_model_artifact[("Saved Model<br/>[knn_td_model.pkl]")]
end

subgraph group_evaluation["Evaluation"]
  node_evaluation["Model Evaluation<br/>[evaluate.py]"]
  node_reports["Metrics and Plots"]
end

node_farmer(("Image Uploader"))
node_dataset[("Labeled Images")]

node_farmer -->|"uploads image"| node_app
node_app -->|"preprocesses image"| node_preprocess
node_app -->|"extracts features"| node_features
node_features -->|"builds contour mask"| node_preprocess
node_app -->|"validates leaf"| node_validation
node_app -->|"predicts class"| node_classifier
node_app -->|"displays prediction"| node_results_ui
node_dataset -->|"provides images"| node_pipeline
node_pipeline -->|"builds features"| node_dataset_builder
node_dataset_builder -->|"loads and preprocesses"| node_preprocess
node_dataset_builder -->|"extracts features"| node_features
node_pipeline -->|"trains classifier"| node_knn_training
node_knn_training -->|"saves model"| node_model_artifact
node_pipeline -->|"evaluates model"| node_evaluation
node_evaluation -->|"writes reports"| node_reports

click node_app "https://github.com/gioaprilino/grape-leaf-disesase-detection/blob/main/app.py"
click node_preprocess "https://github.com/gioaprilino/grape-leaf-disesase-detection/blob/main/src/preprocess.py"
click node_features "https://github.com/gioaprilino/grape-leaf-disesase-detection/blob/main/src/features.py"
click node_validation "https://github.com/gioaprilino/grape-leaf-disesase-detection/blob/main/app.py"
click node_classifier "https://github.com/gioaprilino/grape-leaf-disesase-detection/blob/main/models/knn_td_model.pkl"
click node_results_ui "https://github.com/gioaprilino/grape-leaf-disesase-detection/blob/main/app.py"
click node_pipeline "https://github.com/gioaprilino/grape-leaf-disesase-detection/blob/main/run_pipeline.py"
click node_dataset_builder "https://github.com/gioaprilino/grape-leaf-disesase-detection/blob/main/src/train.py"
click node_knn_training "https://github.com/gioaprilino/grape-leaf-disesase-detection/blob/main/src/train.py"
click node_model_artifact "https://github.com/gioaprilino/grape-leaf-disesase-detection/blob/main/models/knn_td_model.pkl"
click node_evaluation "https://github.com/gioaprilino/grape-leaf-disesase-detection/blob/main/src/evaluate.py"
click node_reports "https://github.com/gioaprilino/grape-leaf-disesase-detection/tree/main/results"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app,node_preprocess,node_features,node_validation,node_classifier,node_results_ui toneBlue
class node_pipeline,node_dataset_builder,node_knn_training,node_model_artifact,node_dataset toneAmber
class node_evaluation,node_reports toneMint
class node_farmer toneIndigo
```

## Components

### Image Detection

- [Streamlit App](https://github.com/gioaprilino/grape-leaf-disesase-detection/blob/main/app.py): `app.py`
- [Image Preprocessing](https://github.com/gioaprilino/grape-leaf-disesase-detection/blob/main/src/preprocess.py): `src/preprocess.py`
- [Feature Extraction](https://github.com/gioaprilino/grape-leaf-disesase-detection/blob/main/src/features.py): `src/features.py`
- [Leaf Validation](https://github.com/gioaprilino/grape-leaf-disesase-detection/blob/main/app.py): `app.py`
- [Trained KNN](https://github.com/gioaprilino/grape-leaf-disesase-detection/blob/main/models/knn_td_model.pkl): `models/knn_td_model.pkl`
- [Prediction Results](https://github.com/gioaprilino/grape-leaf-disesase-detection/blob/main/app.py): `app.py`

### Model Training

- [Training Pipeline](https://github.com/gioaprilino/grape-leaf-disesase-detection/blob/main/run_pipeline.py): `run_pipeline.py`
- [Feature Dataset Builder](https://github.com/gioaprilino/grape-leaf-disesase-detection/blob/main/src/train.py): `src/train.py`
- [KNN Tuning](https://github.com/gioaprilino/grape-leaf-disesase-detection/blob/main/src/train.py): `src/train.py`
- [Saved Model](https://github.com/gioaprilino/grape-leaf-disesase-detection/blob/main/models/knn_td_model.pkl): `models/knn_td_model.pkl`

### Evaluation

- [Model Evaluation](https://github.com/gioaprilino/grape-leaf-disesase-detection/blob/main/src/evaluate.py): `src/evaluate.py`
- [Metrics and Plots](https://github.com/gioaprilino/grape-leaf-disesase-detection/tree/main/results): `results`

### Other components

- **Image Uploader**
- **Labeled Images**

## Connections

- Image Uploader → Streamlit App: uploads image (evidence: `README.md`)
- Streamlit App → Image Preprocessing: preprocesses image (evidence: `README.md`)
- Streamlit App → Feature Extraction: extracts features (evidence: `README.md`)
- Feature Extraction → Image Preprocessing: builds contour mask (evidence: `src/features.py`)
- Streamlit App → Leaf Validation: validates leaf (evidence: `README.md`)
- Streamlit App → Trained KNN: predicts class (evidence: `README.md`)
- Streamlit App → Prediction Results: displays prediction (evidence: `README.md`)
- Labeled Images → Training Pipeline: provides images (evidence: `README.md`)
- Training Pipeline → Feature Dataset Builder: builds features (evidence: `run_pipeline.py`)
- Feature Dataset Builder → Image Preprocessing: loads and preprocesses (evidence: `src/train.py`)
- Feature Dataset Builder → Feature Extraction: extracts features (evidence: `src/train.py`)
- Training Pipeline → KNN Tuning: trains classifier (evidence: `run_pipeline.py`)
- KNN Tuning → Saved Model: saves model
- Training Pipeline → Model Evaluation: evaluates model (evidence: `run_pipeline.py`)
- Model Evaluation → Metrics and Plots: writes reports (evidence: `src/evaluate.py`)
