# likhitha-poojary/vegetable-chemical-detection architecture

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

- Interactive diagram: https://gitdiagram.com/likhitha-poojary/vegetable-chemical-detection
- Repository: https://github.com/likhitha-poojary/vegetable-chemical-detection

## Overview

This repository is a produce-freshness classification and sorting project, with image-only and image-plus-sensor model workflows. The live workflow captures produce on camera, classifies it with a TFLite model, and actuates a conveyor rejection gate for confident rotten predictions. Training and evaluation are separate workflows. The README is empty; several scripts are represented only by their filenames, so their internal behavior and wiring are not inferred.

Main entry points: [`split_dataset`](https://github.com/likhitha-poojary/vegetable-chemical-detection/tree/main/split_dataset) (Image splits), [`models/vegetable_classifier_mobilenetv2.keras`](https://github.com/likhitha-poojary/vegetable-chemical-detection/blob/main/models/vegetable_classifier_mobilenetv2.keras) (MobileNetV2 model), [`collect_real_dataset.py`](https://github.com/likhitha-poojary/vegetable-chemical-detection/blob/main/collect_real_dataset.py) (Capture labeled samples), [`models/vegetable_classifier.tflite`](https://github.com/likhitha-poojary/vegetable-chemical-detection/blob/main/models/vegetable_classifier.tflite) (TFLite classifier)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Data collection"]
  node_public_data["Public images"]
  node_collect["Capture labeled samples"]
  node_split["Split image dataset<br/>[split_dataset.py]"]
  node_split_data["Image splits"]
  node_synthetic["Generate sensor records"]
  node_multi_records["Multimodal records"]
end

subgraph group_models["Model development"]
  node_train_image["Train image classifier<br/>[train_model.py]"]
  node_train_fusion["Train sensor fusion"]
  node_keras_model["MobileNetV2 model"]
  node_convert["Convert to TFLite<br/>[convert_tflite.py]"]
  node_tflite_model["TFLite classifier"]
end

subgraph group_inference["Classification"]
  node_predict["Classify image<br/>[predict.py]"]
  node_evaluate["Evaluate classifier"]
  node_benchmark["Benchmark latency"]
end

subgraph group_sorting["Sorting hardware"]
  node_live["Live sorting pipeline"]
end

node_operator(("Operator"))
node_camera(("Camera"))
node_sensors(("Physical sensors"))
node_actuators{{"Conveyor and gate"}}

node_operator -->|"selects samples"| node_collect
node_camera -->|"provides frames"| node_collect
node_sensors -->|"provides readings"| node_collect
node_collect -->|"writes CSV for"| node_train_fusion
node_public_data -.->|"source images"| node_split
node_split -->|"writes splits"| node_split_data
node_split_data -->|"training data"| node_train_image
node_split_data -->|"image inputs"| node_synthetic
node_synthetic -->|"writes records"| node_multi_records
node_multi_records -->|"records data"| node_train_fusion
node_train_image -->|"saves model"| node_keras_model
node_keras_model -->|"loads model"| node_predict
node_keras_model -->|"loads model"| node_evaluate
node_split_data -->|"test images"| node_evaluate
node_keras_model -.->|"conversion input"| node_convert
node_convert -.->|"produces model"| node_tflite_model
node_camera -->|"streams frames"| node_live
node_tflite_model -->|"loads model"| node_live
node_live -->|"controls gate"| node_actuators
node_tflite_model -->|"loads model"| node_benchmark
node_split_data -->|"test images"| node_benchmark

click node_public_data "https://github.com/likhitha-poojary/vegetable-chemical-detection/tree/main/public_dataset"
click node_collect "https://github.com/likhitha-poojary/vegetable-chemical-detection/blob/main/collect_real_dataset.py"
click node_split "https://github.com/likhitha-poojary/vegetable-chemical-detection/blob/main/split_dataset.py"
click node_split_data "https://github.com/likhitha-poojary/vegetable-chemical-detection/tree/main/split_dataset"
click node_synthetic "https://github.com/likhitha-poojary/vegetable-chemical-detection/blob/main/generate_multimodal_dataset.py"
click node_multi_records "https://github.com/likhitha-poojary/vegetable-chemical-detection/tree/main/multimodal_records"
click node_train_image "https://github.com/likhitha-poojary/vegetable-chemical-detection/blob/main/train_model.py"
click node_train_fusion "https://github.com/likhitha-poojary/vegetable-chemical-detection/blob/main/train_multimodal_fusion.py"
click node_keras_model "https://github.com/likhitha-poojary/vegetable-chemical-detection/blob/main/models/vegetable_classifier_mobilenetv2.keras"
click node_convert "https://github.com/likhitha-poojary/vegetable-chemical-detection/blob/main/convert_tflite.py"
click node_tflite_model "https://github.com/likhitha-poojary/vegetable-chemical-detection/blob/main/models/vegetable_classifier.tflite"
click node_predict "https://github.com/likhitha-poojary/vegetable-chemical-detection/blob/main/predict.py"
click node_evaluate "https://github.com/likhitha-poojary/vegetable-chemical-detection/blob/main/evaluate_and_plot.py"
click node_benchmark "https://github.com/likhitha-poojary/vegetable-chemical-detection/blob/main/benchmark_latency.py"
click node_live "https://github.com/likhitha-poojary/vegetable-chemical-detection/blob/main/main_sorting_pipeline.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_public_data,node_collect,node_split,node_split_data,node_synthetic,node_multi_records toneBlue
class node_train_image,node_train_fusion,node_keras_model,node_convert,node_tflite_model toneAmber
class node_predict,node_evaluate,node_benchmark toneMint
class node_live toneRose
class node_operator,node_camera,node_sensors,node_actuators toneIndigo
```

## Components

### Data collection

- [Public images](https://github.com/likhitha-poojary/vegetable-chemical-detection/tree/main/public_dataset): `public_dataset`
- [Capture labeled samples](https://github.com/likhitha-poojary/vegetable-chemical-detection/blob/main/collect_real_dataset.py): `collect_real_dataset.py`
- [Split image dataset](https://github.com/likhitha-poojary/vegetable-chemical-detection/blob/main/split_dataset.py): `split_dataset.py`
- [Image splits](https://github.com/likhitha-poojary/vegetable-chemical-detection/tree/main/split_dataset): `split_dataset`
- [Generate sensor records](https://github.com/likhitha-poojary/vegetable-chemical-detection/blob/main/generate_multimodal_dataset.py): `generate_multimodal_dataset.py`
- [Multimodal records](https://github.com/likhitha-poojary/vegetable-chemical-detection/tree/main/multimodal_records): `multimodal_records`

### Model development

- [Train image classifier](https://github.com/likhitha-poojary/vegetable-chemical-detection/blob/main/train_model.py): `train_model.py`
- [Train sensor fusion](https://github.com/likhitha-poojary/vegetable-chemical-detection/blob/main/train_multimodal_fusion.py): `train_multimodal_fusion.py`
- [MobileNetV2 model](https://github.com/likhitha-poojary/vegetable-chemical-detection/blob/main/models/vegetable_classifier_mobilenetv2.keras): `models/vegetable_classifier_mobilenetv2.keras`
- [Convert to TFLite](https://github.com/likhitha-poojary/vegetable-chemical-detection/blob/main/convert_tflite.py): `convert_tflite.py`
- [TFLite classifier](https://github.com/likhitha-poojary/vegetable-chemical-detection/blob/main/models/vegetable_classifier.tflite): `models/vegetable_classifier.tflite`

### Classification

- [Classify image](https://github.com/likhitha-poojary/vegetable-chemical-detection/blob/main/predict.py): `predict.py`
- [Evaluate classifier](https://github.com/likhitha-poojary/vegetable-chemical-detection/blob/main/evaluate_and_plot.py): `evaluate_and_plot.py`
- [Benchmark latency](https://github.com/likhitha-poojary/vegetable-chemical-detection/blob/main/benchmark_latency.py): `benchmark_latency.py`

### Sorting hardware

- [Live sorting pipeline](https://github.com/likhitha-poojary/vegetable-chemical-detection/blob/main/main_sorting_pipeline.py): `main_sorting_pipeline.py`

### Other components

- **Operator**
- **Camera**
- **Physical sensors**
- **Conveyor and gate**

## Connections

- Operator → Capture labeled samples: selects samples
- Camera → Capture labeled samples: provides frames
- Physical sensors → Capture labeled samples: provides readings
- Capture labeled samples → Train sensor fusion: writes CSV for
- Public images → Split image dataset: source images
- Split image dataset → Image splits: writes splits
- Image splits → Train image classifier: training data
- Image splits → Generate sensor records: image inputs
- Generate sensor records → Multimodal records: writes records
- Multimodal records → Train sensor fusion: records data
- Train image classifier → MobileNetV2 model: saves model
- MobileNetV2 model → Classify image: loads model
- MobileNetV2 model → Evaluate classifier: loads model
- Image splits → Evaluate classifier: test images
- MobileNetV2 model → Convert to TFLite: conversion input
- Convert to TFLite → TFLite classifier: produces model
- Camera → Live sorting pipeline: streams frames
- TFLite classifier → Live sorting pipeline: loads model
- Live sorting pipeline → Conveyor and gate: controls gate
- TFLite classifier → Benchmark latency: loads model
- Image splits → Benchmark latency: test images
