SetCon / README.md
lschiweck's picture
Add SetCon-LM: language model on the frozen encoder (three seeds)
57ab439 verified
|
Raw History Blame
16.4 kB
---
license: cc-by-nc-4.0
language:
- en
library_name: transformers
pipeline_tag: feature-extraction
datasets:
- lschiweck/SetCon-eval
tags:
- imu
- wearable-sensing
- human-activity-recognition
- zero-shot-classification
- motion-language
- time-series
- custom_code
---
# SetCon: Setup-Conditioned IMU-Language Learning from 3D Human Motion
Lennart Schiweck<sup>1</sup>, Alaa Saleh<sup>2</sup>, CristΓ³bal Curio<sup>1</sup>
<sup>1</sup> Cognitive Systems Group, Reutlingen University, Germany &nbsp; <sup>2</sup> Bosch Sensortec GmbH, Germany
[[Paper](https://arxiv.org/abs/2611.32548)]
[[Project page](https://lschiweck.github.io/setcon/)]
[[Evaluation data](https://huggingface.co/datasets/lschiweck/SetCon-eval)]
SetCon aligns inertial measurement unit (IMU) signals with text for zero-shot activity recognition across wearable
devices. Its encoder maps a 10-s window of a worn device into the text embedding space of the frozen CLIP ViT-B/32
text encoder, and the window is classified as the activity whose text embedding lies nearest. A worn device's signal
depends on its setup, the combination of body site and mounting. Instead of making the encoder invariant to the
mounting, SetCon replaces full invariance with selective invariance. A calibrator estimates the setup reference of
each device on its known body site from a few unlabeled windows, and the encoder receives every window rotated so
that gravity points up together with gravity in the segment frame. Both networks were trained only on IMU simulated
from the Nymeria motion capture. On 13 real datasets SetCon reaches 56.6 % mean zero-shot accuracy with class names
and 65.3 % with anchors, against 41.8 % and 46.7 % for AnyMo. A language model on the frozen encoder, SetCon-LM
(Qwen3.5-0.8B), answers questions about a window in free text.
The model and its code are released for non-commercial research.
## Contents
```text
SetCon/
β”œβ”€β”€ config.json, model.safetensors seed 1 (default): encoder + calibrator
β”œβ”€β”€ seed2/, seed3/ the two other stage-2 seeds (same stage-1 model and calibrator)
β”œβ”€β”€ lm/ language model on encoder seed 1: Qwen3.5-0.8B + projector, tokenizer
β”‚ β”œβ”€β”€ seed2/, seed3/ the language models on encoder seeds 2 and 3
β”‚ └── LICENSE-QWEN Apache 2.0 license of the base model Qwen3.5-0.8B
β”œβ”€β”€ configuration_setcon.py remote code: configuration
β”œβ”€β”€ modeling_setcon.py remote code: encoder, calibrator, inference helpers
β”œβ”€β”€ processing_setcon.py body sites, gravity canonicalization, calibrator input, 6-of-12 selection
β”œβ”€β”€ configuration_setcon_lm.py remote code: language model configuration (prompt, site names)
β”œβ”€β”€ modeling_setcon_lm.py remote code: language model (projector, prompt, ask / choose / yes_no)
β”œβ”€β”€ setcon/ evaluation package that recomputes the paper's numbers
β”œβ”€β”€ examples/zero_shot.py load, embed one window, classify against class names
β”œβ”€β”€ examples/ask_lm.py load encoder + language model, ask about one real window
β”œβ”€β”€ examples/reproduce_table1.py Tab. 1 and the abstract (with --all: Tab. 2, Tab. 3, Sec. 4.3-4.4)
β”œβ”€β”€ error_bank.json which calibrator the encoders were trained with, and its errors
β”œβ”€β”€ requirements.txt, CHECKSUMS.txt
β”œβ”€β”€ requirements-lm.txt environment of the language model (transformers 5)
└── LICENSE CC BY-NC 4.0, for the weights and the code
```
Each checkpoint holds the graph encoder (6.4 M parameters plus a 0.13 M text projection) and the calibrator
(0.48 M), float32, the exponential moving average of the weights after 100 stage-2 epochs. The training-only heads
are not included.
## Usage
```python
import numpy as np
from transformers import AutoModel
model = AutoModel.from_pretrained("lschiweck/SetCon", trust_remote_code=True) # seed 1
# model = AutoModel.from_pretrained("lschiweck/SetCon", subfolder="seed2", trust_remote_code=True)
model = model.to("cuda").eval()
```
From raw windows of one device to zero-shot predictions (the processing helpers ship with the repository):
```python
import processing_setcon as P # from a local copy of this repository
windows = P.prepare_device(acc, gyro, fs=50) # acc (N, T, 3) m/s^2 with gravity, gyro (N, T, 3) rad/s or None
ref = model.estimate_reference(windows[context_idx], site="r_wrist") # six unlabeled windows of the same device
windows = P.set_reference(windows, ref["reference"])
x = P.place_devices({"r_wrist": windows}) # (N, 200, 22, 9); several devices: one entry per site
z = model.embed(x) # (N, 512) unit vectors in the CLIP ViT-B/32 text space
pred = (z @ class_vectors.T).argmax(1) # class_vectors: unit CLIP ViT-B/32 text embeddings
```
`examples/zero_shot.py` runs these steps on real data (a phone on the waist in UCI-HAR). Site names are listed in
`processing_setcon.SITE_NAMES`, for example `r_wrist`, `l_lowarm`, `c_spine1` (waist), `r_upleg` (thigh pocket),
`c_head`. A window is 10 s at 20 Hz; `prepare_device` resamples, wrap-pads shorter windows and cuts longer ones.
`model.select_context(windows12, site)` picks six of twelve unlabeled windows by the calibrator's tilt uncertainty,
as in the last row of Tab. 1.
## Language model
SetCon-LM puts Qwen3.5-0.8B on the frozen encoder (paper Sec. 3.6) and answers questions about a window in free
text, for example what the person is doing or how the activity is performed. A projector maps the encoder's setup
vector (from the worn-site and gyroscope flags) to one token and its feature of every worn site and 0.2-s patch to one
token each. These tokens precede a chat prompt that names the worn sites and asks the question. The projector was
first trained to caption simulated windows with the language model frozen, then together with the language model on
captions and question-answer pairs that an LLM wrote from the narrations and the measured motion of each window.
```python
from transformers import AutoModel
setcon = AutoModel.from_pretrained("lschiweck/SetCon", trust_remote_code=True).to("cuda").eval()
lm = AutoModel.from_pretrained("lschiweck/SetCon", subfolder="lm", trust_remote_code=True).to("cuda").eval()
# x: (N, 200, 22, 9) windows with the setup reference set, as in Usage above
lm.ask(setcon, x, "What is the person doing?") # one answer per window
lm.ask(setcon, x, "How is the activity performed in terms of pace?")
lm.choose(setcon, x, "Which activity is this: A) walking B) sitting?", ["A) walking", "B) sitting"])
```
`ask` decodes greedily. `choose` picks the candidate answer with the lowest mean token loss, and `yes_no` compares
"Yes" and "No" as the first answer token; this is how the paper scores its questions with candidate answers.
`lm/seed2` and `lm/seed3` belong to the encoders `seed2` and `seed3` and refuse any other encoder. Each language model
holds the fine-tuned Qwen3.5-0.8B (input and output embeddings tied) and the projector in float32, the weights at the
end of training (3.0 GB per seed). It needs `requirements-lm.txt` (Python >= 3.10, transformers 5); the encoder alone
runs with `requirements.txt`. `examples/ask_lm.py` asks about a window of UCI-HAR.
Numbers of the paper (Sec. 4.4 and Tab. 2), mean over the three seeds, in %:
| Question | Paper |
|---|---:|
| "What is the person doing?", free answer mapped to a class name by an LLM judge, Mean-13 accuracy with six random context windows (Tab. 2) | 59.2 Β± 1.5 |
| Encoder on the same windows, class names / anchors | 55.9 / 64.7 |
| Held-out simulated Nymeria windows, five-way questions on execution / order / body region (chance 20) | 71 / 64 / 46 |
| Same windows, five-way activity question (chance 20) / four-way activity choice (chance 25) | 58 / 82 |
| Same windows, yes/no questions (chance 50) | 80 |
The answers depend on the signal: without the IMU tokens the free answers reach 5.6 % Mean-13 accuracy (on a subset
of the windows of Tab. 2), and given the IMU tokens of another window they name that window's class in 59 % of cases.
These numbers cannot be recomputed from this repository alone. The Mean-13 accuracy needs the LLM judge
(Qwen3.6-27B), and the held-out questions need simulated windows; neither is released. With the settings below, the
released language models give the paper run's answers word for word.
Fixed settings: encoder and projector under bfloat16 autocast on CUDA, the language model in float32 without
autocast, batches of 32 windows (left padding), greedy decoding with at most 48 new tokens, stop at `<|im_end|>` or
`<|endoftext|>`. The Gated DeltaNet layers use the flash-linear-attention kernels with
`FLA_DISABLE_BACKEND_DISPATCH=1` (set by the remote code unless already set). Reference environment: Python 3.12,
torch 2.8.0+cu128, transformers 5.14.1, flash-linear-attention 0.5.2, causal-conv1d 1.7.0, triton 3.7.1. Other
devices, precisions, batch sizes or kernels can change single answers.
## Reproducing the paper's numbers
```bash
pip install -r requirements.txt
hf download lschiweck/SetCon --local-dir SetCon
hf download lschiweck/SetCon-eval --repo-type dataset --local-dir SetCon-eval
hf download xiyuanz/UniMTS UniMTS_data.zip --revision 378531dbc1ec649b5bb792fd2e8f4c9a1a3ff99d --local-dir raw
python SetCon/examples/reproduce_table1.py --unimts-zip raw/UniMTS_data.zip --eval-data SetCon-eval --work work
```
The script checks the sha256 of the archive and of the 54 test files it extracts, builds the inputs of the 18 test
sets, runs all three seeds and prints every number next to the printed one. `--all` adds Tab. 2, Tab. 3 and the
numbers of Sec. 4.3 and 4.4 (about 7 min per seed on one H100; seeds can run in parallel with `--step evaluate
--seeds 2` and a final `--step tables`). The evaluation data also hold the paper's per-window predictions, and the
script reports how many of your predictions differ from them. In a clean environment with the reference settings
none differ, and all 29 SetCon numbers of Tab. 1-3 and Sec. 4.3-4.4 equal the printed ones.
The test windows come from `UniMTS_data.zip` of the UniMTS release (4,810,820,152 bytes, sha256
`ad8776dfbfc8acb5d57616f918289e32948a2842b4b54a228d13906e58d1d776`). The archive carries no license, so it is not
redistributed here. The working folder needs about 1.6 GB (1.2 GB extracted test files, 0.35 GB model inputs).
### Expected numbers
Mean-13 in %, mean Β± sd (ddof 1) over the three stage-2 seeds, as printed in the paper. The seeds share one stage-1
model and calibrator, and a single seed alone does not give the printed value.
| Reading (paper) | Metric | Paper |
|---|---|---:|
| 6 of 12 windows (Tab. 1 last row, abstract) | accuracy, names | 56.6 Β± 0.6 |
| | accuracy, anchors | 65.3 Β± 0.4 |
| | macro-F1, names | 51.6 Β± 0.7 |
| | macro-F1, anchors | 62.1 Β± 0.4 |
| | class-mean readout | 91.6 Β± 0.2 |
| 6 random windows (Tab. 1 row 3, Tab. 2) | accuracy, names | 55.9 Β± 0.4 |
| | accuracy, anchors | 64.7 Β± 0.6 |
| | macro-F1, names | 50.2 Β± 0.6 |
| | macro-F1, anchors | 60.5 Β± 0.5 |
| | class-mean readout | 91.5 Β± 0.2 |
| Walking frame (Tab. 2) | accuracy, names / anchors | 54.6 Β± 0.2 / 62.7 Β± 0.6 |
| Zeroed reference (Tab. 2) | accuracy, names / anchors | 41.5 Β± 0.7 / 48.0 Β± 2.1 |
| One context window (Sec. 4.3) | accuracy, names | 53.7 |
With `--all` the script also prints the six groups of Tab. 3 and the remaining SetCon numbers of Sec. 4.3 and 4.4,
29 numbers in total, each with its per-seed values.
For comparison, on the windows of the last row of Tab. 1 the released UniMTS reaches 41.4 / 43.2 and the released
AnyMo 41.8 / 46.7 (names / anchors). These baselines are not part of this repository.
### Fixed settings
- **Device and precision.** Encoder on CUDA under bfloat16 autocast with batches of 64 windows; calibrator on CPU in
float32 with 4 threads. Reference environment: Python 3.9, torch 2.8.0+cu128, numpy 2.0.2, transformers 4.57.6.
Running the encoder on CPU in float32 or with another batch size changes a small share of the predictions and can
move a printed digit.
- **Devices and context.** All test windows of one participant at one site form one device (person ids in the
evaluation data; datasets without exact ids count as one participant). Draw k = 0..4 picks six context windows per
device with `numpy.random.default_rng(1000 + k)`. Context windows are never scored. Groups with fewer than 7
windows get no reference.
- **6 of 12.** Groups with at least 18 windows draw six extra context windows with
`numpy.random.default_rng([0xCA12, i, k, g])` (i = index of the dataset in the list of 18, g = group id). The
calibrator then drops windows one by one until the six with the smallest tilt uncertainty remain.
- **One context window** (Sec. 4.3): `numpy.random.default_rng([2000, k, g])` picks one of the six.
- **Class texts.** Names are the class strings of the datasets. An anchor (paper Eq. 8) averages the CLIP embeddings
of the name, its ten nearest Nymeria narrations and thirty LLM-written descriptions. The paper's exact vectors and
all their texts are in the evaluation data.
## Training
Stage 1 pretrains the encoder and the calibrator on IMU simulated on Momentum Human Rig (MHR) bodies fitted to the
Nymeria motion capture. One movement is simulated under several sets of worn devices, and the calibrator learns each
simulated device's known mounting. Stage 2 aligns the encoder with the frozen CLIP ViT-B/32 text encoder on Nymeria's
narrations and on captions that an LLM generates from the measured motion, under calibrator errors drawn from an
error bank, for 100 epochs. The three released checkpoints are three stage-2 seeds on one stage-1 model. No test
dataset or test participant is used in training. Training code is not part of this release.
## Not included
- The LLM judge that maps the language model's free answers to class names, and the simulated held-out windows of
its questions with given answers.
- Training code (encoder, calibrator and language model), the simulation and the training data pipeline.
- The baselines (UniMTS, AnyMo) and the test data themselves.
## Intended use and limitations
SetCon is meant for non-commercial research on wearable activity recognition, IMU-language representations and
zero-shot classification. It assumes that the body site of each device is known and that the mounting stays fixed
while the device is worn. Unscripted daily life, in which devices slip and sites are unknown, remains to be tested.
The language model writes fluent sentences also when they are wrong.
Activity recognition reveals what the wearer does, so deployment requires the wearers' informed consent. The model
must not be the sole basis for clinical or other high-stakes decisions.
## License
- Model weights: CC BY-NC 4.0 (`LICENSE`), because they were trained on Nymeria (CC BY-NC 4.0). The body model MHR
used for the simulation is licensed under Apache 2.0.
- Language model weights (`lm/`): CC BY-NC 4.0 as well, fine-tuned from Qwen3.5-0.8B (Apache 2.0, `lm/LICENSE-QWEN`).
- Code in this repository: CC BY-NC 4.0 (`LICENSE`), like the weights.
- Evaluation data: CC BY-NC 4.0 (separate dataset repository; it contains Nymeria narration sentences).
- Test data: not included; each benchmark keeps its own terms.
## Acknowledgments
This research was funded by the European Regional Development Fund (ERDF) within the project 'AIDA' (grant
FEIH 2476184). L. Schiweck was supported by a scholarship from Bosch Sensortec GmbH. Views and opinions expressed are
those of the authors only and do not necessarily reflect those of the European Union. Neither the European Union nor
the granting authority can be held responsible for them.
## Citation
```bibtex
@misc{schiweck2026setcon,
title = {{SetCon}: Setup-Conditioned {IMU}-Language Learning from {3D} Human Motion},
author = {Schiweck, Lennart and Saleh, Alaa and Curio, Crist{\'o}bal},
year = {2026},
eprint = {2611.32548},
archivePrefix = {arXiv},
primaryClass = {cs.CV},
url = {https://arxiv.org/abs/2611.32548}
}
```