Qnancy commited on
Commit
ad44ad4
·
verified ·
1 Parent(s): ce5a0f9

Upload folder using huggingface_hub

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +8 -0
  2. .gitignore +9 -0
  3. .zeta/HEAD +1 -0
  4. .zeta/blob/3a/38/3a38d2ab31897292bf43de8aec344a0efdf457a591c9521d7af72b9570ef0c91 +3 -0
  5. .zeta/blob/61/e3/61e3a42098e8f50ec6a6b9e8f29b23f53dfce6ab117d56fd1128a5a7fd07c426 +3 -0
  6. .zeta/blob/6a/e7/6ae7b00616077ae81c444fb286d566458fbf1514b1182ed56d7a5f2b6e06fa01 +3 -0
  7. .zeta/blob/ae/8a/ae8a0566ecdd2569d9b302f7194949b7f90931be18ac2529f6c5fcd4e903a1cd +3 -0
  8. .zeta/blob/cc/df/ccdf466bda0370a48cef5753059c92d9bfba5df645060d9334c4f522641e87c8 +3 -0
  9. .zeta/blob/ed/5d/ed5dda40b934aa8455c1013c226164beee3552c1209de951c07b88fd19740211 +3 -0
  10. .zeta/blob/f3/11/f3117c5c46871e6f268802952b2393ebd1a317d73b292ba244121ea82473c98f +3 -0
  11. .zeta/blob/pack/pack-fa7fc9a2e71deda5bf1019f37f2baa0851bed0f469b76901a6728ecbf95f3920.idx +0 -0
  12. .zeta/blob/pack/pack-fa7fc9a2e71deda5bf1019f37f2baa0851bed0f469b76901a6728ecbf95f3920.mtimes +0 -0
  13. .zeta/blob/pack/pack-fa7fc9a2e71deda5bf1019f37f2baa0851bed0f469b76901a6728ecbf95f3920.pack +3 -0
  14. .zeta/index +0 -0
  15. .zeta/logs/HEAD +1 -0
  16. .zeta/logs/refs/heads/mainline +1 -0
  17. .zeta/metadata/pack/pack-810c11d713c054d5e9d36c7801f05da0bc3286b8ddbdadaafecb443c3564b98b.idx +0 -0
  18. .zeta/metadata/pack/pack-810c11d713c054d5e9d36c7801f05da0bc3286b8ddbdadaafecb443c3564b98b.mtimes +0 -0
  19. .zeta/metadata/pack/pack-810c11d713c054d5e9d36c7801f05da0bc3286b8ddbdadaafecb443c3564b98b.pack +0 -0
  20. .zeta/refs/heads/mainline +1 -0
  21. .zeta/refs/remotes/origin/mainline +1 -0
  22. .zeta/zeta.toml +3 -0
  23. README.md +165 -0
  24. assets/box_trajectory/cartoon_wizard.mp4 +3 -0
  25. assets/box_trajectory/child_horse.mp4 +3 -0
  26. assets/box_trajectory/floatie.mp4 +3 -0
  27. assets/box_trajectory/priestess.mp4 +3 -0
  28. assets/images/condition/camel_royal.png +3 -0
  29. assets/images/condition/cartoon_wizard.jpg +3 -0
  30. assets/images/condition/child_horse.jpg +3 -0
  31. assets/images/condition/floatie.jpg +3 -0
  32. assets/images/condition/mammoth_rhino3.png +3 -0
  33. assets/images/condition/man_head.jpg +3 -0
  34. assets/images/condition/moon_castle.jpg +3 -0
  35. assets/images/condition/priestess.jpg +3 -0
  36. assets/images/gradio/1.png +3 -0
  37. assets/images/gradio/2.png +3 -0
  38. assets/images/ori_image/camel.jpg +3 -0
  39. assets/images/teaser/teaser.jpg +3 -0
  40. assets/mask_trajectory/camel.mp4 +3 -0
  41. assets/mask_trajectory/mammoth_rhino.mp4 +3 -0
  42. assets/mask_trajectory/mammoth_rhino_frozen_pink_bgr_range.mp4 +3 -0
  43. assets/mask_trajectory/mammoth_rhino_h264.mp4 +3 -0
  44. assets/sparse_box_trajectory/man_head.mp4 +3 -0
  45. assets/sparse_box_trajectory/moon_castle.mp4 +3 -0
  46. assets/teaser.mp4 +3 -0
  47. assets/teaser.webp +3 -0
  48. assets/teaser2.webp +3 -0
  49. change_mask.py +106 -0
  50. environment.yml +264 -0
.gitattributes CHANGED
@@ -57,3 +57,11 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
57
  # Video files - compressed
58
  *.mp4 filter=lfs diff=lfs merge=lfs -text
59
  *.webm filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
57
  # Video files - compressed
58
  *.mp4 filter=lfs diff=lfs merge=lfs -text
59
  *.webm filter=lfs diff=lfs merge=lfs -text
60
+ .zeta/blob/3a/38/3a38d2ab31897292bf43de8aec344a0efdf457a591c9521d7af72b9570ef0c91 filter=lfs diff=lfs merge=lfs -text
61
+ .zeta/blob/61/e3/61e3a42098e8f50ec6a6b9e8f29b23f53dfce6ab117d56fd1128a5a7fd07c426 filter=lfs diff=lfs merge=lfs -text
62
+ .zeta/blob/6a/e7/6ae7b00616077ae81c444fb286d566458fbf1514b1182ed56d7a5f2b6e06fa01 filter=lfs diff=lfs merge=lfs -text
63
+ .zeta/blob/ae/8a/ae8a0566ecdd2569d9b302f7194949b7f90931be18ac2529f6c5fcd4e903a1cd filter=lfs diff=lfs merge=lfs -text
64
+ .zeta/blob/cc/df/ccdf466bda0370a48cef5753059c92d9bfba5df645060d9334c4f522641e87c8 filter=lfs diff=lfs merge=lfs -text
65
+ .zeta/blob/ed/5d/ed5dda40b934aa8455c1013c226164beee3552c1209de951c07b88fd19740211 filter=lfs diff=lfs merge=lfs -text
66
+ .zeta/blob/f3/11/f3117c5c46871e6f268802952b2393ebd1a317d73b292ba244121ea82473c98f filter=lfs diff=lfs merge=lfs -text
67
+ .zeta/blob/pack/pack-fa7fc9a2e71deda5bf1019f37f2baa0851bed0f469b76901a6728ecbf95f3920.pack filter=lfs diff=lfs merge=lfs -text
.gitignore ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ magicmotion/scripts/train
2
+ __pycache__/
3
+ samples/
4
+ installation.sh
5
+ accelerate_configs
6
+ magicmotion/dataset
7
+ magicmotion/train.py
8
+ huggingface_download.sh
9
+ huggingface_uplaod.py
.zeta/HEAD ADDED
@@ -0,0 +1 @@
 
 
1
+ ref: refs/heads/mainline
.zeta/blob/3a/38/3a38d2ab31897292bf43de8aec344a0efdf457a591c9521d7af72b9570ef0c91 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2fd7dc9a1d4fa3a4118d63ec01895a332404a5333c5900138327e2b551fc6ab3
3
+ size 691914618
.zeta/blob/61/e3/61e3a42098e8f50ec6a6b9e8f29b23f53dfce6ab117d56fd1128a5a7fd07c426 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6b8debe3df2a75a3ca81d37aea71c7115d417f5a37891254ab7427fa0e4214fa
3
+ size 689359112
.zeta/blob/6a/e7/6ae7b00616077ae81c444fb286d566458fbf1514b1182ed56d7a5f2b6e06fa01 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0219765557537d7baf4beba8ceebdb0d91bf3d338f4cbe9155a4aea7582dea02
3
+ size 6048364
.zeta/blob/ae/8a/ae8a0566ecdd2569d9b302f7194949b7f90931be18ac2529f6c5fcd4e903a1cd ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:41d08467cf6caa25fbe90aa124bda3a768da678a4806e37b47120f69d231d2d3
3
+ size 55691267
.zeta/blob/cc/df/ccdf466bda0370a48cef5753059c92d9bfba5df645060d9334c4f522641e87c8 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:05adf2f972d0aef5818dba9cabe3254ba137ce1646a36f12bbc50834fa45bbf3
3
+ size 7718120
.zeta/blob/ed/5d/ed5dda40b934aa8455c1013c226164beee3552c1209de951c07b88fd19740211 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:038897fc4447be0e6048e5f083c36df89a541c33db0015058c12c954b8203974
3
+ size 22094746
.zeta/blob/f3/11/f3117c5c46871e6f268802952b2393ebd1a317d73b292ba244121ea82473c98f ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:039cdea680a2c9d319197cf6197067fcae3b05ae814d57db3b0d2dda98c6345c
3
+ size 897952482
.zeta/blob/pack/pack-fa7fc9a2e71deda5bf1019f37f2baa0851bed0f469b76901a6728ecbf95f3920.idx ADDED
Binary file (10.9 kB). View file
 
.zeta/blob/pack/pack-fa7fc9a2e71deda5bf1019f37f2baa0851bed0f469b76901a6728ecbf95f3920.mtimes ADDED
Binary file (2.01 kB). View file
 
.zeta/blob/pack/pack-fa7fc9a2e71deda5bf1019f37f2baa0851bed0f469b76901a6728ecbf95f3920.pack ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f2f05cd1bb3cdf97da1dea1caa74604b2a1c2ca6caf482c3e0cb4fc10ca0a9d7
3
+ size 17411178
.zeta/index ADDED
Binary file (26.8 kB). View file
 
.zeta/logs/HEAD ADDED
@@ -0,0 +1 @@
 
 
1
+ 0000000000000000000000000000000000000000000000000000000000000000 83a55ef46cae52886eebe87b90b257c15be3474f7d0f7cd22eee1de59357c967 1446747873@qq.com <qhy> 1768880340 +0800 switch: move from to mainline
.zeta/logs/refs/heads/mainline ADDED
@@ -0,0 +1 @@
 
 
1
+ 0000000000000000000000000000000000000000000000000000000000000000 83a55ef46cae52886eebe87b90b257c15be3474f7d0f7cd22eee1de59357c967 1446747873@qq.com <qhy> 1768880340 +0800 branch: Created from 83a55ef46cae52886eebe87b90b257c15be3474f7d0f7cd22eee1de59357c967
.zeta/metadata/pack/pack-810c11d713c054d5e9d36c7801f05da0bc3286b8ddbdadaafecb443c3564b98b.idx ADDED
Binary file (3.62 kB). View file
 
.zeta/metadata/pack/pack-810c11d713c054d5e9d36c7801f05da0bc3286b8ddbdadaafecb443c3564b98b.mtimes ADDED
Binary file (544 Bytes). View file
 
.zeta/metadata/pack/pack-810c11d713c054d5e9d36c7801f05da0bc3286b8ddbdadaafecb443c3564b98b.pack ADDED
Binary file (19.4 kB). View file
 
.zeta/refs/heads/mainline ADDED
@@ -0,0 +1 @@
 
 
1
+ 83a55ef46cae52886eebe87b90b257c15be3474f7d0f7cd22eee1de59357c967
.zeta/refs/remotes/origin/mainline ADDED
@@ -0,0 +1 @@
 
 
1
+ 83a55ef46cae52886eebe87b90b257c15be3474f7d0f7cd22eee1de59357c967
.zeta/zeta.toml ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ [core]
2
+ remote = "https://zeta.alipay.com/qhy/magicmotion"
3
+ compression-algo = "zstd"
README.md ADDED
@@ -0,0 +1,165 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <img src="assets/teaser2.webp" width="100%" alt="Teaser Image">
2
+ <br>
3
+ <a href="https://arxiv.org/pdf/2503.16421"><img src="https://img.shields.io/static/v1?label=Paper&message=2503.16421&color=red&logo=arxiv"></a>
4
+ <a href="https://quanhaol.github.io/magicmotion-site/"><img src="https://img.shields.io/static/v1?label=Project&message=Page&color=green&logo=github-pages"></a>
5
+ <a href="https://huggingface.co/quanhaol/MagicMotion"><img src="https://img.shields.io/badge/🤗_HuggingFace-Model-ffbd45.svg" alt="HuggingFace"></a>
6
+ <a href="https://huggingface.co/datasets/quanhaol/MagicData"><img src="https://img.shields.io/badge/🤗_HuggingFace-Dataset-ffbd45.svg" alt="HuggingFace"></a>
7
+
8
+ > **MagicMotion: Controllable Video Generation with Dense-to-Sparse Trajectory Guidance**
9
+ > <br>
10
+ > [Quanhao Li\*](https://github.com/quanhaol), [Zhen Xing\*](https://chenhsing.github.io/), [Rui Wang](https://scholar.google.com/citations?user=116smmsAAAAJ&hl=en), [Hui Zhang](https://huizhang0812.github.io/), [Qi Dai](https://daiqi1989.github.io/), and [Zuxuan Wu](https://zxwu.azurewebsites.net/)
11
+ > <br>
12
+ \* equal contribution
13
+
14
+ ## 💡 Abstract
15
+
16
+ Recent advances in video generation have led to remarkable improvements in visual quality and temporal coherence. Upon this, trajectory-controllable video generation has emerged to enable precise object motion control through explicitly defined spatial paths.
17
+ However, existing methods struggle with complex object movements and multi-object motion control, resulting in imprecise trajectory adherence, poor object consistency, and compromised visual quality.
18
+ Furthermore, these methods only support trajectory control in a single format, limiting their applicability in diverse scenarios.
19
+ Additionally, there is no publicly available dataset or benchmark specifically tailored for trajectory-controllable video generation, hindering robust training and systematic evaluation.
20
+ To address these challenges, we introduce **MagicMotion**, a novel image-to-video generation framework that enables trajectory control through three levels of conditions from dense to sparse: masks, bounding boxes, and sparse boxes. Given an input image and trajectories, MagicMotion seamlessly animates objects along defined trajectories while maintaining object consistency and visual quality.
21
+ Furthermore, we present **MagicData**, a large-scale trajectory-controlled video dataset, along with an automated pipeline for annotation and filtering.
22
+ We also introduce **MagicBench**, a comprehensive benchmark that assesses both video quality and trajectory control accuracy across different numbers of objects.
23
+ Extensive experiments demonstrate that MagicMotion outperforms previous methods across various metrics.
24
+
25
+
26
+ <img src="assets/teaser.webp" width="100%" alt="Teaser Image">
27
+
28
+ ## 📣 Updates
29
+ - `2025/07/28` 🔥🔥MagicData has been released [`here`](https://huggingface.co/datasets/quanhaol/MagicData). Welcome to use our dataset!
30
+ - `2025/06/26` 🔥🔥MagicMotion has been accepted by ICCV2025!🎉🎉🎉
31
+ - `2025/03/28` 🔥🔥We released interactive demo with gradio for MagicMotion.
32
+ - `2025/03/27` MagicMotion can now perform inference on a single 4090 GPU (with less than 24GB of GPU memory).
33
+ - `2025/03/21` 🔥🔥We released MagicMotion, including inference code and model weights.
34
+
35
+ ## 📑 Table of Contents
36
+
37
+ - [💡 Abstract](#-abstract)
38
+ - [📣 Updates](#-updates)
39
+ - [📑 Table of Contents](#-table-of-contents)
40
+ - [✅ TODO List](#-todo-list)
41
+ - [🐍 Installation](#-installation)
42
+ - [📦 Model Weights](#-model-weights)
43
+ - [Folder Structure](#folder-structure)
44
+ - [Download Links](#download-links)
45
+ - [🔄 Inference](#-inference)
46
+ - [Scripts](#scripts)
47
+ - [🖥️ Gradio Demo](#️-gradio-demo)
48
+ - [🤝 Acknowledgements](#-acknowledgements)
49
+ - [📚 Contact](#-contact)
50
+
51
+ ## ✅ TODO List
52
+
53
+ - [x] Release our inference code and model weights
54
+ - [x] Release gradio demo
55
+ - [x] Release MagicData
56
+ - [ ] Release MagicBench and evaluation code
57
+ - [ ] Release our training code
58
+
59
+ ## 🐍 Installation
60
+
61
+ ```bash
62
+ # Clone this repository.
63
+ git clone https://github.com/quanhaol/MagicMotion
64
+ cd MagicMotion
65
+
66
+ # Install requirements
67
+ conda env create -n magicmotion --file environment.yml
68
+ conda activate magicmotion
69
+ pip install git+https://github.com/huggingface/diffusers
70
+
71
+ # Install Grounded_SAM2
72
+ cd trajectory_construction/Grounded_SAM2
73
+ pip install -e .
74
+ pip install --no-build-isolation -e grounding_dino
75
+
76
+ # Optional: For image editing
77
+ pip install git+https://github.com/huggingface/image_gen_aux
78
+ ```
79
+
80
+ ## 📦 Model Weights
81
+
82
+ ### Folder Structure
83
+
84
+ ```
85
+ MagicMotion
86
+ └── ckpts
87
+ ├── stage1
88
+ │ ├── mask.pt
89
+ ├── stage2
90
+ │ └── box.pt
91
+ │ └── box_perception_head.pt
92
+ ├── stage3
93
+ │ └── sparse_box.pt
94
+ │ └── sparse_box_perception_head.pt
95
+ ```
96
+
97
+ ### Download Links
98
+
99
+ ```bash
100
+ pip install "huggingface_hub[hf_transfer]"
101
+ HF_HUB_ENABLE_HF_TRANSFER=1 huggingface-cli download quanhaol/MagicMotion --local-dir ckpts
102
+ ```
103
+
104
+ ## 🔄 Inference
105
+ Inference requires **only 23GB of GPU memory** (tested on a single 24GB NVIDIA GeForce RTX 4090 GPU).
106
+ If you have sufficient GPU memory, you can modify `magicmotion/inference.py` to improve runtime performance:
107
+
108
+ ```python
109
+ # Optimized setting (for GPUs with sufficient memory)
110
+ pipe.to("cuda")
111
+ # pipe.enable_sequential_cpu_offload()
112
+ ```
113
+ > **Note**: Using the optimized setting can reduce runtime by up to 2x.
114
+
115
+ ### Scripts
116
+ ```bash
117
+ # Demo inference script of each stage (Input Image & Trajectory already provided)
118
+ bash magicmotion/scripts/inference/inference_mask.sh
119
+ bash magicmotion/scripts/inference/inference_box.sh
120
+ bash magicmotion/scripts/inference/inference_sparse_box.sh
121
+
122
+ # You an also construct trajectory for each stage by yourself -- See MagicMotion/trajectory_construction for more details
123
+ python trajectory_construction/plan_mask.py
124
+ python trajectory_construction/plan_box.py
125
+ python trajectory_construction/plan_sparse_box.py
126
+
127
+ # Optional: Use FLUX to generate input image by text-to-image generation or image editing -- See MagicMotion/first_frame_generation for more details
128
+ python first_frame_generation/t2i_flux.py
129
+ python first_frame_generation/edit_image_flux.py
130
+ ```
131
+ ## 🖥️ Gradio Demo
132
+
133
+ Usage:
134
+
135
+ ```bash
136
+ bash magicmotion/scripts/app/app.sh
137
+ ```
138
+ <img src="assets/images/gradio/1.png" alt="Gradio Demo 1" style="width: 60%; border: 1px solid #ddd; border-radius: 4px; padding: 5px;"> <img src="assets/images/gradio/2.png" alt="Gradio Demo 2" style="width: 60%; border: 1px solid #ddd; border-radius: 4px; padding: 5px;">
139
+
140
+ ## 🤝 Acknowledgements
141
+
142
+ We would like to express our gratitude to the following open-source projects that have been instrumental in the development of our project:
143
+
144
+ - [CogVideo](https://github.com/THUDM/CogVideo): An open source video generation framework by THUKEG.
145
+ - [Open-Sora](https://github.com/hpcaitech/Open-Sora): An open source video generation framework by HPC-AI Tech.
146
+ - [finetrainers](https://github.com/a-r-r-o-w/finetrainers): A Memory-optimized training library for diffusion models.
147
+
148
+ Special thanks to the contributors of these libraries for their hard work and dedication!
149
+
150
+ ## 📚 Contact
151
+
152
+ If you have any suggestions or find our work helpful, feel free to contact us
153
+
154
+ Email: liqh24@m.fudan.edu.cn or zhenxingfd@gmail.com
155
+
156
+ If you find our work useful, <b>please consider giving a star to this github repository and citing it</b>:
157
+
158
+ ```bibtex
159
+ @article{li2025magicmotion,
160
+ title={MagicMotion: Controllable Video Generation with Dense-to-Sparse Trajectory Guidance},
161
+ author={Li, Quanhao and Xing, Zhen and Wang, Rui and Zhang, Hui and Dai, Qi and Wu, Zuxuan},
162
+ journal={arXiv preprint arXiv:2503.16421},
163
+ year={2025}
164
+ }
165
+ ```
assets/box_trajectory/cartoon_wizard.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6b549c275bde28bd18e2b79040802c1c39195464b1dfe3bbb1be15bffef9447c
3
+ size 18610
assets/box_trajectory/child_horse.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:94da9a19c60d3f536f098668e463837fc46a7683627ba6ed9cf9ff83e010766a
3
+ size 27070
assets/box_trajectory/floatie.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8963327dbb5613b20c074fbf6cb39715f3daaadd039fc77bf6ee7635e981c238
3
+ size 18241
assets/box_trajectory/priestess.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0a158f5baa656a911e84e5ed0d3ca7cd934aca25a619c2f10e94dfc9a3a5cb7e
3
+ size 27097
assets/images/condition/camel_royal.png ADDED

Git LFS Details

  • SHA256: 3663efe231e87b7f4003afbc178dfcfc7aeecf6719ece4f22dfe716e71f31b6f
  • Pointer size: 131 Bytes
  • Size of remote file: 741 kB
assets/images/condition/cartoon_wizard.jpg ADDED

Git LFS Details

  • SHA256: 962d9409fdfa9f900adf2a42274787895bf7263e51a79e559db8cd2910c2573b
  • Pointer size: 131 Bytes
  • Size of remote file: 403 kB
assets/images/condition/child_horse.jpg ADDED

Git LFS Details

  • SHA256: 53434240d54ef0c04a886e7f42709d4307f5360a837c502f05629b4400e64a3a
  • Pointer size: 132 Bytes
  • Size of remote file: 1.68 MB
assets/images/condition/floatie.jpg ADDED

Git LFS Details

  • SHA256: e66f40b1b2e04b62ff60b7cb55ca5f9be239376d4905be27956cb8e1172b7404
  • Pointer size: 132 Bytes
  • Size of remote file: 1.34 MB
assets/images/condition/mammoth_rhino3.png ADDED

Git LFS Details

  • SHA256: 3cc400bf8c1fa7fcbef244eb558305d91e905fbd8da9d28a2734f6984e1788a1
  • Pointer size: 131 Bytes
  • Size of remote file: 673 kB
assets/images/condition/man_head.jpg ADDED

Git LFS Details

  • SHA256: f5f7795fc72879202bc5b31a8a7ad903efa3953d63df148cfa49d65297b951c7
  • Pointer size: 132 Bytes
  • Size of remote file: 1.14 MB
assets/images/condition/moon_castle.jpg ADDED

Git LFS Details

  • SHA256: 84a6258580817628fba1c951e5bd712c7e3871394cdb09001d6cffa5e5adf8e0
  • Pointer size: 131 Bytes
  • Size of remote file: 325 kB
assets/images/condition/priestess.jpg ADDED

Git LFS Details

  • SHA256: 089d7a01a4fbebddeb69ea45a26b922ff2d7e3fb833027a6b3ef966832db42ba
  • Pointer size: 131 Bytes
  • Size of remote file: 178 kB
assets/images/gradio/1.png ADDED

Git LFS Details

  • SHA256: d69ccd264c1808dca7e5a4ce9df2fa4e230cef586e4d5ca8bd7a869df0f20fd0
  • Pointer size: 131 Bytes
  • Size of remote file: 621 kB
assets/images/gradio/2.png ADDED

Git LFS Details

  • SHA256: 7a921f443d6e80edc069a7a259612e30ea1112a123a99aca01f0a8051cd51138
  • Pointer size: 131 Bytes
  • Size of remote file: 838 kB
assets/images/ori_image/camel.jpg ADDED

Git LFS Details

  • SHA256: caf4f65c214e0b937e047c44af7f39d0aef2b970a3b48134db8920ad3b3e3ec5
  • Pointer size: 131 Bytes
  • Size of remote file: 154 kB
assets/images/teaser/teaser.jpg ADDED

Git LFS Details

  • SHA256: ff3bce60ad9bf475c1e740235a81f33eeaeeaa478c754973fd1be1367dc710b5
  • Pointer size: 131 Bytes
  • Size of remote file: 655 kB
assets/mask_trajectory/camel.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a76a551d9afa740a8a552fe0a28514a07b8d00d1b7864395a100bc38ac7db17c
3
+ size 72597
assets/mask_trajectory/mammoth_rhino.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0072e07c80d74d870ddc65beb5507b4b9dee05d7e04ce24aefc48b3acf13d81f
3
+ size 110571
assets/mask_trajectory/mammoth_rhino_frozen_pink_bgr_range.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:59253030263289720c8a3baf2cff63508b39cb9793cc41e778c1807088f6ae2e
3
+ size 239308
assets/mask_trajectory/mammoth_rhino_h264.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:eec00ab8e9cb3975fbbe1952ce752c9f4017a3e08eda2e0540d9b68481e4ab4c
3
+ size 335939
assets/sparse_box_trajectory/man_head.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e56ca9d1852d16bb73aa67e43df7e5db18f96829b640d1e573abc071adb0bb84
3
+ size 13102
assets/sparse_box_trajectory/moon_castle.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:16658b080439c4652bbb72ae0fe43cd17f6d5697b75347fe1f3738a1b187b440
3
+ size 19341
assets/teaser.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2c33a896e0b18aaea6d2dc59116ec7eb310d23a0efe3ee2f76e05f62bcd7476c
3
+ size 7718104
assets/teaser.webp ADDED

Git LFS Details

  • SHA256: a37d3c87c2787763f9e2d237f4cd487eb8b528d365bfb8613bacfa1ac8122aff
  • Pointer size: 133 Bytes
  • Size of remote file: 22.1 MB
assets/teaser2.webp ADDED

Git LFS Details

  • SHA256: 878c06bdc18864d4a4e93f02055d338d5cf2e932f87b4153ef422b9a1b1f9f45
  • Pointer size: 132 Bytes
  • Size of remote file: 6.05 MB
change_mask.py ADDED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import cv2
2
+ import numpy as np
3
+ import os
4
+
5
+ # 路径配置
6
+ input_path = "/mnt/prev_nas/qhy/MagicMotion/assets/mask_trajectory/mammoth_rhino.mp4"
7
+ output_path = "/mnt/prev_nas/qhy/MagicMotion/assets/mask_trajectory/mammoth_rhino_frozen_pink_bgr_range.mp4"
8
+
9
+ # 你已经验证通过的两个参考颜色(BGR)
10
+ pink_bgr = np.array([77, 80, 119], dtype=np.float32) # #77504D
11
+ red_bgr = np.array([33, 37, 117], dtype=np.float32) # #752521
12
+
13
+ # 阈值(根据你单帧测试结果,目前用 30,如果想收紧可以再调小)
14
+ T_pink = 30.0
15
+ T_red = 30.0
16
+
17
+ def get_color_masks_bgr(frame_bgr):
18
+ """
19
+ 输入: frame_bgr: uint8, HxWx3
20
+ 输出: pink_mask, red_mask (bool 的 HxW)
21
+ 使用 BGR 空间的欧式距离 + 阈值来划分粉色和红色。
22
+ """
23
+ img = frame_bgr.astype(np.float32)
24
+ pixels = img.reshape(-1, 3)
25
+
26
+ dist_to_pink = np.linalg.norm(pixels - pink_bgr, axis=1)
27
+ dist_to_red = np.linalg.norm(pixels - red_bgr, axis=1)
28
+
29
+ h, w = frame_bgr.shape[:2]
30
+ pink_mask = (dist_to_pink < T_pink).reshape(h, w)
31
+ red_mask = (dist_to_red < T_red ).reshape(h, w)
32
+
33
+ # 冲突点按“谁近归谁”分配
34
+ both = pink_mask & red_mask
35
+ if both.any():
36
+ idx_flat = np.where(both.ravel())[0]
37
+ closer_to_pink = dist_to_pink[idx_flat] <= dist_to_red[idx_flat]
38
+
39
+ both_y, both_x = np.where(both)
40
+ for i, (y, x) in enumerate(zip(both_y, both_x)):
41
+ if closer_to_pink[i]:
42
+ red_mask[y, x] = False
43
+ else:
44
+ pink_mask[y, x] = False
45
+
46
+ return pink_mask, red_mask
47
+
48
+ def main():
49
+ cap = cv2.VideoCapture(input_path)
50
+ if not cap.isOpened():
51
+ raise RuntimeError(f"无法打开视频: {input_path}")
52
+
53
+ fps = cap.get(cv2.CAP_PROP_FPS)
54
+ width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
55
+ height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
56
+
57
+ # 先用 mp4v 写 mp4,如果要 H.264 可以再用 ffmpeg 转
58
+ fourcc = cv2.VideoWriter_fourcc(*"mp4v")
59
+ out = cv2.VideoWriter(output_path, fourcc, fps, (width, height))
60
+ if not out.isOpened():
61
+ cap.release()
62
+ raise RuntimeError("VideoWriter 打开失败")
63
+
64
+ # ---------- 第一帧:冻结粉色 ----------
65
+ ret, first_frame = cap.read()
66
+ if not ret:
67
+ cap.release()
68
+ out.release()
69
+ raise RuntimeError("无法读取第一帧")
70
+
71
+ pink_mask_first, _ = get_color_masks_bgr(first_frame)
72
+
73
+ frozen_pink = np.zeros_like(first_frame)
74
+ frozen_pink[pink_mask_first] = first_frame[pink_mask_first]
75
+
76
+ # 回到第一帧,从头处理整段视频
77
+ cap.set(cv2.CAP_PROP_POS_FRAMES, 0)
78
+
79
+ frame_idx = 0
80
+ while True:
81
+ ret, frame = cap.read()
82
+ if not ret:
83
+ break
84
+
85
+ _, red_mask = get_color_masks_bgr(frame)
86
+
87
+ # 当前帧红色部分
88
+ red_part = np.zeros_like(frame)
89
+ red_part[red_mask] = frame[red_mask]
90
+
91
+ # 背景黑 + 冻结粉色 + 当前红色
92
+ combined = np.zeros_like(frame)
93
+ combined += frozen_pink
94
+ combined += red_part
95
+
96
+ out.write(combined)
97
+ frame_idx += 1
98
+ if frame_idx % 50 == 0:
99
+ print(f"已处理帧数: {frame_idx}")
100
+
101
+ cap.release()
102
+ out.release()
103
+ print("处理完成,输出文件:", output_path)
104
+
105
+ if __name__ == "__main__":
106
+ main()
environment.yml ADDED
@@ -0,0 +1,264 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: magicmotion
2
+ channels:
3
+ - defaults
4
+ dependencies:
5
+ - _libgcc_mutex=0.1=main
6
+ - _openmp_mutex=5.1=1_gnu
7
+ - bzip2=1.0.8=h5eee18b_6
8
+ - ca-certificates=2024.7.2=h06a4308_0
9
+ - ld_impl_linux-64=2.38=h1181459_1
10
+ - libffi=3.4.4=h6a678d5_1
11
+ - libgcc-ng=11.2.0=h1234567_1
12
+ - libgomp=11.2.0=h1234567_1
13
+ - libstdcxx-ng=11.2.0=h1234567_1
14
+ - libuuid=1.41.5=h5eee18b_0
15
+ - ncurses=6.4=h6a678d5_0
16
+ - openssl=3.0.15=h5eee18b_0
17
+ - pip=24.2=py310h06a4308_0
18
+ - python=3.10.14=h955ad1f_1
19
+ - readline=8.2=h5eee18b_0
20
+ - setuptools=72.1.0=py310h06a4308_0
21
+ - sqlite=3.45.3=h5eee18b_0
22
+ - tk=8.6.14=h39e8969_0
23
+ - wheel=0.43.0=py310h06a4308_0
24
+ - xz=5.4.6=h5eee18b_1
25
+ - zlib=1.2.13=h5eee18b_1
26
+ - pip:
27
+ - --extra-index-url https://pypi.nvidia.com
28
+ - absl-py==2.1.0
29
+ - accelerate==1.5.2
30
+ - addict==2.4.0
31
+ - aiohappyeyeballs==2.4.0
32
+ - aiohttp==3.10.5
33
+ - aiosignal==1.3.1
34
+ - anyio==4.4.0
35
+ - argon2-cffi==23.1.0
36
+ - argon2-cffi-bindings==21.2.0
37
+ - arrow==1.3.0
38
+ - async-timeout==4.0.3
39
+ - attrs==24.2.0
40
+ - beautifulsoup4==4.12.3
41
+ - bitsandbytes==0.45.3
42
+ - bleach==6.1.0
43
+ - blobfile==3.0.0
44
+ - bokeh==3.4.3
45
+ - cachetools==5.5.0
46
+ - certifi==2024.8.30
47
+ - cffi==1.17.1
48
+ - charset-normalizer==3.3.2
49
+ - click==8.1.7
50
+ - cloudpickle==3.0.0
51
+ - colorcet==3.1.0
52
+ - contourpy==1.3.0
53
+ - cucim-cu12==24.8.0
54
+ - cuda-python==12.6.0
55
+ - cudf-cu12==24.8.2
56
+ - cugraph-cu12==24.8.0
57
+ - cuml-cu12==24.8.0
58
+ - cuproj-cu12==24.8.0
59
+ - cupy-cuda12x==13.3.0
60
+ - cuspatial-cu12==24.8.0
61
+ - cuvs-cu12==24.8.0
62
+ - cuxfilter-cu12==24.8.0
63
+ - cycler==0.12.1
64
+ - dask==2024.7.1
65
+ - dask-cuda==24.8.2
66
+ - dask-cudf-cu12==24.8.2
67
+ - dask-expr==1.1.9
68
+ - datasets==3.4.1
69
+ - datashader==0.16.3
70
+ - deepspeed==0.16.4
71
+ - defusedxml==0.7.1
72
+ - distributed==2024.7.1
73
+ - distributed-ucxx-cu12==0.39.1
74
+ - distro==1.9.0
75
+ - einops==0.8.1
76
+ - fairscale==0.4.13
77
+ - fastapi==0.114.0
78
+ - fastjsonschema==2.20.0
79
+ - fastrlock==0.8.2
80
+ - ffmpy==0.4.0
81
+ - fire==0.6.0
82
+ - fonttools==4.53.1
83
+ - fqdn==1.5.1
84
+ - frozenlist==1.4.1
85
+ - fsspec==2024.9.0
86
+ - gdown==5.2.0
87
+ - geopandas==1.0.1
88
+ - gitdb==4.0.11
89
+ - gitpython==3.1.43
90
+ - gradio==4.44.0
91
+ - gradio-client==1.3.0
92
+ - grpcio==1.66.1
93
+ - gurobipy==11.0.3
94
+ - h5py==3.11.0
95
+ - hf-transfer==0.1.9
96
+ - hickle==5.0.3
97
+ - holoviews==1.19.1
98
+ - httpcore==1.0.5
99
+ - httpx==0.27.2
100
+ - huggingface-hub==0.27.0
101
+ - hydra-core==1.3.2
102
+ - idna==3.8
103
+ - imageio==2.35.1
104
+ - importlib-metadata==8.5.0
105
+ - importlib-resources==6.4.5
106
+ - iopath==0.1.10
107
+ - isoduration==20.11.0
108
+ - jinja2==3.1.4
109
+ - jiter==0.5.0
110
+ - jmespath==1.0.1
111
+ - joblib==1.4.2
112
+ - jsonpointer==3.0.0
113
+ - jsonschema==4.23.0
114
+ - jsonschema-specifications==2023.12.1
115
+ - jupyter-client==8.6.2
116
+ - jupyter-core==5.7.2
117
+ - jupyter-events==0.10.0
118
+ - jupyter-server==2.14.2
119
+ - jupyter-server-proxy==4.4.0
120
+ - jupyter-server-terminals==0.5.3
121
+ - jupyterlab-pygments==0.3.0
122
+ - kiwisolver==1.4.7
123
+ - kmeans-pytorch==0.3
124
+ - lazy-loader==0.4
125
+ - libucx-cu12==1.15.0.post1
126
+ - linkify-it-py==2.0.3
127
+ - llama-models==0.0.13
128
+ - llama-toolchain==0.0.13
129
+ - llvmlite==0.43.0
130
+ - locket==1.0.0
131
+ - lxml==5.3.0
132
+ - markdown==3.7
133
+ - markupsafe==2.1.5
134
+ - matplotlib==3.9.2
135
+ - mdit-py-plugins==0.4.2
136
+ - mistune==3.0.2
137
+ - multipledispatch==1.0.0
138
+ - nbclient==0.10.0
139
+ - nbconvert==7.16.4
140
+ - nbformat==5.10.4
141
+ - networkx==3.3
142
+ - numba==0.60.0
143
+ - numpy==1.26.4
144
+ - nvidia-cublas-cu12==12.1.3.1
145
+ - nvidia-cuda-cupti-cu12==12.1.105
146
+ - nvidia-cuda-nvrtc-cu12==12.1.105
147
+ - nvidia-cuda-runtime-cu12==12.1.105
148
+ - nvidia-cudnn-cu12==9.1.0.70
149
+ - nvidia-cufft-cu12==11.0.2.54
150
+ - nvidia-curand-cu12==10.3.2.106
151
+ - nvidia-cusolver-cu12==11.4.5.107
152
+ - nvidia-cusparse-cu12==12.1.0.106
153
+ - nvidia-ml-py==12.570.86
154
+ - nvidia-nccl-cu12==2.20.5
155
+ - nvidia-nvjitlink-cu12==12.6.68
156
+ - nvidia-nvtx-cu12==12.1.105
157
+ - nvtx==0.2.10
158
+ - openai==1.44.1
159
+ - opencv-python-headless==4.10.0.84
160
+ - orjson==3.10.7
161
+ - overrides==7.7.0
162
+ - pandas==2.2.2
163
+ - pandocfilters==1.5.1
164
+ - panel==1.4.5
165
+ - param==2.1.1
166
+ - partd==1.4.2
167
+ - peft==0.14.0
168
+ - platformdirs==4.3.2
169
+ - portalocker==2.10.1
170
+ - prometheus-client==0.20.0
171
+ - protobuf==5.28.0
172
+ - psutil==6.0.0
173
+ - ptyprocess==0.7.0
174
+ - pulp==2.9.0
175
+ - pyarrow==16.1.0
176
+ - pycocotools==2.0.8
177
+ - pycparser==2.22
178
+ - pycryptodomex==3.20.0
179
+ - pyct==0.5.0
180
+ - pydantic==2.9.1
181
+ - pydantic-core==2.23.3
182
+ - pygments==2.18.0
183
+ - pylibcugraph-cu12==24.8.0
184
+ - pylibraft-cu12==24.8.1
185
+ - pynvjitlink-cu12==0.3.0
186
+ - pynvml==11.4.1
187
+ - pyogrio==0.9.0
188
+ - pyparsing==3.1.4
189
+ - pyproj==3.6.1
190
+ - pysocks==1.7.1
191
+ - python-json-logger==2.0.7
192
+ - python-multipart==0.0.9
193
+ - pytz==2024.2
194
+ - pyviz-comms==3.0.3
195
+ - pyyaml==6.0.2
196
+ - pyzmq==26.2.0
197
+ - raft-dask-cu12==24.8.1
198
+ - rapids-dask-dependency==24.8.0
199
+ - referencing==0.35.1
200
+ - rfc3339-validator==0.1.4
201
+ - rfc3986-validator==0.1.1
202
+ - rich==13.8.1
203
+ - rmm-cu12==24.8.2
204
+ - rpds-py==0.20.0
205
+ - ruff==0.6.4
206
+ - safetensors==0.4.5
207
+ - scikit-image==0.23.2
208
+ - scikit-learn==1.5.1
209
+ - scipy==1.14.1
210
+ - send2trash==1.8.3
211
+ - sentencepiece==0.2.0
212
+ - shapely==2.0.6
213
+ - simpervisor==1.0.0
214
+ - six==1.16.0
215
+ - smmap==5.0.1
216
+ - sortedcontainers==2.4.0
217
+ - soupsieve==2.6
218
+ - starlette==0.38.5
219
+ - supervision==0.23.0
220
+ - sympy==1.13.2
221
+ - tblib==3.0.0
222
+ - tensorboard==2.17.1
223
+ - tensorboard-data-server==0.7.2
224
+ - termcolor==2.4.0
225
+ - terminado==0.18.1
226
+ - threadpoolctl==3.5.0
227
+ - tifffile==2024.8.30
228
+ - tiktoken==0.7.0
229
+ - timm==1.0.9
230
+ - tinycss2==1.3.0
231
+ - tokenizers==0.19.1
232
+ - tomli==2.0.1
233
+ - toolz==0.12.1
234
+ - torch==2.4.1
235
+ - torchao==0.9.0
236
+ - torchaudio==2.4.1
237
+ - torchdata==0.11.0
238
+ - torchvision==0.19.1
239
+ - tornado==6.4.1
240
+ - traitlets==5.14.3
241
+ - transformers==4.44.2
242
+ - treelite==4.3.0
243
+ - triton==3.0.0
244
+ - typer==0.12.5
245
+ - types-python-dateutil==2.9.0.20240906
246
+ - tzdata==2024.1
247
+ - uc-micro-py==1.0.3
248
+ - ucx-py-cu12==0.39.2
249
+ - ucxx-cu12==0.39.1
250
+ - uri-template==1.3.0
251
+ - urllib3==2.2.2
252
+ - uvicorn==0.30.6
253
+ - webcolors==24.8.0
254
+ - webencodings==0.5.1
255
+ - websocket-client==1.8.0
256
+ - websockets==12.0
257
+ - werkzeug==3.0.4
258
+ - xarray==2024.9.0
259
+ - xyzservices==2024.9.0
260
+ - yapf==0.40.2
261
+ - yarl==1.11.1
262
+ - zict==3.0.0
263
+ - zipp==3.20.1
264
+ - imageio-ffmpeg==0.6.0