MotionRAG is a novel retrieval-augmented framework for image-to-video generation that significantly enhances motion realism by transferring motion priors from relevant reference videos. Our approach addresses the fundamental challenge of generating physically plausible and semantically coherent motion in video generation.
MotionRAG employs a three-stage process:
MotionRAG achieves significant improvements across multiple models and datasets. Here's a comparison between baseline models and their MotionRAG-enhanced versions:
| Model | Action Score β | DINO β | FVD β | Inference Time |
|---|---|---|---|---|
| CogVideoX | 59.9 | 87.8 | 87.1 | 59.4s |
| CogVideoX + RAG | 65.8 (+9.9%) | 89.4 (+1.8%) | 80.2 (-8.0%) | 63.0s (+3.6s) |
| DynamiCrafter | 53.5 | 85.8 | 88.4 | 87.6s |
| DynamiCrafter + RAG | 62.1 (+16.1%) | 88.4 (+3.0%) | 69.0 (-22.0%) | 89.4s (+1.8s) |
To illustrate the effectiveness of MotionRAG, we showcase the generation results from CogVideoX enhanced with MotionRAG:
The figure above visualizes the motion generation effects of our MotionRAG approach. Below we provide detailed comparisons for specific scenarios:
| Scenario | Without RAG | With RAG |
|---|---|---|
| Person riding a horse | ![]() | ![]() |
| Man running on dirt road | ![]() | ![]() |
| Tram traveling down snowy street | ![]() | ![]() |
| Panda eating bamboo | ![]() | ![]() |
| Metal balls suspended in air | ![]() | ![]() |
# Clone the repository
git clone https://github.com/MCG-NJU/MotionRAG.git
cd MotionRAG
# Build the Docker image
docker build -t MotionRAG .
# Run the container
docker run -it --gpus all -v ./:/workspace MotionRAG
First, you'll need to download the pre-trained model checkpoints and dataset:
Create the retrieval-augmented generation database:
python tools/build_rag_database.py
This script will process the dataset and build the vector database for motion retrieval.
Generate videos using the MotionRAG framework:
python main.py test -c configs/cogvideox/MotionRAG_open.yml
This command will run inference using the CogVideoX-based MotionRAG configuration.
MotionRAG employs a two-stage training approach for optimal performance:
python main.py fit -c configs/cogvideox/action_injection.yml
First, preprocess the videos to accelerate training by resizing them to lower resolution:
python tools/resize_video.py -i path/to/original/videos -o path/to/resized/videos
Train the Motion Context Transformer with the second configuration:
python main.py fit -c configs/motion_transformer/condition_trans_dino_cog_open.yml
MotionRAG/
βββ src/
β βββ projects/
β β βββ cogvideox/ # CogVideoX implementation
β β βββ dynamicrafter/ # DynamiCrafter implementation
β β βββ svd/ # Stable Video Diffusion implementation
β β βββ condition/ # Motion adaptation modules
β β βββ encoders/ # Condition encoders (CLIP, DINO, VideoMAE)
β β βββ module.py # Condition transformer modules
β βββ data/ # Data loading and processing
β βββ metrics/ # Evaluation metrics
β βββ utils/ # Utility functions
βββ configs/ # Configuration files
βββ tools/ # Helper scripts
βββ checkpoints/ # Model checkpoints
β βββ CogVideoX/ # CogVideoX checkpoints
β βββ DynamiCrafter/ # DynamiCrafter checkpoints
β βββ SVD/ # SVD checkpoints
βββ datasets/ # Datasets
βββ OpenVid-1M/ # OpenVid-1M dataset
If you find MotionRAG useful for your research, please cite our paper:
@inproceedings{zhu2025motionrag,
title={MotionRAG: Motion Retrieval-Augmented Image-to-Video Generation},
author={Zhu, Chenhui and Wu, Yilu and Wang, Shuai and Wu, Gangshan and Wang, Limin},
booktitle={Proceedings of the 39th International Conference on Neural Information Processing Systems},
year={2025},
}
This project is licensed under the MIT License - see the LICENSE file for details.
We thank the open-source community and the authors of CogVideoX, DynamiCrafter, and Stable Video Diffusion for their excellent work.
8 commits
Python
98.7%
Shell
1.2%
MotionRAG is a novel retrieval-augmented framework for image-to-video generation that significantly enhances motion realism by transferring motion priors from relevant reference videos. Our approach addresses the fundamental challenge of generating physically plausible and semantically coherent motion in video generation.
MotionRAG employs a three-stage process:
MotionRAG achieves significant improvements across multiple models and datasets. Here's a comparison between baseline models and their MotionRAG-enhanced versions:
| Model | Action Score β | DINO β | FVD β | Inference Time |
|---|---|---|---|---|
| CogVideoX | 59.9 | 87.8 | 87.1 | 59.4s |
| CogVideoX + RAG | 65.8 (+9.9%) | 89.4 (+1.8%) | 80.2 (-8.0%) | 63.0s (+3.6s) |
| DynamiCrafter | 53.5 | 85.8 | 88.4 | 87.6s |
| DynamiCrafter + RAG | 62.1 (+16.1%) | 88.4 (+3.0%) | 69.0 (-22.0%) | 89.4s (+1.8s) |
To illustrate the effectiveness of MotionRAG, we showcase the generation results from CogVideoX enhanced with MotionRAG:
The figure above visualizes the motion generation effects of our MotionRAG approach. Below we provide detailed comparisons for specific scenarios:
| Scenario | Without RAG | With RAG |
|---|---|---|
| Person riding a horse | ![]() | ![]() |
| Man running on dirt road | ![]() | ![]() |
| Tram traveling down snowy street | ![]() | ![]() |
| Panda eating bamboo | ![]() | ![]() |
| Metal balls suspended in air | ![]() | ![]() |
# Clone the repository
git clone https://github.com/MCG-NJU/MotionRAG.git
cd MotionRAG
# Build the Docker image
docker build -t MotionRAG .
# Run the container
docker run -it --gpus all -v ./:/workspace MotionRAG
First, you'll need to download the pre-trained model checkpoints and dataset:
Create the retrieval-augmented generation database:
python tools/build_rag_database.py
This script will process the dataset and build the vector database for motion retrieval.
Generate videos using the MotionRAG framework:
python main.py test -c configs/cogvideox/MotionRAG_open.yml
This command will run inference using the CogVideoX-based MotionRAG configuration.
MotionRAG employs a two-stage training approach for optimal performance:
python main.py fit -c configs/cogvideox/action_injection.yml
First, preprocess the videos to accelerate training by resizing them to lower resolution:
python tools/resize_video.py -i path/to/original/videos -o path/to/resized/videos
Train the Motion Context Transformer with the second configuration:
python main.py fit -c configs/motion_transformer/condition_trans_dino_cog_open.yml
MotionRAG/
βββ src/
β βββ projects/
β β βββ cogvideox/ # CogVideoX implementation
β β βββ dynamicrafter/ # DynamiCrafter implementation
β β βββ svd/ # Stable Video Diffusion implementation
β β βββ condition/ # Motion adaptation modules
β β βββ encoders/ # Condition encoders (CLIP, DINO, VideoMAE)
β β βββ module.py # Condition transformer modules
β βββ data/ # Data loading and processing
β βββ metrics/ # Evaluation metrics
β βββ utils/ # Utility functions
βββ configs/ # Configuration files
βββ tools/ # Helper scripts
βββ checkpoints/ # Model checkpoints
β βββ CogVideoX/ # CogVideoX checkpoints
β βββ DynamiCrafter/ # DynamiCrafter checkpoints
β βββ SVD/ # SVD checkpoints
βββ datasets/ # Datasets
βββ OpenVid-1M/ # OpenVid-1M dataset
If you find MotionRAG useful for your research, please cite our paper:
@inproceedings{zhu2025motionrag,
title={MotionRAG: Motion Retrieval-Augmented Image-to-Video Generation},
author={Zhu, Chenhui and Wu, Yilu and Wang, Shuai and Wu, Gangshan and Wang, Limin},
booktitle={Proceedings of the 39th International Conference on Neural Information Processing Systems},
year={2025},
}
This project is licensed under the MIT License - see the LICENSE file for details.
We thank the open-source community and the authors of CogVideoX, DynamiCrafter, and Stable Video Diffusion for their excellent work.
8 commits
Python
98.7%
Shell
1.2%