# spmohanty/plantvillage-dataset architecture

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

- Interactive diagram: https://gitdiagram.com/spmohanty/plantvillage-dataset
- Repository: https://github.com/spmohanty/plantvillage-dataset

## Overview

PlantVillage is a plant-leaf image dataset for disease-diagnosis research. The main user workflow is to load a color, grayscale, or segmented configuration, have the Hugging Face builder obtain the image archive and split metadata, and receive labeled examples enriched with crop, disease, and leaf identifiers. The repository also includes leaf-grouping metadata preparation, documented dataset-generation scripts, and a Hub upload utility. The loader and upload paths are sampled; generation-script wiring is not, so those links are omitted.

Main entry points: [`plant_village.py`](https://github.com/spmohanty/plantvillage-dataset/blob/master/plant_village.py) (Example generation), [`scripts/upload_to_hf.py`](https://github.com/spmohanty/plantvillage-dataset/blob/master/scripts/upload_to_hf.py) (Hub upload utility), [`leaf_grouping/leaf-map.json`](https://github.com/spmohanty/plantvillage-dataset/blob/master/leaf_grouping/leaf-map.json) (Leaf ID map), [`leaf_grouping/aggregate_map.py`](https://github.com/spmohanty/plantvillage-dataset/blob/master/leaf_grouping/aggregate_map.py) (Map aggregation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Dataset access"]
  node_loader["Dataset builder<br/>[plant_village.py]"]
  node_schema["Example schema<br/>[plant_village.py]"]
  node_splitfetch["Split retrieval<br/>[plant_village.py]"]
  node_examples["Example generation<br/>[plant_village.py]"]
  node_images["Leaf images"]
  node_splits["Train/test splits"]
end

subgraph group_metadata["Leaf metadata"]
  node_leafmap["Leaf ID map<br/>[leaf-map.json]"]
  node_mapbuilder["Map aggregation<br/>[aggregate_map.py]"]
  node_filteredmaps["Filtered leaf maps"]
  node_countcsv["Count CSV conversion<br/>[create_map.py]"]
  node_countbooks["Leaf count workbooks"]
end

subgraph group_generation["Dataset operations"]
  node_generators["Dataset generation"]
  node_variants["Image variants"]
  node_uploader["Hub upload utility<br/>[upload_to_hf.py]"]
end

node_researcher(("Dataset user"))
node_hub["Hugging Face Hub"]

node_researcher -->|"loads dataset"| node_loader
node_loader -->|"selects splits"| node_splitfetch
node_loader -->|"downloads archive and metadata"| node_hub
node_splitfetch -->|"downloads split lists"| node_hub
node_splitfetch -->|"provides file lists"| node_examples
node_loader -->|"generates examples"| node_examples
node_examples -->|"reads image paths"| node_images
node_examples -->|"looks up leaf IDs"| node_leafmap
node_examples -->|"yields records"| node_schema
node_countcsv -->|"reads workbooks"| node_countbooks
node_mapbuilder -->|"reads CSV maps"| node_filteredmaps
node_mapbuilder -->|"writes ID map"| node_leafmap
node_generators -.->|"generates variants"| node_variants
node_uploader -->|"archives images"| node_images
node_uploader -->|"uploads metadata"| node_leafmap
node_uploader -->|"uploads dataset files"| node_hub
node_splits -.->|"downloaded split inputs"| node_splitfetch

click node_loader "https://github.com/spmohanty/plantvillage-dataset/blob/master/plant_village.py"
click node_schema "https://github.com/spmohanty/plantvillage-dataset/blob/master/plant_village.py"
click node_splitfetch "https://github.com/spmohanty/plantvillage-dataset/blob/master/plant_village.py"
click node_examples "https://github.com/spmohanty/plantvillage-dataset/blob/master/plant_village.py"
click node_images "https://github.com/spmohanty/plantvillage-dataset/tree/master/raw"
click node_splits "https://github.com/spmohanty/plantvillage-dataset/tree/master/scripts"
click node_leafmap "https://github.com/spmohanty/plantvillage-dataset/blob/master/leaf_grouping/leaf-map.json"
click node_mapbuilder "https://github.com/spmohanty/plantvillage-dataset/blob/master/leaf_grouping/aggregate_map.py"
click node_filteredmaps "https://github.com/spmohanty/plantvillage-dataset/tree/master/leaf_grouping/filtered_leafmaps"
click node_countcsv "https://github.com/spmohanty/plantvillage-dataset/blob/master/leaf_grouping/create_map.py"
click node_countbooks "https://github.com/spmohanty/plantvillage-dataset/tree/master/leaf_grouping/leaf_maps"
click node_generators "https://github.com/spmohanty/plantvillage-dataset/tree/master/scripts"
click node_variants "https://github.com/spmohanty/plantvillage-dataset/tree/master/raw"
click node_uploader "https://github.com/spmohanty/plantvillage-dataset/blob/master/scripts/upload_to_hf.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_loader,node_schema,node_splitfetch,node_examples,node_images,node_splits,node_researcher toneBlue
class node_leafmap,node_mapbuilder,node_filteredmaps,node_countcsv,node_countbooks toneAmber
class node_generators,node_variants,node_uploader toneMint
class node_hub toneIndigo
```

## Components

### Dataset access

- [Dataset builder](https://github.com/spmohanty/plantvillage-dataset/blob/master/plant_village.py): `plant_village.py`
- [Example schema](https://github.com/spmohanty/plantvillage-dataset/blob/master/plant_village.py): `plant_village.py`
- [Split retrieval](https://github.com/spmohanty/plantvillage-dataset/blob/master/plant_village.py): `plant_village.py`
- [Example generation](https://github.com/spmohanty/plantvillage-dataset/blob/master/plant_village.py): `plant_village.py`
- [Leaf images](https://github.com/spmohanty/plantvillage-dataset/tree/master/raw): `raw`
- [Train/test splits](https://github.com/spmohanty/plantvillage-dataset/tree/master/scripts): `scripts`

### Leaf metadata

- [Leaf ID map](https://github.com/spmohanty/plantvillage-dataset/blob/master/leaf_grouping/leaf-map.json): `leaf_grouping/leaf-map.json`
- [Map aggregation](https://github.com/spmohanty/plantvillage-dataset/blob/master/leaf_grouping/aggregate_map.py): `leaf_grouping/aggregate_map.py`
- [Filtered leaf maps](https://github.com/spmohanty/plantvillage-dataset/tree/master/leaf_grouping/filtered_leafmaps): `leaf_grouping/filtered_leafmaps`
- [Count CSV conversion](https://github.com/spmohanty/plantvillage-dataset/blob/master/leaf_grouping/create_map.py): `leaf_grouping/create_map.py`
- [Leaf count workbooks](https://github.com/spmohanty/plantvillage-dataset/tree/master/leaf_grouping/leaf_maps): `leaf_grouping/leaf_maps`

### Dataset operations

- [Dataset generation](https://github.com/spmohanty/plantvillage-dataset/tree/master/scripts): `scripts`
- [Image variants](https://github.com/spmohanty/plantvillage-dataset/tree/master/raw): `raw`
- [Hub upload utility](https://github.com/spmohanty/plantvillage-dataset/blob/master/scripts/upload_to_hf.py): `scripts/upload_to_hf.py`

### Other components

- **Dataset user**
- **Hugging Face Hub**

## Connections

- Dataset user → Dataset builder: loads dataset
- Dataset builder → Split retrieval: selects splits
- Dataset builder → Hugging Face Hub: downloads archive and metadata
- Split retrieval → Hugging Face Hub: downloads split lists
- Split retrieval → Example generation: provides file lists
- Dataset builder → Example generation: generates examples
- Example generation → Leaf images: reads image paths
- Example generation → Leaf ID map: looks up leaf IDs
- Example generation → Example schema: yields records
- Count CSV conversion → Leaf count workbooks: reads workbooks
- Map aggregation → Filtered leaf maps: reads CSV maps
- Map aggregation → Leaf ID map: writes ID map
- Dataset generation → Image variants: generates variants
- Hub upload utility → Leaf images: archives images
- Hub upload utility → Leaf ID map: uploads metadata
- Hub upload utility → Hugging Face Hub: uploads dataset files
- Train/test splits → Split retrieval: downloaded split inputs
