# kushalj123/plant-disease-classification-and-synthetic-image-generation architecture

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

- Interactive diagram: https://gitdiagram.com/kushalj123/plant-disease-classification-and-synthetic-image-generation
- Repository: https://github.com/kushalj123/plant-disease-classification-and-synthetic-image-generation

## Overview

This repository is a set of Python scripts for preparing plant-leaf image datasets, training unconditional or class-conditional variational autoencoders, generating synthetic images, and training/evaluating a CNN classifier. The main workflow prepares images, trains a model, then generates images or evaluates disease classification. The README describes synthetic-data augmentation as a capability, but the sampled CNN script reads `data_clean` directly; no connection from generated images into CNN training is evident. Data directories and saved weights are runtime artifacts, not source files.

Main entry points: [`train_cvae.py`](https://github.com/kushalj123/plant-disease-classification-and-synthetic-image-generation/blob/main/train_cvae.py) (Train CVAE), [`train_cvae_conditional.py`](https://github.com/kushalj123/plant-disease-classification-and-synthetic-image-generation/blob/main/train_cvae_conditional.py) (Train conditional CVAE), [`generate_conditional.py`](https://github.com/kushalj123/plant-disease-classification-and-synthetic-image-generation/blob/main/generate_conditional.py) (Generate by class), [`create_dataset.py`](https://github.com/kushalj123/plant-disease-classification-and-synthetic-image-generation/blob/main/create_dataset.py) (Organize classes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_prep["Dataset preparation"]
  node_rawdata["Raw images"]
  node_organize["Organize classes<br/>[create_dataset.py]"]
  node_clean["Clean dataset"]
  node_sample["Select small set<br/>[prepare_small.py]"]
  node_small["Small dataset"]
end

subgraph group_generation["Image generation"]
  node_trainvae["Train CVAE<br/>[train_cvae.py]"]
  node_vae["CVAE architecture<br/>[cvae.py]"]
  node_vaew["CVAE weights"]
  node_generate["Generate images<br/>[generate.py]"]
  node_synthetic["Synthetic images"]
  node_traincond["Train conditional CVAE"]
  node_condvae["Conditional CVAE"]
  node_condw["Conditional weights"]
  node_gencond["Generate by class"]
end

subgraph group_classification["Disease classification"]
  node_cnn["Train and evaluate CNN<br/>[train_cnn.py]"]
  node_metrics["Classification metrics"]
end

node_user(("Project user"))

node_user -->|"runs"| node_organize
node_rawdata -->|"reads"| node_organize
node_organize -->|"copies classes"| node_clean
node_user -->|"runs"| node_sample
node_clean -->|"samples images"| node_sample
node_sample -->|"copies subset"| node_small
node_user -->|"runs"| node_trainvae
node_small -->|"loads images"| node_trainvae
node_trainvae -->|"uses"| node_vae
node_trainvae -->|"saves weights"| node_vaew
node_user -->|"runs"| node_generate
node_vaew -->|"loads weights"| node_generate
node_generate -->|"saves images"| node_synthetic
node_user -->|"runs"| node_traincond
node_small -->|"loads labeled images"| node_traincond
node_traincond -->|"uses"| node_condvae
node_traincond -->|"saves weights"| node_condw
node_user -->|"runs"| node_gencond
node_condw -->|"loads weights"| node_gencond
node_small -->|"reads class names"| node_gencond
node_gencond -->|"saves by class"| node_synthetic
node_user -->|"runs"| node_cnn
node_clean -->|"loads train and test"| node_cnn
node_cnn -->|"reports"| node_metrics

click node_organize "https://github.com/kushalj123/plant-disease-classification-and-synthetic-image-generation/blob/main/create_dataset.py"
click node_sample "https://github.com/kushalj123/plant-disease-classification-and-synthetic-image-generation/blob/main/prepare_small.py"
click node_trainvae "https://github.com/kushalj123/plant-disease-classification-and-synthetic-image-generation/blob/main/train_cvae.py"
click node_vae "https://github.com/kushalj123/plant-disease-classification-and-synthetic-image-generation/blob/main/cvae.py"
click node_generate "https://github.com/kushalj123/plant-disease-classification-and-synthetic-image-generation/blob/main/generate.py"
click node_traincond "https://github.com/kushalj123/plant-disease-classification-and-synthetic-image-generation/blob/main/train_cvae_conditional.py"
click node_condvae "https://github.com/kushalj123/plant-disease-classification-and-synthetic-image-generation/blob/main/cvae_conditional.py"
click node_gencond "https://github.com/kushalj123/plant-disease-classification-and-synthetic-image-generation/blob/main/generate_conditional.py"
click node_cnn "https://github.com/kushalj123/plant-disease-classification-and-synthetic-image-generation/blob/main/train_cnn.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_rawdata,node_organize,node_clean,node_sample,node_small,node_user toneBlue
class node_trainvae,node_vae,node_vaew,node_generate,node_synthetic,node_traincond,node_condvae,node_condw,node_gencond toneAmber
class node_cnn,node_metrics toneMint
```

## Components

### Dataset preparation

- **Raw images**
- [Organize classes](https://github.com/kushalj123/plant-disease-classification-and-synthetic-image-generation/blob/main/create_dataset.py): `create_dataset.py`
- **Clean dataset**
- [Select small set](https://github.com/kushalj123/plant-disease-classification-and-synthetic-image-generation/blob/main/prepare_small.py): `prepare_small.py`
- **Small dataset**

### Image generation

- [Train CVAE](https://github.com/kushalj123/plant-disease-classification-and-synthetic-image-generation/blob/main/train_cvae.py): `train_cvae.py`
- [CVAE architecture](https://github.com/kushalj123/plant-disease-classification-and-synthetic-image-generation/blob/main/cvae.py): `cvae.py`
- **CVAE weights**
- [Generate images](https://github.com/kushalj123/plant-disease-classification-and-synthetic-image-generation/blob/main/generate.py): `generate.py`
- **Synthetic images**
- [Train conditional CVAE](https://github.com/kushalj123/plant-disease-classification-and-synthetic-image-generation/blob/main/train_cvae_conditional.py): `train_cvae_conditional.py`
- [Conditional CVAE](https://github.com/kushalj123/plant-disease-classification-and-synthetic-image-generation/blob/main/cvae_conditional.py): `cvae_conditional.py`
- **Conditional weights**
- [Generate by class](https://github.com/kushalj123/plant-disease-classification-and-synthetic-image-generation/blob/main/generate_conditional.py): `generate_conditional.py`

### Disease classification

- [Train and evaluate CNN](https://github.com/kushalj123/plant-disease-classification-and-synthetic-image-generation/blob/main/train_cnn.py): `train_cnn.py`
- **Classification metrics**

### Other components

- **Project user**

## Connections

- Project user → Organize classes: runs
- Raw images → Organize classes: reads
- Organize classes → Clean dataset: copies classes
- Project user → Select small set: runs
- Clean dataset → Select small set: samples images
- Select small set → Small dataset: copies subset
- Project user → Train CVAE: runs
- Small dataset → Train CVAE: loads images
- Train CVAE → CVAE architecture: uses
- Train CVAE → CVAE weights: saves weights
- Project user → Generate images: runs
- CVAE weights → Generate images: loads weights
- Generate images → Synthetic images: saves images
- Project user → Train conditional CVAE: runs
- Small dataset → Train conditional CVAE: loads labeled images
- Train conditional CVAE → Conditional CVAE: uses
- Train conditional CVAE → Conditional weights: saves weights
- Project user → Generate by class: runs
- Conditional weights → Generate by class: loads weights
- Small dataset → Generate by class: reads class names
- Generate by class → Synthetic images: saves by class
- Project user → Train and evaluate CNN: runs
- Clean dataset → Train and evaluate CNN: loads train and test
- Train and evaluate CNN → Classification metrics: reports
