mover 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
mover-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,101 @@
1
+ Metadata-Version: 2.4
2
+ Name: mover
3
+ Version: 0.1.0
4
+ Summary: Official implementation of MoVer: Motion Verification for Motion Graphics Animations
5
+ Author-email: Jiaju Ma <jiajuma@stanford.edu>
6
+ License: Apache-2.0
7
+ Project-URL: Homepage, https://mover-dsl.github.io/
8
+ Project-URL: Repository, https://github.com/mover-dsl/MoVer
9
+ Project-URL: Bug Tracker, https://github.com/mover-dsl/MoVer/issues
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.10
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
16
+ Classifier: Topic :: Multimedia :: Graphics
17
+ Requires-Python: >=3.10
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE.txt
20
+ Requires-Dist: cairosvg
21
+ Requires-Dist: fastapi==0.115.14
22
+ Requires-Dist: groq
23
+ Requires-Dist: Jinja2
24
+ Requires-Dist: numpy
25
+ Requires-Dist: openai
26
+ Requires-Dist: opencv-contrib-python==4.11.0.86
27
+ Requires-Dist: Pillow
28
+ Requires-Dist: playwright
29
+ Requires-Dist: protobuf
30
+ Requires-Dist: PyYAML
31
+ Requires-Dist: treelib
32
+ Requires-Dist: uvicorn==0.35.0
33
+ Requires-Dist: torch>=2.7.1
34
+ Requires-Dist: torchvision>=0.22.1
35
+ Requires-Dist: jacinle
36
+ Requires-Dist: concepts
37
+ Requires-Dist: ipykernel>=6.29.5
38
+ Provides-Extra: local
39
+ Requires-Dist: ollama-python; extra == "local"
40
+ Requires-Dist: vllm; extra == "local"
41
+ Dynamic: license-file
42
+
43
+ # MoVer: Motion Verification for Motion Graphics Animations
44
+
45
+ [Jiaju Ma](https://majiaju.io) and
46
+ [Maneesh Agrawala](https://graphics.stanford.edu/~maneesh/)
47
+ <br />
48
+ In ACM Transactions on Graphics (SIGGRAPH), 44(4), August 2025. To Appear.
49
+ <br />
50
+
51
+ [[arXiv](https://arxiv.org/abs/2502.13372)] [[project page](https://mover-dsl.github.io/)]
52
+
53
+
54
+ ## Dataset
55
+ The test prompt dataset used in the paper can be found in `mover_dataset`
56
+
57
+
58
+ ## Setup
59
+
60
+ ### JavaScript animation to MoVer data format converter
61
+ 1. (Optional) We support rendering to video with OpenCV, but the video produced might have limited compatibility. If you optionally install `ffmpeg`, our converter will automatically use it to convert rendered videos.
62
+
63
+ ### MoVer
64
+ 1. Set up a virtual environment with your favorite tool. It is recommended to use `uv` because it is very fast.
65
+ 2. Make sure you have `pytorch` installed
66
+ 3. Install [Jacinle](https://github.com/vacancy/Jacinle).
67
+ ```bash
68
+ git clone https://github.com/vacancy/Jacinle --recursive
69
+ cd Jacinle
70
+ pip install -e . # or uv pip install -e . or follow the instructions on the Jacinle GitHub page
71
+ ```
72
+
73
+ 4. Install [Concepts](https://github.com/concepts-ai/concepts).
74
+ ```bash
75
+ git clone https://github.com/concepts-ai/Concepts.git
76
+ cd Concepts
77
+ pip install -e . # or uv pip install -e .
78
+ ```
79
+
80
+ 5. Run `pip install -r requirements.txt` or `uv pip install -r requirements.txt` to install the remaining dependencies
81
+ - This list includes APIs to interface with OpenAI, Gemini (via OpenAI), and Groq
82
+
83
+ 6. Store your API keys as environment variables (e.g., `OPENAI_API_KEY`, `GEMINI_API_KEY`, `GROQ_API_KEY`).
84
+
85
+ 7. If you plan to run locally-hosted models, install the following dependencies:
86
+ - Install `ollama` if you plan to use ollama with `ollama-python`
87
+ - Install `vLLM` if you plan to use vLLM
88
+
89
+
90
+ ## Usage
91
+ Check out the `tutorial.ipynb` for a tutorial of the motion graphics animation generation with MoVer verification pipeline.
92
+
93
+
94
+ ## Release Checklist
95
+ - [x] MoVer DSL and verifier
96
+ - [x] JavaScript animation to MoVer data format converter
97
+ - [x] LLM-based animation synthesizer
98
+ - [x] LLM-based MoVer synthesizer
99
+ - [x] Scripts to run the full pipeline
100
+ - [ ] Web app for creating animations with MoVer
101
+ - [ ] Scripts for generating animation prompts
mover-0.1.0/README.md ADDED
@@ -0,0 +1,59 @@
1
+ # MoVer: Motion Verification for Motion Graphics Animations
2
+
3
+ [Jiaju Ma](https://majiaju.io) and
4
+ [Maneesh Agrawala](https://graphics.stanford.edu/~maneesh/)
5
+ <br />
6
+ In ACM Transactions on Graphics (SIGGRAPH), 44(4), August 2025. To Appear.
7
+ <br />
8
+
9
+ [[arXiv](https://arxiv.org/abs/2502.13372)] [[project page](https://mover-dsl.github.io/)]
10
+
11
+
12
+ ## Dataset
13
+ The test prompt dataset used in the paper can be found in `mover_dataset`
14
+
15
+
16
+ ## Setup
17
+
18
+ ### JavaScript animation to MoVer data format converter
19
+ 1. (Optional) We support rendering to video with OpenCV, but the video produced might have limited compatibility. If you optionally install `ffmpeg`, our converter will automatically use it to convert rendered videos.
20
+
21
+ ### MoVer
22
+ 1. Set up a virtual environment with your favorite tool. It is recommended to use `uv` because it is very fast.
23
+ 2. Make sure you have `pytorch` installed
24
+ 3. Install [Jacinle](https://github.com/vacancy/Jacinle).
25
+ ```bash
26
+ git clone https://github.com/vacancy/Jacinle --recursive
27
+ cd Jacinle
28
+ pip install -e . # or uv pip install -e . or follow the instructions on the Jacinle GitHub page
29
+ ```
30
+
31
+ 4. Install [Concepts](https://github.com/concepts-ai/concepts).
32
+ ```bash
33
+ git clone https://github.com/concepts-ai/Concepts.git
34
+ cd Concepts
35
+ pip install -e . # or uv pip install -e .
36
+ ```
37
+
38
+ 5. Run `pip install -r requirements.txt` or `uv pip install -r requirements.txt` to install the remaining dependencies
39
+ - This list includes APIs to interface with OpenAI, Gemini (via OpenAI), and Groq
40
+
41
+ 6. Store your API keys as environment variables (e.g., `OPENAI_API_KEY`, `GEMINI_API_KEY`, `GROQ_API_KEY`).
42
+
43
+ 7. If you plan to run locally-hosted models, install the following dependencies:
44
+ - Install `ollama` if you plan to use ollama with `ollama-python`
45
+ - Install `vLLM` if you plan to use vLLM
46
+
47
+
48
+ ## Usage
49
+ Check out the `tutorial.ipynb` for a tutorial of the motion graphics animation generation with MoVer verification pipeline.
50
+
51
+
52
+ ## Release Checklist
53
+ - [x] MoVer DSL and verifier
54
+ - [x] JavaScript animation to MoVer data format converter
55
+ - [x] LLM-based animation synthesizer
56
+ - [x] LLM-based MoVer synthesizer
57
+ - [x] Scripts to run the full pipeline
58
+ - [ ] Web app for creating animations with MoVer
59
+ - [ ] Scripts for generating animation prompts
@@ -0,0 +1,69 @@
1
+ [build-system]
2
+ requires = ["setuptools>=64.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "mover"
7
+ version = "0.1.0"
8
+ description = "Official implementation of MoVer: Motion Verification for Motion Graphics Animations"
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ license = { text = "Apache-2.0" }
12
+ authors = [
13
+ { name = "Jiaju Ma", email = "jiajuma@stanford.edu" },
14
+ ]
15
+ classifiers = [
16
+ "Development Status :: 4 - Beta",
17
+ "Programming Language :: Python :: 3",
18
+ "Programming Language :: Python :: 3.10",
19
+ "Programming Language :: Python :: 3.11",
20
+ "Programming Language :: Python :: 3.12",
21
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
22
+ "Topic :: Multimedia :: Graphics",
23
+ ]
24
+ dependencies = [
25
+ "cairosvg",
26
+ "fastapi==0.115.14",
27
+ "groq",
28
+ "Jinja2",
29
+ "numpy",
30
+ "openai",
31
+ "opencv-contrib-python==4.11.0.86",
32
+ "Pillow",
33
+ "playwright",
34
+ "protobuf",
35
+ "PyYAML",
36
+ "treelib",
37
+ "uvicorn==0.35.0",
38
+ "torch>=2.7.1",
39
+ "torchvision>=0.22.1",
40
+ "jacinle",
41
+ "concepts",
42
+ "ipykernel>=6.29.5",
43
+ ]
44
+
45
+ [project.urls]
46
+ Homepage = "https://mover-dsl.github.io/"
47
+ Repository = "https://github.com/mover-dsl/MoVer"
48
+ "Bug Tracker" = "https://github.com/mover-dsl/MoVer/issues"
49
+
50
+ [tool.setuptools]
51
+ package-dir = {"" = "src"}
52
+ packages = ["mover"]
53
+
54
+ [tool.uv.sources]
55
+ jacinle = { git = "https://github.com/vacancy/Jacinle.git" }
56
+ concepts = { git = "https://github.com/jama1017/Concepts.git"}
57
+
58
+
59
+ [project.optional-dependencies]
60
+ local = [
61
+ "ollama-python",
62
+ "vllm",
63
+ ]
64
+
65
+ [[tool.uv.index]]
66
+ name = "testpypi"
67
+ url = "https://test.pypi.org/simple/"
68
+ publish-url = "https://test.pypi.org/legacy/"
69
+ explicit = true
mover-0.1.0/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
File without changes
@@ -0,0 +1,323 @@
1
+ import json
2
+ import argparse
3
+ import subprocess
4
+ import traceback
5
+ from typing import Dict, Any
6
+ from pathlib import Path
7
+ import yaml
8
+ from mover.synthesizers.animation_synthesizer import AnimationSynthesizer
9
+ from mover.synthesizers.mover_synthesizer import MoverSynthesizer
10
+ from mover.dsl.mover_verifier import MoverVerifier
11
+ from mover.converter.mover_converter import convert_animation
12
+
13
+
14
+ class AnimationPipeline:
15
+ """Main pipeline class for handling animation generation and verification."""
16
+
17
+ def __init__(self, config: Dict[str, Any]):
18
+ """Initialize pipeline with configuration.
19
+
20
+ Args:
21
+ config: Dictionary containing pipeline configuration
22
+ """
23
+ ## Store config
24
+ self.config = config
25
+
26
+ ## Initialize synthesizers and verifier
27
+ self.animation_synthesizer = self._init_synthesizer(
28
+ AnimationSynthesizer,
29
+ self.config['animation_model']
30
+ )
31
+ self.mover_synthesizer = self._init_synthesizer(
32
+ MoverSynthesizer,
33
+ self.config['mover_model']
34
+ )
35
+ self.verifier = MoverVerifier()
36
+
37
+
38
+ def _init_synthesizer(self, synthesizer_class: Any, config: Dict[str, Any]) -> Any:
39
+ """Initialize a synthesizer with its configuration.
40
+
41
+ Args:
42
+ synthesizer_class: The synthesizer class to instantiate
43
+ config: Configuration dictionary for the synthesizer
44
+
45
+ Returns:
46
+ Initialized synthesizer instance
47
+ """
48
+ params = {k: v for k, v in config.get('params', {}).items() if v is not None}
49
+ if config.get('vllm_serve_port') is not None:
50
+ params['vllm_serve_port'] = config['vllm_serve_port']
51
+
52
+ return synthesizer_class(
53
+ model_name=config['name'],
54
+ provider=config['provider'],
55
+ num_ctx=config.get('num_ctx', 128000),
56
+ params=params
57
+ )
58
+
59
+
60
+ def _write_log(self, log_path: Path, status: str, num_iter: int, message: str = "") -> None:
61
+ """Write a log file with consistent formatting.
62
+
63
+ Args:
64
+ log_path: Path to write the log file
65
+ status: Status of the run (success/fail/error)
66
+ num_iter: Number of iterations taken
67
+ message: Optional additional message to include
68
+ """
69
+ with open(log_path, "w") as f:
70
+ if message:
71
+ f.write(f"{message}\n\n")
72
+
73
+ f.write(f"Prompt {log_path.parent.name} {status} in {num_iter} iterations.\n")
74
+
75
+ ## Log all config sections
76
+ for section, values in self.config.items():
77
+ f.write(f"\n[{section}]\n")
78
+ for key, value in values.items():
79
+ f.write(f"{key}: {value}\n")
80
+
81
+
82
+ def _save_chat_messages(self, chat_file_path: Path, chat_messages: list) -> None:
83
+ with open(chat_file_path, "w") as f:
84
+ json.dump(chat_messages, f, indent=4)
85
+
86
+
87
+ def run_loop(self, animation_prompt_data: Dict[str, Any]) -> None:
88
+ """Run the main chat loop for animation generation and verification.
89
+
90
+ Args:
91
+ animation_prompt_data: Data about the animation prompt including the prompt text,
92
+ chat ID, and optional ground truth program
93
+ """
94
+ chat_id_name = animation_prompt_data["chat_id_name"]
95
+ animation_prompt = animation_prompt_data["animation_prompt"]
96
+ paths_config = self.config['paths']
97
+
98
+ chat_dir_path = Path(paths_config['parent_dir']) / chat_id_name
99
+ chat_file_path = chat_dir_path / f"{chat_id_name}.json"
100
+
101
+ if "svg_file_path" not in animation_prompt_data:
102
+ svg_file_path = Path(paths_config['svg_dir']) / animation_prompt_data["svg_name"]
103
+ animation_prompt_data["svg_file_path"] = str(svg_file_path)
104
+
105
+ ## Setup chat directory
106
+ if not chat_dir_path.exists():
107
+ chat_dir_path.mkdir(parents=True)
108
+ else:
109
+ if any(f.suffix == '.log' for f in chat_dir_path.iterdir()):
110
+ print(f"Prompt {chat_id_name} has already been run. Skipping.")
111
+ return
112
+ ## Clear chat directory as it has not been completed yet
113
+ for f in chat_dir_path.iterdir():
114
+ if f.is_file():
115
+ f.unlink()
116
+
117
+ ## Get or generate verification program
118
+ verification_program_path = chat_dir_path / f"{chat_id_name}.py"
119
+ if not verification_program_path.exists():
120
+ if "ground_truth_program" in animation_prompt_data:
121
+ print("\n\nRetrieving verification program")
122
+ verification_program = animation_prompt_data["ground_truth_program"]
123
+ else:
124
+ print("\n\nGenerating verification program")
125
+ chat_history = [
126
+ self.mover_synthesizer.compose_sys_msg(),
127
+ self.mover_synthesizer.compose_initial_user_prompt(animation_prompt)
128
+ ]
129
+ verification_program, error_msg = self.mover_synthesizer.generate(
130
+ chat_history,
131
+ str(verification_program_path)
132
+ )
133
+ if error_msg:
134
+ print(f"Error generating verification program: {error_msg}")
135
+ return
136
+
137
+ with open(verification_program_path, "w") as f:
138
+ f.write(verification_program)
139
+ else:
140
+ print("\n\nReading verification program")
141
+ with open(verification_program_path, "r") as f:
142
+ verification_program = f.read()
143
+
144
+ ## Initialize chat
145
+ chat_messages = [
146
+ self.animation_synthesizer.compose_sys_msg(),
147
+ self.animation_synthesizer.compose_initial_user_prompt(animation_prompt, animation_prompt_data["svg_file_path"])
148
+ ]
149
+
150
+ is_correct = False
151
+ is_mover_doc_sent = False
152
+ num_iter = 0
153
+ server_config = self.config['server']
154
+ pipeline_config = self.config['pipeline']
155
+ max_iter = pipeline_config['max_iter']
156
+
157
+ ## Run loop until correct or max iterations reached
158
+ while not is_correct and num_iter < max_iter:
159
+ print(f"\n\n---------iteration {num_iter}---------")
160
+ animation_model = self.config['animation_model']
161
+ print(f"Chat id: {chat_id_name}, Model: {animation_model['name']}, Provider: {animation_model['provider']}\n")
162
+
163
+ ## Generate animation code
164
+ html_file_name = f"{chat_id_name}_{num_iter}.html"
165
+ html_file_path = chat_dir_path / html_file_name
166
+ response, error_msg = self.animation_synthesizer.generate(
167
+ chat_messages,
168
+ animation_prompt_data["svg_file_path"],
169
+ str(html_file_path)
170
+ )
171
+
172
+ ## Update chat history
173
+ chat_messages.append({"role": "assistant", "content": response})
174
+ self._save_chat_messages(chat_file_path, chat_messages)
175
+
176
+ ## Handle error case
177
+ if error_msg:
178
+ print(f"\n\nError extracting code block: {error_msg}")
179
+ print("Continuing to next iteration with help message.")
180
+ chat_messages.append({
181
+ "role": "user",
182
+ "content": "Animation program code is not wrapped in ```javascript and ``` tags. Please wrap it in ```javascript and ``` tags."
183
+ })
184
+ self._save_chat_messages(chat_file_path, chat_messages)
185
+
186
+ num_iter += 1
187
+ continue
188
+
189
+ ## Convert HTML to animation data
190
+ animation_data_file = f"{chat_id_name}_{num_iter}_data.json"
191
+ animation_data_path = chat_dir_path / animation_data_file
192
+ convert_animation(str(html_file_path), server_config['port'], server_config['create_video'])
193
+
194
+ ## Verify animation
195
+ try:
196
+ verification_result = self.verifier.verify(
197
+ str(verification_program_path),
198
+ str(animation_data_path)
199
+ )
200
+ except Exception as e:
201
+ traceback_str = str(traceback.format_exc())
202
+ print(f"\n\n{traceback_str}")
203
+ print("\n\nVerifier errored out. Setting verification result to False.")
204
+ verification_result = "False: invalid animation."
205
+ with open(chat_dir_path / f"{chat_id_name}_{num_iter}.out", "w") as f:
206
+ f.write(traceback_str)
207
+
208
+ ## Process verification result
209
+ if "False" in verification_result:
210
+ is_correct = False
211
+
212
+ ## Build verification message with DSL documentation on first failure
213
+ verification_message_template = self.verifier.get_correction_msg_template()
214
+
215
+ ## Add DSL documentation only on first verification failure
216
+ template_params = {
217
+ "verification_program": verification_program,
218
+ "verification_result": verification_result
219
+ }
220
+
221
+ if not is_mover_doc_sent:
222
+ template_params["dsl_documentation"] = self.mover_synthesizer.get_dsl_documentation()
223
+ is_mover_doc_sent = True
224
+
225
+ verification_message = verification_message_template.render(**template_params)
226
+
227
+ chat_messages.append({
228
+ "role": "user",
229
+ "content": verification_message
230
+ })
231
+ self._save_chat_messages(chat_file_path, chat_messages)
232
+
233
+ else:
234
+ is_correct = True
235
+ self._write_log(chat_dir_path / "success.log", "succeeded", num_iter)
236
+
237
+ num_iter += 1
238
+
239
+ ## Handle failure case
240
+ if not is_correct and num_iter >= max_iter:
241
+ self._write_log(chat_dir_path / "fail.log", "failed", num_iter)
242
+
243
+
244
+ def load_config() -> Dict[str, Any]:
245
+ """Load configuration from YAML file.
246
+
247
+ Returns:
248
+ Dictionary containing pipeline configuration
249
+
250
+ Raises:
251
+ ValueError: If required fields are missing
252
+ """
253
+ parser = argparse.ArgumentParser(description="Run animation pipeline with YAML configuration.")
254
+ parser.add_argument("config", type=str, help="Path to YAML configuration file")
255
+ args = parser.parse_args()
256
+
257
+ with open(args.config, 'r') as f:
258
+ config = yaml.safe_load(f)
259
+
260
+ ## Validate required sections
261
+ required_sections = ['paths', 'server', 'pipeline', 'animation_model', 'mover_model']
262
+ missing_sections = [s for s in required_sections if s not in config]
263
+ if missing_sections:
264
+ raise ValueError(f"Missing required config sections: {', '.join(missing_sections)}")
265
+
266
+ ## Validate paths section
267
+ paths_config = config['paths']
268
+ required_paths = ['parent_dir', 'svg_dir', 'animation_prompts_file']
269
+ missing_paths = [p for p in required_paths if p not in paths_config]
270
+ if missing_paths:
271
+ raise ValueError(f"Missing required path configurations: {', '.join(missing_paths)}")
272
+
273
+ ## Validate server section
274
+ server_config = config['server']
275
+ required_server = ['port', 'create_video']
276
+ missing_server = [s for s in required_server if s not in server_config]
277
+ if missing_server:
278
+ raise ValueError(f"Missing required server configurations: {', '.join(missing_server)}")
279
+
280
+ ## Validate pipeline section
281
+ pipeline_config = config['pipeline']
282
+ if 'max_iter' not in pipeline_config:
283
+ raise ValueError("Missing required pipeline configuration: max_iter")
284
+
285
+ ## Validate model sections
286
+ for model_key in ['animation_model', 'mover_model']:
287
+ model_config = config[model_key]
288
+ required_model = ['name', 'provider']
289
+ missing_model = [m for m in required_model if m not in model_config]
290
+ if missing_model:
291
+ raise ValueError(f"Missing required {model_key} configurations: {', '.join(missing_model)}")
292
+
293
+ return config
294
+
295
+
296
+ def main() -> None:
297
+ """Main entry point for the animation pipeline."""
298
+ config = load_config()
299
+ pipeline = AnimationPipeline(config)
300
+
301
+ paths_config = config['paths']
302
+ with open(paths_config['animation_prompts_file'], "r") as f:
303
+ animation_prompts = json.load(f)
304
+
305
+ for animation_prompt_data in animation_prompts:
306
+ if animation_prompt_data.get("has_run", False):
307
+ continue
308
+
309
+ print(f"\n\n ---- Running {animation_prompt_data['chat_id_name']} ----\n")
310
+ try:
311
+ pipeline.run_loop(animation_prompt_data)
312
+
313
+ except Exception as e:
314
+ traceback_str = str(traceback.format_exc())
315
+ print(f"\n\n{traceback_str}")
316
+ print("\n\nErrored out. Skipping to next animation prompt.")
317
+ error_file = Path(paths_config['parent_dir']) / animation_prompt_data["chat_id_name"] / "error.txt"
318
+ pipeline._write_log(error_file, "errored", 0, traceback_str)
319
+ continue
320
+
321
+
322
+ if __name__ == "__main__":
323
+ main()
@@ -0,0 +1,198 @@
1
+ import os
2
+ import json
3
+ import heapq
4
+ import argparse
5
+ import yaml
6
+
7
+ parser = argparse.ArgumentParser()
8
+ parser.add_argument("configs", type=str, nargs='+', help="List of YAML config files to process.")
9
+
10
+ args, unknown = parser.parse_known_args()
11
+
12
+ ## Helper function to extract paths from config
13
+ def get_paths_from_config(config_file):
14
+ with open(config_file, 'r') as f:
15
+ config = yaml.safe_load(f)
16
+
17
+ paths_config = config['paths']
18
+ return (
19
+ paths_config['parent_dir'],
20
+ paths_config['animation_prompts_file']
21
+ )
22
+
23
+ def format_stats(total_input, chat_dir, error_count, total, num_more_than_one, num_iterations, num_fail, iterations_data=None, is_total=False):
24
+ """Helper function to format statistics in a consistent format.
25
+
26
+ Args:
27
+ total_input: Number of total input prompts
28
+ chat_dir: Name of chat directory (or "Total stats" for totals)
29
+ error_count: Number of errors
30
+ total: Total number of prompts processed
31
+ num_more_than_one: Number of prompts that took more than one attempt
32
+ num_iterations: Number of prompts that succeeded after multiple attempts
33
+ num_fail: Number of failed prompts
34
+ iterations_data: Tuple of (sum_iterations, min_iter, max_iter) for calculating average
35
+ is_total: Whether this is printing total stats
36
+
37
+ Returns:
38
+ Formatted string containing the statistics
39
+ """
40
+ lines = []
41
+ if not is_total:
42
+ lines.extend([
43
+ f"\n\nTotal input: {total_input}",
44
+ f"Chat dir: {os.path.basename(chat_dir)}"
45
+ ])
46
+ else:
47
+ lines.extend([
48
+ "\n------------",
49
+ "Total stats\n",
50
+ f"Total input: {total_input}"
51
+ ])
52
+
53
+ lines.extend([
54
+ f"error: {error_count}",
55
+ f"Total: {total}",
56
+ f"pass@0: {(total - num_more_than_one)} ({(total - num_more_than_one) / total * 100})",
57
+ f"pass@1+: {num_iterations} ({num_iterations / total * 100})",
58
+ f"fail: {num_fail} ({num_fail / total * 100})"
59
+ ])
60
+
61
+ if iterations_data and iterations_data[1] > 0: # If we have iteration data and at least one multi-attempt success
62
+ avg_iters = iterations_data[0] / iterations_data[1]
63
+ lines.append(f"avg. iters.: {avg_iters} ({iterations_data[2]}-{iterations_data[3]})")
64
+ else:
65
+ lines.append("avg. iters.: N/A")
66
+
67
+ return "\n".join(lines)
68
+
69
+
70
+ def get_stats(parent_dirs, animation_prompts_files, chat_id_prefix=None):
71
+ total_prompts = []
72
+ total_input_prompts = []
73
+ total_num_more_than_one = []
74
+ total_num_fail = []
75
+ total_num_iterations = []
76
+ total_error_count = []
77
+
78
+ for parent_dir in parent_dirs:
79
+ with open(animation_prompts_files[parent_dirs.index(parent_dir)], 'r') as file:
80
+ chat_prompts = json.load(file)
81
+ chat_id_names = [chat_prompt["chat_id_name"] for chat_prompt in chat_prompts]
82
+ total_input_prompts.append(len(chat_prompts))
83
+
84
+ ## for each subdirectory in parent_dir, count the number of html files
85
+ html_file_count = []
86
+ for subdir, _, files in os.walk(parent_dir):
87
+ if subdir == parent_dir:
88
+ continue
89
+
90
+ error_file = [file for file in files if file == 'error.txt']
91
+ subdir_name = os.path.basename(subdir)
92
+ error_count = len(error_file)
93
+
94
+ ## read the json chat_file named the same as the subdir_name and count the number of objects with "role": "assistant"
95
+ chat_file = os.path.join(parent_dir, subdir_name, f"{subdir_name}.json")
96
+ num_assistant_messages = 0
97
+ if os.path.exists(chat_file):
98
+ with open(chat_file, 'r') as f:
99
+ chat_data = json.load(f)
100
+ num_assistant_messages = sum(1 for message in chat_data if message.get("role") == "assistant")
101
+ else:
102
+ error_count = 1
103
+
104
+ if subdir_name in chat_id_names:
105
+ html_file_count.append((subdir_name, num_assistant_messages, error_count))
106
+
107
+ ## sort the subdirectories by its name
108
+ html_file_count = sorted(html_file_count, key=lambda x: x[0].split("_")[2:], reverse=False)
109
+
110
+ ## print the html file count in a table format
111
+ num_more_than_one = 0
112
+ num_fail = 0
113
+ count_num_iterations = []
114
+ num_iterations = 0
115
+ filtered_html_file_count = []
116
+ num_error_count = 0
117
+ for subdir, count, error_count in html_file_count:
118
+ if chat_id_prefix is not None:
119
+ if not subdir.startswith(chat_id_prefix):
120
+ continue
121
+
122
+ if error_count > 0:
123
+ num_error_count += 1
124
+ continue
125
+
126
+ filtered_html_file_count.append((subdir, count, error_count))
127
+ success_log_file = os.path.join(parent_dir, subdir, "success.log")
128
+ fail_log_file = os.path.join(parent_dir, subdir, "fail.log")
129
+
130
+ if count > 1:
131
+ num_more_than_one += 1
132
+
133
+ if os.path.exists(success_log_file):
134
+ ## prompt took more than one attempt
135
+ if count > 1:
136
+ num_iterations += 1
137
+ count_num_iterations.append(count)
138
+
139
+ elif os.path.exists(fail_log_file):
140
+ num_fail += 1
141
+
142
+ html_file_count = filtered_html_file_count
143
+ total_prompts.append(len(html_file_count))
144
+ total_num_more_than_one.append(num_more_than_one)
145
+ total_num_fail.append(num_fail)
146
+ total_num_iterations.append((sum(count_num_iterations), num_iterations, min(count_num_iterations, default=0), heapq.nlargest(1, count_num_iterations)[0] if count_num_iterations else 0))
147
+ total_error_count.append(num_error_count)
148
+
149
+ output = []
150
+ for i in range(len(parent_dirs)):
151
+ stats = format_stats(
152
+ total_input=total_input_prompts[i],
153
+ chat_dir=parent_dirs[i],
154
+ error_count=total_error_count[i],
155
+ total=total_prompts[i],
156
+ num_more_than_one=total_num_more_than_one[i],
157
+ num_iterations=total_num_iterations[i][1],
158
+ num_fail=total_num_fail[i],
159
+ iterations_data=total_num_iterations[i]
160
+ )
161
+ output.append(stats)
162
+
163
+ # Only show total stats if there is more than one config
164
+ if len(parent_dirs) > 1:
165
+ num_total_prompts = sum(total_prompts)
166
+ num_total_more_than_one = sum(total_num_more_than_one)
167
+ num_total_50 = sum(total_num_fail)
168
+ count_num_total_iterations = sum([(x[0]) for x in total_num_iterations])
169
+ num_total_iterations = sum([x[1] for x in total_num_iterations])
170
+ min_iterations = min([x[2] for x in total_num_iterations if x[2] > 0], default=0)
171
+ max_iterations = max([x[3] for x in total_num_iterations], default=0)
172
+
173
+ total_stats = format_stats(
174
+ total_input=sum(total_input_prompts),
175
+ chat_dir="Total stats",
176
+ error_count=sum(total_error_count),
177
+ total=num_total_prompts,
178
+ num_more_than_one=num_total_more_than_one,
179
+ num_iterations=num_total_iterations,
180
+ num_fail=num_total_50,
181
+ iterations_data=(count_num_total_iterations, num_total_iterations, min_iterations, max_iterations),
182
+ is_total=True
183
+ )
184
+ output.append(total_stats)
185
+
186
+ return "\n".join(output)
187
+
188
+ if __name__ == "__main__":
189
+ ## Extract paths from config files
190
+ parent_dirs = []
191
+ animation_prompts_files = []
192
+ for config_file in args.configs:
193
+ parent_dir, prompts_file = get_paths_from_config(config_file)
194
+ parent_dirs.append(parent_dir)
195
+ animation_prompts_files.append(prompts_file)
196
+
197
+ stats_output = get_stats(parent_dirs, animation_prompts_files)
198
+ print(stats_output)
@@ -0,0 +1,101 @@
1
+ Metadata-Version: 2.4
2
+ Name: mover
3
+ Version: 0.1.0
4
+ Summary: Official implementation of MoVer: Motion Verification for Motion Graphics Animations
5
+ Author-email: Jiaju Ma <jiajuma@stanford.edu>
6
+ License: Apache-2.0
7
+ Project-URL: Homepage, https://mover-dsl.github.io/
8
+ Project-URL: Repository, https://github.com/mover-dsl/MoVer
9
+ Project-URL: Bug Tracker, https://github.com/mover-dsl/MoVer/issues
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.10
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
16
+ Classifier: Topic :: Multimedia :: Graphics
17
+ Requires-Python: >=3.10
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE.txt
20
+ Requires-Dist: cairosvg
21
+ Requires-Dist: fastapi==0.115.14
22
+ Requires-Dist: groq
23
+ Requires-Dist: Jinja2
24
+ Requires-Dist: numpy
25
+ Requires-Dist: openai
26
+ Requires-Dist: opencv-contrib-python==4.11.0.86
27
+ Requires-Dist: Pillow
28
+ Requires-Dist: playwright
29
+ Requires-Dist: protobuf
30
+ Requires-Dist: PyYAML
31
+ Requires-Dist: treelib
32
+ Requires-Dist: uvicorn==0.35.0
33
+ Requires-Dist: torch>=2.7.1
34
+ Requires-Dist: torchvision>=0.22.1
35
+ Requires-Dist: jacinle
36
+ Requires-Dist: concepts
37
+ Requires-Dist: ipykernel>=6.29.5
38
+ Provides-Extra: local
39
+ Requires-Dist: ollama-python; extra == "local"
40
+ Requires-Dist: vllm; extra == "local"
41
+ Dynamic: license-file
42
+
43
+ # MoVer: Motion Verification for Motion Graphics Animations
44
+
45
+ [Jiaju Ma](https://majiaju.io) and
46
+ [Maneesh Agrawala](https://graphics.stanford.edu/~maneesh/)
47
+ <br />
48
+ In ACM Transactions on Graphics (SIGGRAPH), 44(4), August 2025. To Appear.
49
+ <br />
50
+
51
+ [[arXiv](https://arxiv.org/abs/2502.13372)] [[project page](https://mover-dsl.github.io/)]
52
+
53
+
54
+ ## Dataset
55
+ The test prompt dataset used in the paper can be found in `mover_dataset`
56
+
57
+
58
+ ## Setup
59
+
60
+ ### JavaScript animation to MoVer data format converter
61
+ 1. (Optional) We support rendering to video with OpenCV, but the video produced might have limited compatibility. If you optionally install `ffmpeg`, our converter will automatically use it to convert rendered videos.
62
+
63
+ ### MoVer
64
+ 1. Set up a virtual environment with your favorite tool. It is recommended to use `uv` because it is very fast.
65
+ 2. Make sure you have `pytorch` installed
66
+ 3. Install [Jacinle](https://github.com/vacancy/Jacinle).
67
+ ```bash
68
+ git clone https://github.com/vacancy/Jacinle --recursive
69
+ cd Jacinle
70
+ pip install -e . # or uv pip install -e . or follow the instructions on the Jacinle GitHub page
71
+ ```
72
+
73
+ 4. Install [Concepts](https://github.com/concepts-ai/concepts).
74
+ ```bash
75
+ git clone https://github.com/concepts-ai/Concepts.git
76
+ cd Concepts
77
+ pip install -e . # or uv pip install -e .
78
+ ```
79
+
80
+ 5. Run `pip install -r requirements.txt` or `uv pip install -r requirements.txt` to install the remaining dependencies
81
+ - This list includes APIs to interface with OpenAI, Gemini (via OpenAI), and Groq
82
+
83
+ 6. Store your API keys as environment variables (e.g., `OPENAI_API_KEY`, `GEMINI_API_KEY`, `GROQ_API_KEY`).
84
+
85
+ 7. If you plan to run locally-hosted models, install the following dependencies:
86
+ - Install `ollama` if you plan to use ollama with `ollama-python`
87
+ - Install `vLLM` if you plan to use vLLM
88
+
89
+
90
+ ## Usage
91
+ Check out the `tutorial.ipynb` for a tutorial of the motion graphics animation generation with MoVer verification pipeline.
92
+
93
+
94
+ ## Release Checklist
95
+ - [x] MoVer DSL and verifier
96
+ - [x] JavaScript animation to MoVer data format converter
97
+ - [x] LLM-based animation synthesizer
98
+ - [x] LLM-based MoVer synthesizer
99
+ - [x] Scripts to run the full pipeline
100
+ - [ ] Web app for creating animations with MoVer
101
+ - [ ] Scripts for generating animation prompts
@@ -0,0 +1,11 @@
1
+ LICENSE.txt
2
+ README.md
3
+ pyproject.toml
4
+ src/mover/__init__.py
5
+ src/mover/pipeline.py
6
+ src/mover/stats.py
7
+ src/mover.egg-info/PKG-INFO
8
+ src/mover.egg-info/SOURCES.txt
9
+ src/mover.egg-info/dependency_links.txt
10
+ src/mover.egg-info/requires.txt
11
+ src/mover.egg-info/top_level.txt
@@ -0,0 +1,22 @@
1
+ cairosvg
2
+ fastapi==0.115.14
3
+ groq
4
+ Jinja2
5
+ numpy
6
+ openai
7
+ opencv-contrib-python==4.11.0.86
8
+ Pillow
9
+ playwright
10
+ protobuf
11
+ PyYAML
12
+ treelib
13
+ uvicorn==0.35.0
14
+ torch>=2.7.1
15
+ torchvision>=0.22.1
16
+ jacinle
17
+ concepts
18
+ ipykernel>=6.29.5
19
+
20
+ [local]
21
+ ollama-python
22
+ vllm
@@ -0,0 +1 @@
1
+ mover