English
tinymyo
emg
bio-signals
foundation-model
File size: 5,377 Bytes
2a91a64
 
 
 
 
 
 
 
3e087c9
 
2a91a64
 
a24bc5a
a5de583
a476d55
f8b506a
45d17fb
a24bc5a
45d17fb
 
 
 
75cce26
 
a24bc5a
808a02d
 
 
 
 
 
 
 
 
 
 
 
 
a5de583
a24bc5a
808a02d
 
 
 
 
 
 
 
 
a5de583
a24bc5a
808a02d
 
 
 
3e087c9
 
808a02d
a5de583
808a02d
 
3e087c9
a24bc5a
808a02d
a5de583
a24bc5a
 
75cce26
3e087c9
808a02d
a5de583
a24bc5a
 
 
a5de583
808a02d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45d17fb
a24bc5a
a5de583
 
45d17fb
 
a476d55
45d17fb
a476d55
 
808a02d
 
a476d55
808a02d
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
---
license: cc-by-nd-4.0
language:
- en
tags:
- emg
- bio-signals
- foundation-model
base_model:
- PulpBio/TinyMyo
---

# TinyMyo: Tiny Foundation Model for EMG Signal Processing

<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" />
</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>

## 📖 Overview
**TinyMyo** is a lightweight, Transformer-based foundation model designed specifically for surface electromyography (sEMG) signal processing. Unlike large-scale models, the TinyMyo family (including the 3.6M parameter base model and the ultra-compact 1.9M parameter **TinyssimoMyo**) is purpose-built for **ultra-low-power edge deployment**. It enables real-time motor intent decoding, neuromuscular assessment, and human-machine interaction directly on microcontrollers like the GAP9.

## ⚙️ Model Configuration
*   **Base model:** 8-layer bidirectional Transformer encoder.
*   **TinyssimoMyo:** 4-layer compact variant.
*   **Embedding dimension:** 192.
*   **Attention heads:** 3.
*   **Temporal patch size:** 20 samples.
*   **Default input:** 16 channels × 1000 samples.
*   **Maximum channels:** 16.
*   **Tokenization:** Channel-independent patching with 50 temporal patches per channel and 800 tokens for the default input.
*   **Position encoding:** Rotary Position Embeddings (RoPE), with temporal positions reset for each channel.
*   **Training objective:** Self-supervised masked patch reconstruction.

## 🧠 Model Architecture
TinyMyo uses channel-independent patch embeddings followed by a bidirectional
Transformer encoder. Tokens are ordered channel-major, while RoPE positions reset
for each channel so flattening does not introduce a false temporal distance between
channels. The learned channel embedding identifies a channel slot; it does not
encode physical electrode coordinates.

For deployment, the family can be paired with offline liveness analysis,
multi-level memory tiling, and INT8 fixed-point execution. See the paper and model
card for deployment measurements.

## ⚡ Deployment (GAP9 MCU)
TinyMyo is designed for resource-constrained deployment on platforms such as the
GAP9 MCU. The repository does not treat deployment measurements as model
configuration; see the [paper](https://arxiv.org/abs/2512.15729) and the
[Hugging Face model card](https://huggingface.co/PulpBio/TinyMyo) for current results.

### TinyMyo (3.6M Parameters)
*   8-layer encoder configuration.

### TinyssimoMyo (1.9M Parameters)
*   4-layer compact configuration.

## 🛠️ Getting Started
TinyMyo is part of the [BioFoundation](https://github.com/pulp-bio/BioFoundation) ecosystem.

### Prerequisites
Install the required dependencies from the [BioFoundation repository](https://github.com/pulp-bio/BioFoundation).

### Loading & Fine-tuning
Fine-tune a pretrained checkpoint using the BioFoundation training entry point:

```bash
python run_train.py +experiment=TinyMyo_finetune pretrained_safetensors_path={*.safetensors}
```

Available checkpoint groups include pretraining, DB5, EPN-612, UCI EMG, and DB8.
Use the matching configuration and checkpoint for each task. The released
classification labels are:

| Dataset | Input channels | Classes | Label convention | Checkpoint |
| :--- | ---: | ---: | :--- | :--- |
| NinaPro DB5 | 16 | 53 | 52 gestures + resting | `DB5/DB5_finetune_5sec.safetensors` |
| EPN-612 | 8 | 6 | 5 gestures + hand relaxed | `EPN612/EPN_finetune_5sec.safetensors` |
| UCI EMG | 8 | 6 | Dataset-specific six-class gesture labels | `UCI_EMG/UCI_finetune_5sec.safetensors` |
| NinaPro DB8 | 16 | 5 | Regression outputs | `DB8/DB8_finetune_500ms.safetensors` |

The model configuration must match the checkpoint, especially `in_chans`,
`num_classes`, and `task`. The built-in BioFoundation `TinyMyo_finetune`
experiment currently points to UCI EMG data and can be launched from a
BioFoundation checkout with:

```bash
python -u run_train.py +experiment=TinyMyo_finetune \
  model.in_chans=8 \
  pretrained_safetensors_path=/absolute/path/to/TinyMyo/UCI_EMG/UCI_finetune_5sec.safetensors
```

DB5, EPN-612, and DB8 require matching dataset-specific data-module settings
in BioFoundation before training. Benchmark results
and the latest experimental protocols are maintained in the paper and model card.

## 📜 License & Citation
This model is licensed under **CC BY-ND 4.0**. If you find TinyMyo useful in your research, please cite our paper:

```bibtex
@misc{fasulo2026tinymyotinyfoundationmodel,
      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={2026},
      eprint={2512.15729},
      archivePrefix={arXiv},
      primaryClass={eess.SP},
      url={https://arxiv.org/abs/2512.15729},
}
```