malansi commited on
Commit
9c3fd5e
Β·
verified Β·
1 Parent(s): 2796429

Add README

Browse files
Files changed (1) hide show
  1. README.md +133 -0
README.md ADDED
@@ -0,0 +1,133 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language: en
3
+ tags:
4
+ - emg
5
+ - gesture-recognition
6
+ - prosthetic-hand
7
+ - cnn-lstm
8
+ - myo-armband
9
+ - quick-calibration
10
+ - real-time
11
+ license: mit
12
+ ---
13
+
14
+ # EMG Hand Control β€” Prosthetic Hand Gesture Recognition
15
+
16
+ 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.
17
+
18
+ ## Performance
19
+
20
+ | Gesture | Accuracy (Self) | Accuracy (New User after Calibration) |
21
+ |---------|----------------|---------------------------------------|
22
+ | rest | 100% | ~85% |
23
+ | fist | 100% | ~85% |
24
+ | grasp | 99% | ~80% |
25
+ | index | 97% | ~75% |
26
+ | middle | 100% | ~85% |
27
+ | ring | 100% | ~85% |
28
+ | pinky | 95% | ~75% |
29
+ | thumb | 100% | ~85% |
30
+ | wrist_rotate_out | 92% | ~80% |
31
+ | wrist_rotate_in | 90% | ~80% |
32
+ | **Overall** | **97.2%** | **~85%** |
33
+
34
+ ## Architecture
35
+ Input: 150 samples Γ— 8 EMG channels (750ms @ 200Hz)
36
+ ↓
37
+ CNN Block:
38
+ Conv1D(64) β†’ BatchNorm β†’ ReLU
39
+ Conv1D(128) β†’ BatchNorm β†’ ReLU β†’ MaxPool β†’ Dropout(0.3)
40
+ Conv1D(256) β†’ BatchNorm β†’ ReLU β†’ MaxPool β†’ Dropout(0.3)
41
+ ↓
42
+ Bidirectional LSTM (hidden=128, layers=2, dropout=0.3)
43
+ ↓
44
+ FC: Dense(128) β†’ ReLU β†’ Dropout(0.4) β†’ Dense(10)
45
+ ↓
46
+ Output: 10 gesture classes
47
+
48
+ ## Quick Calibration System
49
+
50
+ New user calibration in ~2 minutes:
51
+
52
+ User wears Myo Armband
53
+ Performs each gesture 3 times Γ— 5 seconds
54
+ System fine-tunes last layer on user data (30s)
55
+ Ready β€” no full retraining needed
56
+
57
+
58
+ ## Gestures
59
+
60
+ | Label | Gesture |
61
+ |-------|---------|
62
+ | 0 | rest |
63
+ | 1 | fist |
64
+ | 2 | grasp (cylindrical grip) |
65
+ | 3 | index finger extension |
66
+ | 4 | middle finger extension |
67
+ | 5 | ring finger extension |
68
+ | 6 | pinky finger extension |
69
+ | 7 | thumb extension |
70
+ | 8 | wrist rotate out (pronation) |
71
+ | 9 | wrist rotate in (supination) |
72
+
73
+ ## Dataset
74
+
75
+ - 4 personal recording sessions
76
+ - 10 gestures Γ— 10 rounds Γ— 5 seconds each
77
+ - ~400,000 EMG samples
78
+ - Myo Armband β€” 8 channels β€” 200Hz
79
+
80
+ ## Training Details
81
+
82
+ | Parameter | Value |
83
+ |-----------|-------|
84
+ | Window | 150 samples (750ms) |
85
+ | Step | 75 samples (50% overlap) |
86
+ | Optimizer | AdamW (lr=5e-4) |
87
+ | Loss | Weighted CrossEntropy + Label Smoothing |
88
+ | Epochs | 100 (best at epoch 78) |
89
+ | Batch size | 128 |
90
+ | Normalization | Global fixed (saved as .npy files) |
91
+
92
+ ## Key Technical Contributions
93
+
94
+ 1. **Block-level train/test split** β€” prevents data leakage from overlapping windows
95
+ 2. **Fixed global normalization** β€” ensures train/inference consistency (critical fix that improved accuracy from 2% to 94% on rest gesture)
96
+ 3. **Quick calibration via last-layer fine-tuning** β€” enables cross-user generalization without full retraining
97
+ 4. **Hysteresis voting** β€” stable real-time predictions for actuator control
98
+
99
+ ## Files
100
+
101
+ | File | Description |
102
+ |------|-------------|
103
+ | `models/best_model_hand.pt` | Trained PyTorch weights |
104
+ | `models/hand_norm_mean.npy` | Global normalization mean |
105
+ | `models/hand_norm_std.npy` | Global normalization std |
106
+ | `code/train_hand.py` | Training pipeline |
107
+ | `code/quick_calibration.py` | Calibration + real-time inference |
108
+ | `code/collect_hand_data.py` | Guided data collection |
109
+
110
+ ## Usage
111
+
112
+ ```python
113
+ # Quick Calibration for new user
114
+ python3 quick_calibration.py
115
+ # Records 2 min β†’ fine-tunes β†’ real-time inference
116
+ ```
117
+
118
+ ## Hardware
119
+
120
+ - Sensor: Myo Armband (8 EMG channels, 200Hz, Bluetooth)
121
+ - Controller: Raspberry Pi (deployment)
122
+ - Prosthetic: 3D-printed hand with servo motors + tendon system
123
+ - Communication: Serial (115200 baud)
124
+
125
+ ## Related
126
+
127
+ - Drone Control Model: [malansi/EMG-Gesture-Recognition](https://huggingface.co/malansi/EMG-Gesture-Recognition)
128
+ - Dataset: [malansi/EMG-Gesture-Dataset](https://huggingface.co/datasets/malansi/EMG-Gesture-Dataset)
129
+
130
+ ## Author
131
+
132
+ Mohammed Alansi
133
+ AI & Biomechatronics Research β€” EMG-Based Prosthetic Arm Control