# anandchauhan21/pomegranate_disease_prediction architecture

> Architecture diagram of the GitHub repository anandchauhan21/pomegranate_disease_prediction, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-02-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/anandchauhan21/pomegranate_disease_prediction
- Repository: https://github.com/anandchauhan21/pomegranate_disease_prediction

## Overview

##### Project type & purpose (from README + tree)
This is not a traditional “application repo” (no `src/`, no service code). It’s a **research / ML prototype** organized as **Jupyter notebooks** that:
- Trains **CNN image classification models** (TensorFlow) for:
1) **Pomegranate fruit disease prediction**
2) **Pomegranate leaf disease prediction**
- Runs **inference/prediction notebooks** that likely:
- Load a trained model
- Preprocess an input image (OpenCV)
- Predict a disease class
- Class to a **solution/recommendation**
- Appears to be intended for **Google Colab** usage (badge).

##### What the file tree implies about architecture
Top-level artifacts are notebooks only:

- `pomodetectCreateModel_1.ipynb` — **training pipeline for fruit**
- `pomodetectPredict.ipynb` — **inference pipeline for fruit**
- `LeafdetectCreateModel.ipynb` — **training pipeline for leaf**
- `LeafdetectPredict.ipynb` — **inference pipeline for leaf**
- `Tcp_spi.ipynb` — ambiguous; could be:
- hardware integration experiment (TCP/SPI), edge/IoT capture pipeline, or data transfer
- `LICENSE`, `README.md`

This suggests **two parallel model tracks** (fruit + leaf), each with a create/train notebook and a predict notebook.

##### What the README adds (stack & behavior)
Key technologies:
- **TensorFlow** (model definition/training/inference)
- **OpenCV** (image I/O + preprocessing)
- **Colab** (execution environment)

Key functional requirements:
- Disease classification from image
- Provide “corresponding solutions” for each disease (so there’s a **label → recommendation mapping** layer in inference)

##### “Don’t overthink it”: maximize component separation (specific to this repo)
- “Load dataset” separate from “Preprocess”
- “Define model” separate from “Train”
- “Evaluate” separate from “Export”
- “Load model” separate from “Predict”
- “Predict” separate from “Recommendation mapping”

This gives the most faithful architecture view despite the absence of modular source code.

## Diagram (Mermaid)

```mermaid
flowchart TD

%% =========================
%% Shared / External Actors
%% =========================
U["User / Researcher"]:::external
IMG["Input Image (Fruit or Leaf)"]:::external
EDGE["Edge Device / Camera (optional)"]:::optional

%% =========================
%% Execution Environment
%% =========================
subgraph "Execution Environment"
  COLAB["Google Colab / Jupyter Notebook Runtime"]:::runtime
end

%% =========================
%% Shared Data & Artifacts
%% =========================
subgraph "Shared Data & Artifacts"
  REC[("Disease -> Solution\nMapping Table")]:::datastore
  MODEL_STORE[("Model Artifact Storage\n(Google Drive / Colab FS)")]:::datastore
  META[("Training Metadata\n(metrics/version/date)")]:::datastore
end

%% =========================
%% Shared Processing Building Blocks
%% =========================
subgraph "Shared Processing Building Blocks"
  PREP["Image Preprocessing (OpenCV)\n- Load/Decode\n- Resize/Normalize\n- (Optional) Augmentation"]:::process
  TF["TensorFlow / Keras Runtime"]:::process
end

COLAB -->|"runs_notebooks"| TF
COLAB -->|"runs_notebooks"| PREP

%% =========================
%% Fruit Track (Train + Inference)
%% =========================
subgraph "Fruit Model Track (Pomegranate Fruit Disease)"
  direction TB

  FRUIT_DS[("Fruit Image Dataset")]:::datastore
  FRUIT_LABELS[("Disease Labels / Class Annotations")]:::datastore
  FRUIT_SPLIT["Train/Val/Test Split"]:::process

  subgraph "Training Pipeline (Fruit)"
    direction TB
    F_LOAD["Load Fruit Dataset"]:::train
    F_PREP_T["Preprocess & Augment (OpenCV)"]:::train
    F_DEF["Define CNN Architecture (TensorFlow/Keras)"]:::train
    F_TRAIN["Train Model (fit/epochs/optimizer)"]:::train
    F_EVAL["Evaluate (metrics/confusion matrix)"]:::train
    F_EXPORT["Export Artifacts\n- SavedModel/.h5\n- Class index mapping"]:::train
  end

  subgraph "Inference Pipeline (Fruit)"
    direction TB
    F_INPUT["Acquire Fruit Image\n(upload/path)"]:::infer
    F_PREP_I["Preprocess (OpenCV)\n(match training)"]:::infer
    F_LOAD_M["Load Fruit Model Artifact"]:::infer
    F_PRED["Predict (softmax -> top class)"]:::infer
    F_POST["Post-process\n- Disease label\n- Confidence score"]:::infer
    F_REC["Recommendation Lookup\n(label -> solution)"]:::infer
    F_OUT["Output\nPredicted disease + recommended action"]:::output
  end
end

%% Fruit training flow
FRUIT_DS -->|"images"| F_LOAD
FRUIT_LABELS -->|"classes"| F_LOAD
F_LOAD -->|"prepare"| FRUIT_SPLIT
FRUIT_SPLIT -->|"train_batches"| F_PREP_T
F_PREP_T -->|"tensors"| F_DEF
F_DEF -->|"model_graph"| F_TRAIN
F_TRAIN -->|"trained_weights"| F_EVAL
F_EVAL -->|"approved"| F_EXPORT
F_EXPORT -->|"weights+mapping"| MODEL_STORE
F_EVAL -->|"metrics"| META

%% Fruit inference flow
U -->|"provides"| IMG
IMG -->|"fruit_image"| F_INPUT
F_INPUT -->|"image"| F_PREP_I
F_PREP_I -->|"tensor"| F_LOAD_M
MODEL_STORE -->|"fruit_model+class_map"| F_LOAD_M
F_LOAD_M -->|"model"| F_PRED
F_PRED -->|"class_id"| F_POST
F_POST -->|"label"| F_REC
REC -->|"solutions"| F_REC
F_REC -->|"result"| F_OUT

%% =========================
%% Leaf Track (Train + Inference)
%% =========================
subgraph "Leaf Model Track (Pomegranate Leaf Disease)"
  direction TB

  LEAF_DS[("Leaf Image Dataset")]:::datastore
  LEAF_LABELS[("Disease Labels / Class Annotations")]:::datastore
  LEAF_SPLIT["Train/Val/Test Split"]:::process

  subgraph "Training Pipeline (Leaf)"
    direction TB
    L_LOAD["Load Leaf Dataset"]:::train
    L_PREP_T["Preprocess & Augment (OpenCV)"]:::train
    L_DEF["Define CNN Architecture (TensorFlow/Keras)"]:::train
    L_TRAIN["Train Model (fit/epochs/optimizer)"]:::train
    L_EVAL["Evaluate (metrics/confusion matrix)"]:::train
    L_EXPORT["Export Artifacts\n- SavedModel/.h5\n- Class index mapping"]:::train
  end

  subgraph "Inference Pipeline (Leaf)"
    direction TB
    L_INPUT["Acquire Leaf Image\n(upload/path)"]:::infer
    L_PREP_I["Preprocess (OpenCV)\n(match training)"]:::infer
    L_LOAD_M["Load Leaf Model Artifact"]:::infer
    L_PRED["Predict (softmax -> top class)"]:::infer
    L_POST["Post-process\n- Disease label\n- Confidence score"]:::infer
    L_REC["Recommendation Lookup\n(label -> solution)"]:::infer
    L_OUT["Output\nPredicted disease + recommended action"]:::output
  end
end

%% Leaf training flow
LEAF_DS -->|"images"| L_LOAD
LEAF_LABELS -->|"classes"| L_LOAD
L_LOAD -->|"prepare"| LEAF_SPLIT
LEAF_SPLIT -->|"train_batches"| L_PREP_T
L_PREP_T -->|"tensors"| L_DEF
L_DEF -->|"model_graph"| L_TRAIN
L_TRAIN -->|"trained_weights"| L_EVAL
L_EVAL -->|"approved"| L_EXPORT
L_EXPORT -->|"weights+mapping"| MODEL_STORE
L_EVAL -->|"metrics"| META

%% Leaf inference flow
IMG -->|"leaf_image"| L_INPUT
L_INPUT -->|"image"| L_PREP_I
L_PREP_I -->|"tensor"| L_LOAD_M
MODEL_STORE -->|"leaf_model+class_map"| L_LOAD_M
L_LOAD_M -->|"model"| L_PRED
L_PRED -->|"class_id"| L_POST
L_POST -->|"label"| L_REC
REC -->|"solutions"| L_REC
L_REC -->|"result"| L_OUT

%% =========================
%% Optional / Experimental Integration (Tcp_spi)
%% =========================
subgraph "Optional / Experimental Integration"
  direction TB
  TCP_SPI["TCP/SPI Integration Notebook\n(image transfer / capture experiment)"]:::optional
  LINK["TCP Link / SPI Bus (conceptual)"]:::optional
end

EDGE -.->|"captures"| LINK
LINK -.->|"streams/transfers"| TCP_SPI
TCP_SPI -.->|"provides_image"| IMG

%% =========================
%% Notebook-to-Component Mapping (Repo)
%% =========================
subgraph "Repository Notebooks & Docs (File-Level Map)"
  direction TB
  NB_F_TRAIN["pomodetectCreateModel_1.ipynb\n(Fruit training)"]:::notebook
  NB_F_PRED["pomodetectPredict.ipynb\n(Fruit inference)"]:::notebook
  NB_L_TRAIN["LeafdetectCreateModel.ipynb\n(Leaf training)"]:::notebook
  NB_L_PRED["LeafdetectPredict.ipynb\n(Leaf inference)"]:::notebook
  NB_TCP["Tcp_spi.ipynb\n(Optional integration)"]:::notebook
  DOC_README["README.md\n(Workflow/usage)"]:::doc
  DOC_LICENSE["LICENSE"]:::doc
end

COLAB -->|"executes"| NB_F_TRAIN
COLAB -->|"executes"| NB_F_PRED
COLAB -->|"executes"| NB_L_TRAIN
COLAB -->|"executes"| NB_L_PRED
COLAB -->|"executes"| NB_TCP

NB_F_TRAIN -->|"implements"| F_LOAD
NB_F_TRAIN -->|"implements"| F_TRAIN
NB_F_TRAIN -->|"produces"| MODEL_STORE

NB_F_PRED -->|"implements"| F_INPUT
NB_F_PRED -->|"implements"| F_PRED
NB_F_PRED -->|"uses"| MODEL_STORE
NB_F_PRED -->|"uses"| REC

NB_L_TRAIN -->|"implements"| L_LOAD
NB_L_TRAIN -->|"implements"| L_TRAIN
NB_L_TRAIN -->|"produces"| MODEL_STORE

NB_L_PRED -->|"implements"| L_INPUT
NB_L_PRED -->|"implements"| L_PRED
NB_L_PRED -->|"uses"| MODEL_STORE
NB_L_PRED -->|"uses"| REC

NB_TCP -.->|"implements"| TCP_SPI

DOC_README -->|"describes"| NB_F_TRAIN
DOC_README -->|"describes"| NB_F_PRED
DOC_README -->|"describes"| NB_L_TRAIN
DOC_README -->|"describes"| NB_L_PRED
DOC_LICENSE -->|"governs"| DOC_README

%% =========================
%% Click Events (mapped paths)
%% =========================
click COLAB "https://github.com/anandchauhan21/pomegranate_disease_prediction/blob/main/LeafdetectCreateModel.ipynb"
click NB_L_TRAIN "https://github.com/anandchauhan21/pomegranate_disease_prediction/blob/main/LeafdetectCreateModel.ipynb"
click NB_L_PRED "https://github.com/anandchauhan21/pomegranate_disease_prediction/blob/main/LeafdetectPredict.ipynb"
click NB_F_TRAIN "https://github.com/anandchauhan21/pomegranate_disease_prediction/blob/main/pomodetectCreateModel_1.ipynb"
click NB_F_PRED "https://github.com/anandchauhan21/pomegranate_disease_prediction/blob/main/pomodetectPredict.ipynb"
click NB_TCP "https://github.com/anandchauhan21/pomegranate_disease_prediction/blob/main/Tcp_spi.ipynb"
click TCP_SPI "https://github.com/anandchauhan21/pomegranate_disease_prediction/blob/main/Tcp_spi.ipynb"
click DOC_README "https://github.com/anandchauhan21/pomegranate_disease_prediction/blob/main/README.md"
click DOC_LICENSE "https://github.com/anandchauhan21/pomegranate_disease_prediction/tree/main/LICENSE"

%% =========================
%% Styles (color is critical)
%% =========================
classDef runtime fill:#E6F0FF,stroke:#2B6CB0,stroke-width:2px,color:#0B1F44
classDef process fill:#EEF2F6,stroke:#4A5568,stroke-width:1.5px,color:#1A202C
classDef datastore fill:#FFF4E6,stroke:#C05621,stroke-width:2px,color:#3B1D0F
classDef train fill:#E8F1FF,stroke:#2C5282,stroke-width:2px,color:#102A43
classDef infer fill:#E7FAF0,stroke:#2F855A,stroke-width:2px,color:#0F2F1E
classDef output fill:#F0FFF4,stroke:#38A169,stroke-width:2.5px,color:#0F2F1E
classDef optional fill:#F7FAFC,stroke:#718096,stroke-width:2px,stroke-dasharray:5 4,color:#2D3748
classDef notebook fill:#FDEFF7,stroke:#B83280,stroke-width:2px,color:#3B0A2A
classDef doc fill:#FFF5F5,stroke:#C53030,stroke-width:2px,color:#3B0A0A
classDef external fill:#FFFFFF,stroke:#2D3748,stroke-width:1.5px,color:#1A202C
```
