# shimekano/plant-disease-detection architecture

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

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

## Overview

Plant Disease AI is a Streamlit app for classifying uploaded leaf images and presenting Vietnamese results and educational treatment guidance. The main workflow resizes and normalizes an image, runs the saved 15-class model, maps scores to disease information, and displays the leading prediction plus Top-3 scores. The README also describes a training notebook and the model artifact. Runtime behavior is concentrated in app.py; the notebook’s implementation was not sampled, so its internal training steps are not shown.

Main entry points: [`app.py`](https://github.com/shimekano/plant-disease-detection/blob/main/app.py) (Streamlit upload UI), [`model/best_model.h5`](https://github.com/shimekano/plant-disease-detection/blob/main/model/best_model.h5) (15-class model), [`notebooks/plant_disease_training.ipynb`](https://github.com/shimekano/plant-disease-detection/blob/main/notebooks/plant_disease_training.ipynb) (Training notebook)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["User interface"]
  node_streamlit_ui["Streamlit upload UI<br/>[app.py]"]
  node_image_input["Uploaded leaf image<br/>[app.py]"]
end

subgraph group_inference["Image inference"]
  node_model_loader["Model loader<br/>[app.py]"]
  node_model_artifact["15-class model<br/>[best_model.h5]"]
  node_preprocessing["Image preprocessing<br/>[app.py]"]
  node_classifier["MobileNetV2 inference<br/>[app.py]"]
end

subgraph group_advice["Results and guidance"]
  node_class_mapping["Class name mapping<br/>[app.py]"]
  node_disease_info["Disease information<br/>[app.py]"]
  node_result_view["Prediction and Top-3<br/>[app.py]"]
  node_treatment_view["Treatment and safety guidance<br/>[app.py]"]
end

subgraph group_development["Model development"]
  node_training_notebook["Training notebook"]
end

node_grower(("Grower"))

node_grower -->|"uploads image"| node_streamlit_ui
node_streamlit_ui -->|"receives image"| node_image_input
node_model_loader -->|"loads weights"| node_model_artifact
node_streamlit_ui -->|"loads model"| node_model_loader
node_streamlit_ui -->|"resizes and normalizes"| node_preprocessing
node_streamlit_ui -->|"predicts tensor"| node_classifier
node_classifier -->|"returns scores"| node_class_mapping
node_streamlit_ui -->|"renders prediction"| node_result_view
node_streamlit_ui -->|"renders guidance"| node_treatment_view
node_class_mapping -->|"selects disease details"| node_disease_info
node_training_notebook -.->|"trains model"| node_model_artifact

click node_streamlit_ui "https://github.com/shimekano/plant-disease-detection/blob/main/app.py"
click node_image_input "https://github.com/shimekano/plant-disease-detection/blob/main/app.py"
click node_model_loader "https://github.com/shimekano/plant-disease-detection/blob/main/app.py"
click node_model_artifact "https://github.com/shimekano/plant-disease-detection/blob/main/model/best_model.h5"
click node_preprocessing "https://github.com/shimekano/plant-disease-detection/blob/main/app.py"
click node_classifier "https://github.com/shimekano/plant-disease-detection/blob/main/app.py"
click node_class_mapping "https://github.com/shimekano/plant-disease-detection/blob/main/app.py"
click node_disease_info "https://github.com/shimekano/plant-disease-detection/blob/main/app.py"
click node_result_view "https://github.com/shimekano/plant-disease-detection/blob/main/app.py"
click node_treatment_view "https://github.com/shimekano/plant-disease-detection/blob/main/app.py"
click node_training_notebook "https://github.com/shimekano/plant-disease-detection/blob/main/notebooks/plant_disease_training.ipynb"

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_streamlit_ui,node_image_input toneBlue
class node_model_loader,node_model_artifact,node_preprocessing,node_classifier toneAmber
class node_class_mapping,node_disease_info,node_result_view,node_treatment_view toneMint
class node_training_notebook toneRose
class node_grower toneIndigo
```

## Components

### User interface

- [Streamlit upload UI](https://github.com/shimekano/plant-disease-detection/blob/main/app.py): `app.py`
- [Uploaded leaf image](https://github.com/shimekano/plant-disease-detection/blob/main/app.py): `app.py`

### Image inference

- [Model loader](https://github.com/shimekano/plant-disease-detection/blob/main/app.py): `app.py`
- [15-class model](https://github.com/shimekano/plant-disease-detection/blob/main/model/best_model.h5): `model/best_model.h5`
- [Image preprocessing](https://github.com/shimekano/plant-disease-detection/blob/main/app.py): `app.py`
- [MobileNetV2 inference](https://github.com/shimekano/plant-disease-detection/blob/main/app.py): `app.py`

### Results and guidance

- [Class name mapping](https://github.com/shimekano/plant-disease-detection/blob/main/app.py): `app.py`
- [Disease information](https://github.com/shimekano/plant-disease-detection/blob/main/app.py): `app.py`
- [Prediction and Top-3](https://github.com/shimekano/plant-disease-detection/blob/main/app.py): `app.py`
- [Treatment and safety guidance](https://github.com/shimekano/plant-disease-detection/blob/main/app.py): `app.py`

### Model development

- [Training notebook](https://github.com/shimekano/plant-disease-detection/blob/main/notebooks/plant_disease_training.ipynb): `notebooks/plant_disease_training.ipynb`

### Other components

- **Grower**

## Connections

- Grower → Streamlit upload UI: uploads image
- Streamlit upload UI → Uploaded leaf image: receives image
- Model loader → 15-class model: loads weights
- Streamlit upload UI → Model loader: loads model
- Streamlit upload UI → Image preprocessing: resizes and normalizes
- Streamlit upload UI → MobileNetV2 inference: predicts tensor
- MobileNetV2 inference → Class name mapping: returns scores
- Streamlit upload UI → Prediction and Top-3: renders prediction
- Streamlit upload UI → Treatment and safety guidance: renders guidance
- Class name mapping → Disease information: selects disease details
- Training notebook → 15-class model: trains model
