A production-grade, real-time American Sign Language (ASL) detection application powered by YOLOv5, FastAPI, and React.
- Real-Time Detection: Low-latency video streaming and hand gesture inference utilizing WebSockets.
- High-Performance Backend: FastAPI-based server with YOLOv5 integration, automated GPU/CUDA acceleration, and singleton model loader.
- Sleek Front-End: Modern, glassmorphic UI built in React + TypeScript with Tailwind CSS and dynamic HTML5 Canvas overlay.
- Privacy-Centric: Video frames are processed entirely in-memory and are never stored or logged.
- Environment Driven: Hardened architecture fully configurable via environment variables.
- Frontend: React 18, Vite, TypeScript, Tailwind CSS, Lucide React, react-use-websocket.
- Backend: FastAPI, Python 3.11, PyTorch (torch), OpenCV (headless), NumPy, Uvicorn, Python-dotenv.
- Model: YOLOv5 Custom trained architecture (
sign_language_best.pt).
git clone https://github.com/SyedRasab/Sign-Language-Detection.git
cd Sign-Language-DetectionTo run the model inference, clone the official YOLOv5 v7.0 source code into the project root:
git clone https://github.com/ultralytics/yolov5.git --branch v7.0 --depth 1 yolov5Create a Python virtual environment, activate it, and install dependencies:
# Create virtual environment
python -m venv venv
# Activate it (Windows PowerShell)
.\venv\Scripts\Activate.ps1
# Activate it (Linux/macOS)
source venv/bin/activate
# Install requirements
pip install -r backend/requirements.txtInstall the Node.js packages:
cd frontend
npm installCreate a .env file in the root directory. Refer to .env.example for the required keys:
# Backend Server Configuration
HOST=0.0.0.0
PORT=8000
MODEL_PATH=sign_language_best.pt
# Frontend Configuration (used to locate the backend WebSocket server)
VITE_WS_URL=ws://localhost:8000/ws/detectActivate your virtual environment, navigate to the backend directory, and start the FastAPI application:
cd backend
python main.pyThe backend server will run on http://localhost:8000 (WebSocket endpoint available at /ws/detect).
From the frontend directory, start the Vite server:
cd frontend
npm run devThe frontend development server will launch on http://localhost:5174 (or http://localhost:5173). Open the printed address in your web browser, click "Start Camera", and perform supported ASL gestures.
Sign-Language-Detection/
├── backend/
│ ├── main.py # FastAPI application server with WebSocket detection endpoint
│ └── requirements.txt # Python backend dependencies
├── frontend/
│ ├── src/ # React frontend application source
│ │ ├── CameraFeed.tsx # Canvas overlays and real-time WebSocket video frame streaming
│ │ ├── GesturesGuide.tsx# UI Component detailing supported sign language gestures
│ │ └── App.tsx # App structure and style layout
│ ├── index.html
│ ├── package.json
│ └── tailwind.config.js
├── sign_language_best.pt # Custom trained YOLOv5 PyTorch model weights
├── Dockerfile # Production Docker container setup
├── .env.example # Template for environment configuration
├── .gitignore # System-wide git tracking exclusions
└── README.md # Professional project documentation
Important
PyTorch ≥ 2.6 changed the default loading behavior of torch.load() to weights_only=True, which blocks custom checkpoint formats from loading and raises a WeightsUnpickler error.
If you are running PyTorch 2.6 or later, please apply a quick patch to your cloned yolov5/ framework by running this terminal command:
python -c "
import pathlib
files = {
'yolov5/models/experimental.py': [\"torch.load(attempt_download(w), map_location='cpu')\"],
'yolov5/hubconf.py': [\"torch.load(attempt_download(path), map_location=device)\"],
'yolov5/utils/general.py': [\"torch.load(f, map_location=torch.device('cpu'))\"],
'yolov5/train.py': [
\"torch.load(weights, map_location='cpu')\",
\"torch.load(last, map_location='cpu')\"
],
}
for fpath, targets in files.items():
p = pathlib.Path(fpath)
if p.exists():
text = p.read_text(encoding='utf-8')
for t in targets:
text = text.replace(t, t.replace(')', ', weights_only=False)'))
p.write_text(text, encoding='utf-8')
print(f'Patched: {fpath}')
print('Compatibility patch complete.')
"Ensure you have installed the requirements inside your active virtual environment:
pip install opencv-python-headlessThe system is running on CPU. Ensure a CUDA-capable NVIDIA graphics card is available and check your PyTorch installation:
python -c "import torch; print('CUDA Available:', torch.cuda.is_available())"- Verify that no other application (e.g. Zoom, Teams) is currently using your webcam.
- Grant camera access permissions in your browser.
Please note that the custom raw training dataset and raw images folder (Data/) are not committed or included in this repository to keep the codebase lightweight and maintain production-ready focus.
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
This project is licensed under the terms of the MIT License. See LICENSE for details.