File size: 9,627 Bytes
f403983
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9e4f343
0e88913
cf93910
0e88913
cf93910
0e88913
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
cf93910
 
0e88913
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
cf93910
 
0e88913
cf93910
0e88913
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
cf93910
0e88913
cf93910
0e88913
cf93910
0e88913
 
 
 
 
 
 
 
 
 
cf93910
0e88913
 
 
cf93910
 
0e88913
 
 
cf93910
 
0e88913
 
 
 
 
 
 
 
cf93910
 
 
 
0e88913
cf93910
 
 
0e88913
cf93910
 
 
 
0e88913
cf93910
 
 
0e88913
cf93910
0e88913
 
cf93910
 
 
0e88913
 
 
9e4f343
0e88913
 
 
 
9e4f343
0e88913
9e4f343
0e88913
9e4f343
0e88913
 
 
9e4f343
0e88913
 
 
9e4f343
0e88913
9e4f343
0e88913
9e4f343
0e88913
9e4f343
0e88913
9e4f343
0e88913
9e4f343
 
0e88913
 
9e4f343
 
0e88913
9e4f343
0e88913
cf93910
0e88913
 
 
 
 
cf93910
0e88913
cf93910
0e88913
 
 
 
cf93910
0e88913
cf93910
0e88913
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
cf93910
0e88913
cf93910
0e88913
cf93910
0e88913
cf93910
f403983
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
---
title: Sanket Setu
emoji: πŸƒ
colorFrom: blue
colorTo: purple
sdk: docker
sdk_version: 4.36.1
python_version: 3.1
app_file: app.py
pinned: false
license: mit
short_description: Gujarati Sign Language Translator using AI
---
 
 <div align="center">

# 🀟 SanketSetu | ΰͺΈΰͺ‚ΰͺ•ેΰͺ€-ΰͺΈΰ«‡ΰͺ€ΰ«

**Real-time Gujarati Sign Language Recognition System**

[![Live Demo](https://img.shields.io/badge/Live%20Demo-Vercel-black?style=for-the-badge&logo=vercel)](https://sanket-setu.vercel.app)
[![Backend](https://img.shields.io/badge/Backend-HuggingFace%20Spaces-yellow?style=for-the-badge&logo=huggingface)](https://huggingface.co/spaces/devrajsinh2012/Sanket-Setu)
[![License](https://img.shields.io/badge/License-All%20Rights%20Reserved-red?style=for-the-badge)](#license)

</div>

---

## πŸ“– About

**SanketSetu** (Sanskrit: *Sanket* = gesture/sign, *Setu* = bridge) is a production-grade, real-time **Gujarati Sign Language (GSL)** recognition system. It bridges the communication gap between the hearing-impaired community and the broader public by translating hand gestures corresponding to **34 Gujarati consonants** (ΰͺ•–ΰͺœΰ«ΰͺž) into text β€” all in real time, directly in the browser.

The system uses your device camera, processes hand landmarks locally via **MediaPipe**, and sends them over a **WebSocket** connection to a machine-learning backend that classifies the gesture using a **3-pipeline ensemble** of models.

---

## ✨ Features

- **Real-time gesture detection** β€” sub-100 ms end-to-end latency
- **3-pipeline ensemble inference** β€” XGBoost β†’ Autoencoder+LightGBM β†’ CNN+SVM, invoked in order of confidence
- **34 Gujarati sign classes** β€” complete consonant alphabet (ΰͺ•, ΰͺ–, ΰͺ— … ΰͺ•્ΰͺ·, ΰͺœΰ«ΰͺž)
- **WebSocket streaming** β€” live bidirectional communication between browser and backend
- **MediaPipe hand tracking** β€” 21 landmark coordinates extracted client-side (no raw video sent to server)
- **Onboarding wizard** β€” animated step-by-step guide for first-time users
- **Calibration screen** β€” transparent overlay keeps camera feed fully visible while detecting hand readiness
- **Landmark canvas overlay** β€” live 21-point skeleton drawn over the webcam feed
- **Prediction HUD** β€” displays recognised sign, confidence bar, latency, and prediction history
- **Low-bandwidth mode** β€” auto-throttles to 5 fps when latency is high
- **Docker-ready backend** β€” deployable on Hugging Face Spaces in one push

---

## πŸ—οΈ System Architecture

```
Browser (React + TypeScript)
β”‚
β”œβ”€ MediaPipe Hands (WASM)    ← extracts 21 hand landmarks (63 floats) locally
β”œβ”€ WebcamFeed + LandmarkCanvas
β”œβ”€ Calibration / Onboarding UI
β”‚
└─ WebSocket (wss://)
        β”‚
        β–Ό
FastAPI Backend (Python)
β”‚
β”œβ”€ Pipeline A β€” XGBoost (63 landmarks β†’ 34 classes)        ← primary, fastest
β”‚       └─ if confidence < 0.70 ↓
β”œβ”€ Pipeline B β€” Autoencoder (63β†’16) + LightGBM             ← secondary
β”‚       └─ if confidence < 0.60 ↓
└─ Pipeline C β€” ResNet50 CNN (128Γ—128 image) + SVM         ← tertiary
        └─ Ensemble weighted average β†’ final prediction
```

---

## πŸ“ Project Structure

```
SanketSetu/
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ main.py              # FastAPI entry-point, WebSocket + REST
β”‚   β”‚   β”œβ”€β”€ config.py            # Settings (thresholds, model paths, env vars)
β”‚   β”‚   β”œβ”€β”€ schemas.py           # Pydantic request/response models
β”‚   β”‚   β”œβ”€β”€ inference/
β”‚   β”‚   β”‚   β”œβ”€β”€ pipeline_a.py    # XGBoost inference (63 MediaPipe landmarks)
β”‚   β”‚   β”‚   β”œβ”€β”€ pipeline_b.py    # Autoencoder encoder + LightGBM
β”‚   β”‚   β”‚   β”œβ”€β”€ pipeline_c.py    # ResNet CNN + SVM (image-based)
β”‚   β”‚   β”‚   └── ensemble.py      # Confidence-weighted ensemble logic
β”‚   β”‚   └── models/
β”‚   β”‚       β”œβ”€β”€ loader.py        # Singleton model loader
β”‚   β”‚       └── label_map.py     # Index 0–33 β†’ Gujarati character
β”‚   β”œβ”€β”€ tests/                   # Pytest test suite
β”‚   β”œβ”€β”€ requirements.txt
β”‚   └── requirements-dev.txt
β”‚
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ App.tsx              # App shell, stage machine (onboarding β†’ calibration β†’ running)
β”‚   β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”‚   β”œβ”€β”€ WebcamFeed.tsx       # Webcam stream + canvas overlay
β”‚   β”‚   β”‚   β”œβ”€β”€ LandmarkCanvas.tsx   # Draws 21-point hand skeleton
β”‚   β”‚   β”‚   β”œβ”€β”€ PredictionHUD.tsx    # Live sign, confidence bar, latency, history
β”‚   β”‚   β”‚   β”œβ”€β”€ OnboardingGuide.tsx  # Animated intro wizard
β”‚   β”‚   β”‚   └── Calibration.tsx      # Transparent hand-detection calibration card
β”‚   β”‚   β”œβ”€β”€ hooks/
β”‚   β”‚   β”‚   β”œβ”€β”€ useWebSocket.ts      # WS connection, send/receive
β”‚   β”‚   β”‚   β”œβ”€β”€ useMediaPipe.ts      # MediaPipe Hands JS integration
β”‚   β”‚   β”‚   └── useWebcam.ts         # Camera permissions + stream
β”‚   β”‚   └── lib/
β”‚   β”‚       └── landmarkUtils.ts     # Landmark normalisation helpers
β”‚   β”œβ”€β”€ .env.production          # VITE_WS_URL for Vercel build
β”‚   β”œβ”€β”€ vite.config.ts
β”‚   └── package.json
β”‚
β”œβ”€β”€ CNN_Autoencoder_LightGBM/    # Autoencoder + LightGBM model weights
β”œβ”€β”€ CNN_PreTrained/              # ResNet CNN + SVM model weights
β”œβ”€β”€ Mediapipe_XGBoost/           # XGBoost model weights
β”œβ”€β”€ Dockerfile                   # Multi-stage Docker build for HF Spaces
└── start.ps1                    # One-command local dev launcher (Windows)
```

---

## πŸ› οΈ Tech Stack

| Layer | Technology |
|---|---|
| **Frontend** | React 18, TypeScript, Vite, TailwindCSS, Framer Motion |
| **Hand Tracking** | MediaPipe Hands (browser WASM) |
| **Real-time Comm.** | WebSocket (native browser API) |
| **Backend** | FastAPI, Python 3.10+ |
| **ML β€” Pipeline A** | XGBoost (scikit-learn API) |
| **ML β€” Pipeline B** | Keras/TensorFlow Autoencoder + LightGBM |
| **ML β€” Pipeline C** | PyTorch ResNet50 CNN + scikit-learn SVM |
| **Deployment** | Hugging Face Spaces (Docker SDK) + Vercel |

---

## πŸš€ Getting Started

### Prerequisites

- Python 3.10+
- Node.js 18+
- npm or yarn

### 1. Clone the repository

```bash
git clone https://github.com/devrajsinh2012/Sanket-Setu.git
cd Sanket-Setu
```

### 2. Backend Setup

```bash
cd backend
pip install -r requirements.txt
# Starts FastAPI server on http://localhost:8000
python -m app.main
```

### 3. Frontend Setup

```bash
cd frontend
npm install
# Starts Vite dev server on http://localhost:5173
npm run dev
```

### 4. One-Command Start (Windows)

```powershell
# From the repo root β€” starts both backend and frontend
.\start.ps1
```

---

## πŸ§ͺ Testing

```bash
cd backend
pytest tests/ -v
```

---

## 🐳 Docker (Local)

```bash
# Build the image
docker build -t sanketsetu .

# Run on port 7860 (matches HF Spaces)
docker run -p 7860:7860 sanketsetu
```

---

## ☁️ Deployment

### Backend β€” Hugging Face Spaces

The backend runs as a [Hugging Face Space](https://huggingface.co/spaces/devrajsinh2012/Sanket-Setu) using the **Docker SDK**.

**Push to the Space:**

```bash
# From repo root
git push space main
```

HF Spaces automatically builds the Docker image and serves the container on port 7860.

**Space Secrets** (HF Space β†’ Settings β†’ Repository secrets):

| Secret | Example value |
|--------|---------------|
| `CORS_ORIGINS` | `https://sanket-setu.vercel.app,http://localhost:5173` |
| `PIPELINE_MODE` | `ensemble` |
| `CONFIDENCE_THRESHOLD` | `0.70` |

**Live URLs:**

| Endpoint | URL |
|---|---|
| Health check | `https://devrajsinh2012-sanket-setu.hf.space/health` |
| WebSocket | `wss://devrajsinh2012-sanket-setu.hf.space/ws/landmarks` |

### Frontend β€” Vercel

Connect the GitHub repository in the [Vercel dashboard](https://vercel.com) and add the **Environment Variable**:

| Variable | Value |
|---|---|
| `VITE_WS_URL` | `wss://devrajsinh2012-sanket-setu.hf.space` |

Vercel auto-deploys on every push to `main`.

---

## πŸ”§ Environment Variables

| Variable | Scope | Default | Description |
|---|---|---|---|
| `VITE_WS_URL` | Frontend (build-time) | β€” | WebSocket URL of the backend |
| `CORS_ORIGINS` | Backend (runtime) | `*` | Comma-separated allowed origins |
| `PIPELINE_MODE` | Backend (runtime) | `ensemble` | `ensemble` / `A` / `B` / `C` |
| `CONFIDENCE_THRESHOLD` | Backend (runtime) | `0.70` | Primary confidence cutoff |
| `SECONDARY_THRESHOLD` | Backend (runtime) | `0.60` | Secondary confidence cutoff |
| `WEIGHTS_DIR` | Backend (runtime) | repo root | Override path to model weight files |

---

## 🀝 Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. Please make sure to update tests as appropriate.

---

## πŸ‘₯ Team & Acknowledgements

This project was developed by:

| Name | Contribution |
|---|---|
| **Devrajsinh Gohil** | Full-stack development, ML integration, deployment |
| **Jay Nasit** | Machine learning models, dataset preparation, testing |

**Guided by:** Dr. Om Prakash Suthar

> We express our sincere gratitude to **Dr. Om Prakash Suthar** for his invaluable guidance, encouragement, and technical insights throughout the development of SanketSetu. His mentorship was instrumental in shaping both the research direction and the system architecture of this project.

---

## πŸ“„ License

Β© 2026 Devrajsinh Gohil & Jay Nasit. All Rights Reserved.