Spaces:
Sleeping
A newer version of the Streamlit SDK is available:
1.41.1
ASL Recognition App
This application recognizes American Sign Language (ASL) hand signs using image processing and machine learning techniques.
How it works
- Image Upload: Users can upload an image of an ASL hand sign.
- Hand Detection: The app uses MediaPipe to detect hand landmarks in the image.
- Feature Extraction: Angles between hand landmarks are calculated and normalized.
- Prediction: A Random Forest model predicts the ASL sign based on the extracted features.
- Visualization: The app displays the detected hand landmarks and top predictions.
Supported Alphabets
The app currently works for the following ASL alphabets: A, B, C, E, F, G, H, I, J, K, L, O, Q, R, S, W, Y
The app does not support or may not work correctly for: D, M, N, P, T, U, V, X, Z
Note: The model's performance may vary and is subject to improvement.
Image Preprocessing and Feature Extraction
Image Preprocessing
- Image Loading: We use OpenCV (cv2) to load and process images.
- Color Conversion: Images are converted from BGR to RGB color space for compatibility with MediaPipe.
Hand Landmark Detection
We use MediaPipe Hands for detecting hand landmarks in the images:
- MediaPipe Hands: Initializes with
static_image_mode=True
,max_num_hands=1
, andmin_detection_confidence=0.5
. - Landmark Extraction: 21 hand landmarks are extracted from each image.
Feature Extraction
Landmark Normalization
- Centering: Landmarks are centered by subtracting the mean position.
- Scaling: Centered landmarks are scaled to unit variance.
Angle Calculation
We calculate angles between all pairs of landmarks:
- Vector Calculation: For each pair of landmarks (i, j), we calculate the vector from i to j.
- Angle Computation: We compute the arcosine of the x and y components of the normalized vector.
- Feature Vector: The angles form a 420-dimensional feature vector (21 choose 2 = 210 pairs, 2 angles per pair).
Model Input
The preprocessed features (angles) are used as input to our Random Forest model for ASL sign classification.
This preprocessing pipeline ensures that our model receives consistent and informative features, regardless of the hand's position or size in the original image.
Usage
The "View Hand Landmarks" tab allows users to see hand landmarks for pre-loaded ASL signs. Select one or more alphabets from the supported list to view their corresponding hand landmarks.