# ramsharma144/fruit_image_classifier architecture

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

- Interactive diagram: https://gitdiagram.com/ramsharma144/fruit_image_classifier
- Repository: https://github.com/ramsharma144/fruit_image_classifier

## Overview

This repository is a command-line fruit-image classifier. Its main workflows are training a CNN from a directory-organized image dataset and predicting a fruit label from one image using the saved model and class names. The training script also produces accuracy/loss plots and validation classification metrics, including a confusion matrix. The graph follows the sampled scripts and README; artifact locations are represented by their existing repository directories, not assumed generated files.

Main entry points: [`src/train_model.py`](https://github.com/ramsharma144/fruit_image_classifier/blob/main/src/train_model.py) (Train command), [`src/predict_fruit.py`](https://github.com/ramsharma144/fruit_image_classifier/blob/main/src/predict_fruit.py) (Predict command), [`models/class_names.json`](https://github.com/ramsharma144/fruit_image_classifier/blob/main/models/class_names.json) (Class names), [`models/.gitkeep`](https://github.com/ramsharma144/fruit_image_classifier/blob/main/models/.gitkeep) (Saved model)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_training["Model training"]
  node_train_command["Train command<br/>[train_model.py]"]
  node_image_dataset["Fruit images<br/>[.gitkeep]"]
  node_dataset_split["Dataset split<br/>[train_model.py]"]
  node_cnn["CNN and augmentation<br/>[train_model.py]"]
  node_fit["Model fitting<br/>[train_model.py]"]
  node_evaluation["Validation evaluation<br/>[train_model.py]"]
end

subgraph group_artifacts["Model artifacts"]
  node_model_artifact["Saved model<br/>[.gitkeep]"]
  node_class_labels["Class names<br/>[class_names.json]"]
  node_training_outputs["Training plots<br/>[.gitkeep]"]
end

subgraph group_prediction["Image prediction"]
  node_predict_command["Predict command<br/>[predict_fruit.py]"]
  node_image_prep["Image preprocessing<br/>[predict_fruit.py]"]
  node_inference["Model inference<br/>[predict_fruit.py]"]
  node_prediction_result["Label and confidence<br/>[predict_fruit.py]"]
end

node_user(("User"))

node_user -->|"runs"| node_train_command
node_dataset_split -->|"loads and splits"| node_image_dataset
node_train_command -->|"creates"| node_dataset_split
node_train_command -->|"builds"| node_cnn
node_train_command -->|"writes"| node_class_labels
node_train_command -->|"fits"| node_fit
node_fit -->|"trains"| node_cnn
node_train_command -->|"saves"| node_model_artifact
node_train_command -->|"writes plots"| node_training_outputs
node_train_command -->|"evaluates validation"| node_evaluation
node_evaluation -->|"predicts with"| node_cnn
node_user -->|"runs"| node_predict_command
node_predict_command -->|"loads"| node_model_artifact
node_predict_command -->|"loads"| node_class_labels
node_predict_command -->|"prepares image"| node_image_prep
node_predict_command -->|"predicts"| node_inference
node_inference -->|"prints result"| node_prediction_result
node_image_prep -->|"supplies image"| node_inference
node_class_labels -->|"names class"| node_prediction_result

click node_train_command "https://github.com/ramsharma144/fruit_image_classifier/blob/main/src/train_model.py"
click node_image_dataset "https://github.com/ramsharma144/fruit_image_classifier/blob/main/data/fruits/.gitkeep"
click node_dataset_split "https://github.com/ramsharma144/fruit_image_classifier/blob/main/src/train_model.py"
click node_cnn "https://github.com/ramsharma144/fruit_image_classifier/blob/main/src/train_model.py"
click node_fit "https://github.com/ramsharma144/fruit_image_classifier/blob/main/src/train_model.py"
click node_evaluation "https://github.com/ramsharma144/fruit_image_classifier/blob/main/src/train_model.py"
click node_model_artifact "https://github.com/ramsharma144/fruit_image_classifier/blob/main/models/.gitkeep"
click node_class_labels "https://github.com/ramsharma144/fruit_image_classifier/blob/main/models/class_names.json"
click node_training_outputs "https://github.com/ramsharma144/fruit_image_classifier/blob/main/outputs/.gitkeep"
click node_predict_command "https://github.com/ramsharma144/fruit_image_classifier/blob/main/src/predict_fruit.py"
click node_image_prep "https://github.com/ramsharma144/fruit_image_classifier/blob/main/src/predict_fruit.py"
click node_inference "https://github.com/ramsharma144/fruit_image_classifier/blob/main/src/predict_fruit.py"
click node_prediction_result "https://github.com/ramsharma144/fruit_image_classifier/blob/main/src/predict_fruit.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_train_command,node_image_dataset,node_dataset_split,node_cnn,node_fit,node_evaluation,node_user toneBlue
class node_model_artifact,node_class_labels,node_training_outputs toneAmber
class node_predict_command,node_image_prep,node_inference,node_prediction_result toneMint
```

## Components

### Model training

- [Train command](https://github.com/ramsharma144/fruit_image_classifier/blob/main/src/train_model.py): `src/train_model.py`
- [Fruit images](https://github.com/ramsharma144/fruit_image_classifier/blob/main/data/fruits/.gitkeep): `data/fruits/.gitkeep`
- [Dataset split](https://github.com/ramsharma144/fruit_image_classifier/blob/main/src/train_model.py): `src/train_model.py`
- [CNN and augmentation](https://github.com/ramsharma144/fruit_image_classifier/blob/main/src/train_model.py): `src/train_model.py`
- [Model fitting](https://github.com/ramsharma144/fruit_image_classifier/blob/main/src/train_model.py): `src/train_model.py`
- [Validation evaluation](https://github.com/ramsharma144/fruit_image_classifier/blob/main/src/train_model.py): `src/train_model.py`

### Model artifacts

- [Saved model](https://github.com/ramsharma144/fruit_image_classifier/blob/main/models/.gitkeep): `models/.gitkeep`
- [Class names](https://github.com/ramsharma144/fruit_image_classifier/blob/main/models/class_names.json): `models/class_names.json`
- [Training plots](https://github.com/ramsharma144/fruit_image_classifier/blob/main/outputs/.gitkeep): `outputs/.gitkeep`

### Image prediction

- [Predict command](https://github.com/ramsharma144/fruit_image_classifier/blob/main/src/predict_fruit.py): `src/predict_fruit.py`
- [Image preprocessing](https://github.com/ramsharma144/fruit_image_classifier/blob/main/src/predict_fruit.py): `src/predict_fruit.py`
- [Model inference](https://github.com/ramsharma144/fruit_image_classifier/blob/main/src/predict_fruit.py): `src/predict_fruit.py`
- [Label and confidence](https://github.com/ramsharma144/fruit_image_classifier/blob/main/src/predict_fruit.py): `src/predict_fruit.py`

### Other components

- **User**

## Connections

- User → Train command: runs (evidence: `README.md`)
- Dataset split → Fruit images: loads and splits (evidence: `src/train_model.py`)
- Train command → Dataset split: creates (evidence: `src/train_model.py`)
- Train command → CNN and augmentation: builds (evidence: `src/train_model.py`)
- Train command → Class names: writes (evidence: `src/train_model.py`)
- Train command → Model fitting: fits (evidence: `src/train_model.py`)
- Model fitting → CNN and augmentation: trains (evidence: `src/train_model.py`)
- Train command → Saved model: saves (evidence: `src/train_model.py`)
- Train command → Training plots: writes plots (evidence: `src/train_model.py`)
- Train command → Validation evaluation: evaluates validation (evidence: `src/train_model.py`)
- Validation evaluation → CNN and augmentation: predicts with (evidence: `src/train_model.py`)
- User → Predict command: runs (evidence: `README.md`)
- Predict command → Saved model: loads (evidence: `src/predict_fruit.py`)
- Predict command → Class names: loads (evidence: `src/predict_fruit.py`)
- Predict command → Image preprocessing: prepares image (evidence: `src/predict_fruit.py`)
- Predict command → Model inference: predicts (evidence: `src/predict_fruit.py`)
- Model inference → Label and confidence: prints result (evidence: `src/predict_fruit.py`)
- Image preprocessing → Model inference: supplies image (evidence: `src/predict_fruit.py`)
- Class names → Label and confidence: names class (evidence: `src/predict_fruit.py`)
