8000 GitHub - showlab/o2laf: Repurposing Video Priors for Self-Supervised Latent Action Learning ยท GitHub
[go: up one dir, main page]

Skip to content
showlabPublic

About

Repurposing Video Priors for Self-Supervised Latent Action Learning

Topics

Resources

Stars

34 stars

Watchers

0 watching

Forks

Latest commit

ย 

History

10 Commits

Folders and files

Repository files navigation

OยฒLaF: One Prior, Two Dynamics

Yuxin Jiang, Wenqiang Sun, Jiaqi Li, Yuchao Gu, Lvmin Zhang, Ivor W. Tsang, and Mike Zheng Shou

arXiv HF Paper Project Page Code HuggingFace Video X

OยฒLaF video: latent actions inferred from a human video drive a GR-1 robot world model. Click to watch on YouTube.

๐Ÿ“– Overview

Official code for One Prior, Two Dynamics: Repurposing Video Diffusion Transformers for Self-Supervised Latent Action Learning. OยฒLaF learns latent actions from unlabelled video, using one pretrained video DiT (Wan 2.2 TI2V-5B) as the prior for both dynamics:

  • Latent action encoder: inverse dynamics that maps video transitions to 32-D latent actions.
  • Causal world model: forward dynamics trained jointly with the latent action encoder.
  • Bidirectional world model (optional): fine-tuned with the frozen latent action encoder.

๐Ÿ“Œ Updates

  • [26/11] IDM as a motion annotator (CameraBench & custom datasets)
  • [25/11] Additional latent action encoders: V-JEPA 2 and ST-Transformer
  • [23/11] Model weights trained on MiraData and EgoDexMix
  • [23/11] Training and inference code
  • [19/11] Paper and project page
  • Probing and evaluation tools

๐Ÿ› ๏ธ Setup Environment

conda create -n o2laf python=3.12 && conda activate o2laf
git clone https://github.com/showlab/o2laf.git && cd o2laf
pip install torch==2.8.0 torchvision==0.23.0 --index-url https://download.pytorch.org/whl/cu128
pip install -e .

๐Ÿ—‚๏ธ Model Zoo

Every model is one latent action encoder plus two world models. Pass the folder as the model name, e.g. --model YuxinJ/O2LaF/o2laf_dit_mixed.

Model Training data Latent action encoder Bidirectional world model from
o2laf_dit_mixed MiraData + EgoDexMix Wan DiT the causal world model
o2laf_dit_mira< 8000 /td> MiraData Wan DiT Wan 2.2
o2laf_dit_mira_e2e MiraData Wan DiT the causal world model
o2laf_dit_egodexmix EgoDexMix Wan DiT the causal world model
o2laf_vjepa2_mira MiraData V-JEPA 2 โ€  Wan 2.2
o2laf_st_transformer_mira MiraData spatio-temporal transformer Wan 2.2

o2laf_dit_mixed is the model the paper evaluates, and the only one that ships the atomic action library. The last column is where stage 2 started from; see Training.

โ€  The V-JEPA 2 latent action encoder keeps its trunk frozen, so that trunk is not part of the release. Download vitg-384.pt and pass --base-action-encoder /path/to/vitg-384.pt.

๐ŸŽฎ Run Demo

Weights download on first use. To use local copies, download them with hf download YuxinJ/O2LaF --include "o2laf_dit_mixed/*" --local-dir <o2laf_dir> and hf download Wan-AI/Wan2.2-TI2V-5B-Diffusers --local-dir <wan_dir> (the base model), then pass --model <o2laf_dir>/o2laf_dit_mixed --base-model <wan_dir>.

โ–ถ๏ธ Transfer the actions of a video

o2laf-transfer --model YuxinJ/O2LaF/o2laf_dit_mixed \
    --source-video assets/examples/gta5.mp4 --first-frame assets/examples/wild_west.jpg \
    --output results/transfer.mp4

Options: --mode bidirectional|causal (world model), --cfg-scale (action guidance, default 3), --control transfer|self|zero|shuffle.

๐Ÿ•น๏ธ Drive a frame with an atomic action

o2laf-generate --model YuxinJ/O2LaF/o2laf_dit_mixed --list    # idle, w, s, a, d, camera_up/down/left/right
o2laf-generate --model YuxinJ/O2LaF/o2laf_dit_mixed --action w \
    --first-frame assets/examples/wild_west.jpg --output results/w.mp4

๐Ÿ” Visualize latent action attention

o2laf-attention --model YuxinJ/O2LaF/o2laf_dit_mixed \
    --video assets/examples/gr1.mp4 --output results/gr1_b22_h02.mp4 \
    --block 22 --head 2

๐Ÿ Python API

from pathlib import Path

from o2laf import ActionGuidance, LatentActionPipeline
from o2laf.inference.cli.common import load_first_frame, load_source_video

pipe = LatentActionPipeline.from_pretrained("YuxinJ/O2LaF/o2laf_dit_mixed", mode="bidirectional")
actions = pipe.encode_source_actions(load_source_video(Path("assets/examples/gta5.mp4"), pipe.fps))
first_frame = load_first_frame(Path("assets/examples/wild_west.jpg"), pipe.fps)
video = pipe.generate(actions=actions, first_frame=first_frame, guidance=ActionGuidance(scale=3.0))

๐Ÿ‹๏ธ Training

Stage Config Clips
1. Latent action model configs/latent_action/{wan_dit,vjepa2,st_transformer}_mira.yaml 41 frames
2. Bidirectional world model configs/world_model/{wan_dit,vjepa2,st_transformer}_mira.yaml 81 frames

Training data is WebDataset tar shards (one .mp4 per sample) listed in a metadata file; no captions are needed:

{"wids_version": 1, "shardlist": [{"url": "/data/miradata/shard-00000.tar", "nsamples": 50}]}
# Stage 1 
torchrun --nnodes=2 --nproc_per_node=8 --node_rank=$NODE_RANK \
    --master_addr=$MASTER_ADDR --master_port=$MASTER_PORT -m o2laf.train \
    config_path=configs/latent_action/wan_dit_mira.yaml \
    models.transformer_cfg.model_name=$WAN_MODEL models.idm_cfg.model_name=$WAN_MODEL \
    datasets.train.meta_path=$META

# Stage 2 on the frozen stage 1 latent action encoder 
STAGE1=experiments/latent_action_wan_dit_mira/visualization/latent_action_eval/iter_10000/latent_action_state.pt

# (a) bidirectional world model initialised from Wan 2.2
torchrun --nproc_per_node=8 -m o2laf.train \
    config_path=configs/world_model/wan_dit_mira.yaml \
    models.transformer_cfg.model_name=$WAN_MODEL models.idm_cfg.model_name=$WAN_MODEL \
    datasets.train.meta_path=$META \
    models.fixed_idm_cfg.state_path=$STAGE1

# (b) bidirectional world model initialised from the stage 1 causal world model
torchrun --nproc_per_node=8 -m o2laf.train \
    config_path=configs/world_model/wan_dit_mira.yaml \
    models.transformer_cfg.model_name=$WAN_MODEL models.idm_cfg.model_name=$WAN_MODEL \
    datasets.train.meta_path=$META \
    models.fixed_idm_cfg.state_path=$STAGE1 \
    models.fixed_idm_cfg.fdm_init=merged_e2e_decoder

$WAN_MODEL is a local copy of Wan-AI/Wan2.2-TI2V-5B-Diffusers; $META is the metadata file. Runs write to experiments/<run_name>/ and resume when relaunched.

  • Stage 2 initialisation. (b) merges the causal world model's LoRA into the Wan weights and keeps its action embedder; the released model was trained this way.
  • From the released model. state_path and models.action_cfg.latent_action_state_path also accept a released model directory, so you can train a world model on the released latent action encoder or continue stage 1.
  • Publishing. o2laf-export writes your two stages in the Hugging Face layout.

๐Ÿงฉ Adding a Latent Action Encoder

A new latent action encoder is one file and one registration; the trainers need no change:

from o2laf.action_encoders.base import ActionEncoderSpec, register_action_encoder_spec


@register_action_encoder_spec('my_encoder')
class MyEncoderSpec(ActionEncoderSpec):
    codes_per_transition = 2        # codes emitted per latent transition
    action_ratio_cfg_key = 'my_encoder_action_compression_ratio'
    reads_pixels = True             # False: it reads the VAE latents the caller already holds
    window_rgb_frames = 41          # RGB frames per pass over a longer clip; None for the whole clip

    def build_contract(self, trainer, idm_cfg):
        """What identifies the action space this encoder defines."""
        return {'version': 1, 'architecture': 'my_encoder',
                'action_compression_ratio': trainer.action_compression_ratio}

    def build_encoder(self, trainer, idm_cfg, dtype):
        """Construct, select trainable parameters, and FSDP-wrap."""
        ...
        trainer.set_params_to_optimize(encoder, idm_cfg['param_names_to_optimize'], ())
        return fsdp2_wrap(encoder, transformer_block_clsname='MyBlock')

    def encode(self, encoder, *, latents=None, pixel_values=None, prompt_embeds=None):
        """Take whichever form of the clip this encoder reads."""
        return encoder(pixel_values=pixel_values)

Select it with models.idm_cfg.backend: my_encoder.

๐ŸŽฌ IDM as a Motion Annotator

motion_annotation/ repurposes OยฒLaF's latent action encoder (IDM) for supervised motion annotation on CameraBench and custom multi-label video datasets, achieving state-of-the-art performance on CameraBench (89.9%).

Also check out the great 0.4B camera-motion IDM from Hy-Nomas๐ŸŽ‰!

๐Ÿ“œ License

OยฒLaF is released under the MIT License; see LICENSE.

๐Ÿ“ฌ Contact & Discussion

Feel free to open an issue, or email Yuxin Jiang, with questions about the codebase.

โญ Acknowledgement

This codebase is built on AnyFlow and Diffusers, and the models on Wan 2.2. The alternative latent action encoders use code from V-JEPA 2 and Olaf-World. We thank the authors for open-sourcing their work.

๐Ÿ“š Citation

If you find OยฒLaF useful in your research, please cite:

@article{jiang2026o2laf,
  title   = {One Prior, Two Dynamics: Repurposing Video Diffusion Transformers for Self-Supervised Latent Action Learning},
  author  = {Jiang, Yuxin and Sun, Wenqiang and Li, Jiaqi and Gu, Yuchao and Zhang, Lvmin and Tsang, Ivor and Shou, Mike Zheng},
  journal = {arXiv preprint arXiv:2611.26617},
  year    = {2026}
}

About

Repurposing Video Priors for Self-Supervised Latent Action Learning

Topics

Resources

Stars

34 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

0