File size: 11,378 Bytes
78b2ca4
 
 
 
a5de583
 
 
d8d0a57
 
 
 
a5de583
 
d8d0a57
a5de583
 
 
 
 
 
 
d8d0a57
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d78cc43
d8d0a57
 
 
 
 
 
 
 
 
 
 
 
 
d78cc43
d8d0a57
 
 
d78cc43
d8d0a57
 
 
d78cc43
d8d0a57
 
 
 
 
 
 
 
 
 
 
3aa0143
d8d0a57
d78cc43
d8d0a57
 
 
 
 
 
 
 
 
 
 
3aa0143
d8d0a57
d78cc43
d8d0a57
 
 
75cce26
a5de583
a476d55
f8b506a
a5de583
 
 
a476d55
 
 
 
 
 
 
 
 
75cce26
 
a5de583
c57b77f
a5de583
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22799db
a5de583
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22799db
a5de583
 
 
 
 
 
 
 
22799db
a5de583
 
 
 
 
22799db
 
 
a5de583
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22799db
a5de583
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75cce26
 
 
a5de583
 
 
 
 
 
 
 
 
a476d55
 
 
 
 
 
 
 
 
a5de583
 
 
 
 
 
 
 
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
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
---
license: cc-by-nd-4.0
language:
- en
model-index:
- name: TinyMyo
  results:

  # -------------------------
  # Hand Gesture Classification
  # -------------------------
  - task:
      type: gesture-classification
    dataset:
      type: ninapro_db5
      name: Ninapro DB5
    metrics:
    - name: acc@1
      type: acc@1
      value: 0.8941
      verified: false
    - name: f1
      type: f1
      value: 0.7797
      verified: false

  - task:
      type: gesture-classification
    dataset:
      type: epn612
      name: EPN-612
    metrics:
    - name: acc@1
      type: acc@1
      value: 0.9674
      verified: false
    - name: f1
      type: f1
      value: 0.9674
      verified: false

  - task:
      type: gesture-classification
    dataset:
      type: uci_emg
      name: UCI-EMG
    metrics:
    - name: acc@1
      type: acc@1
      value: 0.9756
      verified: false
    - name: f1
      type: f1
      value: 0.9755
      verified: false

  # -------------------------
  # Generic Neuromotor Interface (Meta RL)
  # -------------------------
  - task:
      type: gesture-classification
    dataset:
      type: gni_meta_rl
      name: Generic Neuromotor Interface (Discrete Gesture)
    metrics:
    - name: CLER
      type: classification-error-rate
      value: 0.153
      verified: false

  # -------------------------
  # Hand Kinematic Regression
  # -------------------------
  - task:
      type: kinematic-regression
    dataset:
      type: ninapro_db8
      name: Ninapro DB8
    metrics:
    - name: MAE
      type: mean-absolute-error
      value: 8.77
      verified: false
    - name: RMSE
      type: root-mean-square-error
      value: 13.35
      verified: false
    - name: R2
      type: r2
      value: 0.62
      verified: false

  # -------------------------
  # Silent Speech Synthesis
  # -------------------------
  - task:
      type: speech-synthesis
    dataset:
      type: gaddy_silent_speech
      name: Gaddy Silent Speech (MFCC to Audio)
    metrics:
    - name: WER
      type: word-error-rate
      value: 0.3354
      verified: false

  # -------------------------
  # Silent Speech Recognition
  # -------------------------
  - task:
      type: speech-recognition
    dataset:
      type: gaddy_silent_speech
      name: Gaddy Silent Speech (EMG to Text)
    metrics:
    - name: WER
      type: word-error-rate
      value: 0.3395
      verified: false
---

<div align="center">
  <img src="https://raw.githubusercontent.com/MatteoFasulo/BioFoundation/refs/heads/TinyMyo/docs/model/logo/TinyMyo_logo.png" alt="TinyMyo Logo" width="400" />
  <h1>TinyMyo: a Tiny Foundation Model for Flexible EMG Signal Processing at the Edge</h1> 
</div> 
<p align="center"> 
  <a href="https://github.com/pulp-bio/BioFoundation">
    <img src ="https://img.shields.io/github/stars/pulp-bio/BioFoundation?color=ccf" alt="Github">
  </a>
  <a href="https://creativecommons.org/licenses/by-nd/4.0/">
    <img src="https://img.shields.io/badge/License-CC_BY--ND_4.0-lightgrey.svg" alt="License">
  </a>
  <a href="https://arxiv.org/abs/2512.15729">
    <img src="https://img.shields.io/badge/arXiv-2512.15729-b31b1b.svg" alt="Paper">
  </a>
</p>

**TinyMyo** is a **3.6M-parameter** Transformer-based **foundation model for surface EMG (sEMG)**.
It is pretrained on >480 GB of EMG data and optimized for **ultra-low-power, real-time deployment**, including **microcontrollers (GAP9)** where it achieves an inference time of **0.785 s**, energy of **44.91 mJ** and power envelope of **57.18 mW**.

TinyMyo is built for **broad generalization** across datasets, sensor configurations, movement tasks, subjects, and domains (gesture, kinematics, speech).

---

# 🔒 License & Usage (Model Weights)

The released TinyMyo weights are licensed under **CC BY-ND 4.0**.
This summary is not legal advice—please read the full license.

### ✅ You may

* **Use** and **redistribute** the **unmodified** TinyMyo weights (including commercially) **with attribution**.
* **Fine-tune/modify internally** for research or production without redistributing modified weights.
* **Publish code, configs, evaluations, and papers** using TinyMyo.

### 🚫 You may not

* **Share or host modified weights** in any form (including LoRA/adapter deltas, pruned/quantized models).
* **Claim endorsement** from the TinyMyo authors without permission.
* **Use the TinyMyo name** for derivative models.

### 🤝 Contributing Improvements

To upstream improvements, submit a **PR** to the
**[BioFoundation repository](https://github.com/pulp-bio/BioFoundation)** with:

1. Full reproducibility artifacts (configs, logs, seeds, environment).
2. Evaluation on standard protocols (e.g., DB5, EPN-612, UCI EMG, DB8, Silent Speech).
3. Comparison to TinyMyo’s reported metrics.

Approved PRs will be retrained and released as **official TinyMyo** checkpoints under CC BY-ND.

---

# 🔎 1. Default Input & Preprocessing

Unless specified otherwise, TinyMyo expects:

* **Channels:** 16
* **Sampling rate:** 2000 Hz
* **Segment length:** 1000 samples (0.5 s)
* **Windowing:** 50% overlap (pretraining)
* **Preprocessing:**

  * 4th-order **20–450 Hz bandpass**
  * **50 Hz notch filter**
  * **Min–max normalization** (pretraining)
  * **Z-score normalization** (downstream)

Datasets with <16 channels are **zero-padded (pretraining only)**.

---

# 🔬 2. Pretraining Overview

TinyMyo is pretrained via masked reconstruction on **three large-scale EMG datasets**:

| Dataset     | Subjects | fs      | Channels | Size    |
| ----------- | -------- | ------- | -------- | ------- |
| Ninapro DB6 | 10       | 2000 Hz | 14       | 20.3 GB |
| Ninapro DB7 | 22       | 2000 Hz | 12       | 30.9 GB |
| EMG2Pose    | 192      | 2000 Hz | 16       | 431 GB  |

## Tokenization: Channel-Independent Patches

Unlike EEG FMs that mix channels early, TinyMyo uses **per-channel patching**:

* Patch length: **20 samples**
* Patch stride: **20 samples**
* Tokens/channel: **50**
* Total seq length: **800 tokens** (16 x 50)
* Positional encoding: **RoPE (rotary)**

This preserves electrode-specific structure while allowing attention to learn cross-channel relationships.

## Transformer Encoder

* **8 layers**, **3 heads**
* Embedding dim: **192**
* Pre-LayerNorm
* Dropout & drop-path: **0.1**

## Lightweight Decoder

A **single linear layer** (~3.9k params) reconstructs masked patches.
Following SimMIM, this forces the encoder to learn robust latent structure.

## Masking Objective

* **50% random masking** with a learnable `[MASK]` token
* Loss: **Smooth L1** with small penalty on visible patches
$$
  \mathcal{L} = \mathcal{L}*{\text{masked}} + 0.1,\mathcal{L}*{\text{visible}}
$$

## Training Setup

* Optimizer: **AdamW** (β=(0.9,0.98), wd=0.01)
* LR: **1e-4** with cosine decay
* Batch size: **512** (with grad accumulation)
* Epochs: **50**, warm-up: 10
* Hardware: **4× NVIDIA GH200 GPUs**

---

# 🧠 3. Architecture Summary

### Model Variant

| Variant | Params   | (Layers, Dim) |
| ------- | -------- | ------------- |
| TinyMyo | **3.6M** | (8, 192)      |

---

# 🎯 4. Downstream Tasks

TinyMyo generalizes across **gesture classification**, **kinematic regression**, and **speech EMG**—with state-of-the-art or competitive results.

---

## 4.1 Hand Gesture Classification

Evaluated on:

* **Ninapro DB5** (52 classes, 10 subjects)
* **EPN-612** (5 classes, 612 subjects)
* **UCI EMG** (6 classes, 36 subjects)
* **Meta Neuromotor Interface** (9 gestures)

### Preprocessing

* EMG filtering: **20–90 Hz bandpass + 50 Hz notch**
* Window sizes:

  * **200 ms** (best for DB5)
  * **1000 ms** (best for EPN, UCI)

### Linear Classification Head

* Input: **C × 192**
* Params: **<40k**

### Performance (Fine-tuned)

| Dataset                  | Metric | Result            |
| ------------------------ | ------ | ----------------- |
| **Ninapro DB5** (200 ms) | Acc    | **89.41 ± 0.16%** |
| **EPN-612** (1000 ms)    | Acc    | **96.74 ± 0.09%** |
| **UCI EMG** (1000 ms)    | Acc    | **97.56 ± 0.32%** |
| **Neuromotor**           | CLER   | **0.153 ± 0.006** |

TinyMyo achieves **new state-of-the-art** on DB5, EPN-612, and UCI.

---

## 4.2 Hand Kinematic Regression (Ninapro DB8)

* Predict **5 joint angles**
* Windows: **200 ms** or **1000 ms**
* Normalization: z-score only

### Regression Head (~788k params)

* Depthwise + pointwise convs
* Upsampling
* Global average pooling
* Linear projection to 5 outputs

### Performance

* **MAE = 8.77 ± 0.12°** (1000 ms)

Note: Prior works reporting ~6.9° MAE are **subject-specific**; TinyMyo trains a **single cross-subject model**, a significantly harder setting.

---

## 4.3 Speech Production & Recognition (Silent Speech)

Dataset: **Gaddy Silent Speech**
(8 channels, 1000 Hz, face/neck EMG)

### Speech Production (EMG → MFCC → HiFi-GAN → Audio)

Pipeline:

1. Residual downsampling
2. TinyMyo encoder
3. Linear projection → **26-dim MFCC**
4. HiFi-GAN vocoder

**WER:** **33.54 ± 1.12%**
≈ state-of-the-art with **>90% fewer params** in the transduction model.

### Speech Recognition (EMG → Text)

* TinyMyo encoder
* Linear projection → **37 characters**
* **CTC** loss
* 4-gram LM + beam search

**WER:** **33.95 ± 0.97%**

TinyMyo is EMG-only, unlike multimodal systems like MONA-LISA.

---

# ⚡ 5. Edge Deployment (GAP9 MCU)

TinyMyo runs efficiently on **GAP9 (RISC-V)** via:

* **INT8 quantization**, including attention
* Multi-level streaming (L3 to L2 to L1)
* Integer LayerNorm, GELU, softmax
* Static memory arena via liveness analysis

### Runtime (DB5 pipeline)

* **Inference time**: **0.785 s**
* **Energy**: **44.91 mJ**
* **Average power**: **57.18 mW**

This is the **first EMG foundation model demonstrated on a microcontroller**.

---

# 📊 6. Results Summary

### Pretraining

* Smooth L1 reconstruction with high fidelity
* Total compute ≈ **4.0 GFLOPs**

### Downstream Highlights

* **DB5:** 89.41%
* **EPN-612:** 96.74%
* **UCI EMG:** 97.56%
* **Neuromotor:** 0.153 CLER
* **DB8 Regression:** MAE 8.77°
* **Silent Speech Production:** 33.54% WER
* **Silent Speech Recognition:** 33.95% WER

TinyMyo matches or exceeds state-of-the-art performance, while being smaller and more efficient than all prior EMG foundation models.

---

# 🛠️ Code & Usage

To fine-tune TinyMyo on downstream tasks, follow the examples in the
**[BioFoundation repository](https://github.com/pulp-bio/BioFoundation)**.

```bash
python -u run_train.py +experiment=TinyMyo_finetune \
    pretrained_safetensors_path=/path/to/model.safetensors
```

Environment variables:

* `DATA_PATH` → dataset path
* `CHECKPOINT_DIR` → checkpoint to load

---

## 🔗 Resources

- **Code:** https://github.com/pulp-bio/BioFoundation  

---

# 📜 Citation

Please cite TinyMyo using:

```bibtex
@misc{fasulo2025tinymyotinyfoundationmodel,
      title={TinyMyo: a Tiny Foundation Model for Flexible EMG Signal Processing at the Edge}, 
      author={Matteo Fasulo and Giusy Spacone and Thorir Mar Ingolfsson and Yawei Li and Luca Benini and Andrea Cossettini},
      year={2025},
      eprint={2512.15729},
      archivePrefix={arXiv},
      primaryClass={eess.SP},
      url={https://arxiv.org/abs/2512.15729}, 
}
```

---

# 🧭 Contact & Support

* Questions or issues?
  Open an issue on the **BioFoundation GitHub repository**.