| --- |
| language: en |
| tags: |
| - emg |
| - gesture-recognition |
| - prosthetic-hand |
| - cnn-lstm |
| - myo-armband |
| - quick-calibration |
| - real-time |
| license: mit |
| --- |
| |
| # EMG Hand Control β Prosthetic Hand Gesture Recognition |
|
|
| Real-time EMG-based hand gesture recognition for prosthetic arm control using CNN+LSTM with Quick Calibration. Works for any new user after ~2 minutes of calibration. |
|
|
| ## Performance |
|
|
| | Gesture | Accuracy (Self) | Accuracy (New User after Calibration) | |
| |---------|----------------|---------------------------------------| |
| | rest | 100% | ~85% | |
| | fist | 100% | ~85% | |
| | grasp | 99% | ~80% | |
| | index | 97% | ~75% | |
| | middle | 100% | ~85% | |
| | ring | 100% | ~85% | |
| | pinky | 95% | ~75% | |
| | thumb | 100% | ~85% | |
| | wrist_rotate_out | 92% | ~80% | |
| | wrist_rotate_in | 90% | ~80% | |
| | **Overall** | **97.2%** | **~85%** | |
|
|
| ## Architecture |
| Input: 150 samples Γ 8 EMG channels (750ms @ 200Hz) |
| β |
| CNN Block: |
| Conv1D(64) β BatchNorm β ReLU |
| Conv1D(128) β BatchNorm β ReLU β MaxPool β Dropout(0.3) |
| Conv1D(256) β BatchNorm β ReLU β MaxPool β Dropout(0.3) |
| β |
| Bidirectional LSTM (hidden=128, layers=2, dropout=0.3) |
| β |
| FC: Dense(128) β ReLU β Dropout(0.4) β Dense(10) |
| β |
| Output: 10 gesture classes |
|
|
| ## Quick Calibration System |
|
|
| New user calibration in ~2 minutes: |
|
|
| User wears Myo Armband |
| Performs each gesture 3 times Γ 5 seconds |
| System fine-tunes last layer on user data (30s) |
| Ready β no full retraining needed |
|
|
|
|
| ## Gestures |
|
|
| | Label | Gesture | |
| |-------|---------| |
| | 0 | rest | |
| | 1 | fist | |
| | 2 | grasp (cylindrical grip) | |
| | 3 | index finger extension | |
| | 4 | middle finger extension | |
| | 5 | ring finger extension | |
| | 6 | pinky finger extension | |
| | 7 | thumb extension | |
| | 8 | wrist rotate out (pronation) | |
| | 9 | wrist rotate in (supination) | |
|
|
| ## Dataset |
|
|
| - 4 personal recording sessions |
| - 10 gestures Γ 10 rounds Γ 5 seconds each |
| - ~400,000 EMG samples |
| - Myo Armband β 8 channels β 200Hz |
|
|
| ## Training Details |
|
|
| | Parameter | Value | |
| |-----------|-------| |
| | Window | 150 samples (750ms) | |
| | Step | 75 samples (50% overlap) | |
| | Optimizer | AdamW (lr=5e-4) | |
| | Loss | Weighted CrossEntropy + Label Smoothing | |
| | Epochs | 100 (best at epoch 78) | |
| | Batch size | 128 | |
| | Normalization | Global fixed (saved as .npy files) | |
|
|
| ## Key Technical Contributions |
|
|
| 1. **Block-level train/test split** β prevents data leakage from overlapping windows |
| 2. **Fixed global normalization** β ensures train/inference consistency (critical fix that improved accuracy from 2% to 94% on rest gesture) |
| 3. **Quick calibration via last-layer fine-tuning** β enables cross-user generalization without full retraining |
| 4. **Hysteresis voting** β stable real-time predictions for actuator control |
|
|
| ## Files |
|
|
| | File | Description | |
| |------|-------------| |
| | `models/best_model_hand.pt` | Trained PyTorch weights | |
| | `models/hand_norm_mean.npy` | Global normalization mean | |
| | `models/hand_norm_std.npy` | Global normalization std | |
| | `code/train_hand.py` | Training pipeline | |
| | `code/quick_calibration.py` | Calibration + real-time inference | |
| | `code/collect_hand_data.py` | Guided data collection | |
|
|
| ## Usage |
|
|
| ```python |
| # Quick Calibration for new user |
| python3 quick_calibration.py |
| # Records 2 min β fine-tunes β real-time inference |
| ``` |
|
|
| ## Hardware |
|
|
| - Sensor: Myo Armband (8 EMG channels, 200Hz, Bluetooth) |
| - Controller: Raspberry Pi (deployment) |
| - Prosthetic: 3D-printed hand with servo motors + tendon system |
| - Communication: Serial (115200 baud) |
|
|
| ## Related |
|
|
| - Drone Control Model: [malansi/EMG-Gesture-Recognition](https://huggingface.co/malansi/EMG-Gesture-Recognition) |
| - Dataset: [malansi/EMG-Gesture-Dataset](https://huggingface.co/datasets/malansi/EMG-Gesture-Dataset) |
|
|
| ## Demo |
|
|
| https://youtube.com/shorts/JOfaNj-Af6Q |
|
|
| ## Author |
|
|
| Mohammed Alansi |
| AI & Biomechatronics Research β EMG-Based Prosthetic Arm Control |
|
|