# milansinghal2004/gesture-bridge architecture

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

- Interactive diagram: https://gitdiagram.com/milansinghal2004/gesture-bridge
- Repository: https://github.com/milansinghal2004/gesture-bridge

## Overview

##### Project Type and Purpose
- This is a Python‐based machine learning application for real-time sign-language recognition and “air drawing.”
- It consists of two main subsystems:
a. A data-preparation and model-training pipeline (HaGrid)
b. A real-time gesture-detection and drawing UI (AirCanvas)
- The root directory also holds shared scripts (e.g., launcher.py, evaluate_yolo.py) and the trained model (best.pt).

##### File Structure
- Top-level folders:
- AirCanvas/: real-time inference and UI
- HaGrid/: notebooks and scripts for data prep, training, evaluation
- Root scripts:
- launcher.py – entry point to choose tasks (train vs. infer)
- evaluate_yolo.py – evaluation harness for the YOLO model
- button.py, try.py – auxiliary/testing scripts
- best.pt – final trained YOLO weights
- requirements.txt – Python dependencies
- Key patterns:
- ML training pipeline separated from inference/UI
- Modular Python packages under src/ for clean separation (e.g., hand_tracker, gesture, drawing)

##### README
- Confirms the project name: “Gesture-Bridge—Sign-Language-Recognition”

##### Main Components & Interactions
A. Data-Preparation & Model-Training (HaGrid)
1. Raw data ingestion (images/videos)
2. Data_Preparation.ipynb & Implementation scripts
3. Label encoding (label_encoder.pkl)
4. Model training (Implementation_using_Mediapipepy.py)
5. Output: best_model.pkl / best.pt
6. Evaluation notebooks / eval.py
B. Inference & UI (AirCanvas)
1. Input: live camera feed (OpenCV)
2. hand_tracker module: detect & track hands (Mediapipe/YOLO)
3. gesture module: classify gestures via loaded model (best.pt)
4. drawing module: convert gesture classes into strokes on the canvas
5. ui module: display the drawing window and controls
C. Orchestration & Shared Components
- launcher.py: CLI or GUI menu to kick off either training (HaGrid) or inference (AirCanvas).
- evaluate_yolo.py: standalone evaluation tool using trained weights.
- requirements.txt: list of external libraries (OpenCV, PyTorch, Mediapipe, etc.).

##### Architectural Patterns and Design Principles
- Layered Separation:
- Data Layer: raw images, label encoders, trained weights
- ML Layer: training scripts & evaluation, inference code
- Application Layer: gesture→drawing logic
- Presentation Layer: UI for real-time display
- Modularity: each package under src/ is a self-contained component.
- Single Responsibility: e.g., hand_tracker only tracks landmarks; drawing only renders strokes.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Orchestration Layer
    ORC["Launcher\nlauncher.py"]:::orchestr
    click ORC "https://github.com/milansinghal2004/gesture-bridge/blob/main/launcher.py"

    %% HaGrid Training Pipeline
    subgraph "HaGrid Training Pipeline"
        direction TB
        DS["Data Source\n(images/videos)"]:::data
        DP["Data Preparation Notebook\nData_Preparation.ipynb"]:::ml
        click DP "https://github.com/milansinghal2004/gesture-bridge/blob/main/HaGrid/Data_Preparation.ipynb"
        PS["Data Preparation Scripts\nImplementation.py\nImplementation_using_Mediapipepy.py"]:::ml
        click PS "https://github.com/milansinghal2004/gesture-bridge/blob/main/HaGrid/Implementation.py"
        click PS "https://github.com/milansinghal2004/gesture-bridge/blob/main/HaGrid/Implementation_using_Mediapipepy.py"
        LE["Label Encoder\nlabel_encoder.pkl"]:::storage
        click LE "https://github.com/milansinghal2004/gesture-bridge/blob/main/HaGrid/label_encoder.pkl"
        MT["Model Training\noutputs best_model.pkl"]:::ml
        click MT "https://github.com/milansinghal2004/gesture-bridge/blob/main/HaGrid/best_model.pkl"
        EvalT["Model Evaluation\neval.py\nTraining_and_Evaluation.ipynb"]:::ml
        click EvalT "https://github.com/milansinghal2004/gesture-bridge/blob/main/HaGrid/eval.py"
        click EvalT "https://github.com/milansinghal2004/gesture-bridge/blob/main/HaGrid/Training_and_Evaluation.ipynb"
        MS["Model Store"]:::storage
        BM["best_model.pkl"]:::storage
        click BM "https://github.com/milansinghal2004/gesture-bridge/blob/main/HaGrid/best_model.pkl"
        BTP["best.pt"]:::storage
        click BTP "https://github.com/milansinghal2004/gesture-bridge/blob/main/best.pt"
    end

    %% Independent Evaluator
    EY["YOLO Evaluator\nevaluate_yolo.py"]:::ml
    click EY "https://github.com/milansinghal2004/gesture-bridge/blob/main/evaluate_yolo.py"

    %% AirCanvas Inference Pipeline
    subgraph "AirCanvas Inference"
        direction TB
        CAM["Camera Input\n(video frames)"]:::data
        HT["Hand Tracking\nhand_tracker.py"]:::ml
        click HT "https://github.com/milansinghal2004/gesture-bridge/blob/main/AirCanvas/src/hand_tracker.py"
        GC["Gesture Classification\ngesture.py"]:::app
        click GC "https://github.com/milansinghal2004/gesture-bridge/blob/main/AirCanvas/src/gesture.py"
        DR["Drawing Logic\ndrawing.py"]:::app
        click DR "https://github.com/milansinghal2004/gesture-bridge/blob/main/AirCanvas/src/drawing.py"
        COL["Colour Management\ncolours.py"]:::config
        click COL "https://github.com/milansinghal2004/gesture-bridge/blob/main/AirCanvas/src/colours.py"
        CFG["Configuration\nconfig.py"]:::config
        click CFG "https://github.com/milansinghal2004/gesture-bridge/blob/main/AirCanvas/src/config.py"
        UI["UI Rendering\nui.py"]:::ui
        click UI "https://github.com/milansinghal2004/gesture-bridge/blob/main/AirCanvas/src/ui.py"
        IE["Inference Eval Utility\neval.py"]:::ml
        click IE "https://github.com/milansinghal2004/gesture-bridge/blob/main/AirCanvas/src/eval.py"
    end

    %% Data Flows
    ORC -->|"start training"| DS
    DS --> DP --> PS --> LE --> MT --> BM
    MT --> BTP
    BM --> EvalT
    BTP --> EY
    ORC -->|"start inference"| CAM
    CAM --> HT --> GC --> DR --> UI
    BTP --> GC
    BM --> GC
    IE --> BTP

    %% Styles
    classDef data fill:#D6E9FE,stroke:#5DA8EE,color:#0B3D91
    classDef ml fill:#DFF2D8,stroke:#72C24A,color:#29570F
    classDef app fill:#FFE5B9,stroke:#FFB648,color:#8A4A00
    classDef ui fill:#EAD8FE,stroke:#B78DE3,color:#4E2370
    classDef storage fill:#F2F2F2,stroke:#AAAAAA,color:#333333
    classDef config fill:#FFF5D9,stroke:#FFD24A,color:#664C00
    classDef orchestr fill:#ECECEC,stroke:#CCCCCC,color:#333333
```
