# tarangver/traffic-sign-recognition-system-using-cnn-and-keras architecture

> Architecture diagram of the GitHub repository tarangver/traffic-sign-recognition-system-using-cnn-and-keras, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-03-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/tarangver/traffic-sign-recognition-system-using-cnn-and-keras
- Repository: https://github.com/tarangver/traffic-sign-recognition-system-using-cnn-and-keras

## Overview

This repo is not a “service-based system” (no backend/frontend). It’s a **notebook-driven ML application** implementing a **Traffic Sign Recognition pipeline** using **CNNs in TensorFlow/Keras**, trained on **GTSRB** (43 classes), with **offline training/evaluation** plus **inference** modes:
- **Single image prediction** (from `testIMG/`)
- **Real-time detection** (webcam via OpenCV)

- An **ML lifecycle / data pipeline** (preprocess → train → evaluate → inference)
- A **runtime inference flow** (webcam/image → preprocessing → model → class label)

##### Read the file tree as architecture boundaries
From the tree, the repo is organized around **artifacts and stages** rather than modules/packages:

- `traffic_sign_recognition/notebooks/`
- `1_Data_Preprocessing.ipynb` — dataset loading + cleaning + normalization + splits
- `2_Model_Training.ipynb` — CNN definition + training loop + checkpointing (likely)
- `3_Model_Evaluation.ipynb` — metrics + confusion matrix + plots
- `4_Image_Prediction.ipynb` — inference on images (e.g., `testIMG/*.png`)
- `5_RealTime_Detection.ipynb` — webcam capture + frame inference (OpenCV)
- `traffic_sign_recognition/data/dataset.txt` — dataset reference/details (source pointer)
- `traffic_sign_recognition/testIMG/` — inference inputs
- `traffic_sign_recognition/Outpur Screenshot/` — results images (outputs)
- `Documentations/` — report/paper/PPT (context, not runtime)

##### Offline ML pipeline (build/train/evaluate)
**Components to show**
##### Data Source
- “GTSRB dataset (~50k images, 43 classes)”
- As an external datastore (downloaded dataset) feeding preprocessing
##### Data Preprocessing Stage (`1_Data_Preprocessing.ipynb`)
- Resize/crop (if any), normalization, label encoding
- Train/val/test split
- Output: preprocessed tensors/arrays + labels (and possibly augmented samples)
##### Model Training Stage (`2_Model_Training.ipynb`)
- Keras CNN: Conv2D/ReLU → MaxPool → Dropout → Dense → Softmax(43)
- Output: **trained model artifact** (e.g., `.h5`/SavedModel) + training history
##### Model Evaluation Stage (`3_Model_Evaluation.ipynb`)
- Metrics: accuracy/loss curves, confusion matrix, classification report
- Output: plots + evaluation summary (stored as images in “Output Screenshot”)
##### Artifacts/Outputs
- Screenshots/plots (`Outpur Screenshot/`)
- Documentation PDFs (optional, separate lane)

##### Online/interactive inference (predict)
**Components to show**
##### Batch/Single Image Predictor (`4_Image_Prediction.ipynb`)
- Input: `testIMG/*.png` (or user-supplied image)
- Preprocess (must match training preprocessing)
- Load trained model → predict → map class index → label
##### Real-Time Detector (`5_RealTime_Detection.ipynb`)
- Input: Webcam frames (OpenCV)
- Frame preprocessing → model inference → overlay label on frame → display UI

- TensorFlow/Keras (training + inference)
- OpenCV (webcam + image IO)
- NumPy (arrays)
- Scikit-learn (confusion matrix / metrics)
- Matplotlib/Seaborn (plots)

##### Relationships and interactions to show (b)

- **GTSRB dataset** → `1_Data_Preprocessing.ipynb`
- `1_Data_Preprocessing.ipynb` → (Preprocessed Train/Val/Test sets) → `2_Model_Training.ipynb`
- `2_Model_Training.ipynb` → (Trained Model Artifact) → “Model Registry/Model File”
- `2_Model_Training.ipynb` → (Training History) → `3_Model_Evaluation.ipynb` (optional)
- Preprocessed Test Set → `3_Model_Evaluation.ipynb`
- `3_Model_Evaluation.ipynb` → “Metrics/Confusion Matrix/Plots” → `Outpur Screenshot/`

- “Model File” → `4_Image_Prediction.ipynb`
- `testIMG/*.png` → `4_Image_Prediction.ipynb` → “Predicted Class + Confidence”
- “Model File” → `5_RealTime_Detection.ipynb`
- “Webcam” → `5_RealTime_Detection.ipynb` → “Annotated Live Video Feed”

- `Preprocessing Function (resize/normalize)` used by both `1_Data_Preprocessing` and inference notebooks (even if duplicated in notebooks today).

##### Architectural patterns / principles to highlight (c)

- **Pipeline architecture**: sequential stages with clearly defined inputs/outputs.
- **Artifact-driven workflow**: training produces a model artifact consumed by inference.
- **Separation of concerns** (by notebook):
- Data prep vs training vs evaluation vs inference.
- **Consistency constraint**: same preprocessing + label mapping across all inference paths.
- **Two runtime modes**:
- Offline evaluation (batch metrics)
- Interactive/real-time inference loop (webcam frames)

- Normalization scheme (e.g., /255.0)
- Output vector size = 43 softmax probabilities

##### Technologies to place
Attach these to the components where they matter:
- **TensorFlow/Keras**: model definition, training, saving/loading, inference
- **OpenCV**: webcam capture, frame conversion, possibly ROI extraction
- **Scikit-learn**: confusion matrix, classification report
- **Matplotlib/Seaborn**: training curves, confusion matrix plots
- **NumPy**: data arrays, transformations

To make it principal-engineer-grade and unambiguous:

##### Labels
- Use exact names from repo:
- `1_Data_Preprocessing.ipynb`, `2_Model_Training.ipynb`, etc.
- `testIMG/`, `data/dataset.txt`, `Outpur Screenshot/`
- Semantic labels under them: “Split/Normalize”, “Train CNN”, “Confusion Matrix”, “Webcam Loop”.

##### Detail level (don’t under-specify)
Because “separating into as many components as possible is best”, explicitly break out:
- “Image Preprocessing (resize/normalize)” as a shared subcomponent
- “Model Artifact Store (SavedModel/H5)” even if not present in the tree

##### Gaps (and how to represent them honestly)
- “Model file (generated)” as an artifact node with a note: “Produced during training”.

## Diagram (Mermaid)

```mermaid
flowchart TD

%% =========================
%% Global / External Inputs
%% =========================
subgraph "External Inputs"
direction TB
GTSRB[("GTSRB Dataset\n(~50k images, 43 classes)")]:::external
Webcam{{"Webcam Device"}}:::external
TestIMG[("testIMG/\nSingle images (*.png)")]:::data
end

%% =========================
%% Execution Environment
%% =========================
subgraph "Python Environment / Jupyter Runtime"
direction TB

subgraph "Shared Contracts (Must Match Train & Inference)"
direction TB
Preproc["Image Preprocessing\nresize → normalize (/255.0)\nshape (e.g., 32×32×3)"]:::shared
LabelMap["Label Mapping\nclass_id → sign_name\n43 classes"]:::shared
end

subgraph "Training & Evaluation Pipeline (Offline)"
direction TB
NB1["1_Data_Preprocessing.ipynb\nLoad/Clean/Split"]:::offline
PreDS[("Preprocessed Dataset\nTrain/Val/Test arrays")]:::data
NB2["2_Model_Training.ipynb\nCNN Train (Keras)\nConv2D→MaxPool→Dropout→Dense→Softmax(43)"]:::offline
ModelFile[("Trained Model Artifact\nSavedModel / .h5\n(generated during training)")]:::artifact
History[("Training History\nloss/accuracy curves data")]:::data
NB3["3_Model_Evaluation.ipynb\nMetrics/Confusion Matrix"]:::offline
Screens[("Outpur Screenshot/\nPlots & Results Images")]:::artifact
end

subgraph "Inference System (Interactive)"
direction TB
NB4["4_Image_Prediction.ipynb\nSingle Image Inference"]:::runtime
PredOut["Prediction Output\nTop class + confidence"]:::runtimeOut
NB5["5_RealTime_Detection.ipynb\nWebcam Loop (OpenCV)\nOverlay label → display"]:::runtime
LiveFeed["Annotated Live Video Feed"]:::runtimeOut
end

subgraph "Project Context (Non-runtime)"
direction TB
Docs[("Documentations/")]:::docs
PPT["PPT\nTSRS CNN and Keras PPT"]:::docs
Report["Report\nTSRS CNN and Keras Report"]:::docs
Paper["Research Paper\nTSRS CNN and Keras Research Paper"]:::docs
Readme["README\nUsage/Overview"]:::docs
end

%% Library callouts (inside runtime, not services)
subgraph "Libraries (Used Inside Notebooks)"
direction TB
TF["TensorFlow / Keras\n(model, train, save/load, infer)"]:::lib
NP["NumPy\n(arrays, transforms)"]:::lib
SK["Scikit-learn\n(confusion matrix, report)"]:::lib
PLT["Matplotlib / Seaborn\n(plots)"]:::lib
CV["OpenCV\n(image IO, webcam frames)"]:::lib
end

end

%% =========================
%% Offline data / artifact flow
%% =========================
GTSRB -->|"raw_images+labels"| NB1
NB1 -->|"calls"| Preproc
Preproc -->|"processed_tensors"| PreDS
NB1 -->|"writes"| PreDS

PreDS -->|"train/val"| NB2
NB2 -->|"uses"| TF
NB2 -->|"uses"| NP
NB2 -->|"saves"| ModelFile
NB2 -->|"emits"| History

PreDS -->|"test_split"| NB3
History -.->|"optional_input"| NB3
NB3 -->|"uses"| SK
NB3 -->|"uses"| PLT
NB3 -->|"writes_plots"| Screens

%% =========================
%% Inference flows (shared preprocessing + model load)
%% =========================
ModelFile -.->|"load_model()"| NB4
TestIMG -->|"image_file"| NB4
NB4 -->|"calls"| Preproc
NB4 -->|"calls"| LabelMap
NB4 -->|"predict"| PredOut
NB4 -->|"uses"| TF
NB4 -->|"uses"| NP
NB4 -->|"uses"| CV

ModelFile -.->|"load_model()"| NB5
Webcam -->|"frames"| NB5
NB5 -->|"calls"| Preproc
NB5 -->|"calls"| LabelMap
NB5 -->|"annotate+display"| LiveFeed
NB5 -->|"uses"| TF
NB5 -->|"uses"| CV
NB5 -->|"uses"| NP

%% =========================
%% Docs relationships (context only)
%% =========================
Readme -.->|"explains_workflow"| NB1
Readme -.->|"explains_workflow"| NB2
Readme -.->|"explains_workflow"| NB3
Readme -.->|"explains_usage"| NB4
Readme -.->|"explains_usage"| NB5
Docs -->|"contains"| PPT
Docs -->|"contains"| Report
Docs -->|"contains"| Paper

%% =========================
%% Click Events (from component mapping)
%% =========================
click GTSRB "https://github.com/tarangver/traffic-sign-recognition-system-using-cnn-and-keras/blob/main/traffic_sign_recognition/data/dataset.txt"
click NB1 "https://github.com/tarangver/traffic-sign-recognition-system-using-cnn-and-keras/blob/main/traffic_sign_recognition/notebooks/1_Data_Preprocessing.ipynb"
click NB2 "https://github.com/tarangver/traffic-sign-recognition-system-using-cnn-and-keras/blob/main/traffic_sign_recognition/notebooks/2_Model_Training.ipynb"
click NB3 "https://github.com/tarangver/traffic-sign-recognition-system-using-cnn-and-keras/blob/main/traffic_sign_recognition/notebooks/3_Model_Evaluation.ipynb"
click NB4 "https://github.com/tarangver/traffic-sign-recognition-system-using-cnn-and-keras/blob/main/traffic_sign_recognition/notebooks/4_Image_Prediction.ipynb"
click TestIMG "https://github.com/tarangver/traffic-sign-recognition-system-using-cnn-and-keras/tree/main/traffic_sign_recognition/testIMG/"
click NB5 "https://github.com/tarangver/traffic-sign-recognition-system-using-cnn-and-keras/blob/main/traffic_sign_recognition/notebooks/5_RealTime_Detection.ipynb"
click Screens "https://github.com/tarangver/traffic-sign-recognition-system-using-cnn-and-keras/tree/main/traffic_sign_recognition/Outpur Screenshot/"
click Docs "https://github.com/tarangver/traffic-sign-recognition-system-using-cnn-and-keras/tree/main/Documentations/"
click PPT "https://github.com/tarangver/traffic-sign-recognition-system-using-cnn-and-keras/blob/main/Documentations/TSRS CNN and Keras PPT.pptx"
click Report "https://github.com/tarangver/traffic-sign-recognition-system-using-cnn-and-keras/blob/main/Documentations/TSRS CNN and Keras Report.pdf"
click Paper "https://github.com/tarangver/traffic-sign-recognition-system-using-cnn-and-keras/blob/main/Documentations/TSRS CNN and Keras Research Paper.pdf"
click Readme "https://github.com/tarangver/traffic-sign-recognition-system-using-cnn-and-keras/blob/main/README.md"

%% =========================
%% Styles
%% =========================
classDef external fill:#ECEFF1,stroke:#607D8B,stroke-width:1.5px,color:#263238
classDef offline fill:#E3F2FD,stroke:#1E88E5,stroke-width:1.5px,color:#0D47A1
classDef runtime fill:#E8F5E9,stroke:#43A047,stroke-width:1.5px,color:#1B5E20
classDef shared fill:#FFF3E0,stroke:#FB8C00,stroke-width:1.5px,color:#E65100
classDef data fill:#F3E5F5,stroke:#8E24AA,stroke-width:1.5px,color:#4A148C
classDef artifact fill:#FCE4EC,stroke:#D81B60,stroke-width:1.5px,color:#880E4F
classDef runtimeOut fill:#E0F7FA,stroke:#00838F,stroke-width:1.5px,color:#004D40
classDef docs fill:#FFFDE7,stroke:#F9A825,stroke-width:1.5px,color:#5D4037
classDef lib fill:#F5F5F5,stroke:#9E9E9E,stroke-width:1.2px,color:#424242
```
