# anjaneyayashwanth/fruit-freshness-yolov8 architecture

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

- Interactive diagram: https://gitdiagram.com/anjaneyayashwanth/fruit-freshness-yolov8
- Repository: https://github.com/anjaneyayashwanth/fruit-freshness-yolov8

## Overview

This is a fruit-freshness classifier that labels images Fresh, Ripe, or Overripe and reports confidence, probabilities, and a freshness score. The main user workflow is image upload in the Streamlit app, image/texture preparation, selected-model inference, and displayed results. Separate scripts support dataset preparation, training and hyperparameter search, and model evaluation. The README documents both dual-stream and 5-channel models. Some listed modules were not excerpted, so their internal behavior and connections are left unspecified.

Main entry points: [`dataset_loader.py`](https://github.com/anjaneyayashwanth/fruit-freshness-yolov8/blob/main/dataset_loader.py) (Split dataset loader), [`app.py`](https://github.com/anjaneyayashwanth/fruit-freshness-yolov8/blob/main/app.py) (Streamlit interface), [`models/dual_stream_model.py`](https://github.com/anjaneyayashwanth/fruit-freshness-yolov8/blob/main/models/dual_stream_model.py) (Dual-stream network), [`train_dual_stream.py`](https://github.com/anjaneyayashwanth/fruit-freshness-yolov8/blob/main/train_dual_stream.py) (Dual-stream training)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Prediction App"]
  node_webapp["Streamlit interface<br/>[app.py]"]
  node_prep["Image preparation<br/>[app.py]"]
  node_inference["Dual-stream inference<br/>[app.py]"]
  node_five_inference["5-channel inference<br/>[app.py]"]
  node_results["Prediction results<br/>[app.py]"]
  node_single_prediction["Single-image prediction<br/>[predict.py]"]
  node_dual_prediction["Dual-stream prediction<br/>[predict_dual.py]"]
  node_webcam["Webcam prediction<br/>[webcam_predict.py]"]
end

subgraph group_data["Data Preparation"]
  node_split["Dataset splitting<br/>[dataset_split.py]"]
  node_preprocessing["Dataset preprocessing<br/>[preprocessing.py]"]
  node_dataset["Split dataset loader<br/>[dataset_loader.py]"]
end

subgraph group_models["Models and Training"]
  node_dual_model["Dual-stream network"]
  node_dual_training["Dual-stream training"]
  node_custom_training["5-channel training<br/>[train_custom.py]"]
  node_yolo_training["5-channel tuning<br/>[gwo_train.py]"]
  node_dual_tuning["Dual-stream tuning<br/>[gwo_dual_train.py]"]
end

subgraph group_evaluation["Evaluation"]
  node_evaluation["Dual-stream evaluation<br/>[evaluate_dual.py]"]
  node_confusion_dual["Dual-stream confusion matrix"]
  node_confusion_five["5-channel confusion matrix"]
end

node_user(("Image uploader"))
node_yolo["Ultralytics YOLO"]

node_user -->|"uploads image"| node_webapp
node_webapp -->|"prepares image"| node_prep
node_webapp -->|"selects model"| node_inference
node_webapp -->|"selects model"| node_five_inference
node_inference -->|"runs model"| node_dual_model
node_webapp -->|"shows prediction"| node_results
node_dual_training -->|"loads samples"| node_dataset
node_dual_training -->|"trains model"| node_dual_model
node_custom_training -->|"loads samples"| node_dataset
node_custom_training -->|"builds model"| node_yolo
node_yolo_training -->|"loads samples"| node_dataset
node_dual_tuning -->|"loads samples"| node_dataset
node_dual_tuning -->|"evaluates parameters"| node_dual_model
node_evaluation -->|"loads test data"| node_dataset
node_evaluation -->|"evaluates model"| node_dual_model
node_confusion_dual -->|"loads test data"| node_dataset
node_confusion_dual -->|"gets predictions"| node_dual_model
node_confusion_five -->|"loads validation data"| node_dataset
node_confusion_five -->|"builds model"| node_yolo

click node_webapp "https://github.com/anjaneyayashwanth/fruit-freshness-yolov8/blob/main/app.py"
click node_prep "https://github.com/anjaneyayashwanth/fruit-freshness-yolov8/blob/main/app.py"
click node_inference "https://github.com/anjaneyayashwanth/fruit-freshness-yolov8/blob/main/app.py"
click node_five_inference "https://github.com/anjaneyayashwanth/fruit-freshness-yolov8/blob/main/app.py"
click node_results "https://github.com/anjaneyayashwanth/fruit-freshness-yolov8/blob/main/app.py"
click node_split "https://github.com/anjaneyayashwanth/fruit-freshness-yolov8/blob/main/dataset_split.py"
click node_preprocessing "https://github.com/anjaneyayashwanth/fruit-freshness-yolov8/blob/main/preprocessing.py"
click node_dataset "https://github.com/anjaneyayashwanth/fruit-freshness-yolov8/blob/main/dataset_loader.py"
click node_dual_model "https://github.com/anjaneyayashwanth/fruit-freshness-yolov8/blob/main/models/dual_stream_model.py"
click node_dual_training "https://github.com/anjaneyayashwanth/fruit-freshness-yolov8/blob/main/train_dual_stream.py"
click node_custom_training "https://github.com/anjaneyayashwanth/fruit-freshness-yolov8/blob/main/train_custom.py"
click node_yolo_training "https://github.com/anjaneyayashwanth/fruit-freshness-yolov8/blob/main/gwo_train.py"
click node_dual_tuning "https://github.com/anjaneyayashwanth/fruit-freshness-yolov8/blob/main/gwo_dual_train.py"
click node_single_prediction "https://github.com/anjaneyayashwanth/fruit-freshness-yolov8/blob/main/predict.py"
click node_dual_prediction "https://github.com/anjaneyayashwanth/fruit-freshness-yolov8/blob/main/predict_dual.py"
click node_webcam "https://github.com/anjaneyayashwanth/fruit-freshness-yolov8/blob/main/webcam_predict.py"
click node_evaluation "https://github.com/anjaneyayashwanth/fruit-freshness-yolov8/blob/main/evaluate_dual.py"
click node_confusion_dual "https://github.com/anjaneyayashwanth/fruit-freshness-yolov8/blob/main/confusion_matrix_dual.py"
click node_confusion_five "https://github.com/anjaneyayashwanth/fruit-freshness-yolov8/blob/main/confusion_matrix.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_webapp,node_prep,node_inference,node_five_inference,node_results,node_single_prediction,node_dual_prediction,node_webcam toneBlue
class node_split,node_preprocessing,node_dataset toneAmber
class node_dual_model,node_dual_training,node_custom_training,node_yolo_training,node_dual_tuning toneMint
class node_evaluation,node_confusion_dual,node_confusion_five toneRose
class node_user,node_yolo toneIndigo
```

## Components

### Prediction App

- [Streamlit interface](https://github.com/anjaneyayashwanth/fruit-freshness-yolov8/blob/main/app.py): `app.py`
- [Image preparation](https://github.com/anjaneyayashwanth/fruit-freshness-yolov8/blob/main/app.py): `app.py`
- [Dual-stream inference](https://github.com/anjaneyayashwanth/fruit-freshness-yolov8/blob/main/app.py): `app.py`
- [5-channel inference](https://github.com/anjaneyayashwanth/fruit-freshness-yolov8/blob/main/app.py): `app.py`
- [Prediction results](https://github.com/anjaneyayashwanth/fruit-freshness-yolov8/blob/main/app.py): `app.py`
- [Single-image prediction](https://github.com/anjaneyayashwanth/fruit-freshness-yolov8/blob/main/predict.py): `predict.py`
- [Dual-stream prediction](https://github.com/anjaneyayashwanth/fruit-freshness-yolov8/blob/main/predict_dual.py): `predict_dual.py`
- [Webcam prediction](https://github.com/anjaneyayashwanth/fruit-freshness-yolov8/blob/main/webcam_predict.py): `webcam_predict.py`

### Data Preparation

- [Dataset splitting](https://github.com/anjaneyayashwanth/fruit-freshness-yolov8/blob/main/dataset_split.py): `dataset_split.py`
- [Dataset preprocessing](https://github.com/anjaneyayashwanth/fruit-freshness-yolov8/blob/main/preprocessing.py): `preprocessing.py`
- [Split dataset loader](https://github.com/anjaneyayashwanth/fruit-freshness-yolov8/blob/main/dataset_loader.py): `dataset_loader.py`

### Models and Training

- [Dual-stream network](https://github.com/anjaneyayashwanth/fruit-freshness-yolov8/blob/main/models/dual_stream_model.py): `models/dual_stream_model.py`
- [Dual-stream training](https://github.com/anjaneyayashwanth/fruit-freshness-yolov8/blob/main/train_dual_stream.py): `train_dual_stream.py`
- [5-channel training](https://github.com/anjaneyayashwanth/fruit-freshness-yolov8/blob/main/train_custom.py): `train_custom.py`
- [5-channel tuning](https://github.com/anjaneyayashwanth/fruit-freshness-yolov8/blob/main/gwo_train.py): `gwo_train.py`
- [Dual-stream tuning](https://github.com/anjaneyayashwanth/fruit-freshness-yolov8/blob/main/gwo_dual_train.py): `gwo_dual_train.py`

### Evaluation

- [Dual-stream evaluation](https://github.com/anjaneyayashwanth/fruit-freshness-yolov8/blob/main/evaluate_dual.py): `evaluate_dual.py`
- [Dual-stream confusion matrix](https://github.com/anjaneyayashwanth/fruit-freshness-yolov8/blob/main/confusion_matrix_dual.py): `confusion_matrix_dual.py`
- [5-channel confusion matrix](https://github.com/anjaneyayashwanth/fruit-freshness-yolov8/blob/main/confusion_matrix.py): `confusion_matrix.py`

### Other components

- **Image uploader**
- **Ultralytics YOLO**

## Connections

- Image uploader → Streamlit interface: uploads image (evidence: `app.py`)
- Streamlit interface → Image preparation: prepares image (evidence: `app.py`)
- Streamlit interface → Dual-stream inference: selects model (evidence: `app.py`)
- Streamlit interface → 5-channel inference: selects model (evidence: `app.py`)
- Dual-stream inference → Dual-stream network: runs model (evidence: `app.py`)
- Streamlit interface → Prediction results: shows prediction (evidence: `app.py`)
- Dual-stream training → Split dataset loader: loads samples (evidence: `train_dual_stream.py`)
- Dual-stream training → Dual-stream network: trains model (evidence: `train_dual_stream.py`)
- 5-channel training → Split dataset loader: loads samples (evidence: `train_custom.py`)
- 5-channel training → Ultralytics YOLO: builds model (evidence: `train_custom.py`)
- 5-channel tuning → Split dataset loader: loads samples (evidence: `gwo_train.py`)
- Dual-stream tuning → Split dataset loader: loads samples (evidence: `gwo_dual_train.py`)
- Dual-stream tuning → Dual-stream network: evaluates parameters (evidence: `gwo_dual_train.py`)
- Dual-stream evaluation → Split dataset loader: loads test data (evidence: `evaluate_dual.py`)
- Dual-stream evaluation → Dual-stream network: evaluates model (evidence: `evaluate_dual.py`)
- Dual-stream confusion matrix → Split dataset loader: loads test data (evidence: `confusion_matrix_dual.py`)
- Dual-stream confusion matrix → Dual-stream network: gets predictions (evidence: `confusion_matrix_dual.py`)
- 5-channel confusion matrix → Split dataset loader: loads validation data (evidence: `confusion_matrix.py`)
- 5-channel confusion matrix → Ultralytics YOLO: builds model (evidence: `confusion_matrix.py`)
