cozyclay 1.9.0 → 2.0.0

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.
Files changed (286) hide show
  1. package/CHANGELOG.md +171 -0
  2. package/bin/agent/agent-routes.mjs +74 -70
  3. package/bin/agent/agent-runner.mjs +10 -3
  4. package/bin/agent/motion-runtime.mjs +32 -260
  5. package/bin/agent/providers.mjs +46 -3
  6. package/bin/agent/session-store.mjs +41 -5
  7. package/bin/agent/studio-prompt.mjs +1 -1
  8. package/bin/agent/studio-tools.mjs +48 -11
  9. package/bin/cozyclay.mjs +26 -8
  10. package/bin/live/cli.mjs +22 -3
  11. package/bin/mcp-runtime.mjs +35 -20
  12. package/bin/telemetry-state.mjs +5 -2
  13. package/bin/update-check.mjs +15 -0
  14. package/dist/app/index.html +6 -6
  15. package/dist/assets/analytics-MVZOEW8O.js +1 -0
  16. package/dist/assets/app-C1sdVbg4.css +1 -0
  17. package/dist/assets/app-CA55tcI3.js +4876 -0
  18. package/dist/assets/{demo-B-eg1CT8.js → demo-ByeYp-dY.js} +1 -1
  19. package/dist/assets/{first-shot-handoff-CGgnvNu8.js → first-shot-handoff-DgT28ZiV.js} +1 -1
  20. package/dist/assets/{landing-IbRp3FnQ.js → landing-BaXkpFip.js} +1 -1
  21. package/dist/assets/shot-prompt-CbqWcWYi.css +1 -0
  22. package/dist/assets/shot-prompt-Yrt99wZx.js +17 -0
  23. package/dist/assets/{ticket-BgIzOBOf.js → ticket-BcmsnHn5.js} +1 -1
  24. package/dist/assets/workflow-DRdwoDBT.css +1 -0
  25. package/dist/assets/workflow-dNPGY9xz.js +179 -0
  26. package/dist/cozyclay-package.json +1 -1
  27. package/dist/fonts/IBM-Plex-Sans-OFL.txt +92 -0
  28. package/dist/fonts/JetBrains-Mono-OFL.txt +93 -0
  29. package/dist/fonts/README.md +13 -9
  30. package/dist/fonts/ibm-plex-sans-400-latin.woff2 +0 -0
  31. package/dist/fonts/ibm-plex-sans-500-latin.woff2 +0 -0
  32. package/dist/fonts/ibm-plex-sans-600-latin.woff2 +0 -0
  33. package/dist/fonts/jetbrains-mono-400-latin.woff2 +0 -0
  34. package/dist/fonts/jetbrains-mono-500-latin.woff2 +0 -0
  35. package/dist/index.html +7 -7
  36. package/dist/privacy/index.html +13 -8
  37. package/dist/sitemap.xml +6 -6
  38. package/dist/workflow/index.html +5 -5
  39. package/mcp/LIVE-PROTOCOL.md +1 -1
  40. package/mcp/live-hub.mjs +35 -93
  41. package/mcp/mesh-file.mjs +48 -0
  42. package/mcp/server.mjs +6 -77
  43. package/mcp/tool-handlers.mjs +224 -377
  44. package/package.json +2 -1
  45. package/src/App.jsx +1273 -9075
  46. package/src/analytics.js +393 -9
  47. package/src/app-context.js +211 -0
  48. package/src/app-stage.jsx +25 -24
  49. package/src/ardy/auto-fix-panel.css +108 -0
  50. package/src/ardy/collision-blockers.js +9 -3
  51. package/src/ardy/fix-collisions.js +10 -66
  52. package/src/ardy/ground.js +4 -4
  53. package/src/ardy/ik-drag.js +101 -0
  54. package/src/ardy/ik-key-json.js +43 -0
  55. package/src/ardy/ik.js +122 -76
  56. package/src/ardy/physics-panel.css +2 -0
  57. package/src/ardy/physics-panel.jsx +17 -5
  58. package/src/ardy/platform-fit-panel.css +64 -0
  59. package/src/ardy/platform-fit-panel.jsx +40 -0
  60. package/src/ardy/platform-fit.js +326 -0
  61. package/src/ardy/playback.js +166 -20
  62. package/src/ardy/range-pin.js +299 -0
  63. package/src/ardy/timeline-coordinates.js +26 -0
  64. package/src/ardy/timeline.css +1199 -0
  65. package/src/ardy/timeline.jsx +149 -41
  66. package/src/ardy/waypoints.js +2 -2
  67. package/src/asset-pane.css +462 -0
  68. package/src/asset-pane.jsx +461 -232
  69. package/src/command-bus.js +349 -0
  70. package/src/commands/ai.js +31 -0
  71. package/src/commands/cast.js +140 -0
  72. package/src/commands/elements/character.js +13 -0
  73. package/src/commands/elements/motion.js +14 -0
  74. package/src/commands/elements/object.js +22 -0
  75. package/src/commands/elements/scene.js +16 -0
  76. package/src/commands/elements/shot.js +9 -0
  77. package/src/commands/elements/stage.js +11 -0
  78. package/src/commands/elements.js +155 -0
  79. package/src/commands/export.js +20 -0
  80. package/src/commands/index.js +40 -0
  81. package/src/commands/motion.js +231 -0
  82. package/src/commands/objects.js +174 -0
  83. package/src/commands/project.js +53 -0
  84. package/src/commands/scene.js +81 -0
  85. package/src/commands/shared.js +19 -0
  86. package/src/commands/shot.js +103 -0
  87. package/src/commands/stage.js +17 -0
  88. package/src/commands/view.js +42 -0
  89. package/src/document-store.js +144 -0
  90. package/src/domains/cast.js +1007 -0
  91. package/src/domains/motion.js +3219 -0
  92. package/src/domains/objects.js +932 -0
  93. package/src/domains/scenes.js +817 -0
  94. package/src/domains/shots.js +404 -0
  95. package/src/domains/stage.js +93 -0
  96. package/src/dualview.jsx +113 -57
  97. package/src/facing-marks.js +3 -0
  98. package/src/first-success-guide.jsx +14 -14
  99. package/src/grid-view.js +18 -5
  100. package/src/hierarchy-model.js +24 -16
  101. package/src/hierarchy-panel.css +386 -0
  102. package/src/hierarchy-panel.jsx +150 -21
  103. package/src/{fal-motion-client.js → i2v-motion-client.js} +13 -13
  104. package/src/i2v-motion-studio.jsx +180 -0
  105. package/src/ik-camera.js +3 -0
  106. package/src/main.jsx +6 -0
  107. package/src/motion/generation.js +105 -0
  108. package/src/motion-readiness-ui.jsx +4 -4
  109. package/src/motion-readiness.js +11 -0
  110. package/src/motion-trail.js +366 -9
  111. package/src/object-gizmo.jsx +7 -1
  112. package/src/otio.js +2 -1
  113. package/src/panels/CameraPanel.jsx +60 -0
  114. package/src/panels/CharacterTransformPanel.jsx +48 -0
  115. package/src/panels/EnvironmentPanel.jsx +40 -0
  116. package/src/panels/Foldout.jsx +32 -0
  117. package/src/panels/LightPanel.jsx +24 -0
  118. package/src/panels/ObjectTransformPanel.jsx +554 -0
  119. package/src/panels/PosePanel.jsx +97 -0
  120. package/src/panels/ProjectPanel.jsx +33 -0
  121. package/src/panels/PromptBlocksPanel.jsx +442 -0
  122. package/src/panels/PropsPanel.jsx +70 -0
  123. package/src/panels/ReferenceImageField.jsx +91 -0
  124. package/src/panels/RigControlPanel.jsx +78 -0
  125. package/src/panels/RigPanel.jsx +37 -0
  126. package/src/panels/SubjectBox.jsx +47 -0
  127. package/src/panels/SubjectsPanel.jsx +39 -0
  128. package/src/panels/VideoCapturePanel.jsx +180 -0
  129. package/src/panels/details.css +1171 -0
  130. package/src/panels/motion.css +197 -0
  131. package/src/panels/pose.css +39 -0
  132. package/src/planview.jsx +60 -31
  133. package/src/posestudio.jsx +59 -4
  134. package/src/project-browser.css +1073 -0
  135. package/src/project-browser.jsx +284 -123
  136. package/src/range-pin-object-transform.js +19 -0
  137. package/src/range-pin-panel.css +518 -0
  138. package/src/range-pin-panel.jsx +344 -0
  139. package/src/result-modal.jsx +5 -5
  140. package/src/room.jsx +79 -51
  141. package/src/scene-objects.js +37 -1
  142. package/src/scenes.js +5 -0
  143. package/src/semantic-edit.js +2 -0
  144. package/src/settings-menu.jsx +39 -105
  145. package/src/shell/BottomDock.jsx +450 -0
  146. package/src/shell/DetailsSlot.jsx +513 -0
  147. package/src/shell/LibrarySlot.jsx +86 -0
  148. package/src/shell/MenuBar.jsx +601 -0
  149. package/src/shell/OutlinerSlot.jsx +50 -0
  150. package/src/shell/PreferencesDialog.jsx +538 -0
  151. package/src/shell/PreferencesSlot.jsx +40 -0
  152. package/src/shell/StatusBar.jsx +125 -0
  153. package/src/shell/StudioShell.jsx +92 -0
  154. package/src/shell/TopBar.jsx +129 -0
  155. package/src/shell/ViewportToolbar.jsx +656 -0
  156. package/src/shell/agent-glass.css +296 -0
  157. package/src/shell/dock.css +93 -0
  158. package/src/shell/glass-regions.css +985 -0
  159. package/src/shell/glass.css +687 -0
  160. package/src/shell/log-store.js +52 -0
  161. package/src/shell/mode.css +9 -0
  162. package/src/shell/preferences.css +651 -0
  163. package/src/shell/shell.css +282 -0
  164. package/src/shell/studio-shell-context.js +19 -0
  165. package/src/shell/topbar.css +435 -0
  166. package/src/shell/viewport.css +451 -0
  167. package/src/store/authored-intent.js +22 -0
  168. package/src/store/runtime-adapters.js +92 -0
  169. package/src/store/scene-stage.js +21 -0
  170. package/src/store/use-document-store.js +14 -0
  171. package/src/studio-actions.js +210 -0
  172. package/src/studio-agent-commands.js +41 -271
  173. package/src/studio-agent-context.js +39 -10
  174. package/src/studio-agent-motion.js +122 -373
  175. package/src/studio-agent-protocol.js +67 -31
  176. package/src/studio-app-binding.js +379 -0
  177. package/src/studio-contact-sheet.js +73 -0
  178. package/src/studio-elements.js +58 -51
  179. package/src/styles/themes.css +200 -0
  180. package/src/styles/tokens.css +69 -0
  181. package/src/styles.css +460 -1742
  182. package/src/theme.js +44 -0
  183. package/src/timeline-extent.js +16 -0
  184. package/src/trail-key-conflicts.js +39 -0
  185. package/src/trail-pick.js +59 -0
  186. package/src/ui.jsx +8 -8
  187. package/src/use-case-question.jsx +66 -0
  188. package/src/workflow/AgentPanel.jsx +82 -69
  189. package/src/workflow/agent-client.js +12 -2
  190. package/src/workflow/agent-panel.css +34 -32
  191. package/src/workflow/cozy-scene-node.css +2 -0
  192. package/src/workflow/workflow.css +2 -0
  193. package/tools/ardy/__pycache__/cclay_gvhmr_worker.cpython-313.pyc +0 -0
  194. package/tools/ardy/bridge.mjs +164 -146
  195. package/tools/ardy/visual-qa.mjs +5 -5
  196. package/tools/bench/EXP3.md +61 -0
  197. package/tools/bench/cclay_bench_extract_incam.py +125 -0
  198. package/tools/bench/cclay_bench_extract_obs.py +204 -0
  199. package/tools/bench/cclay_bench_runner.py +42 -0
  200. package/tools/bench/cube-contact.mjs +162 -0
  201. package/tools/bench/exp3.mjs +152 -0
  202. package/tools/bench/extract-bench-lib.mjs +216 -0
  203. package/tools/bench/extract-bench.mjs +302 -0
  204. package/tools/bench/fal-generate.mjs +88 -0
  205. package/tools/bench/fit/README.md +189 -0
  206. package/tools/bench/fit/camera.mjs +59 -0
  207. package/tools/bench/fit/contact.mjs +419 -0
  208. package/tools/bench/fit/footlock.mjs +234 -0
  209. package/tools/bench/fit/motion.mjs +85 -0
  210. package/tools/bench/fit/pin.mjs +27 -0
  211. package/tools/bench/fit/remote.mjs +105 -0
  212. package/tools/bench/fit-bench.mjs +126 -0
  213. package/tools/bench/fit-sanity.mjs +45 -0
  214. package/tools/bench/metrics.mjs +313 -0
  215. package/tools/bench/obs/depth.mjs +258 -0
  216. package/tools/bench/obs/extrinsics.mjs +175 -0
  217. package/tools/bench/obs/fit_mannequin_betas.py +340 -0
  218. package/tools/bench/obs/ground.mjs +294 -0
  219. package/tools/bench/obs/heading.mjs +151 -0
  220. package/tools/bench/obs/ladder.mjs +555 -0
  221. package/tools/bench/obs/mannequin-betas.json +124 -0
  222. package/tools/bench/obs/remote.mjs +83 -0
  223. package/tools/bench/obs/rest_joints.py +52 -0
  224. package/tools/bench/obs/ybot-targets.mjs +49 -0
  225. package/tools/bench/obs-bench.mjs +520 -0
  226. package/tools/bench/score.mjs +343 -0
  227. package/tools/bench/summarize.mjs +86 -0
  228. package/tools/dev/pages/privacy.html +13 -8
  229. package/tools/gt-render/browser.mjs +159 -0
  230. package/tools/gt-render/camera-math.mjs +276 -0
  231. package/tools/gt-render/page.mjs +267 -0
  232. package/tools/gt-render/render.mjs +514 -0
  233. package/tools/gt-render/scene-box.mjs +31 -0
  234. package/tools/gt-render/take-transform.mjs +87 -0
  235. package/tools/morphgs/assets/gen_truth.py +39 -0
  236. package/tools/morphgs/assets/mesh_ori_rig.txt +27 -0
  237. package/tools/morphgs/assets/playback-check.mjs +30 -0
  238. package/tools/morphgs/demo-gate.sh +26 -0
  239. package/tools/morphgs/fbx2morphgs.mjs +68 -0
  240. package/tools/morphgs/morphgs-to-cskel27.mjs +105 -0
  241. package/tools/morphgs/patches/preprocess_src-none-mode.patch +76 -0
  242. package/tools/morphgs/setup-on-cluster.sh +126 -0
  243. package/tools/qa/css-rule-usage.mjs +283 -0
  244. package/tools/qa/studio-control-count.mjs +70 -32
  245. package/tools/run-tests.mjs +134 -12
  246. package/tools/track/DESIGN.md +513 -0
  247. package/tools/track/backfill-provenance.mjs +116 -0
  248. package/tools/track/budget.mjs +8 -0
  249. package/tools/track/check-rig.mjs +209 -0
  250. package/tools/track/diagnostics.schema.json +60 -0
  251. package/tools/track/export-rig.mjs +256 -0
  252. package/tools/track/fallback.mjs +7 -0
  253. package/tools/track/fk-parity-fixture.mjs +161 -0
  254. package/tools/track/gate.mjs +349 -0
  255. package/tools/track/masks.mjs +318 -0
  256. package/tools/track/metrics.mjs +201 -0
  257. package/tools/track/publish-obs.mjs +108 -0
  258. package/tools/track/py/check_env.py +61 -0
  259. package/tools/track/py/eval_lr.py +229 -0
  260. package/tools/track/py/lr_viterbi.py +294 -0
  261. package/tools/track/py/masks.py +405 -0
  262. package/tools/track/py/objective.py +382 -0
  263. package/tools/track/py/rig.py +508 -0
  264. package/tools/track/py/scene.py +326 -0
  265. package/tools/track/py/test_joint_indices.py +123 -0
  266. package/tools/track/py/test_lr_viterbi.py +195 -0
  267. package/tools/track/py/test_masks.py +229 -0
  268. package/tools/track/py/test_rig.py +288 -0
  269. package/tools/track/py/test_scene.py +354 -0
  270. package/tools/track/py/test_track.py +328 -0
  271. package/tools/track/py/track.py +411 -0
  272. package/tools/track/remote.mjs +140 -0
  273. package/tools/track/rig-dump.mjs +227 -0
  274. package/tools/track/run-box-tests.mjs +14 -0
  275. package/tools/track/run-box.mjs +168 -0
  276. package/tools/track/setup-box.sh +59 -0
  277. package/tools/track/study-2d.mjs +728 -0
  278. package/dist/assets/analytics-B1hnH66c.js +0 -1
  279. package/dist/assets/app-BWusbqgO.js +0 -4861
  280. package/dist/assets/app-qKDo4PBX.css +0 -1
  281. package/dist/assets/shot-prompt-CHUtw6af.js +0 -17
  282. package/dist/assets/shot-prompt-C_g2BHVc.css +0 -1
  283. package/dist/assets/workflow-CVwzMhz2.js +0 -179
  284. package/dist/assets/workflow-DsudxKHF.css +0 -1
  285. package/src/fal-motion-studio.jsx +0 -180
  286. package/src/scene-history.js +0 -129
@@ -0,0 +1,39 @@
1
+ # Ground truth from MorphGS's own Animation.step: writes rot_params.npy + pred_joints.npy exactly like src/render.py:606-618.
2
+ # usage: python gen_truth.py <MorphGS-root> <mesh.obj> <rig.txt> <outdir>
3
+ import sys, os
4
+ morphgs_root, mesh_path, rig_path, out = sys.argv[1:5]
5
+ sys.path.insert(0, os.path.join(morphgs_root, "src"))
6
+ import numpy as np, torch, trimesh
7
+ from model.RigModel import Rig
8
+ from model.AnimationField import Animation, get_embedder
9
+
10
+ os.makedirs(out, exist_ok=True)
11
+ mesh = trimesh.load_mesh(mesh_path, process=False, maintain_order=True)
12
+ rig = Rig(mesh, rig_path, smooth_w=0, device="cpu", skinning_method="lbs")
13
+ N = rig.joints_name; J = len(N); ix = N.index
14
+ # Emulate MorphGS morphology (ParametricModel.get_joints_pos): legs +8%, arms -5%, same bone directions.
15
+ scale = {n: 1.08 for n in N if "Leg" in n or "Foot" in n or "Toe" in n}
16
+ scale.update({n: 0.95 for n in N if "Arm" in n or "Hand" in n})
17
+ joints = rig.joints_pos.clone()
18
+ for p, c in rig.bones: # bones are BFS-ordered from the root, parents first
19
+ joints[c] = joints[p] + (rig.joints_pos[c] - rig.joints_pos[p]) * scale.get(N[c], 1.0)
20
+ # Animation.__init__ hard-codes a CUDA deform net (AnimationField.py:83); step() with explicit rot_params never uses it.
21
+ anim = Animation.__new__(Animation)
22
+ anim.skinning_method, anim.embed_time_fn, anim.joint_num = "lbs", get_embedder(6, 1)[0], J
23
+ fixed = rig.fixed_joint_indices
24
+ torch.manual_seed(0)
25
+ frames = []
26
+ f1 = torch.zeros(J, 3) # the lead's spec
27
+ f1[ix("LeftForeArm")] = torch.tensor([0, 0, np.pi / 2]); f1[ix("RightLeg")] = torch.tensor([np.pi / 3, 0, 0])
28
+ f1[ix("Hips")] = torch.tensor([0, np.pi / 6, 0])
29
+ frames += [(torch.zeros(J, 3), torch.zeros(3)), (f1, torch.tensor([0.3, 0.0, 0.2]))]
30
+ for _ in range(4): # random full-body poses, every joint (fixed ones included -- step() must zero them)
31
+ frames.append((torch.randn(J, 3) * 0.5, torch.randn(3) * 0.3))
32
+ rps, pj = [], []
33
+ for i, (rp, gt) in enumerate(frames):
34
+ d = anim.step(rig.vertices, joints, rig.skinning_weights, rig, torch.tensor([i / len(frames)]),
35
+ rot_params=rp.clone(), global_translation=gt, fixed_joints=fixed)
36
+ rps.append(d["rot_params"].numpy()); pj.append(d["joints_warped"].numpy())
37
+ np.save(f"{out}/rot_params.npy", np.stack(rps).astype(np.float32))
38
+ np.save(f"{out}/pred_joints.npy", np.stack(pj).astype(np.float32))
39
+ print(f"frames={len(frames)} J={J} fixed={[N[i] for i in fixed]} -> {out}")
@@ -0,0 +1,27 @@
1
+ Hips -0.000000 1.042749 0.015543 -1
2
+ Spine -0.000000 1.144565 0.016858 Hips
3
+ Spine1 -0.000000 1.243504 0.002151 Spine
4
+ Spine2 0.000000 1.335712 -0.011555 Spine1
5
+ Neck 0.000000 1.503116 -0.032045 Spine2
6
+ Head 0.000000 1.599295 -0.015195 Neck
7
+ HeadTop_End 0.000000 1.819668 0.059816 Head
8
+ RightShoulder -0.045700 1.445861 -0.033164 Spine2
9
+ RightArm -0.151628 1.440613 -0.055485 RightShoulder
10
+ RightForeArm -0.430043 1.440613 -0.055485 RightArm
11
+ RightHand -0.713332 1.440613 -0.055485 RightForeArm
12
+ RightHandEnd -0.808657 1.440613 -0.055485 RightHand
13
+ LeftShoulder 0.045705 1.445859 -0.033164 Spine2
14
+ LeftArm 0.151628 1.440613 -0.055485 LeftShoulder
15
+ LeftForeArm 0.430043 1.440613 -0.055485 LeftArm
16
+ LeftHand 0.713332 1.440612 -0.055484 LeftForeArm
17
+ LeftHandEnd 0.808666 1.440612 -0.055484 LeftHand
18
+ RightUpLeg -0.082078 0.975232 -0.000452 Hips
19
+ RightLeg -0.082078 0.531531 0.003007 RightUpLeg
20
+ RightFoot -0.082078 0.087294 -0.027429 RightLeg
21
+ RightToeBase -0.082078 0.000007 0.079677 RightFoot
22
+ RightToe_End -0.082079 0.000001 0.172458 RightToeBase
23
+ LeftUpLeg 0.082078 0.975232 -0.000452 Hips
24
+ LeftLeg 0.082078 0.531531 0.003017 LeftUpLeg
25
+ LeftFoot 0.082077 0.087295 -0.027427 LeftLeg
26
+ LeftToeBase 0.082077 0.000008 0.079678 LeftFoot
27
+ LeftToe_End 0.082077 0.000001 0.172460 LeftToeBase
@@ -0,0 +1,30 @@
1
+ // Real-surface check: CozyClay's own decodeMotionNpz + applyMotionFrame (src/ardy/playback.js) drive the x-bot FBX loaded with
2
+ // three FBXLoader; compare each driven bone's world position with MorphGS joints_warped. usage: node playback-check.mjs <take.npz> <pred_joints.npy> <rig.txt>
3
+ import { readFileSync } from "node:fs";
4
+ import * as THREE from "three";
5
+ import { FBXLoader } from "three/examples/jsm/loaders/FBXLoader.js";
6
+ globalThis.window ??= { innerWidth: 1920, innerHeight: 1080, URL };
7
+ const COZY = process.env.COZYCLAY ?? `${process.env.HOME}/CozyClay`;
8
+ const { decodeMotionNpz } = await import(`${COZY}/src/ardy/npz.js`);
9
+ const { applyMotionFrame } = await import(`${COZY}/src/ardy/playback.js`);
10
+ const [npzPath, pjPath, rigPath] = process.argv.slice(2);
11
+ const motion = await decodeMotionNpz(new Uint8Array(readFileSync(npzPath)));
12
+ const b = readFileSync(pjPath), hl = b.readUInt16LE(8), pj = new Float32Array(b.buffer.slice(b.byteOffset + 10 + hl, b.byteOffset + b.length));
13
+ const names = readFileSync(rigPath, "utf8").split("\n").map((l) => l.trim().split(/\s+/)).filter((t) => t.length === 5 && t[0] !== "fixed_joint").map((t) => t[0]);
14
+ const J = names.length, X = (f, n) => [0, 1, 2].map((a) => pj[(f * J + names.indexOf(n)) * 3 + a] * 100); // cm, x-bot frame
15
+ const fbx = readFileSync(`${COZY}/public/models/x-bot-tpose.fbx`);
16
+ const rig = new FBXLoader().parse(fbx.buffer.slice(fbx.byteOffset, fbx.byteOffset + fbx.byteLength), "");
17
+ rig.updateMatrixWorld(true);
18
+ const bone = (n) => { let hit = null; rig.traverse((o) => { if (!hit && o.isBone && o.name === `mixamorig${n}`) hit = o; }); return hit; };
19
+ const CHECK = ["Hips", "Spine", "Spine1", "Spine2", "Neck", "Head", "HeadTop_End", ...["Left", "Right"].flatMap((s) =>
20
+ ["Shoulder", "Arm", "ForeArm", "Hand", "HandMiddle1", "UpLeg", "Leg", "Foot", "ToeBase", "Toe_End"].map((b) => s + b))];
21
+ const err = Object.fromEntries(CHECK.map((n) => [n, 0])); let off = null;
22
+ for (let f = 0; f < motion.frames; f++) {
23
+ applyMotionFrame(rig, motion, f);
24
+ const W = (n) => new THREE.Vector3().setFromMatrixPosition(bone(n).matrixWorld).toArray();
25
+ if (f === 0) off = W("Hips").map((v, a) => (a === 1 ? 0 : v - X(0, "Hips")[a])); // playback anchors frame-0 root XZ at the origin
26
+ for (const n of CHECK) { const x = X(f, n.replace("HandMiddle1", "HandEnd")), w = W(n);
27
+ err[n] = Math.max(err[n], Math.hypot(...w.map((v, a) => v - off[a] - x[a]))); }
28
+ }
29
+ for (const n of CHECK) console.log(`${n.padEnd(18)} ${err[n].toFixed(3).padStart(8)} cm`);
30
+ console.log(`frames=${motion.frames} boneScale=${motion.boneScale ? "yes" : "no"} MAX=${Math.max(...Object.values(err)).toFixed(3)} cm`);
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env bash
2
+ # Run the cached MorphGS tennis→Ninja demo and require motion render outputs.
3
+ set -euo pipefail
4
+ MORPHGS_ROOT="${MORPHGS_ROOT:-/data2/${USER:?USER must be set}/MorphGS}"
5
+ DEMO_ID="${MORPHGS_DEMO_ID:-1oMkA02aJYhoBSNPZX9tMPknvVvX50i-z}"
6
+ LOG_DIR="${MORPHGS_LOG_DIR:-$MORPHGS_ROOT/logs}"
7
+ mkdir -p "$LOG_DIR"
8
+ cd "$MORPHGS_ROOT"
9
+
10
+ if [[ "${MORPHGS_SKIP_DOWNLOAD:-0}" != 1 ]]; then
11
+ uv run --with gdown python -m gdown "$DEMO_ID" 2>&1 | tee "$LOG_DIR/demo-download.log"
12
+ fi
13
+ # gdown leaves the archive intact; MorphGS expects demo/processed_videos and demo/characters.
14
+ [[ -d demo/processed_videos/tennis ]] || unzip -q -o demo.zip
15
+ VENV_DIR="${MORPHGS_VENV:-.venv}"
16
+ [[ -x "$VENV_DIR/bin/python" ]] || VENV_DIR="venv"
17
+ source "$VENV_DIR/bin/activate"
18
+ export TORCH_FORCE_NO_WEIGHTS_ONLY_LOAD="${TORCH_FORCE_NO_WEIGHTS_ONLY_LOAD:-1}"
19
+ python src/main.py --config demo/tennis_to_Ninja.yaml 2>&1 | tee "$LOG_DIR/demo-main.log"
20
+ python src/render.py --config demo/tennis_to_Ninja.yaml 2>&1 | tee "$LOG_DIR/demo-render.log"
21
+
22
+ OUTPUT_ROOT="${MORPHGS_OUTPUT_ROOT:-$MORPHGS_ROOT/output}"
23
+ for artifact in "$OUTPUT_ROOT/rot_params.npy" "$OUTPUT_ROOT/pred_joints.npy"; do
24
+ [[ -s "$artifact" ]] || { echo "missing demo artifact: $artifact" >&2; exit 1; }
25
+ done
26
+ printf 'PASS MorphGS demo gate: %s\n' "$OUTPUT_ROOT"
@@ -0,0 +1,68 @@
1
+ #!/usr/bin/env node
2
+ // x-bot FBX -> MorphGS target: <out>/mesh.obj + <out>/rigging/mesh_ori_rig.txt (compact format, no skin -> heat skinning)
3
+ // usage: node fbx2morphgs.mjs <in.fbx> <outDir> [--all-bones]
4
+ import * as THREE from "three";
5
+ import { FBXLoader } from "three/examples/jsm/loaders/FBXLoader.js";
6
+ import { mergeVertices } from "three/examples/jsm/utils/BufferGeometryUtils.js";
7
+ import { readFileSync, writeFileSync, mkdirSync } from "node:fs";
8
+ globalThis.window ??= { innerWidth: 1920, innerHeight: 1080, URL };
9
+
10
+ const [inPath, outDir] = process.argv.slice(2);
11
+ const allBones = process.argv.includes("--all-bones");
12
+ const FIXED_JOINTS = ["Spine", "LeftUpLeg", "RightUpLeg", "Neck", "LeftShoulder", "RightShoulder", "LeftHandEnd", "RightHandEnd"];
13
+ const SCALE = 0.01; // FBX is centimetres -> metres; Y-up, faces +Z already (pytorch3d look_at defaults)
14
+ const buf = readFileSync(inPath);
15
+ const root = new FBXLoader().parse(buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength), "");
16
+ root.updateMatrixWorld(true);
17
+
18
+ // Control skeleton = skinned skeleton whose root bone hangs off a non-bone (same rule as tools/ardy/extract-rest.mjs);
19
+ // FBXLoader also nests same-name zero-length copies of every bone, which must not reach the rig (zero-length bone -> NaN).
20
+ const meshes = [];
21
+ root.traverse((o) => o.isSkinnedMesh && meshes.push(o));
22
+ const skel = meshes.find((m) => m.skeleton.bones.some((b) => !b.parent?.isBone)).skeleton;
23
+ const bones = skel.bones.filter((b, i, a) => a.findIndex((c) => c.name === b.name) === i);
24
+ const strip = (n) => n.replace(/^mixamorig:?/, "");
25
+ const KEEP = new Set(["Hips", "Spine", "Spine1", "Spine2", "Neck", "Head", "HeadTop_End",
26
+ ...["Left", "Right"].flatMap((s) => [`${s}Shoulder`, `${s}Arm`, `${s}ForeArm`, `${s}Hand`, `${s}HandMiddle1`,
27
+ `${s}UpLeg`, `${s}Leg`, `${s}Foot`, `${s}ToeBase`, `${s}Toe_End`])]);
28
+ const kept = bones.filter((b) => allBones || KEEP.has(strip(b.name)));
29
+ const keptSet = new Set(kept);
30
+ const pos = (o) => new THREE.Vector3().setFromMatrixPosition(o.matrixWorld).multiplyScalar(SCALE);
31
+ const lines = kept.map((b) => {
32
+ let p = b.parent;
33
+ while (p?.isBone && !keptSet.has(p)) p = p.parent; // skip dropped joints (fingers) up to nearest kept ancestor
34
+ const name = allBones ? strip(b.name) : strip(b.name).replace(/HandMiddle1$/, "HandEnd");
35
+ const v = pos(b);
36
+ return { b, name, line: `${name} ${v.x.toFixed(6)} ${v.y.toFixed(6)} ${v.z.toFixed(6)} ` };
37
+ });
38
+ const nameOf = new Map(lines.map((l) => [l.b, l.name]));
39
+ const rig = lines.map(({ b, line }) => {
40
+ let p = b.parent;
41
+ while (p?.isBone && !keptSet.has(p)) p = p.parent;
42
+ return line + (p?.isBone ? nameOf.get(p) : "-1");
43
+ });
44
+
45
+ // Mesh: skin every vertex at the loaded (T-)pose into world space, weld the triangle soup FBXLoader emits.
46
+ const soup = [];
47
+ const v = new THREE.Vector3();
48
+ for (const m of meshes) {
49
+ const g = m.geometry;
50
+ const idx = g.index ? g.index.array : null;
51
+ const n = idx ? idx.length : g.attributes.position.count;
52
+ for (let k = 0; k < n; k++) {
53
+ m.getVertexPosition(idx ? idx[k] : k, v);
54
+ v.applyMatrix4(m.matrixWorld).multiplyScalar(SCALE);
55
+ soup.push(v.x, v.y, v.z);
56
+ }
57
+ }
58
+ const geo = new THREE.BufferGeometry();
59
+ geo.setAttribute("position", new THREE.Float32BufferAttribute(soup, 3));
60
+ const welded = mergeVertices(geo, 1e-5);
61
+ const P = welded.attributes.position.array, I = welded.index.array;
62
+ let obj = "";
63
+ for (let k = 0; k < P.length; k += 3) obj += `v ${P[k].toFixed(6)} ${P[k + 1].toFixed(6)} ${P[k + 2].toFixed(6)}\n`;
64
+ for (let k = 0; k < I.length; k += 3) obj += `f ${I[k] + 1} ${I[k + 1] + 1} ${I[k + 2] + 1}\n`;
65
+ mkdirSync(`${outDir}/rigging`, { recursive: true });
66
+ writeFileSync(`${outDir}/mesh.obj`, obj);
67
+ writeFileSync(`${outDir}/rigging/mesh_ori_rig.txt`, rig.join("\n") + `\nfixed_joint ${FIXED_JOINTS.join(" ")}\n`);
68
+ console.log(`meshes=${meshes.map((m) => m.name)} verts=${P.length / 3} faces=${I.length / 3} joints=${rig.length}`);
@@ -0,0 +1,105 @@
1
+ #!/usr/bin/env node
2
+ // MorphGS render outputs (rot_params.npy [T,J,3], pred_joints.npy [T,J,3]; src/render.py:606-618) + x-bot rig txt -> cskel27 take npz.
3
+ // usage: node morphgs-to-cskel27.mjs <mesh_ori_rig.txt> <rot_params.npy> <pred_joints.npy> <out.npz> [--fps 30] [--check]
4
+ import { readFileSync } from "node:fs";
5
+ const COZY = process.env.COZYCLAY ?? new URL("../..", import.meta.url).pathname;
6
+ const { CSKEL27_JOINTS: CJ, CSKEL27_PARENTS: CP } = await import(`${COZY}/src/ardy/cskel27.js`);
7
+ const { CSKEL27_NEUTRAL: NEU } = await import(`${COZY}/src/ardy/cskel27-neutral.js`);
8
+ const { deriveBoneOffsets, forwardKinematics, matMul, matTranspose } = await import(`${COZY}/src/ardy/convert.js`);
9
+ const { canonicalCskel27Reference } = await import(`${COZY}/src/ardy/to-cskel27.js`);
10
+ const { motionArraysToNpzMembers, writeNpz } = await import(`${COZY}/tools/ardy/npz.mjs`);
11
+
12
+ const [rigPath, rotPath, jointsPath, outPath] = process.argv.slice(2);
13
+ const fps = Number(process.argv[process.argv.indexOf("--fps") + 1]) || 30;
14
+ const npy = (p) => { // float32 little-endian C-order .npy
15
+ const b = readFileSync(p), hl = b.readUInt16LE(8), h = b.toString("latin1", 10, 10 + hl);
16
+ if (!h.includes("'<f4'") || h.includes("True")) throw new Error(`${p}: need <f4 C-order`);
17
+ return { shape: h.match(/\(([^)]*)\)/)[1].split(",").filter(Boolean).map(Number), d: new Float32Array(b.buffer.slice(b.byteOffset + 10 + hl, b.byteOffset + b.length)) };
18
+ };
19
+ // Rig: compact "<name> x y z <parent|-1>" (file order == MorphGS joint index, root first) + fixed_joint lines.
20
+ const names = [], parent = [], rest = [], fixed = new Set();
21
+ for (const t of readFileSync(rigPath, "utf8").split("\n").map((l) => l.trim().split(/\s+/))) {
22
+ if (t[0] === "fixed_joint") t.slice(1).forEach((n) => fixed.add(n));
23
+ else if (t.length === 5) { names.push(t[0]); rest.push(t.slice(1, 4).map(Number)); parent.push(t[4] === "-1" ? -1 : names.indexOf(t[4])); }
24
+ }
25
+ const J = names.length, ix = (n) => names.indexOf(n), kids = names.map((_, j) => parent.flatMap((p, k) => (p === j ? [k] : [])));
26
+ // cskel27 joint -> x-bot bone it drives: playback.js SKINNING_MAP / cskel27.js (Mixamo Spine,Spine1,Spine2 -> Spine1,Spine2,Spine3).
27
+ const SRC = { Hips: "Hips", Spine1: "Spine", Spine2: "Spine1", Spine3: "Spine2", Neck: "Neck", Head: "Head" };
28
+ for (const s of ["Left", "Right"]) for (const b of ["Shoulder", "Arm", "ForeArm", "Hand", "UpLeg", "Leg", "Foot", "ToeBase"]) SRC[s + b] = s + b;
29
+ const ARM = /Shoulder|Arm|Hand/; // playback: arm chain = bind translation + rotation; wrist undriven; rest positional
30
+ for (const x of Object.values(SRC)) {
31
+ const free = kids[ix(x)].filter((k) => !fixed.has(names[k]));
32
+ if (kids[ix(x)].length > 1 && free.length && !process.env.ALLOW_FREE) throw new Error(`${x} has ${kids[ix(x)].length} children; add fixed_joint ${free.map((k) => names[k]).join(" ")}`);
33
+ }
34
+ const I3 = [[1, 0, 0], [0, 1, 0], [0, 0, 1]], mv = (m, v) => m.map((r) => r[0] * v[0] + r[1] * v[1] + r[2] * v[2]);
35
+ const rod = (v) => {
36
+ const a = Math.hypot(...v); if (a < 1e-12) return I3;
37
+ const [x, y, z] = v.map((u) => u / a), s = Math.sin(a), c = Math.cos(a), t = 1 - c;
38
+ return [[t * x * x + c, t * x * y - s * z, t * x * z + s * y], [t * x * y + s * z, t * y * y + c, t * y * z - s * x], [t * x * z - s * y, t * y * z + s * x, t * z * z + c]];
39
+ };
40
+ const rot = npy(rotPath), pj = npy(jointsPath), T = rot.shape[0];
41
+ if (rot.shape[1] !== J || pj.shape[1] !== J) throw new Error(`rig has ${J} joints, npy has ${rot.shape[1]}/${pj.shape[1]}`);
42
+ const P = (f, j) => [0, 1, 2].map((a) => pj.d[(f * J + j) * 3 + a]);
43
+ const dist = (a, b) => Math.hypot(a[0] - b[0], a[1] - b[1], a[2] - b[2]);
44
+ const len = (a, b) => dist(P(0, ix(a)), P(0, ix(b))); // MorphGS (morphed) bone length; rigid motion keeps it
45
+ // Playback constants for the x-bot (playback.js prepOf): bind = FBX world cm; s = leg height / 0.9544128.
46
+ const bind = (x) => rest[ix(x)].map((v) => v * 100), MINY = -0.9544128;
47
+ const s = (bind("Hips")[1] - Math.min(...Object.values(SRC).filter((x) => !/Hand$/.test(x)).map((x) => bind(x)[1]))) / -MINY;
48
+ const nf = (c) => { const n = NEU[CJ.indexOf(c)]; return [n[0], n[1] - MINY, n[2]]; };
49
+ // bone_scale only on the arm chain (playback boneStretch): girdle joints take morphed/bind, ForeArm/Hand morphed/(s*canonical).
50
+ const boneScale = new Float32Array(27).fill(1);
51
+ for (const c of CJ) {
52
+ if (!ARM.test(c) || !SRC[c] || /Thumb|End/.test(c)) continue;
53
+ const x = SRC[c], px = names[parent[ix(x)]], i = CJ.indexOf(c), m = len(x, px) * 100;
54
+ boneScale[i] = /Shoulder|^(Left|Right)Arm$/.test(c) ? m / dist(bind(x), bind(px)) : m / (s * dist(NEU[i], NEU[CP[i]]));
55
+ }
56
+ const canon = deriveBoneOffsets(canonicalCskel27Reference().posed_joints, canonicalCskel27Reference().local_rot_mats);
57
+ const rotMats = new Float32Array(T * 243), rootPos = new Float32Array(T * 3), posed = new Float32Array(T * 81), frames = [];
58
+ for (let f = 0; f < T; f++) {
59
+ const Gm = []; // MorphGS parent-pivot: R_j swings segment parent(j)->j; its world rotation is the chain product
60
+ for (let j = 0; j < J; j++) {
61
+ const R = fixed.has(names[j]) ? I3 : rod([0, 1, 2].map((a) => rot.d[(f * J + j) * 3 + a]));
62
+ Gm[j] = parent[j] < 0 ? R : matMul(Gm[parent[j]], R);
63
+ }
64
+ const G = [], pos = [];
65
+ CJ.forEach((c, i) => { G[i] = SRC[c] ? Gm[kids[ix(SRC[c])][0]] : G[CP[i]]; }); // outgoing segment of the driven bone
66
+ const L = CJ.map((_, i) => (CP[i] === null ? G[i] : matMul(matTranspose(G[CP[i]]), G[i])));
67
+ CJ.forEach((c, i) => { // posed_joints = inverse of playback's positional skinning; unskinned joints hang off their parent
68
+ if (SRC[c] && !ARM.test(c)) { const b = bind(SRC[c]), g = mv(G[i], b.map((v, a) => v - s * nf(c)[a])); pos[i] = P(f, ix(SRC[c])).map((v, a) => (v * 100 - g[a]) / s); }
69
+ else { const o = mv(G[CP[i]], canon[i]); pos[i] = pos[CP[i]].map((v, a) => v + o[a]); }
70
+ });
71
+ L.forEach((m, i) => rotMats.set(m.flat(), (f * 27 + i) * 9));
72
+ pos.forEach((p, i) => posed.set(p, (f * 27 + i) * 3));
73
+ rootPos.set(pos[0], f * 3);
74
+ frames.push({ G, L, pos });
75
+ }
76
+ writeNpz(outPath, motionArraysToNpzMembers({ frames: T, fps, rotMats, rootPos, posedJoints: posed, boneScale }));
77
+ console.log(`wrote ${outPath}: ${T} frames, fixed=[${[...fixed]}], s=${s.toFixed(3)}`);
78
+
79
+ // ---- --check: compare against MorphGS joints_warped (truth), per mapped x-bot joint, max over frames, in cm ----
80
+ if (process.argv.includes("--check")) {
81
+ // (a) CozyClay convert.js forwardKinematics over the exported local_rot_mats with the x-bot's own morphed offsets
82
+ const xr = CJ.map((c) => (SRC[c] ? rest[ix(SRC[c])] : null));
83
+ xr[CJ.indexOf("Spine")] = rest[0].map((v, a) => (v + rest[ix("Spine")][a]) / 2);
84
+ CJ.forEach((c, i) => { if (!xr[i]) xr[i] = c.endsWith("HandEnd") ? rest[ix(c)] : xr[CP[i]]; });
85
+ const xOff = xr.map((p, i) => { if (CP[i] === null) return [0, 0, 0]; const d = p.map((v, a) => v - xr[CP[i]][a]), n = Math.hypot(...d);
86
+ const x = SRC[CJ[i]] ?? (CJ[i].endsWith("HandEnd") ? CJ[i] : null), px = SRC[CJ[CP[i]]];
87
+ const l = CJ[i] === "Spine" || CJ[i] === "Spine1" ? len("Spine", "Hips") / 2 : x && px ? len(x, px) : n; return n > 0 ? d.map((v) => (v / n) * l) : d; });
88
+ // (b) previous iteration: canonical cskel27 FK (what posed_joints would be if written as plain FK)
89
+ // (c) playback.js simulated on the x-bot with the written npz arrays (positional skinning + arm chain), /100 -> m
90
+ const stretch = (i) => /Shoulder|^(Left|Right)Arm$/.test(CJ[i]) ? boneScale[i] : boneScale[i] * s * dist(NEU[i], NEU[CP[i]]) / dist(bind(SRC[CJ[i]]), bind(names[parent[ix(SRC[CJ[i]])]]));
91
+ const rows = Object.entries(SRC).map(([c, x]) => ({ c, x, i: CJ.indexOf(c), a: 0, b: 0, cc: 0 }));
92
+ frames.forEach(({ G, L, pos }, f) => {
93
+ const fa = forwardKinematics(L, xOff, P(f, 0)), fb = forwardKinematics(L, canon, P(f, 0)), W = [];
94
+ CJ.forEach((c, i) => {
95
+ if (!SRC[c]) return;
96
+ if (!ARM.test(c)) { const g = mv(G[i], bind(SRC[c]).map((v, a) => v - s * nf(c)[a])); W[i] = pos[i].map((v, a) => (s * v + g[a]) / 100); return; }
97
+ const pi = /Shoulder/.test(c) ? CJ.indexOf("Spine3") : CP[i], o = mv(G[pi], bind(SRC[c]).map((v, a) => (v - bind(SRC[CJ[pi]])[a]) * stretch(i)));
98
+ W[i] = W[pi].map((v, a) => v + o[a] / 100);
99
+ });
100
+ for (const r of rows) { const t = P(f, ix(r.x)); r.a = Math.max(r.a, dist(fa[r.i], t) * 100); r.b = Math.max(r.b, dist(fb[r.i], t) * 100); r.cc = Math.max(r.cc, dist(W[r.i], t) * 100); }
101
+ });
102
+ console.log("cskel27 <- x-bot (a)FK x-bot offs (b)canonical FK (c)playback sim bone_scale");
103
+ for (const r of rows) console.log(`${r.c.padEnd(14)}<- ${r.x.padEnd(14)} ${r.a.toFixed(4).padStart(8)} ${r.b.toFixed(3).padStart(15)} ${r.cc.toFixed(4).padStart(15)} ${boneScale[r.i].toFixed(3).padStart(10)}`);
104
+ for (const k of ["a", "b", "cc"]) console.log(`MAX ${k} = ${Math.max(...rows.map((r) => r[k])).toFixed(4)} cm`);
105
+ }
@@ -0,0 +1,76 @@
1
+ --- a/src/preprocess/preprocess_src.py 2026-09-23 18:54:26
2
+ +++ b/src/preprocess/preprocess_src.py 2026-09-23 22:00:59
3
+ @@ -18,14 +18,6 @@
4
+
5
+ # Add generative-models to path
6
+ sys.path.append(os.path.join(os.path.dirname(__file__), "../extlibs/generative-models"))
7
+ -
8
+ -from scripts.demo.sv4d_helpers import (
9
+ - load_model,
10
+ - preprocess_video,
11
+ - read_video,
12
+ - run_img2vid,
13
+ -)
14
+ -from sgm.modules.encoders.modules import VideoPredictionEmbedderWithEncoder
15
+
16
+ IMAGE_EXTS = {".png", ".jpg", ".jpeg", ".bmp", ".webp", ".PNG", ".JPG", ".JPEG", ".BMP", ".WEBP"}
17
+ VIDEO_EXTS = {".mp4", ".gif", ".mov", ".avi", ".mkv", ".webm", ".MP4", ".GIF", ".MOV", ".AVI", ".MKV", ".WEBM"}
18
+ @@ -137,6 +129,8 @@
19
+ verbose=False,
20
+ remove_bg=False,
21
+ ):
22
+ + from scripts.demo.sv4d_helpers import load_model, preprocess_video, read_video, run_img2vid
23
+ + from sgm.modules.encoders.modules import VideoPredictionEmbedderWithEncoder
24
+ sp4d_model = "sp4d"
25
+ config = sp4d_configs[sp4d_model]
26
+ T = config["T"]
27
+ @@ -319,6 +313,8 @@
28
+ Simple script to generate multiple novel-view videos conditioned on a video `input_path` or multiple frames, one for each
29
+ image file in folder `input_path`. If you run out of VRAM, try decreasing `decoding_t` and `encoding_t`.
30
+ """
31
+ + from scripts.demo.sv4d_helpers import load_model, preprocess_video, read_video, run_img2vid
32
+ + from sgm.modules.encoders.modules import VideoPredictionEmbedderWithEncoder
33
+ # Set model config
34
+ assert os.path.basename(model_path) in [
35
+ "sv4d2.safetensors",
36
+ @@ -582,6 +578,7 @@
37
+ "sv4d": [0, 60, 120, 180, 240],
38
+ "sp4d": [0, 60, 120, 180, 240],
39
+ "sv4d2_8views": [0, 30, 75, 120, 165, 210, 255, 300, 330],
40
+ + "none": [0],
41
+ }
42
+
43
+
44
+ @@ -630,6 +627,23 @@
45
+ yield
46
+ finally:
47
+ os.chdir(prev_cwd)
48
+ + if mode == "none":
49
+ + # MorphGS can train from the source view alone. Keep the same square,
50
+ + # white-background contract as generated views and avoid importing or
51
+ + # loading the SV4D checkpoints on CPU-only preprocessing nodes.
52
+ + color_dir = os.path.join(out_dir, "view_0", "color")
53
+ + os.makedirs(color_dir, exist_ok=True)
54
+ + frames = _list_image_frames(src_video_path)
55
+ + if not frames:
56
+ + raise RuntimeError(f"no image frames found under {src_video_path}")
57
+ + for index, name in enumerate(frames):
58
+ + image = Image.open(os.path.join(src_video_path, name)).convert("RGB")
59
+ + side = max(image.size)
60
+ + canvas = Image.new("RGB", (side, side), (255, 255, 255))
61
+ + canvas.paste(image, ((side - image.width) // 2, (side - image.height) // 2))
62
+ + canvas.save(os.path.join(color_dir, f"{index:03d}.png"))
63
+ + return out_dir
64
+ +
65
+ model_root = "src/extlibs/generative-models"
66
+ sparse_input_path, sparse_cleanup_dir, sparse_nf = _build_sparse_input_dir(
67
+ src_video_path,
68
+ @@ -766,7 +780,7 @@
69
+
70
+ parser = argparse.ArgumentParser(description="Preprocess source data for MorphGS.")
71
+ parser.add_argument("src_video_path", help="Path to source frames folder / mp4 / gif.")
72
+ - parser.add_argument("--mode", default="sv4d", choices=["sv4d", "sp4d", "sv4d2_8views"])
73
+ + parser.add_argument("--mode", default="sv4d", choices=["sv4d", "sp4d", "sv4d2_8views", "none"])
74
+ parser.add_argument("--sv4d_num_steps", type=int, default=50)
75
+ parser.add_argument("--sv4d_img_size", type=int, default=512)
76
+ parser.add_argument("--sv4d_max_frames", type=int, default=None)
@@ -0,0 +1,126 @@
1
+ #!/usr/bin/env bash
2
+ # Reproduce the verified MorphGS Blackwell environment on the shared cluster.
3
+ # Allocate first (sbatch is unavailable on the full login filesystem):
4
+ # srun --gres=gpu:1 --cpus-per-task=8 --mem=40G --time=02:00:00 --pty bash
5
+ set -euo pipefail
6
+
7
+ usage() {
8
+ cat <<'USAGE'
9
+ Usage: setup-on-cluster.sh [--dry-run]
10
+
11
+ Run inside an srun allocation on mkseoul2. The default root is
12
+ /data2/$USER/MorphGS; override MORPHGS_ROOT, DATA_ROOT, or CUDA_HOME when needed.
13
+ Set CUDA_RUNFILE to an existing CUDA 12.8.1 runfile (or CUDA_RUNFILE_URL to
14
+ fetch it). --dry-run prints every command without changing the cluster.
15
+ USAGE
16
+ }
17
+
18
+ DRY_RUN=0
19
+ for arg in "$@"; do
20
+ case "$arg" in
21
+ --dry-run) DRY_RUN=1 ;;
22
+ -h|--help) usage; exit 0 ;;
23
+ *) echo "unknown argument: $arg" >&2; usage >&2; exit 2 ;;
24
+ esac
25
+ done
26
+
27
+ DATA_ROOT="${DATA_ROOT:-/data2/${USER:?USER must be set}}"
28
+ MORPHGS_ROOT="${MORPHGS_ROOT:-$DATA_ROOT/MorphGS}"
29
+ CUDA_HOME="${CUDA_HOME:-$DATA_ROOT/cuda-12.8}"
30
+ CUDA_RUNFILE="${CUDA_RUNFILE:-$DATA_ROOT/cuda_12.8.1_*.run}"
31
+ CUDA_RUNFILE_URL="${CUDA_RUNFILE_URL:-https://developer.download.nvidia.com/compute/cuda/12.8.1/local_installers/cuda_12.8.1_570.124.06_linux.run}"
32
+ GEO_ROOT="${GEO_ROOT:-$DATA_ROOT/GeoAware-SC}"
33
+ GEO_VENV="${GEO_VENV:-$DATA_ROOT/venv-geo}"
34
+
35
+ run() {
36
+ if (( DRY_RUN )); then
37
+ printf '+ '
38
+ printf '%q ' "$@"
39
+ printf '\n'
40
+ else
41
+ "$@"
42
+ fi
43
+ }
44
+
45
+ mkdir_p() { run mkdir -p "$1"; }
46
+ mkdir_p "$DATA_ROOT"
47
+
48
+ if [[ ! -d "$MORPHGS_ROOT/.git" ]]; then
49
+ run git clone https://github.com/xodus777/MorphGS "$MORPHGS_ROOT"
50
+ fi
51
+ run git -C "$MORPHGS_ROOT" submodule update --init
52
+
53
+ # GCC 13 needs these standard headers in the two CUDA extensions. Keep the
54
+ # edits idempotent so rerunning setup never adds duplicate includes.
55
+ if (( DRY_RUN )); then
56
+ echo '+ add #include <cstdint> to src/extlibs/latent-gaussian-rasterization/cuda_rasterizer/rasterizer_impl.h'
57
+ echo '+ add #include <cfloat> to src/extlibs/simple-knn/simple_knn.cu'
58
+ else
59
+ grep -q '^#include <cstdint>$' "$MORPHGS_ROOT/src/extlibs/latent-gaussian-rasterization/cuda_rasterizer/rasterizer_impl.h" || \
60
+ sed -i '1i #include <cstdint>' "$MORPHGS_ROOT/src/extlibs/latent-gaussian-rasterization/cuda_rasterizer/rasterizer_impl.h"
61
+ grep -q '^#include <cfloat>$' "$MORPHGS_ROOT/src/extlibs/simple-knn/simple_knn.cu" || \
62
+ sed -i '1i #include <cfloat>' "$MORPHGS_ROOT/src/extlibs/simple-knn/simple_knn.cu"
63
+ fi
64
+
65
+ # CUDA 12.8 is required for sm_120. The pip nvcc package only supplies ptxas.
66
+ if (( DRY_RUN )); then
67
+ echo "+ install CUDA runfile at $CUDA_HOME (CUDA_RUNFILE or CUDA_RUNFILE_URL)"
68
+ else
69
+ shopt -s nullglob
70
+ runfiles=( $CUDA_RUNFILE )
71
+ shopt -u nullglob
72
+ if (( ${#runfiles[@]} == 0 )); then
73
+ CUDA_RUNFILE="$DATA_ROOT/cuda_12.8.1_linux.run"
74
+ run curl -L --fail --retry 3 -o "$CUDA_RUNFILE" "$CUDA_RUNFILE_URL"
75
+ else
76
+ CUDA_RUNFILE="${runfiles[0]}"
77
+ fi
78
+ if [[ ! -x "$CUDA_HOME/bin/nvcc" ]]; then
79
+ run sh "$CUDA_RUNFILE" --silent --toolkit --installpath="$CUDA_HOME"
80
+ fi
81
+ fi
82
+ export CUDA_HOME
83
+ export PATH="$CUDA_HOME/bin:$PATH"
84
+ # MorphGS demo caches contain trusted PyTorch3D camera pickles; PyTorch 2.11
85
+ # otherwise defaults torch.load to weights_only=True and rejects them.
86
+ export TORCH_FORCE_NO_WEIGHTS_ONLY_LOAD=1
87
+
88
+ run uv venv "$MORPHGS_ROOT/.venv" --python 3.10
89
+ run uv pip install --python "$MORPHGS_ROOT/.venv/bin/python" torch==2.11.0 --index-url https://download.pytorch.org/whl/cu128
90
+ run uv pip install --python "$MORPHGS_ROOT/.venv/bin/python" 'pytorch3d==0.7.9+pt2110cu128' --extra-index-url https://ImageMindAnalytics.github.io/pytorch3d-wheels/simple/
91
+
92
+ REQ_TMP="${TMPDIR:-/tmp}/morphgs-requirements-${USER}.txt"
93
+ if (( DRY_RUN )); then
94
+ echo "+ grep -v scikit-sparse $MORPHGS_ROOT/requirements.txt > $REQ_TMP"
95
+ else
96
+ grep -v '^scikit-sparse' "$MORPHGS_ROOT/requirements.txt" > "$REQ_TMP"
97
+ fi
98
+ run uv pip install --python "$MORPHGS_ROOT/.venv/bin/python" -r "$REQ_TMP"
99
+
100
+ export TORCH_CUDA_ARCH_LIST=12.0
101
+ run uv pip install --python "$MORPHGS_ROOT/.venv/bin/python" --no-build-isolation -e "$MORPHGS_ROOT/src/extlibs/latent-gaussian-rasterization"
102
+ run uv pip install --python "$MORPHGS_ROOT/.venv/bin/python" --no-build-isolation "$MORPHGS_ROOT/src/extlibs/simple-knn"
103
+
104
+ # GeoAware's numpy 1.23 / Pillow 9.5 stack is intentionally isolated from the
105
+ # training venv (numpy 2.2). Its MSDeformAttn patch targets torch 2.11 APIs.
106
+ run uv venv "$GEO_VENV" --python 3.10
107
+ run uv pip install --python "$GEO_VENV/bin/python" torch==2.11.0 --index-url https://download.pytorch.org/whl/cu128
108
+ if [[ ! -d "$GEO_ROOT/.git" ]]; then run git clone https://github.com/Junyi42/GeoAware-SC "$GEO_ROOT"; fi
109
+ run git -C "$GEO_ROOT" checkout b20fab9
110
+ if (( DRY_RUN )); then
111
+ echo '+ patch GeoAware MSDeformAttn value.type() and .type().is_cuda()'
112
+ else
113
+ grep -rl 'value.type()' --include='ms_deform_attn*' "$GEO_ROOT/third_party" | xargs -r sed -i \
114
+ -e 's/\.type()\.is_cuda()/\.is_cuda()/g' -e 's/value\.type()/value.scalar_type()/g'
115
+ fi
116
+ OVERRIDE="${TMPDIR:-/tmp}/geo-override-${USER}.txt"
117
+ if (( DRY_RUN )); then echo "+ printf 'faiss-cpu>=1.7.1\\n' > $OVERRIDE"; else printf 'faiss-cpu>=1.7.1\n' > "$OVERRIDE"; fi
118
+ run uv pip install --python "$GEO_VENV/bin/python" 'numpy==1.23.5' 'pillow==9.5.0'
119
+ run uv pip install --python "$GEO_VENV/bin/python" --override "$OVERRIDE" --no-build-isolation -e "$GEO_ROOT"
120
+ if (( DRY_RUN )); then
121
+ echo "+ ln -s $GEO_ROOT $MORPHGS_ROOT/src/extlibs/GeoAware"
122
+ else
123
+ ln -sfn "$GEO_ROOT" "$MORPHGS_ROOT/src/extlibs/GeoAware"
124
+ fi
125
+
126
+ echo "MorphGS cluster setup complete: $MORPHGS_ROOT"