# saadtechie/plant-disease-detection architecture

> Architecture diagram of the GitHub repository saadtechie/plant-disease-detection, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/saadtechie/plant-disease-detection
- Repository: https://github.com/saadtechie/plant-disease-detection

## Overview

This repository is a plant-leaf disease classifier. Its documented workflow downloads and organizes image data, trains an augmented CNN, then serves predictions through a Gradio interface. The sampled code also includes a separate image-prediction script and a directory-setup helper. The README documents the broader pipeline; the graph’s links reflect only relationships visible in the README or sampled source, so it does not assume unsampled orchestration.

Main entry points: [`demonstration.py`](https://github.com/saadtechie/plant-disease-detection/blob/main/demonstration.py) (Image preprocessing and prediction), [`repartition.py`](https://github.com/saadtechie/plant-disease-detection/blob/main/repartition.py) (Train/val/test split), [`train_model_aug.py`](https://github.com/saadtechie/plant-disease-detection/blob/main/train_model_aug.py) (Augmented CNN training), [`download_with_token.py`](https://github.com/saadtechie/plant-disease-detection/blob/main/download_with_token.py) (Dataset download)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Data preparation"]
  node_download["Dataset download"]
  node_raw[("Raw images")]
  node_organize["Class directories<br/>[classement.py]"]
  node_split["Train/val/test split<br/>[repartition.py]"]
  node_processed[("Processed images")]
end

subgraph group_training["Model training"]
  node_trainer["Augmented CNN training<br/>[train_model_aug.py]"]
  node_model[("Trained CNN")]
end

subgraph group_inference["Diagnosis"]
  node_gradio["Gradio interface<br/>[demonstration.py]"]
  node_webpredict["Image preprocessing and prediction<br/>[demonstration.py]"]
  node_standalone["Standalone prediction<br/>[predict_aug.py]"]
end

node_user(("User"))
node_kaggle{{"Kaggle dataset"}}

node_user -->|"uploads leaf image"| node_gradio
node_gradio -->|"dispatches prediction"| node_webpredict
node_webpredict -->|"loads and predicts"| node_model
node_webpredict -->|"returns class scores"| node_user
node_user -->|"runs image prediction"| node_standalone
node_standalone -->|"loads and predicts"| node_model
node_kaggle -->|"provides dataset"| node_download
node_download -->|"downloads images"| node_raw
node_organize -->|"creates class folders"| node_processed
node_split -->|"moves images from"| node_raw
node_split -->|"writes image splits"| node_processed
node_trainer -->|"loads train and validation"| node_processed
node_trainer -->|"saves best checkpoint"| node_model

click node_download "https://github.com/saadtechie/plant-disease-detection/blob/main/download_with_token.py"
click node_organize "https://github.com/saadtechie/plant-disease-detection/blob/main/classement.py"
click node_split "https://github.com/saadtechie/plant-disease-detection/blob/main/repartition.py"
click node_trainer "https://github.com/saadtechie/plant-disease-detection/blob/main/train_model_aug.py"
click node_gradio "https://github.com/saadtechie/plant-disease-detection/blob/main/demonstration.py"
click node_webpredict "https://github.com/saadtechie/plant-disease-detection/blob/main/demonstration.py"
click node_standalone "https://github.com/saadtechie/plant-disease-detection/blob/main/predict_aug.py"

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_download,node_raw,node_organize,node_split,node_processed,node_user toneBlue
class node_trainer,node_model toneAmber
class node_gradio,node_webpredict,node_standalone toneMint
class node_kaggle toneIndigo
```

## Components

### Data preparation

- [Dataset download](https://github.com/saadtechie/plant-disease-detection/blob/main/download_with_token.py): `download_with_token.py`
- **Raw images**
- [Class directories](https://github.com/saadtechie/plant-disease-detection/blob/main/classement.py): `classement.py`
- [Train/val/test split](https://github.com/saadtechie/plant-disease-detection/blob/main/repartition.py): `repartition.py`
- **Processed images**

### Model training

- [Augmented CNN training](https://github.com/saadtechie/plant-disease-detection/blob/main/train_model_aug.py): `train_model_aug.py`
- **Trained CNN**

### Diagnosis

- [Gradio interface](https://github.com/saadtechie/plant-disease-detection/blob/main/demonstration.py): `demonstration.py`
- [Image preprocessing and prediction](https://github.com/saadtechie/plant-disease-detection/blob/main/demonstration.py): `demonstration.py`
- [Standalone prediction](https://github.com/saadtechie/plant-disease-detection/blob/main/predict_aug.py): `predict_aug.py`

### Other components

- **User**
- **Kaggle dataset**

## Connections

- User → Gradio interface: uploads leaf image (evidence: `demonstration.py`)
- Gradio interface → Image preprocessing and prediction: dispatches prediction (evidence: `demonstration.py`)
- Image preprocessing and prediction → Trained CNN: loads and predicts (evidence: `demonstration.py`)
- Image preprocessing and prediction → User: returns class scores (evidence: `demonstration.py`)
- User → Standalone prediction: runs image prediction (evidence: `predict_aug.py`)
- Standalone prediction → Trained CNN: loads and predicts (evidence: `predict_aug.py`)
- Kaggle dataset → Dataset download: provides dataset (evidence: `download_with_token.py`)
- Dataset download → Raw images: downloads images (evidence: `download_with_token.py`)
- Class directories → Processed images: creates class folders (evidence: `classement.py`)
- Train/val/test split → Raw images: moves images from (evidence: `repartition.py`)
- Train/val/test split → Processed images: writes image splits (evidence: `repartition.py`)
- Augmented CNN training → Processed images: loads train and validation (evidence: `train_model_aug.py`)
- Augmented CNN training → Trained CNN: saves best checkpoint (evidence: `train_model_aug.py`)
