Tinghong-Ye22's picture
Add supplementary training, evaluation, and inference reference code
2bade0e verified
|
Raw History Blame Contribute Delete
5.99 kB

Movens-Live

Compact reference code for joint interaction control and streaming motion generation. The implementation contains a shared causal backbone, separate speech and motion memories, gated cross-attention, predicted-state write-back, private answer snapshots, and a conditional flow-matching motion head.

The small configuration runs on a CPU. It accepts synchronized audio-visual features rather than raw video and audio. Pretrained encoders, speech tokenizers and codecs, robot retargeting, simulation assets, and trained weights are external. This package uses its own checkpoint format; it does not load the full pretrained system's checkpoints or reproduce the paper's reported scores directly.

Run

Python 3.10 or newer is required.

python -m pip install -r requirements.txt
python make_example.py --output examples/sessions.pt
python train.py --data examples/sessions.pt --steps 20 --output outputs/model.pt
python infer.py --checkpoint outputs/model.pt --data examples/sessions.pt --output outputs/predictions.pt
python evaluate.py --prediction outputs/predictions.pt --reference examples/sessions.pt --output outputs/metrics.json
python -m unittest discover -s tests -v

The example contains synthetic features and motion for checking the software path. It is not benchmark data. Set --device cuda for training or inference on a GPU.

Source layout

File Role
movens_live/model.py Causal backbone, private branch memories, gated exchange, state and duration heads, answer decoder, motion velocity field
movens_live/losses.py Flow matching, state and reply classification, token prediction, duration supervision, temporal and height losses
movens_live/runtime.py Streaming state, reply debounce, answer replacement, progress, retained-prefix integration
movens_live/data.py Tensor-file validation and session loading
movens_live/metrics.py Action and position metrics, retrieval, FID, post-hoc event scoring
train.py, infer.py, evaluate.py Training, streaming inference, and evaluation entry points

Tensor format

Files are tensor dictionaries saved with torch.save. B is the number of sessions, T the number of input packets, and H the motion horizon.

Key Shape Meaning
features B, T, input_dim Causally available, synchronized input features
motion B, T, H, 40 Normalized target actions
states B, T 0: idle, 1: motion, 2: listen
speech_tokens B, T Optional token targets; 0 is padding, 1 BOS, 2 EOS
reply B, T Optional reply-start targets
durations B, T Optional target motion durations in seconds
context B, T, 2, 40 Two action frames preceding each target window
observed_motion B, T, 40 Optional observed action at each packet
valid B, T, H Optional valid-frame mask
progress B, T, H, 5 Optional progress features

Action channels are 29 joint coordinates, two local horizontal displacements, six rotation coordinates, root height, and two foot contacts. Data normalization and conversion to a robot representation belong in the dataset adapter.

The model conditions motion on its own hard state prediction during both training and inference. State labels supervise the classifier; they do not replace that prediction. Token inputs are shifted by one position. Speech losses update the shared and speech paths; the motion-to-speech exchange stops gradients into the private motion branch. Runtime answers use detached private snapshots, so continued input processing cannot alter an answer's saved context.

The default rollout predicts 30 frames at 50 Hz, executes 20, and retains the remaining 10 as the next prefix. The prefix is restored after every integration step. Duration uses 48 log-spaced bins and their median quantile. Temporal losses prepend two observed frames, include the kept/new seam, and operate on normalized action differences without division by the frame interval. Foot contacts are excluded from the joint and root temporal terms.

Evaluation

The basic command reports normalized action MSE, state accuracy, and non-padding token accuracy. These are software and training diagnostics, not physical tracking scores.

Additional fields enable the following metrics:

Fields Metric
joint_positions in both files, shaped B, frames, joints, 3, in metres MPJPE in millimetres and position jerk in metres per second cubed
motion_embeddings in the prediction and text_embeddings in the reference Retrieval in fixed pools of 32, with the incomplete remainder reported
motion_embeddings in both files Raw, unscaled feature FID

Embeddings must come from the same fixed external encoder, with identical preprocessing and sample ordering. Joint positions must come from a consistent forward-kinematics or tracking pipeline. Normalized action vectors are not joint positions.

evaluate.py --events events.json --segments segments.json --output events-scored.json evaluates post-hoc observations. Events provide event_id, branch, operation (respond, wait, or stop), span, and valid_until; response events also provide target, and stop events provide old_target. Segments provide branch, start, end, target, and optional kind, resolved, role, and utterance_id. Windows are fixed from the inputs and end before the next relevant request. Unknown observations remain missing. Response latency is target-matched; the summary reports the median among nonnegative observations, with early and censored counts separate. Stop latency requires actual old-output overlap.

This event scorer exposes the core attribution rules. It does not include the full benchmark's detector, task-specific event construction, or every benchmark metric. Model state tokens must not be substituted for observed speech or motion.