|
| 1 | +<!-- Copyright 2026 The HuggingFace Team. All rights reserved. --> |
| 2 | + |
| 3 | +# Motif-Video |
| 4 | + |
| 5 | +[Technical Report](https://arxiv.org/abs/2604.16503) |
| 6 | + |
| 7 | +Motif-Video is a 2B parameter diffusion transformer designed for text-to-video and image-to-video generation. It features a three-stage architecture with 12 dual-stream + 16 single-stream + 8 DDT decoder layers, Shared Cross-Attention for stable text-video alignment under long video sequences, T5Gemma2 text encoder, and rectified flow matching for velocity prediction. |
| 8 | + |
| 9 | +<p align="center"> |
| 10 | + <img src="https://huggingface.co/Motif-Technologies/Motif-Video-2B/resolve/main/assets/architecture.png" width="90%" alt="Motif-Video architecture"/> |
| 11 | +</p> |
| 12 | + |
| 13 | +## Text-to-Video Generation |
| 14 | + |
| 15 | +Use `MotifVideoPipeline` for text-to-video generation: |
| 16 | + |
| 17 | +```python |
| 18 | +import torch |
| 19 | +from diffusers import MotifVideoPipeline |
| 20 | +from diffusers.utils import export_to_video |
| 21 | + |
| 22 | + |
| 23 | +pipe = MotifVideoPipeline.from_pretrained( |
| 24 | + "Motif-Technologies/Motif-Video-2B", |
| 25 | + torch_dtype=torch.bfloat16, |
| 26 | +) |
| 27 | +pipe.to("cuda") |
| 28 | + |
| 29 | +prompt = "A woman with long brown hair and light skin smiles at another woman with long blonde hair." |
| 30 | +negative_prompt = "worst quality, inconsistent motion, blurry, jittery, distorted" |
| 31 | + |
| 32 | +video = pipe( |
| 33 | + prompt=prompt, |
| 34 | + negative_prompt=negative_prompt, |
| 35 | + width=1280, |
| 36 | + height=736, |
| 37 | + num_frames=121, |
| 38 | + num_inference_steps=50, |
| 39 | +).frames[0] |
| 40 | +export_to_video(video, "output.mp4", fps=24) |
| 41 | +``` |
| 42 | + |
| 43 | +## Image-to-Video Generation |
| 44 | + |
| 45 | +Use `MotifVideoImage2VideoPipeline` for image-to-video generation: |
| 46 | + |
| 47 | +```python |
| 48 | +import torch |
| 49 | +from diffusers import MotifVideoImage2VideoPipeline |
| 50 | +from diffusers.utils import export_to_video, load_image |
| 51 | + |
| 52 | + |
| 53 | +pipe = MotifVideoImage2VideoPipeline.from_pretrained( |
| 54 | + "Motif-Technologies/Motif-Video-2B", |
| 55 | + torch_dtype=torch.bfloat16, |
| 56 | +) |
| 57 | +pipe.to("cuda") |
| 58 | + |
| 59 | +image = load_image("input_image.png") |
| 60 | +prompt = "A cinematic scene with vivid colors." |
| 61 | +negative_prompt = "worst quality, blurry, jittery, distorted" |
| 62 | + |
| 63 | +video = pipe( |
| 64 | + image=image, |
| 65 | + prompt=prompt, |
| 66 | + negative_prompt=negative_prompt, |
| 67 | + width=1280, |
| 68 | + height=736, |
| 69 | + num_frames=121, |
| 70 | + num_inference_steps=50, |
| 71 | +).frames[0] |
| 72 | +export_to_video(video, "i2v_output.mp4", fps=24) |
| 73 | +``` |
| 74 | + |
| 75 | +### Memory-efficient Inference |
| 76 | + |
| 77 | +For GPUs with less than 30GB VRAM (e.g., RTX 4090), use model CPU offloading: |
| 78 | + |
| 79 | +```bash |
| 80 | +export PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True |
| 81 | +``` |
| 82 | + |
| 83 | +```python |
| 84 | +import torch |
| 85 | +from diffusers import MotifVideoPipeline |
| 86 | +from diffusers.utils import export_to_video |
| 87 | + |
| 88 | + |
| 89 | +pipe = MotifVideoPipeline.from_pretrained( |
| 90 | + "Motif-Technologies/Motif-Video-2B", |
| 91 | + torch_dtype=torch.bfloat16, |
| 92 | +) |
| 93 | +pipe.enable_model_cpu_offload() |
| 94 | + |
| 95 | +prompt = "A woman with long brown hair and light skin smiles at another woman with long blonde hair." |
| 96 | +negative_prompt = "worst quality, inconsistent motion, blurry, jittery, distorted" |
| 97 | + |
| 98 | +video = pipe( |
| 99 | + prompt=prompt, |
| 100 | + negative_prompt=negative_prompt, |
| 101 | + width=1280, |
| 102 | + height=736, |
| 103 | + num_frames=121, |
| 104 | + num_inference_steps=50, |
| 105 | +).frames[0] |
| 106 | +export_to_video(video, "output.mp4", fps=24) |
| 107 | +``` |
| 108 | + |
| 109 | +## MotifVideoPipeline |
| 110 | + |
| 111 | +[[autodoc]] MotifVideoPipeline |
| 112 | + - all |
| 113 | + - __call__ |
| 114 | + |
| 115 | +## MotifVideoImage2VideoPipeline |
| 116 | + |
| 117 | +[[autodoc]] MotifVideoImage2VideoPipeline |
| 118 | + - all |
| 119 | + - __call__ |
| 120 | + |
| 121 | +## MotifVideoPipelineOutput |
| 122 | + |
| 123 | +[[autodoc]] pipelines.motif_video.pipeline_output.MotifVideoPipelineOutput |
0 commit comments