MinPair / README.md
lschiweck's picture
Licence notices for the STMC/TMR feature decoding
131f08a verified
|
Raw History Blame Contribute Delete
14.9 kB
---
license: other
license_name: frankenmotion-noncommercial
license_link: LICENSE
language:
- en
library_name: transformers
tags:
- text-to-motion
- motion-generation
- human-motion
- diffusion
- smpl-h
- custom_code
---
# MinPair: Measured Minimal Pairs for Fine-Grained Control in Text-to-Motion Generation
Lennart Schiweck, CristΓ³bal Curio
Cognitive Systems Group, Reutlingen University, Germany
[[Paper](https://arxiv.org/abs/2611.32549)]
[[Project page](https://lschiweck.github.io/minpair/)]
MinPair is a text-to-motion diffusion model that controls how an action is executed: how high, how fast and how far
a movement goes and how much it turns. Like [FrankenMotion](https://github.com/Coral79/FrankenMotion-Code), it reads
part captions, timed sentences for each body part on eight tracks. It was trained on MinPair captions, timed part
captions written from measurements of each motion, and with measured minimal pairs: the true caption of a real clip
and an altered copy in which only one attribute takes the value measured in another real clip of the same action. A
contrastive pair loss requires the denoiser to reconstruct the clip more accurately from its true caption than from
the altered copy. Inference stays unchanged, a standard diffusion sampler.
The model and its code are released for non-commercial research (see the license below).
## Model components
```text
minpair/
β”œβ”€β”€ model.safetensors denoiser weights (exponential moving average) and motion normalization
β”œβ”€β”€ config.json hyperparameters of the denoiser, the sampler and the text encoders
β”œβ”€β”€ configuration_minpair.py MinPairConfig
β”œβ”€β”€ modeling_minpair.py part-track denoiser, sampler, MinPairModel.generate_motion
β”œβ”€β”€ text_minpair.py part captions, one-sentence prompts, CLIP and T5 text encoders
β”œβ”€β”€ motion_minpair.py motion features -> SMPL-H joint rotations and joint positions
β”œβ”€β”€ requirements.txt
β”œβ”€β”€ LICENSE non-commercial license (inherited from FrankenMotion)
β”œβ”€β”€ LICENSE-PYTORCH3D license of the rotation helpers in motion_minpair.py
β”œβ”€β”€ CHECKSUMS.txt sha256 of every file
└── examples/ leg height example and the foot height measurement
```
The part-track denoiser is a Transformer over motion frames with 14.8 M parameters. Two extra tokens carry the
diffusion step and the global caption. In each of four blocks, every frame reads the segment that is active at this
frame on each of the eight tracks through cross-attention. The text encoders are frozen and not part of this
repository; they are loaded from their public sources on first use:
- global caption: OpenAI CLIP ViT-B/32 (`clip` package at a pinned commit)
- track sentences: T5-Large encoder, [`google-t5/t5-large`](https://huggingface.co/google-t5/t5-large) at revision `150ebc2c4b72291e770f58e6057481c8d2ed331a`
Sampling uses 100 DDPM steps with a cosine schedule and clean-motion prediction, without classifier-free guidance.
Motions have 20 frames per second and at most 400 frames (20 s).
## Installation
```bash
pip install setuptools==80.9.0 wheel==0.45.1
pip install --no-build-isolation -r requirements.txt
```
The CLIP package still imports `pkg_resources` during its build, hence the pinned `setuptools` and
`--no-build-isolation`. A CUDA GPU is recommended.
## Using the model
```python
import torch
from transformers import AutoModel
model = AutoModel.from_pretrained("lschiweck/MinPair", trust_remote_code=True).to("cuda")
prompt = {
"caption": "a person kicks with the left leg.",
"segments": [
{"track": "left_leg", "start": 0.5, "end": 1.5,
"text": "The left leg lifts from the ground to hip height with fast ankle motion."},
{"track": "left_leg", "start": 1.5, "end": 2.5,
"text": "The left foot lands from hip height to the ground with fast then still ankle motion."},
{"track": "spine", "start": 0.0, "end": 3.0, "text": "The torso remains upright."},
],
"duration": 3.0,
"seed": 0,
}
motion = model.generate_motion(prompt)
motion.save("kick.npz")
```
`generate_motion` takes one prompt or a list of prompts and returns one `Motion` per prompt. Lists are sorted by
length and generated in batches (`batch_frames`, default 32000 frames per batch).
### Input format
| field | meaning |
|---|---|
| `caption` | global caption of the whole motion, optional (`None` = no caption) |
| `segments` | timed sentences, each with `track`, `text`, `start` and `end` in seconds |
| `duration` | seconds covered by the caption |
| `num_frames` | motion length in frames, default `int(duration * 20)`, at most 400 |
| `offset` | time origin of the segment times, default 0 |
| `seed` | noise seed, default 0 |
The eight tracks are `action`, `trajectory` (the path of the pelvis, called path in the paper; `path` is accepted as
well), `spine`, `head`, `left_arm`, `right_arm`, `left_leg` and `right_leg`. Tracks need not share their boundaries.
A frame without a segment on a track carries no instruction there.
The model was trained on MinPair captions, which state the attributes of each body part in each phase with level
words on fixed word scales, for example *knee height*, *shoulder height* or *overhead* for heights and *still*,
*slow*, *moderate* or *fast* for tempo, a number of steps for the distance travelled and a turn angle rounded to
5 degrees. `examples/leg_height.json` holds a complete part caption in this style. Prompts close to this style work
best.
**One sentence.** `model.one_sentence` puts a single sentence into the global caption and on all eight tracks for the
whole motion, the one-sentence input of the paper:
```python
prompt = model.one_sentence("a person kicks to hip height with the left leg.", duration=3.0, seed=0)
motion = model.generate_motion(prompt)
```
Part captions give finer control than one sentence (see the results below).
**Seeds.** Each motion draws its noise from its own generator seeded with `seed`. A caption and an edit of it with the
same seed and length therefore receive identical noise, whatever else is in the batch, so a difference between the two
motions comes from the text alone. Outputs are reproducible for a fixed seed on the same hardware and software
versions.
### Output format
A `Motion` holds, at 20 frames per second (z up, meters):
| field | shape | content |
|---|---|---|
| `features` | `[T, 205]` | the generated motion features (FrankenMotion's SMPL-RiFKE representation) |
| `poses` | `[T, 22, 3]` | rotations of the 22 SMPL-H body joints, axis-angle, root first |
| `trans` | `[T, 3]` | root translation |
| `joints` | `[T, 24, 3]` | joint positions stored in the features (names in `motion_minpair.JOINT_NAMES`) |
`poses` and `trans` follow the SMPL-H body parametrization and need no model file. The joint positions stored in the
features come from the skeleton of the training data. For joints and meshes of the SMPL-H body, see below.
`Motion.save(path)` writes all fields to an `.npz` file.
### SMPL-H meshes (optional)
Generation runs without any body model file. SMPL-H is licensed separately and is not included in this repository.
To obtain meshes:
1. Register at [mano.is.tue.mpg.de](https://mano.is.tue.mpg.de), download SMPL-H yourself and prepare it as
described in the
[TEMOS instructions](https://github.com/Mathux/TEMOS?tab=readme-ov-file#4-optional-smpl-body-model), which
FrankenMotion follows: the extended SMPL+H model of [AMASS](https://amass.is.tue.mpg.de) (16 shape coefficients),
merged with the MANO hand components into `SMPLH_MALE.npz`, `SMPLH_FEMALE.npz` and `SMPLH_NEUTRAL.npz`. The
unmerged `model.npz` files lack the hand components and do not load. The male file we tested has sha256
`74e7343fc65afa4c6b78be7871459c1d219e1a5d904ba7e24f4f0e34011f3d91`.
2. Put the files into a folder, for example `smplh/`.
3. Run the forward kinematics:
```python
body = model.smplh_body("smplh/", gender="male")
out = body(motion) # {"vertices": [T, 6890, 3], "joints": [T, 24, 3]}, faces in body.faces
```
`smplh_body` uses the male model with zero shape coefficients and the mean hand pose. Like FrankenMotion's decoder,
it passes `trans` as the SMPL-H translation, so the SMPL-H pelvis sits at `trans` plus the model's rest-pose pelvis
offset (a constant shift of about 24 cm in the ground plane and 3 cm upward for the male model). Heights above the
floor are unaffected.
## Example: leg height
`examples/leg_height.py` generates the part caption of a held-out test clip three times. Only the height word of the
left leg changes, *ankle*, *knee* or *hip*, in the sentence that lifts the leg and in the one that lands it. All three
motions share the same seed. `examples/measure_foot_height.py` measures how high the left ankle rises above its
standing level, in standing knee heights of the same body.
```bash
python examples/leg_height.py --model lschiweck/MinPair
```
Expected output (NVIDIA H100, pinned requirements; other hardware changes the last digits):
```text
height word foot lift (cm) knee heights
ankle 21.6 0.48
knee 33.3 0.74
hip 74.7 1.66
```
## Results
From Tab. 1 of the paper. Attribute accuracy (target tasks) is the share of generated motions whose measured value
falls into the target range of the requested level, averaged over the task and level cells of 22 target tasks such as
kick height, arm height, turn angle, walking distance, squat count, trunk lean and knee bend. Template and free-form
edits change one attribute in the MinPair caption of a held-out test clip; an edit is followed when the motion moves
in the requested direction by at least half the change observed between real clips. M2M, R@3 and FID are computed
with the FrankenMotion evaluator. Every model reads its own input format; one-sentence inputs carry no side edits.
Success and R@3 in %.
| Model | Input | Data (h) | Target tasks ↑ | Template edits ↑ | Free-form edits ↑ | All edits ↑ | M2M ↑ | R@3 ↑ | FID ↓ |
|---|---|---|---:|---:|---:|---:|---:|---:|---:|
| MARDM | one sentence | <29 | 42.3 | 13.7 | 7.0 | 10.8 | 0.694 | 81.4 | 0.117 |
| HY-Motion 1.0 | one sentence | >3,000 | 55.2 | 22.5 | 16.7 | 20.0 | 0.754 | 89.0 | 0.059 |
| Kimodo | one sentence | 700 | 51.4 | 17.1 | 13.4 | 15.5 | 0.618 | 56.7 | 0.431 |
| FrankenMotion | part captions | 30 | 31.2 | 1.2 | 0.2 | 0.8 | 0.745 | 86.0 | 0.057 |
| **MinPair** | part captions | 30 | **62.7** | **60.2** | **55.0** | **58.1** | **0.830** | 85.9 | **0.038** |
When MinPair reads the one sentence of MARDM, HY-Motion and Kimodo in the global caption and on all eight tracks
instead of part captions, it follows 50.7 % of the template edits and 50.0 % of the free-form edits.
**Sampling options.** `generate_motion` draws per-motion noise of width 613 per frame and uses its first 205
columns (613 is the width of FrankenMotion's representation with its text channels). Precomputed CLIP vectors of
global captions can be passed with `generate_motion(..., caption_vectors={caption: vector})`; captions without a
vector are encoded by this package. `noise_factory` replaces the noise for other sampling schemes, and
`reuse_text_features=True` keeps sentence features across calls.
## Intended use and limitations
MinPair is intended for non-commercial research on controllable text-to-motion generation. It was trained on the
AMASS split of FrankenMotion (30 h of motion capture), on the 12,822 training clips of 1 to 20 s, so its range of
actions is that of this corpus. It covers attributes that can be measured from joint positions and expressed by a
word scale or a short phrase, such as height, tempo, turn, step count, side, trunk lean and twist, head speed and
joint bends. Style, emotion and contact with objects lie outside this set. Single sentences give less control than
part captions. The output is a body without hand motion. Generated motions can contain artifacts such as foot sliding
or floor penetration. Exact numbers depend on the GPU, the software versions and the batch composition (motions in
one batch are padded to the longest); the text encoders and the sampler run with TensorFloat-32 matrix
multiplications, the setting of the paper's results (`matmul_precision` in the config). On the CPU, CLIP runs in
float32 and results differ slightly from GPU results.
## Training data and licenses
- **Code and weights.** This repository builds on FrankenMotion and is released under its non-commercial license
(`LICENSE`): non-commercial scientific research, education and artistic projects only. Please also cite FrankenMotion.
- **Training data.** The model was trained on motions from [AMASS](https://amass.is.tue.mpg.de), which may be used for
non-commercial research only, with the clip split and the global and action captions of FrankenMotion and with
MinPair captions written from measurements of these clips. This repository contains the model and its inference
code only, no motion data, captions or benchmark data apart from the prompt of one example clip. The model expects part captions in the format of
`examples/leg_height.json`.
- **Body model.** SMPL-H is not included and not needed for generation; its use is subject to its own license.
- **Text encoders.** CLIP (MIT license) and T5-Large (Apache 2.0) are downloaded from their sources.
- **Rotation helpers.** Adapted from PyTorch3D (BSD 3-Clause, `LICENSE-PYTORCH3D`).
- **Feature decoding.** The smplrifke feature decoding follows [STMC](https://github.com/nv-tlabs/stmc) (NVIDIA License,
`LICENSE-STMC`) and [TMR](https://github.com/Mathux/TMR) (MIT, `LICENSE-TMR`), as used in FrankenMotion.
## Acknowledgments
This research was funded by the European Regional Development Fund (ERDF) within the project 'AIDA' (grant
FEIH 2476184). 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{schiweck2026minpair,
title = {{MinPair}: Measured Minimal Pairs for Fine-Grained Control in Text-to-Motion Generation},
author = {Schiweck, Lennart and Curio, Crist{\'o}bal},
year = {2026},
eprint = {2611.32549},
archivePrefix = {arXiv},
primaryClass = {cs.CV},
url = {https://arxiv.org/abs/2611.32549}
}
@article{li2026frankenmotion,
title = {FrankenMotion: Part-level Human Motion Generation and Composition},
author = {Li, Chuqiao and Xie, Xianghui and Cao, Yong and Geiger, Andreas and Pons-Moll, Gerard},
journal = {arXiv preprint arXiv:2601.10909},
year = {2026}
}
```