Xiangyue-Zhang commited on
Commit
9860236
·
1 Parent(s): dac1a9a

Release retrained GlobalDiff generators and WAV inference bundles

Browse files
Files changed (43) hide show
  1. README.md +103 -3
  2. SHA256SUMS +41 -0
  3. retrained_20261113/RELEASE.json +124 -0
  4. retrained_20261113/globaldiff_e630_all_cfg1p25.zip +3 -0
  5. retrained_20261113/globaldiff_e630_all_cfg1p25/CONFIG.json +108 -0
  6. retrained_20261113/globaldiff_e630_all_cfg1p25/METRICS.json +49 -0
  7. retrained_20261113/globaldiff_e630_all_cfg1p25/README.txt +49 -0
  8. retrained_20261113/globaldiff_e630_all_cfg1p25/SEED_PROVENANCE.json +12 -0
  9. retrained_20261113/globaldiff_e630_all_cfg1p25/SHA256SUMS.json +74 -0
  10. retrained_20261113/globaldiff_e630_all_cfg1p25/VALIDATION.json +12 -0
  11. retrained_20261113/globaldiff_e630_all_cfg1p25/WAVLM_DOWNLOAD_COMPLETE.json +50 -0
  12. retrained_20261113/globaldiff_e630_all_cfg1p25/generator.pt +3 -0
  13. retrained_20261113/globaldiff_e630_all_cfg1p25/infer_wav.py +198 -0
  14. retrained_20261113/globaldiff_e630_all_cfg1p25/requirements-inference.txt +9 -0
  15. retrained_20261113/globaldiff_e630_all_cfg1p25/seed_pose_speaker2.npz +3 -0
  16. retrained_20261113/globaldiff_e630_all_cfg1p25/source/Scripts/FM/Filter.py +79 -0
  17. retrained_20261113/globaldiff_e630_all_cfg1p25/source/Scripts/FM/Net.py +0 -0
  18. retrained_20261113/globaldiff_e630_all_cfg1p25/source/Scripts/FM/ckpt/split/SimpleSpeechModel/best.pt +3 -0
  19. retrained_20261113/globaldiff_e630_all_cfg1p25/source/Scripts/PositionalEncoding.py +89 -0
  20. retrained_20261113/globaldiff_e630_all_cfg1p25/source/Scripts/SMPLXConfig.py +1679 -0
  21. retrained_20261113/globaldiff_e630_all_cfg1p25/source/Scripts/SMPLX_Util.py +278 -0
  22. retrained_20261113/globaldiff_e630_all_cfg1p25/source/Scripts/Util.py +569 -0
  23. retrained_20261113/globaldiff_e630_all_cfg1p25/verify_sha256.py +12 -0
  24. retrained_20261113/globaldiff_e880_all_cfg1p25.zip +3 -0
  25. retrained_20261113/globaldiff_e880_all_cfg1p25/CONFIG.json +108 -0
  26. retrained_20261113/globaldiff_e880_all_cfg1p25/METRICS.json +49 -0
  27. retrained_20261113/globaldiff_e880_all_cfg1p25/README.txt +49 -0
  28. retrained_20261113/globaldiff_e880_all_cfg1p25/SEED_PROVENANCE.json +12 -0
  29. retrained_20261113/globaldiff_e880_all_cfg1p25/SHA256SUMS.json +74 -0
  30. retrained_20261113/globaldiff_e880_all_cfg1p25/VALIDATION.json +12 -0
  31. retrained_20261113/globaldiff_e880_all_cfg1p25/WAVLM_DOWNLOAD_COMPLETE.json +50 -0
  32. retrained_20261113/globaldiff_e880_all_cfg1p25/generator.pt +3 -0
  33. retrained_20261113/globaldiff_e880_all_cfg1p25/infer_wav.py +198 -0
  34. retrained_20261113/globaldiff_e880_all_cfg1p25/requirements-inference.txt +9 -0
  35. retrained_20261113/globaldiff_e880_all_cfg1p25/seed_pose_speaker2.npz +3 -0
  36. retrained_20261113/globaldiff_e880_all_cfg1p25/source/Scripts/FM/Filter.py +79 -0
  37. retrained_20261113/globaldiff_e880_all_cfg1p25/source/Scripts/FM/Net.py +0 -0
  38. retrained_20261113/globaldiff_e880_all_cfg1p25/source/Scripts/FM/ckpt/split/SimpleSpeechModel/best.pt +3 -0
  39. retrained_20261113/globaldiff_e880_all_cfg1p25/source/Scripts/PositionalEncoding.py +89 -0
  40. retrained_20261113/globaldiff_e880_all_cfg1p25/source/Scripts/SMPLXConfig.py +1679 -0
  41. retrained_20261113/globaldiff_e880_all_cfg1p25/source/Scripts/SMPLX_Util.py +278 -0
  42. retrained_20261113/globaldiff_e880_all_cfg1p25/source/Scripts/Util.py +569 -0
  43. retrained_20261113/globaldiff_e880_all_cfg1p25/verify_sha256.py +12 -0
README.md CHANGED
@@ -14,7 +14,7 @@ datasets:
14
  - H-Liu1997/BEAT2
15
  ---
16
 
17
- # GlobalDiff official checkpoints
18
 
19
  Official checkpoints for **Mitigating Error Accumulation in Co-Speech Motion Generation via Global Rotation Diffusion and Multi-Level Constraints** (AAAI 2026), a diffusion approach to long-horizon **co-speech gesture generation**.
20
 
@@ -23,7 +23,107 @@ Official checkpoints for **Mitigating Error Accumulation in Co-Speech Motion Gen
23
  - [Published version](https://doi.org/10.1609/aaai.v40i15.38281)
24
  - [Generated inference data](https://huggingface.co/datasets/X-Zhang/GlobalDiff-Inference-Data)
25
 
26
- ## Files
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
 
28
  The checkpoint files mirror the official repository while preserving their repository-relative paths:
29
 
@@ -33,7 +133,7 @@ The checkpoint files mirror the official repository while preserving their repos
33
  | `Scripts/VAE/ckpt/split/global/MaskedVAE3-HorizonFlip/best.pt` | Global rotation VAE checkpoint |
34
  | `Scripts/FM/ckpt/split/SimpleSpeechModel/best.zip` | Speech model checkpoint archive |
35
  | `Scripts/FM/EMAGE_VAE/AESKConv_240_100.bin` | Evaluation/representation asset |
36
- See the code repository's environment checker and inference instructions for all runtime dependencies.
37
 
38
  Verify the files from the repository root with `sha256sum -c SHA256SUMS`.
39
 
 
14
  - H-Liu1997/BEAT2
15
  ---
16
 
17
+ # GlobalDiff checkpoints and retrained motion generators
18
 
19
  Official checkpoints for **Mitigating Error Accumulation in Co-Speech Motion Generation via Global Rotation Diffusion and Multi-Level Constraints** (AAAI 2026), a diffusion approach to long-horizon **co-speech gesture generation**.
20
 
 
23
  - [Published version](https://doi.org/10.1609/aaai.v40i15.38281)
24
  - [Generated inference data](https://huggingface.co/datasets/X-Zhang/GlobalDiff-Inference-Data)
25
 
26
+ ## Retrained motion generators (2026-11-13)
27
+
28
+ The motion-generator weights below are **newly retrained checkpoints**, not
29
+ the original checkpoints used to produce the paper's results. Both were
30
+ trained on the original **BEAT2 English training CSV, covering 25 speakers**.
31
+ They are not Speaker-2-only training checkpoints; selecting `--pid 2` at
32
+ inference does not change their training protocol.
33
+
34
+ Each complete bundle contains the generator, matching `CONFIG.json`, the
35
+ official frozen `SimpleSpeechModel`, required source files, an example
36
+ eight-frame training seed, `infer_wav.py`, and SHA-256 verification files.
37
+
38
+ | Checkpoint | Complete runnable bundle | Raw generator | Matching configuration | Intended choice |
39
+ | --- | --- | --- | --- | --- |
40
+ | Epoch 880, CFG=1.25 | [Download ZIP](https://huggingface.co/X-Zhang/GlobalDiff/resolve/main/retrained_20261113/globaldiff_e880_all_cfg1p25.zip) | [generator.pt](https://huggingface.co/X-Zhang/GlobalDiff/resolve/main/retrained_20261113/globaldiff_e880_all_cfg1p25/generator.pt) | [CONFIG.json](https://huggingface.co/X-Zhang/GlobalDiff/blob/main/retrained_20261113/globaldiff_e880_all_cfg1p25/CONFIG.json) | Lowest recorded all-speaker FGD |
41
+ | Epoch 630, CFG=1.25 | [Download ZIP](https://huggingface.co/X-Zhang/GlobalDiff/resolve/main/retrained_20261113/globaldiff_e630_all_cfg1p25.zip) | [generator.pt](https://huggingface.co/X-Zhang/GlobalDiff/resolve/main/retrained_20261113/globaldiff_e630_all_cfg1p25/generator.pt) | [CONFIG.json](https://huggingface.co/X-Zhang/GlobalDiff/blob/main/retrained_20261113/globaldiff_e630_all_cfg1p25/CONFIG.json) | Diversity closer to the paper reference |
42
+
43
+ The generator architecture is `DiffusionDITNetPartsFixedExpressions2PostNorm`
44
+ with 384 hidden channels, 6 layers, 8 seed frames, 333 motion channels and
45
+ 31 person embeddings. Each raw file is a native PyTorch state dictionary
46
+ with 249 tensors. In the legacy zero-based naming convention, epoch 880
47
+ corresponds to `epoch_879`, and epoch 630 to `epoch_629`.
48
+
49
+ On the 265-clip all-speaker test set, using full-clip official AESK FGD:
50
+
51
+ | Model | FGD ↓ | BA ↑ | DIV ↑ | Facial vertex MSE ×10⁻⁸ ↓ |
52
+ | --- | ---: | ---: | ---: | ---: |
53
+ | Paper reference | 0.263 | 0.404 | 8.240 | 4.144 |
54
+ | Retrained epoch 880 | 0.25584 | 0.40269 | 7.68382 | 4.03187 |
55
+ | Retrained epoch 630 | 0.26364 | 0.42779 | 8.15266 | 4.18662 |
56
+
57
+ The table uses sampling seed 0. For seeds 0/1/2, epoch 880 has FGD
58
+ 0.25584/0.26016/0.26717 (mean 0.26105); epoch 630 has
59
+ 0.26364/0.26672/0.26539 (mean 0.26525). These measure sampling variation
60
+ of a fixed checkpoint, not independent training runs. Checkpoint/CFG
61
+ selection used the public test benchmark. Exact equivalence to the
62
+ original private paper training protocol is unverified, and lower FGD
63
+ does not imply improvement in every metric. Full details are in each
64
+ bundle's `METRICS.json`.
65
+
66
+ The earlier `best_pid_2.zip` and all-speaker inference archives contain
67
+ **generated predictions**, not motion-generator weights. The existing
68
+ VAE, speech and AESK assets on Hugging Face are retained.
69
+
70
+ ## Custom WAV inference
71
+
72
+ Use the complete bundle for inference on new speech; BEAT2 test data is
73
+ not required. The bundle was tested with **Python 3.12 and PyTorch 2.10.0**
74
+ (CUDA 12.8 on Linux). Install the appropriate PyTorch build for your platform.
75
+ For the tested Linux CUDA environment:
76
+
77
+ ```shell
78
+ python3.12 -m venv globaldiff-infer-env
79
+ source globaldiff-infer-env/bin/activate
80
+ python -m pip install torch==2.10.0 --index-url https://download.pytorch.org/whl/cu128
81
+ curl -fL 'https://huggingface.co/X-Zhang/GlobalDiff/resolve/main/retrained_20261113/globaldiff_e880_all_cfg1p25.zip' -o globaldiff_e880_all_cfg1p25.zip
82
+ unzip globaldiff_e880_all_cfg1p25.zip
83
+ cd globaldiff_e880_all_cfg1p25
84
+ python -m pip install -r requirements-inference.txt
85
+ python verify_sha256.py
86
+ python infer_wav.py --checkpoint generator.pt \
87
+ --wav /path/to/input.wav \
88
+ --seed-pose seed_pose_speaker2.npz --pid 2 \
89
+ --out motion.npz --device cuda
90
+ ```
91
+
92
+ For epoch 630, download its ZIP and use the corresponding extracted
93
+ directory; the inference command is the same. `CONFIG.json` automatically
94
+ sets CFG=1.25. Use `--device cpu` with a CPU-compatible PyTorch installation
95
+ for CPU inference, and `--seed 1` to change sampling noise. Use a new output
96
+ filename for each invocation.
97
+
98
+ - **WavLM:** `patrickvonplaten/wavlm-libri-clean-100h-large`, pinned to
99
+ revision `e70e3a062ec399c46008ee55d1fb52c7ba338d5c`. It downloads on first
100
+ use. For offline inference, pass `--wavlm /path/to/that/local/snapshot`;
101
+ the bundle verifies its required files against the supplied manifest.
102
+ - **Seed pose:** eight SMPL-X frames at 30 FPS, in a NumPy `.npz` containing
103
+ local axis-angle `poses` of shape `[>=8, 165]` and `trans` of shape
104
+ `[>=8, 3]`; optional `betas` contains the 300-dimensional body shape.
105
+ The included example comes from a Speaker 2 **training** clip. For another
106
+ speaker/avatar, supply a matching seed and trained person ID.
107
+ - **Trained IDs:** `1,2,3,4,5,6,7,9,10,11,12,13,15,16,17,18,20,21,22,23,24,25,27,28,30`.
108
+ ID 0 is the unconditional identity; unsupported IDs are rejected.
109
+ - **Preprocessing and sampling:** the script mixes audio channels to mono,
110
+ resamples to 16 kHz, uses two-second/60-frame windows with eight seed
111
+ frames, and applies five midpoint steps. The audio hop is 27,734 samples.
112
+ It converts seed rotations to global 6D internally, pads the final partial
113
+ audio window, and trims output to the audio duration. No manual motion
114
+ normalization is required.
115
+ - **Output:** local SMPL-X axis-angle `poses [T,165]`, `trans [T,3]`,
116
+ `expressions [T,100]`, body shape and 30 FPS metadata. Parameter inference
117
+ does not require an SMPL-X mesh asset; rendering requires the separately
118
+ obtained SMPL-X model. CPU FP32 and CUDA FP16 sampling are not bitwise
119
+ identical.
120
+
121
+ The two frozen VAEs are used for training losses and are not required by
122
+ this custom-WAV entrypoint. Third-party datasets, pretrained encoders and
123
+ SMPL-X assets remain subject to their respective terms.
124
+
125
+
126
+ ## Original auxiliary files
127
 
128
  The checkpoint files mirror the official repository while preserving their repository-relative paths:
129
 
 
133
  | `Scripts/VAE/ckpt/split/global/MaskedVAE3-HorizonFlip/best.pt` | Global rotation VAE checkpoint |
134
  | `Scripts/FM/ckpt/split/SimpleSpeechModel/best.zip` | Speech model checkpoint archive |
135
  | `Scripts/FM/EMAGE_VAE/AESKConv_240_100.bin` | Evaluation/representation asset |
136
+ These original auxiliary assets are preserved. See the custom-WAV instructions above for the new runnable bundles.
137
 
138
  Verify the files from the repository root with `sha256sum -c SHA256SUMS`.
139
 
SHA256SUMS CHANGED
@@ -2,3 +2,44 @@
2
  984686c7670aee3798b63aea51bfd2bf0e5edcc8662e4451c722b3415b777f73 Scripts/FM/ckpt/split/SimpleSpeechModel/best.zip
3
  1d25a0ba9823776e0af97b644b931ea088816bec22587409ecd63e3ff9e01553 Scripts/VAE/ckpt/split/global/MaskedVAE2-HorizonFlip/best.pt
4
  921e4a8c47e44cf05622dda4aacdfb59a00a752ed04a7525e4f1f104d1d8a931 Scripts/VAE/ckpt/split/global/MaskedVAE3-HorizonFlip/best.pt
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  984686c7670aee3798b63aea51bfd2bf0e5edcc8662e4451c722b3415b777f73 Scripts/FM/ckpt/split/SimpleSpeechModel/best.zip
3
  1d25a0ba9823776e0af97b644b931ea088816bec22587409ecd63e3ff9e01553 Scripts/VAE/ckpt/split/global/MaskedVAE2-HorizonFlip/best.pt
4
  921e4a8c47e44cf05622dda4aacdfb59a00a752ed04a7525e4f1f104d1d8a931 Scripts/VAE/ckpt/split/global/MaskedVAE3-HorizonFlip/best.pt
5
+ ca85420d3e102b0dcd86ef9709aea310873f9899ad60f0cd677925c05a2aaa3e retrained_20261113/RELEASE.json
6
+ d2e109673d009ec03e195c747d077955205bbaa2e830202021f7b587fcf25537 retrained_20261113/globaldiff_e630_all_cfg1p25/CONFIG.json
7
+ f6eb8349c47e6c0b0e0808d46f5ac5a26c9255bd8a7dd681f3559356823cf036 retrained_20261113/globaldiff_e630_all_cfg1p25/METRICS.json
8
+ 3bf3bd2f38fd60b85b42d8a3468fb910dc2d3e7560457e02c01c9624217d13a1 retrained_20261113/globaldiff_e630_all_cfg1p25/README.txt
9
+ 297b826cefa1ac2db02f23cd12b447e9028eb673859a38d235a0de0ae5f986a0 retrained_20261113/globaldiff_e630_all_cfg1p25/SEED_PROVENANCE.json
10
+ 437b8db4dfd1e9a44b20e23d2d7e70445d3736166a7776ad0bab3f1180460048 retrained_20261113/globaldiff_e630_all_cfg1p25/SHA256SUMS.json
11
+ ddbd90fe89176d03c19ebf2a5836ded9f3b9c0b09c859cd0cb195d62d0a0462d retrained_20261113/globaldiff_e630_all_cfg1p25/VALIDATION.json
12
+ 69ba38b21d7ebef08cbae69b7a6cd0c9afc9ccd5cbbb2fb8a7b35780076ef13f retrained_20261113/globaldiff_e630_all_cfg1p25/WAVLM_DOWNLOAD_COMPLETE.json
13
+ d8988ea41542afb5a7c10632a0056f6c143f075101044e7ce2c0a9d8c938eea1 retrained_20261113/globaldiff_e630_all_cfg1p25/generator.pt
14
+ 9ca0469945c4f0cfe19f3cf17e91cd68e253ac17fa4d3aaa2e9742997390b18a retrained_20261113/globaldiff_e630_all_cfg1p25/infer_wav.py
15
+ 839228c977ace2994e269c5086b5e7f4520193bc7deeb535fe53db7de6ec0a3b retrained_20261113/globaldiff_e630_all_cfg1p25/requirements-inference.txt
16
+ a0f8a79e60996a366a9659359ac91144bcbf5abf37d29782452c33bd5a65046c retrained_20261113/globaldiff_e630_all_cfg1p25/seed_pose_speaker2.npz
17
+ bb524fd1fccbf45b45c5a9f42d31c6255175786e17f5e20c86a62065cc4c3d47 retrained_20261113/globaldiff_e630_all_cfg1p25/source/Scripts/FM/Filter.py
18
+ ddf305fe001fa03b912361afe4bc7f92e67c71641fd9a2b1c794199e10b2ea6e retrained_20261113/globaldiff_e630_all_cfg1p25/source/Scripts/FM/Net.py
19
+ 187df39de64c7a20983904cfca3145e44bee1630fdbad6da018d23b1e0fedaf9 retrained_20261113/globaldiff_e630_all_cfg1p25/source/Scripts/FM/ckpt/split/SimpleSpeechModel/best.pt
20
+ f10b8c1aeb6068f1ee025811886535191a26a84dde4d4c9185fbcb5302059f4c retrained_20261113/globaldiff_e630_all_cfg1p25/source/Scripts/PositionalEncoding.py
21
+ 13999c52b99056ad7895eda955e78b3a156bc02266213e400cd90b3e532002e6 retrained_20261113/globaldiff_e630_all_cfg1p25/source/Scripts/SMPLXConfig.py
22
+ b604fe04f657b9a29586c5da3eaafeafc4919aaae84668c62e79c4e19eb95837 retrained_20261113/globaldiff_e630_all_cfg1p25/source/Scripts/SMPLX_Util.py
23
+ 8e0fa2e1b149c66c7238b78ba28ef8593ad4e99f9fcb64220c5738d2dd98f773 retrained_20261113/globaldiff_e630_all_cfg1p25/source/Scripts/Util.py
24
+ 8ac7f85467754a66a9f6a48b914b104bced75e86322de539c3e16b1c164e9ffd retrained_20261113/globaldiff_e630_all_cfg1p25/verify_sha256.py
25
+ e5089f4233b60328bdbcaade83747e2ee23eb8c5d0108f4f5de6885ff1913c83 retrained_20261113/globaldiff_e630_all_cfg1p25.zip
26
+ 13df420179d062db0ed655f31c6741d674e46334ec60d040eafae37be9f7b527 retrained_20261113/globaldiff_e880_all_cfg1p25/CONFIG.json
27
+ da53223c1c1b26399e4153341b3d6b813eb7b5e8271d17568f5211022ae1bfe0 retrained_20261113/globaldiff_e880_all_cfg1p25/METRICS.json
28
+ 12c243e23c13f17ed0132337bdef37ccec2ce60f9571187aa6d73a3778ba59e2 retrained_20261113/globaldiff_e880_all_cfg1p25/README.txt
29
+ 297b826cefa1ac2db02f23cd12b447e9028eb673859a38d235a0de0ae5f986a0 retrained_20261113/globaldiff_e880_all_cfg1p25/SEED_PROVENANCE.json
30
+ fd7e8d7b38f61dd989ff908976747d28a4e98179b8f9a26eebb20878fc11ffbe retrained_20261113/globaldiff_e880_all_cfg1p25/SHA256SUMS.json
31
+ 61bd7c47ed481e6f7d399989dd7e51b1323cd1dc24f54088dde59567eef957cf retrained_20261113/globaldiff_e880_all_cfg1p25/VALIDATION.json
32
+ 69ba38b21d7ebef08cbae69b7a6cd0c9afc9ccd5cbbb2fb8a7b35780076ef13f retrained_20261113/globaldiff_e880_all_cfg1p25/WAVLM_DOWNLOAD_COMPLETE.json
33
+ 120bcedcffef8a268bb2bba92a8b70b21e174cedf4578778449cade638a89488 retrained_20261113/globaldiff_e880_all_cfg1p25/generator.pt
34
+ 9ca0469945c4f0cfe19f3cf17e91cd68e253ac17fa4d3aaa2e9742997390b18a retrained_20261113/globaldiff_e880_all_cfg1p25/infer_wav.py
35
+ 839228c977ace2994e269c5086b5e7f4520193bc7deeb535fe53db7de6ec0a3b retrained_20261113/globaldiff_e880_all_cfg1p25/requirements-inference.txt
36
+ a0f8a79e60996a366a9659359ac91144bcbf5abf37d29782452c33bd5a65046c retrained_20261113/globaldiff_e880_all_cfg1p25/seed_pose_speaker2.npz
37
+ bb524fd1fccbf45b45c5a9f42d31c6255175786e17f5e20c86a62065cc4c3d47 retrained_20261113/globaldiff_e880_all_cfg1p25/source/Scripts/FM/Filter.py
38
+ ddf305fe001fa03b912361afe4bc7f92e67c71641fd9a2b1c794199e10b2ea6e retrained_20261113/globaldiff_e880_all_cfg1p25/source/Scripts/FM/Net.py
39
+ 187df39de64c7a20983904cfca3145e44bee1630fdbad6da018d23b1e0fedaf9 retrained_20261113/globaldiff_e880_all_cfg1p25/source/Scripts/FM/ckpt/split/SimpleSpeechModel/best.pt
40
+ f10b8c1aeb6068f1ee025811886535191a26a84dde4d4c9185fbcb5302059f4c retrained_20261113/globaldiff_e880_all_cfg1p25/source/Scripts/PositionalEncoding.py
41
+ 13999c52b99056ad7895eda955e78b3a156bc02266213e400cd90b3e532002e6 retrained_20261113/globaldiff_e880_all_cfg1p25/source/Scripts/SMPLXConfig.py
42
+ b604fe04f657b9a29586c5da3eaafeafc4919aaae84668c62e79c4e19eb95837 retrained_20261113/globaldiff_e880_all_cfg1p25/source/Scripts/SMPLX_Util.py
43
+ 8e0fa2e1b149c66c7238b78ba28ef8593ad4e99f9fcb64220c5738d2dd98f773 retrained_20261113/globaldiff_e880_all_cfg1p25/source/Scripts/Util.py
44
+ 8ac7f85467754a66a9f6a48b914b104bced75e86322de539c3e16b1c164e9ffd retrained_20261113/globaldiff_e880_all_cfg1p25/verify_sha256.py
45
+ 7966dd5f356f535f940d1497c9736083ef71db332e55ad315172bf1225dbbc1e retrained_20261113/globaldiff_e880_all_cfg1p25.zip
retrained_20261113/RELEASE.json ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "release_date": "2026-11-13",
3
+ "weight_origin": "Newly retrained generators",
4
+ "checkpoints": [
5
+ {
6
+ "epoch": 880,
7
+ "label": "globaldiff_e880_all_cfg1p25",
8
+ "zip_path": "retrained_20261113/globaldiff_e880_all_cfg1p25.zip",
9
+ "zip_sha256": "7966dd5f356f535f940d1497c9736083ef71db332e55ad315172bf1225dbbc1e",
10
+ "zip_size": 225631513,
11
+ "generator_path": "retrained_20261113/globaldiff_e880_all_cfg1p25/generator.pt",
12
+ "generator_sha256": "120bcedcffef8a268bb2bba92a8b70b21e174cedf4578778449cade638a89488",
13
+ "config_path": "retrained_20261113/globaldiff_e880_all_cfg1p25/CONFIG.json",
14
+ "metrics": {
15
+ "evaluation_scope": "265 original English BEAT2 test clips",
16
+ "protocol": "official full-clip AESK, clipwise min length then multiple 32, CPU FP32 batch1, epsilon1e-6",
17
+ "seed0": {
18
+ "FGD": 0.25583519134479715,
19
+ "clips": 265,
20
+ "frames": 554936,
21
+ "BA": 0.40268533924495015,
22
+ "BA_before_L1div_mutation": 0.4042058941014386,
23
+ "DIV": 7.683824100588148,
24
+ "facial_vertex_MSE": 4.0318737077334556e-08
25
+ },
26
+ "sampling_seeds": [
27
+ 0,
28
+ 1,
29
+ 2
30
+ ],
31
+ "sampling_FGD": {
32
+ "values": [
33
+ 0.25583519134479715,
34
+ 0.2601576319326693,
35
+ 0.2671707086430146
36
+ ],
37
+ "mean": 0.26105451064016033,
38
+ "population_std": 0.004670958621561532,
39
+ "min": 0.25583519134479715,
40
+ "max": 0.2671707086430146
41
+ },
42
+ "sampling_note": "Sampling variation of a single fixed checkpoint, not independent training runs.",
43
+ "paper_all_speakers": {
44
+ "FGD": 0.263,
45
+ "BA": 0.404,
46
+ "DIV": 8.24,
47
+ "facial_vertex_MSE": 4.144e-08
48
+ },
49
+ "public_prediction_calibration": {
50
+ "FGD": 0.2624656903227027,
51
+ "BA": 0.40586601635105224,
52
+ "DIV": 8.240758192266485,
53
+ "facial_vertex_MSE": 4.149304934655536e-08
54
+ },
55
+ "paper_url": "https://arxiv.org/abs/2511.10076",
56
+ "selection_caveats": [
57
+ "Selected using the public test benchmark; not an untouched-test generalization estimate.",
58
+ "Both released checkpoints were trained on all training CSV speakers, not Speaker2-only training.",
59
+ "Exact equivalence to the original private paper training protocol is unverified.",
60
+ "Lower FGD does not imply improvement in every metric."
61
+ ]
62
+ }
63
+ },
64
+ {
65
+ "epoch": 630,
66
+ "label": "globaldiff_e630_all_cfg1p25",
67
+ "zip_path": "retrained_20261113/globaldiff_e630_all_cfg1p25.zip",
68
+ "zip_sha256": "e5089f4233b60328bdbcaade83747e2ee23eb8c5d0108f4f5de6885ff1913c83",
69
+ "zip_size": 225631530,
70
+ "generator_path": "retrained_20261113/globaldiff_e630_all_cfg1p25/generator.pt",
71
+ "generator_sha256": "d8988ea41542afb5a7c10632a0056f6c143f075101044e7ce2c0a9d8c938eea1",
72
+ "config_path": "retrained_20261113/globaldiff_e630_all_cfg1p25/CONFIG.json",
73
+ "metrics": {
74
+ "evaluation_scope": "265 original English BEAT2 test clips",
75
+ "protocol": "official full-clip AESK, clipwise min length then multiple 32, CPU FP32 batch1, epsilon1e-6",
76
+ "seed0": {
77
+ "FGD": 0.2636432704627847,
78
+ "clips": 265,
79
+ "frames": 554936,
80
+ "BA": 0.4277922631425832,
81
+ "BA_before_L1div_mutation": 0.4283574183909472,
82
+ "DIV": 8.152655286487992,
83
+ "facial_vertex_MSE": 4.186624735091204e-08
84
+ },
85
+ "sampling_seeds": [
86
+ 0,
87
+ 1,
88
+ 2
89
+ ],
90
+ "sampling_FGD": {
91
+ "values": [
92
+ 0.2636432704627847,
93
+ 0.26671848472740756,
94
+ 0.2653850988202606
95
+ ],
96
+ "mean": 0.26524895133681764,
97
+ "population_std": 0.0012591366873830378,
98
+ "min": 0.2636432704627847,
99
+ "max": 0.26671848472740756
100
+ },
101
+ "sampling_note": "Sampling variation of a single fixed checkpoint, not independent training runs.",
102
+ "paper_all_speakers": {
103
+ "FGD": 0.263,
104
+ "BA": 0.404,
105
+ "DIV": 8.24,
106
+ "facial_vertex_MSE": 4.144e-08
107
+ },
108
+ "public_prediction_calibration": {
109
+ "FGD": 0.2624656903227027,
110
+ "BA": 0.40586601635105224,
111
+ "DIV": 8.240758192266485,
112
+ "facial_vertex_MSE": 4.149304934655536e-08
113
+ },
114
+ "paper_url": "https://arxiv.org/abs/2511.10076",
115
+ "selection_caveats": [
116
+ "Selected using the public test benchmark; not an untouched-test generalization estimate.",
117
+ "Both released checkpoints were trained on all training CSV speakers, not Speaker2-only training.",
118
+ "Exact equivalence to the original private paper training protocol is unverified.",
119
+ "Lower FGD does not imply improvement in every metric."
120
+ ]
121
+ }
122
+ }
123
+ ]
124
+ }
retrained_20261113/globaldiff_e630_all_cfg1p25.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e5089f4233b60328bdbcaade83747e2ee23eb8c5d0108f4f5de6885ff1913c83
3
+ size 225631530
retrained_20261113/globaldiff_e630_all_cfg1p25/CONFIG.json ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "trained_person_ids": [
3
+ 1,
4
+ 2,
5
+ 3,
6
+ 4,
7
+ 5,
8
+ 6,
9
+ 7,
10
+ 9,
11
+ 10,
12
+ 11,
13
+ 12,
14
+ 13,
15
+ 15,
16
+ 16,
17
+ 17,
18
+ 18,
19
+ 20,
20
+ 21,
21
+ 22,
22
+ 23,
23
+ 24,
24
+ 25,
25
+ 27,
26
+ 28,
27
+ 30
28
+ ],
29
+ "source_commit": "0fece4fbf884198285769d12a9cc4bdb67185181",
30
+ "architecture": "DiffusionDITNetPartsFixedExpressions2PostNorm",
31
+ "hidden_size": 384,
32
+ "num_layers": 6,
33
+ "motion_channels": 333,
34
+ "expression_channels": 100,
35
+ "rotation_representation": "global row-6D rotations; native BEAT2 translations without normalization",
36
+ "parameters": 43081293,
37
+ "state_elements": 43081485,
38
+ "state_tensors": 249,
39
+ "generator_filename": "generator.pt",
40
+ "generator_sha256": "d8988ea41542afb5a7c10632a0056f6c143f075101044e7ce2c0a9d8c938eea1",
41
+ "completed_epoch": 630,
42
+ "optimizer_step": 125370,
43
+ "training_scope": "All original BEAT2 English train CSV speakers",
44
+ "training_optimizer": {
45
+ "type": "Adam",
46
+ "parameter_groups": [
47
+ {
48
+ "lr": 0.0001,
49
+ "betas": [
50
+ 0.9,
51
+ 0.999
52
+ ],
53
+ "eps": 1e-08,
54
+ "weight_decay": 0,
55
+ "amsgrad": false,
56
+ "maximize": false,
57
+ "foreach": null,
58
+ "capturable": true,
59
+ "differentiable": false,
60
+ "fused": null,
61
+ "decoupled_weight_decay": false
62
+ }
63
+ ]
64
+ },
65
+ "precision_lineage": "Fresh own generator: epochs1-10 BF16 pilot, then own full-state continuation in FP32/TF32",
66
+ "initialization": "Random generator seed0; official frozen speech and VAE auxiliaries; no StreamTalk generator weights",
67
+ "inference": {
68
+ "wavlm_id": "patrickvonplaten/wavlm-libri-clean-100h-large",
69
+ "wavlm_revision": "e70e3a062ec399c46008ee55d1fb52c7ba338d5c",
70
+ "speech_checkpoint_sha256": "187df39de64c7a20983904cfca3145e44bee1630fdbad6da018d23b1e0fedaf9",
71
+ "n_seed": 8,
72
+ "persons": 31,
73
+ "sample_rate": 16000,
74
+ "fps": 30,
75
+ "window_frames": 60,
76
+ "audio_stride_samples": 27734,
77
+ "solver": "released five-step midpoint",
78
+ "steps": 5,
79
+ "cfg": 1.25,
80
+ "seed_pose": "8 local SMPL-X axis-angle frames [8,165] plus translations [8,3]; converted internally to global row-6D rotations",
81
+ "custom_wav_padding": "final partial window padded and output trimmed to WAV duration; benchmark retains the original keep_last=False convention"
82
+ },
83
+ "format_version": 2,
84
+ "release_date": "2026-11-13",
85
+ "label": "globaldiff_e630_all_cfg1p25",
86
+ "weight_origin": "Newly retrained GlobalDiff generator; not the original paper checkpoint",
87
+ "training": {
88
+ "dataset": "H-Liu1997/BEAT2 English v2.0.0, original training CSV",
89
+ "train_clips": 1093,
90
+ "train_windows": 102041,
91
+ "window_frames": 60,
92
+ "stride_frames": 20,
93
+ "epochs": 1000,
94
+ "global_batch": 512,
95
+ "batch_per_device": 128,
96
+ "devices": 4,
97
+ "checkpoint_every_epochs": 5,
98
+ "random_initialization_seed": 0,
99
+ "execution": "Frozen auxiliary targets cached; vectorized FK and CUDA graphs; FP32/TF32 after the first10 BF16 epochs"
100
+ },
101
+ "selection": "Alternative with diversity closer to the paper reference",
102
+ "limitations": [
103
+ "Selected using the public test benchmark; not an untouched-test generalization estimate.",
104
+ "Both released checkpoints were trained on all training CSV speakers, not Speaker2-only training.",
105
+ "Exact equivalence to the original private paper training protocol is unverified.",
106
+ "Lower FGD does not imply improvement in every metric."
107
+ ]
108
+ }
retrained_20261113/globaldiff_e630_all_cfg1p25/METRICS.json ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "evaluation_scope": "265 original English BEAT2 test clips",
3
+ "protocol": "official full-clip AESK, clipwise min length then multiple 32, CPU FP32 batch1, epsilon1e-6",
4
+ "seed0": {
5
+ "FGD": 0.2636432704627847,
6
+ "clips": 265,
7
+ "frames": 554936,
8
+ "BA": 0.4277922631425832,
9
+ "BA_before_L1div_mutation": 0.4283574183909472,
10
+ "DIV": 8.152655286487992,
11
+ "facial_vertex_MSE": 4.186624735091204e-08
12
+ },
13
+ "sampling_seeds": [
14
+ 0,
15
+ 1,
16
+ 2
17
+ ],
18
+ "sampling_FGD": {
19
+ "values": [
20
+ 0.2636432704627847,
21
+ 0.26671848472740756,
22
+ 0.2653850988202606
23
+ ],
24
+ "mean": 0.26524895133681764,
25
+ "population_std": 0.0012591366873830378,
26
+ "min": 0.2636432704627847,
27
+ "max": 0.26671848472740756
28
+ },
29
+ "sampling_note": "Sampling variation of a single fixed checkpoint, not independent training runs.",
30
+ "paper_all_speakers": {
31
+ "FGD": 0.263,
32
+ "BA": 0.404,
33
+ "DIV": 8.24,
34
+ "facial_vertex_MSE": 4.144e-08
35
+ },
36
+ "public_prediction_calibration": {
37
+ "FGD": 0.2624656903227027,
38
+ "BA": 0.40586601635105224,
39
+ "DIV": 8.240758192266485,
40
+ "facial_vertex_MSE": 4.149304934655536e-08
41
+ },
42
+ "paper_url": "https://arxiv.org/abs/2511.10076",
43
+ "selection_caveats": [
44
+ "Selected using the public test benchmark; not an untouched-test generalization estimate.",
45
+ "Both released checkpoints were trained on all training CSV speakers, not Speaker2-only training.",
46
+ "Exact equivalence to the original private paper training protocol is unverified.",
47
+ "Lower FGD does not imply improvement in every metric."
48
+ ]
49
+ }
retrained_20261113/globaldiff_e630_all_cfg1p25/README.txt ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ GlobalDiff retrained motion generator: epoch 630, all speakers, CFG=1.25
2
+
3
+ These are newly retrained weights released on 2026-11-13. They are not the
4
+ original paper checkpoints. Both epoch880 and epoch630 use the original
5
+ 25-English-speaker BEAT2 training CSV. Speaker2-only training is not claimed.
6
+ The generator has249 native state tensors and43,081,293 trainable parameters.
7
+
8
+ Tested environment: Python3.12, PyTorch2.10.0; training/evaluation used CUDA12.8.
9
+ Install PyTorch for your platform, then:
10
+ python -m pip install -r requirements-inference.txt
11
+ python verify_sha256.py
12
+
13
+ From this extracted directory, generate parameters for your WAV:
14
+ python infer_wav.py --checkpoint generator.pt --wav input.wav --seed-pose seed_pose_speaker2.npz --pid 2 --out motion.npz --device cuda
15
+
16
+ CONFIG.json supplies CFG=1.25 automatically. Use --device cpu for CPU inference.
17
+ Use a new output filename for each invocation. --seed controls sampling noise.
18
+ The example uses eight frames from a Speaker2 training clip. For another
19
+ trained speaker/avatar, provide a matching seed NPZ with local axis-angle
20
+ poses[>=8,165] and trans[>=8,3], plus optional betas[300], and select its pid.
21
+ Trained IDs: [1, 2, 3, 4, 5, 6, 7, 9, 10, 11, 12, 13, 15, 16, 17, 18, 20, 21, 22, 23, 24, 25, 27, 28, 30]. ID0 is reserved for unconditional conditioning.
22
+
23
+ WavLM: patrickvonplaten/wavlm-libri-clean-100h-large
24
+ Fixed revision: e70e3a062ec399c46008ee55d1fb52c7ba338d5c
25
+ It downloads on first use. For offline use, pass --wavlm /path/to/the/snapshot;
26
+ the supplied WavLM manifest verifies the local snapshot's required files.
27
+
28
+ The script mixes channels to mono, resamples to16kHz, processes two-second
29
+ windows, uses eight seed frames and five midpoint steps, and returns30FPS.
30
+ The final partial window is padded and output is trimmed to the WAV duration.
31
+ Seed poses are converted internally from local axis-angle to global6D rotation.
32
+ Output: local SMPL-X poses[T,165], trans[T,3], expressions[T,100], betas, and FPS.
33
+ CPU FP32 and GPU FP16 sampling are not bitwise identical.
34
+
35
+ The official SimpleSpeechModel and source files are included. Training-only
36
+ VAEs and an SMPL-X mesh asset are not needed for parameter inference. Mesh
37
+ rendering requires the separately obtained SMPL-X model. Code and all
38
+ third-party data/assets remain subject to their respective terms; this bundle
39
+ does not grant new rights to those assets.
40
+
41
+ CONFIG.json records the matching architecture, inference and training settings.
42
+ METRICS.json reports seed0 metrics, three sampling seeds and the calibration
43
+ against the public predictions. Selection used the public test benchmark.
44
+ Epoch880 has lower FGD and lower diversity; epoch630 has diversity closer to
45
+ the paper reference. The release does not claim superiority on every metric.
46
+
47
+ Code: https://github.com/Xiangyue-Zhang/GlobalDiff
48
+ Source snapshot: 0fece4fbf884198285769d12a9cc4bdb67185181
49
+ Paper: https://arxiv.org/abs/2511.10076
retrained_20261113/globaldiff_e630_all_cfg1p25/SEED_PROVENANCE.json ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "dataset": "https://huggingface.co/datasets/H-Liu1997/BEAT2",
3
+ "source_train_clip": "2_scott_0_100_100",
4
+ "frames": [
5
+ 0,
6
+ 8
7
+ ],
8
+ "fps": 30,
9
+ "pid": 2,
10
+ "representation": "8 local SMPL-X axis-angle poses [8,165], translations [8,3], and source body shape",
11
+ "purpose": "Example initialization for new WAV inference; no test-sequence seed is included"
12
+ }
retrained_20261113/globaldiff_e630_all_cfg1p25/SHA256SUMS.json ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "CONFIG.json": {
3
+ "size": 3435,
4
+ "sha256": "d2e109673d009ec03e195c747d077955205bbaa2e830202021f7b587fcf25537"
5
+ },
6
+ "METRICS.json": {
7
+ "size": 1566,
8
+ "sha256": "f6eb8349c47e6c0b0e0808d46f5ac5a26c9255bd8a7dd681f3559356823cf036"
9
+ },
10
+ "README.txt": {
11
+ "size": 2921,
12
+ "sha256": "3bf3bd2f38fd60b85b42d8a3468fb910dc2d3e7560457e02c01c9624217d13a1"
13
+ },
14
+ "SEED_PROVENANCE.json": {
15
+ "size": 370,
16
+ "sha256": "297b826cefa1ac2db02f23cd12b447e9028eb673859a38d235a0de0ae5f986a0"
17
+ },
18
+ "VALIDATION.json": {
19
+ "size": 462,
20
+ "sha256": "ddbd90fe89176d03c19ebf2a5836ded9f3b9c0b09c859cd0cb195d62d0a0462d"
21
+ },
22
+ "WAVLM_DOWNLOAD_COMPLETE.json": {
23
+ "size": 1567,
24
+ "sha256": "69ba38b21d7ebef08cbae69b7a6cd0c9afc9ccd5cbbb2fb8a7b35780076ef13f"
25
+ },
26
+ "generator.pt": {
27
+ "size": 172404427,
28
+ "sha256": "d8988ea41542afb5a7c10632a0056f6c143f075101044e7ce2c0a9d8c938eea1"
29
+ },
30
+ "infer_wav.py": {
31
+ "size": 10807,
32
+ "sha256": "9ca0469945c4f0cfe19f3cf17e91cd68e253ac17fa4d3aaa2e9742997390b18a"
33
+ },
34
+ "requirements-inference.txt": {
35
+ "size": 166,
36
+ "sha256": "839228c977ace2994e269c5086b5e7f4520193bc7deeb535fe53db7de6ec0a3b"
37
+ },
38
+ "seed_pose_speaker2.npz": {
39
+ "size": 7420,
40
+ "sha256": "a0f8a79e60996a366a9659359ac91144bcbf5abf37d29782452c33bd5a65046c"
41
+ },
42
+ "source/Scripts/FM/Filter.py": {
43
+ "size": 3194,
44
+ "sha256": "bb524fd1fccbf45b45c5a9f42d31c6255175786e17f5e20c86a62065cc4c3d47"
45
+ },
46
+ "source/Scripts/FM/Net.py": {
47
+ "size": 126155,
48
+ "sha256": "ddf305fe001fa03b912361afe4bc7f92e67c71641fd9a2b1c794199e10b2ea6e"
49
+ },
50
+ "source/Scripts/FM/ckpt/split/SimpleSpeechModel/best.pt": {
51
+ "size": 52982500,
52
+ "sha256": "187df39de64c7a20983904cfca3145e44bee1630fdbad6da018d23b1e0fedaf9"
53
+ },
54
+ "source/Scripts/PositionalEncoding.py": {
55
+ "size": 3220,
56
+ "sha256": "f10b8c1aeb6068f1ee025811886535191a26a84dde4d4c9185fbcb5302059f4c"
57
+ },
58
+ "source/Scripts/SMPLXConfig.py": {
59
+ "size": 48003,
60
+ "sha256": "13999c52b99056ad7895eda955e78b3a156bc02266213e400cd90b3e532002e6"
61
+ },
62
+ "source/Scripts/SMPLX_Util.py": {
63
+ "size": 9840,
64
+ "sha256": "b604fe04f657b9a29586c5da3eaafeafc4919aaae84668c62e79c4e19eb95837"
65
+ },
66
+ "source/Scripts/Util.py": {
67
+ "size": 19180,
68
+ "sha256": "8e0fa2e1b149c66c7238b78ba28ef8593ad4e99f9fcb64220c5738d2dd98f773"
69
+ },
70
+ "verify_sha256.py": {
71
+ "size": 496,
72
+ "sha256": "8ac7f85467754a66a9f6a48b914b104bced75e86322de539c3e16b1c164e9ffd"
73
+ }
74
+ }
retrained_20261113/globaldiff_e630_all_cfg1p25/VALIDATION.json ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "generator_sha256": "d8988ea41542afb5a7c10632a0056f6c143f075101044e7ce2c0a9d8c938eea1",
3
+ "native_state_dictionary_tensors": 249,
4
+ "full_training_state_and_optimizer_verified": true,
5
+ "source_files_and_inference_settings_unchanged": true,
6
+ "original_packaged_cpu_smoke_test": {
7
+ "input_seconds": 4,
8
+ "output_frames": 120,
9
+ "finite": true
10
+ },
11
+ "public_release_verification": "See release-level verification receipt for public download checks"
12
+ }
retrained_20261113/globaldiff_e630_all_cfg1p25/WAVLM_DOWNLOAD_COMPLETE.json ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "train_results.json": {
3
+ "bytes": 196,
4
+ "sha256": "5c7980ba296a96bf6ff95d0932d755059552afa4a287af8c621047e32d9bb289"
5
+ },
6
+ "preprocessor_config.json": {
7
+ "bytes": 214,
8
+ "sha256": "60ca5a31e13f69ee2fbf147504c8676db5f6398fd7a6b12294341dff838edfcf"
9
+ },
10
+ "eval_results.json": {
11
+ "bytes": 223,
12
+ "sha256": "dacc5c722deddf383e0885ce21abc3893735980163408e9ac1d499e49e8e9a36"
13
+ },
14
+ "pytorch_model.bin": {
15
+ "bytes": 1262130157,
16
+ "sha256": "4fb4e34572862ffa9bc01483e2065fecead1fda4941fb7fbd166d574afeae5fc"
17
+ },
18
+ "added_tokens.json": {
19
+ "bytes": 23,
20
+ "sha256": "a078eb364da8305a28070ed844edf5792449ef165d67ffdad3c128ec6a7fa422"
21
+ },
22
+ "training_args.bin": {
23
+ "bytes": 2991,
24
+ "sha256": "16a69eb1dc7d0fd6fbada6d6bbfd9e4b781eb0c64524b8c51d51d08eeedb0251"
25
+ },
26
+ "vocab.json": {
27
+ "bytes": 259,
28
+ "sha256": "a935095e5968d3e329ff178c249515d06780ff76e2067a2434617106bd756330"
29
+ },
30
+ "special_tokens_map.json": {
31
+ "bytes": 309,
32
+ "sha256": "fe9499f3f127cf340419ded12d4175b3a28a58c99c949bf3f8343a6f6b9fa872"
33
+ },
34
+ "config.json": {
35
+ "bytes": 2196,
36
+ "sha256": "2cd56602937a33bcaf9eed0fac2ad69dc2d3e98ae5299ea7d60bc2ca850a7473"
37
+ },
38
+ "trainer_state.json": {
39
+ "bytes": 322429,
40
+ "sha256": "2995eb823b0f2dca21d44fb88fef7489ea64da93f31db93d3390cea843ba7d90"
41
+ },
42
+ "all_results.json": {
43
+ "bytes": 399,
44
+ "sha256": "6f5390d53b6fff38af00c5d93b410cc41857b29152ee0d96804ddcf940ec584a"
45
+ },
46
+ "tokenizer_config.json": {
47
+ "bytes": 293,
48
+ "sha256": "e8fd48231bd72bccec02ca42ab49a4b7d51622be5d55b0f91fc11c35a4ef3a27"
49
+ }
50
+ }
retrained_20261113/globaldiff_e630_all_cfg1p25/generator.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d8988ea41542afb5a7c10632a0056f6c143f075101044e7ce2c0a9d8c938eea1
3
+ size 172404427
retrained_20261113/globaldiff_e630_all_cfg1p25/infer_wav.py ADDED
@@ -0,0 +1,198 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Generate SMPL-X parameters for one WAV using a released GlobalDiff weight.
2
+
3
+ No SMPL-X mesh asset is needed for parameter inference. Use the original
4
+ GlobalDiff source tree, the matching SimpleSpeechModel, and fixed WavLM revision.
5
+ The final partial window is padded so custom audio is covered to its last frame.
6
+ """
7
+ import argparse
8
+ import contextlib
9
+ import hashlib
10
+ import json
11
+ import math
12
+ import os
13
+ from pathlib import Path
14
+ import sys
15
+ import time
16
+
17
+ os.environ.setdefault('USE_TF', '0')
18
+ os.environ.setdefault('TRANSFORMERS_NO_TF', '1')
19
+ WAVLM_ID = 'patrickvonplaten/wavlm-libri-clean-100h-large'
20
+ WAVLM_REVISION = 'e70e3a062ec399c46008ee55d1fb52c7ba338d5c'
21
+
22
+
23
+ def sha(path):
24
+ h = hashlib.sha256()
25
+ with Path(path).open('rb') as f:
26
+ for block in iter(lambda: f.read(16 << 20), b''):
27
+ h.update(block)
28
+ return h.hexdigest()
29
+
30
+
31
+ def main():
32
+ p = argparse.ArgumentParser(description=__doc__)
33
+ p.add_argument('--repo', type=Path, default=Path(__file__).parent/'source')
34
+ p.add_argument('--checkpoint', type=Path, required=True)
35
+ p.add_argument('--speech', type=Path)
36
+ p.add_argument('--wavlm', default=WAVLM_ID, help='Fixed model id or a local snapshot directory')
37
+ p.add_argument('--wav', type=Path, required=True)
38
+ p.add_argument('--seed-pose', type=Path, required=True, help='SMPL-X NPZ: poses [>=8,165] local axis-angle, trans [>=8,3]')
39
+ p.add_argument('--pid', type=int, default=2)
40
+ p.add_argument('--out', type=Path, required=True)
41
+ p.add_argument('--cfg', type=float, default=None, help='Defaults to matching CONFIG.json, otherwise 0')
42
+ p.add_argument('--seed', type=int, default=0)
43
+ p.add_argument('--device', choices=['cpu','cuda'], default='cuda')
44
+ p.add_argument('--threads', type=int, default=4)
45
+ p.add_argument('--feature-batch', type=int, default=16)
46
+ a = p.parse_args()
47
+ if a.out.suffix != '.npz':
48
+ p.error('--out must end in .npz')
49
+ if not 0 <= a.pid <= 30:
50
+ p.error('--pid must be 0..30; 0 is the unconditional identity')
51
+ if a.out.exists() or a.out.with_suffix('.json').exists():
52
+ p.error('Output already exists; select a new path')
53
+ config = None
54
+ config_path = a.checkpoint.parent/'CONFIG.json'
55
+ if config_path.exists():
56
+ config = json.loads(config_path.read_text())
57
+ if sha(a.checkpoint) != config['generator_sha256']:
58
+ p.error('Checkpoint SHA does not match the accompanying CONFIG.json')
59
+ if a.pid != 0 and a.pid not in config['trained_person_ids']:
60
+ p.error('Unsupported person ID; trained IDs: '+str(config['trained_person_ids']))
61
+ if a.cfg is None:
62
+ a.cfg = config['inference']['cfg']
63
+ if a.cfg is None:
64
+ a.cfg = 0
65
+ speech_path = a.speech or a.repo/'Scripts/FM/ckpt/split/SimpleSpeechModel/best.pt'
66
+ if config and sha(speech_path) != config['inference']['speech_checkpoint_sha256']:
67
+ p.error('Speech checkpoint SHA does not match CONFIG.json')
68
+ if Path(a.wavlm).is_dir():
69
+ manifest_path = a.checkpoint.parent/'WAVLM_DOWNLOAD_COMPLETE.json'
70
+ if manifest_path.exists():
71
+ manifest = json.loads(manifest_path.read_text())
72
+ for name in ['pytorch_model.bin','config.json','preprocessor_config.json',
73
+ 'tokenizer_config.json','vocab.json','special_tokens_map.json','added_tokens.json']:
74
+ path = Path(a.wavlm)/name
75
+ if not path.is_file() or sha(path) != manifest[name]['sha256']:
76
+ p.error('Local WavLM snapshot does not match the fixed release: '+name)
77
+ elif a.wavlm != WAVLM_ID:
78
+ p.error('Use the fixed WavLM model ID or its verified local snapshot')
79
+ for path in [a.repo/'Scripts', a.repo/'Scripts/FM']:
80
+ sys.path.insert(0, str(path.resolve()))
81
+ import numpy as np
82
+ import soundfile as sf
83
+ import torch
84
+ import torch.nn.functional as F
85
+ from scipy.signal import resample_poly
86
+ from transformers import Wav2Vec2Processor, WavLMModel
87
+ from Net import DiffusionDITNetPartsFixedExpressions2PostNorm, SimpleSpeechModel
88
+ from SMPLXConfig import GetBodyPartIndices
89
+ from SMPLX_Util import LocalToGlobalAA, global_to_local_batch
90
+ from Util import axis_angle_to_rotation_6d, NormalizeRot6d, rotation_6d_to_matrix, rotation_matrix_to_axis_angle
91
+ from Filter import Filter1D
92
+
93
+ torch.set_num_threads(a.threads)
94
+ torch.manual_seed(a.seed)
95
+ np.random.seed(a.seed)
96
+ device = torch.device(a.device)
97
+ if device.type == 'cuda':
98
+ torch.backends.cuda.matmul.allow_tf32 = True
99
+ torch.backends.cudnn.allow_tf32 = True
100
+ started = time.monotonic()
101
+ audio, source_sr = sf.read(a.wav, dtype='float32', always_2d=True)
102
+ audio = audio.mean(axis=1)
103
+ if source_sr != 16000:
104
+ gcd = math.gcd(source_sr,16000)
105
+ audio = resample_poly(audio,16000//gcd,source_sr//gcd).astype(np.float32)
106
+ if not len(audio) or not np.isfinite(audio).all():
107
+ p.error('WAV must contain finite, nonempty audio')
108
+ frames = max(1, int(len(audio)*30/16000))
109
+ count = max(1, math.ceil(max(0,len(audio)-32000)/27734)+1)
110
+ # Integer audio strides accumulate a sub-frame offset on long recordings.
111
+ # Ensure the stitched 52-frame strides also cover the requested output.
112
+ count = max(count, math.ceil(max(0, frames-60)/52)+1)
113
+ padded = np.pad(audio,(0,32000+(count-1)*27734-len(audio)))
114
+ windows = [padded[i*27734:i*27734+32000] for i in range(count)]
115
+ kwargs = dict(local_files_only=True) if Path(a.wavlm).is_dir() else dict(revision=WAVLM_REVISION)
116
+ processor = Wav2Vec2Processor.from_pretrained(a.wavlm,**kwargs)
117
+ values = processor(windows,sampling_rate=16000,return_tensors='pt').input_values
118
+ wavlm = WavLMModel.from_pretrained(a.wavlm,**kwargs).eval().requires_grad_(False).to(device)
119
+ speech = SimpleSpeechModel().eval().requires_grad_(False).to(device)
120
+ speech.load_state_dict(torch.load(speech_path,map_location='cpu',weights_only=True),strict=True)
121
+ net = DiffusionDITNetPartsFixedExpressions2PostNorm(n_seed=8,num_person=31).eval().requires_grad_(False).to(device)
122
+ net.load_state_dict(torch.load(a.checkpoint,map_location='cpu',weights_only=True),strict=True)
123
+ with np.load(a.seed_pose,allow_pickle=False) as data:
124
+ local = data['poses'].astype(np.float32)[:8]
125
+ trans = data['trans'].astype(np.float32)[:8]
126
+ betas = data['betas'].astype(np.float32) if 'betas' in data else np.zeros(300,dtype=np.float32)
127
+ if local.shape != (8,165) or trans.shape != (8,3):
128
+ p.error('Seed pose requires eight local SMPL-X axis-angle frames and translations')
129
+ seed = np.concatenate([axis_angle_to_rotation_6d(LocalToGlobalAA(local)),trans],axis=-1)
130
+ if not np.isfinite(seed).all():
131
+ p.error('Seed pose contains nonfinite values')
132
+ seed = torch.from_numpy(seed.astype(np.float32)).unsqueeze(0).to(device)
133
+ indices = {k+'_indices':GetBodyPartIndices(k,'rot6d') for k in ['hand','upper','lower']}
134
+ indices['lower_indices'] = np.concatenate([indices['lower_indices'],np.arange(330,333)])
135
+ face = GetBodyPartIndices('face','rot6d')
136
+ indices['face_joint_indices'] = face
137
+ indices['face_indices'] = np.concatenate([face,np.arange(333,433)])
138
+ pid = torch.tensor([a.pid],device=device)
139
+ filt = Filter1D(window_length=7,polyorder=2).to(device)
140
+ amp = lambda: torch.autocast('cuda',dtype=torch.float16) if device.type == 'cuda' else contextlib.nullcontext()
141
+ feature_rows = []
142
+ with torch.inference_mode():
143
+ for start in range(0,count,a.feature_batch):
144
+ with amp():
145
+ value = wavlm(values[start:start+a.feature_batch].to(device)).last_hidden_state
146
+ value = F.interpolate(value.transpose(1,2),60,mode='linear',align_corners=True).transpose(1,2)
147
+ feature_rows.append(value.float())
148
+ features = torch.cat(feature_rows)
149
+ del wavlm
150
+ expressions = speech(features,pid.expand(count))
151
+ motions = []
152
+ # Each call has its own documented sampling seed, independent of model initialization.
153
+ torch.manual_seed(a.seed)
154
+ for n in range(count):
155
+ cond = dict(pid=pid,seed_poses=seed,hubert=features[n:n+1],expressions=expressions[n:n+1],**indices)
156
+ noise = torch.randn(1,60,333,device=device)
157
+ xt = noise
158
+ times = torch.linspace(0,1,6,device=device)
159
+ for i in range(5):
160
+ ts,te = times[i],times[i+1]
161
+ middle = (ts+te)/2
162
+ for t,next_t in [(ts,middle),(middle,te)]:
163
+ with amp():
164
+ pred = net(xt,t.expand(1),**cond)
165
+ if a.cfg > 0:
166
+ uncond = net(xt,t.expand(1),**dict(cond,pid=torch.zeros_like(pid)))
167
+ pred = (pred-uncond)*a.cfg+uncond
168
+ pred[:,:8] = (seed+pred[:,:8])/2
169
+ xt = (1-next_t)*noise+next_t*pred
170
+ xt[:,5:] = filt(xt[:,5:])
171
+ xt[...,:330] = NormalizeRot6d(xt[...,:330])
172
+ seed = xt[:,-8:]
173
+ motions.append(torch.cat([xt,expressions[n:n+1]],-1))
174
+ for n in range(1,len(motions)):
175
+ motions[n-1][:,-8:] = (motions[n-1][:,-8:]+motions[n][:,:8])/2
176
+ motions[n] = motions[n][:,8:]
177
+ motion = torch.cat(motions,1)[:,:frames]
178
+ matrices = rotation_6d_to_matrix(motion[...,:330].reshape(-1,55,6))
179
+ poses = rotation_matrix_to_axis_angle(global_to_local_batch(matrices)).reshape(-1,165).cpu().numpy()
180
+ translations = motion[0,:,330:333].cpu().numpy()
181
+ expression = motion[0,:,333:].cpu().numpy()
182
+ assert len(poses)==frames and all(np.isfinite(v).all() for v in [poses,translations,expression])
183
+ a.out.parent.mkdir(parents=True,exist_ok=True)
184
+ np.savez(a.out,poses=poses,trans=translations,expressions=expression,betas=betas,
185
+ mocap_frame_rate=np.array(30),model=np.array('smplx2020'),gender=np.array('neutral'))
186
+ meta = dict(checkpoint_sha256=sha(a.checkpoint),speech_sha256=sha(speech_path),wav_sha256=sha(a.wav),
187
+ seed_pose_sha256=sha(a.seed_pose),wavlm_id=WAVLM_ID,wavlm_revision=WAVLM_REVISION,
188
+ pid=a.pid,seed=a.seed,cfg=a.cfg,n_seed=8,steps=5,window_frames=60,audio_stride=27734,
189
+ input_sample_rate=source_sr,processed_sample_rate=16000,frames=frames,
190
+ padding='pad final partial audio window and trim to audio length; custom WAV mode',
191
+ precision='FP16 WavLM/generator, FP32 speech' if device.type=='cuda' else 'CPU FP32',
192
+ source_commit='0fece4fbf884198285769d12a9cc4bdb67185181',elapsed=time.monotonic()-started)
193
+ a.out.with_suffix('.json').write_text(json.dumps(meta,indent=2)+'\n')
194
+ print(json.dumps(meta),flush=True)
195
+
196
+
197
+ if __name__=='__main__':
198
+ main()
retrained_20261113/globaldiff_e630_all_cfg1p25/requirements-inference.txt ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ numpy==1.26.4
2
+ scipy==1.16.3
3
+ soundfile==0.13.0
4
+ einops==0.8.1
5
+ smplx==0.1.28
6
+ transformers==4.57.1
7
+ safetensors==0.7.0
8
+ huggingface-hub==0.36.2
9
+ positional-encodings==6.0.4
retrained_20261113/globaldiff_e630_all_cfg1p25/seed_pose_speaker2.npz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a0f8a79e60996a366a9659359ac91144bcbf5abf37d29782452c33bd5a65046c
3
+ size 7420
retrained_20261113/globaldiff_e630_all_cfg1p25/source/Scripts/FM/Filter.py ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ '''
3
+ Copyright (c) 2021, Alibaba Cloud and its affiliates;
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ '''
16
+
17
+ import torch
18
+ from einops import rearrange
19
+
20
+ def generate_savgol_matrix(window_length: int=5, polyorder: int=2, dtype=torch.float32) -> torch.Tensor:
21
+ """
22
+ Generate the Savitzky-Golay design matrix X for polynomial fitting.
23
+
24
+ Args:
25
+ window_length (int): Length of the filter window (must be odd).
26
+ polyorder (int): Order of the polynomial fit.
27
+ dtype (torch.dtype): Data type of the output tensor.
28
+
29
+ Returns:
30
+ torch.Tensor: Design matrix X of shape (window_length, polyorder + 1).
31
+ """
32
+ if window_length % 2 != 1:
33
+ raise ValueError("window_length must be odd.")
34
+
35
+ m = (window_length - 1) // 2 # Half-width of the window
36
+ x = torch.arange(-m, m + 1, dtype=dtype) # [-m, -m+1, ..., m]
37
+
38
+ # Construct Vandermonde matrix: each row is [1, x, x^2, ..., x^K]
39
+ X = x.unsqueeze(1).pow(torch.arange(polyorder + 1, dtype=dtype))
40
+
41
+ return X
42
+
43
+ def generate_savgol_coefficients(window_length: int=5, polyorder: int=2, dtype=torch.float32):
44
+ X = generate_savgol_matrix(window_length, polyorder, dtype)
45
+ XT = X.transpose(0, 1)
46
+ mat = torch.linalg.inv(XT @ X) @ XT
47
+ return mat[0, :] # Return the first row of the inverse matrix
48
+
49
+
50
+ class Filter1D(torch.nn.Module):
51
+ def __init__(self, window_length:int = 7, polyorder:int =2):
52
+ super().__init__()
53
+ self.window_length =window_length
54
+ coefficients = generate_savgol_coefficients(window_length=window_length, polyorder=polyorder)
55
+ self.register_buffer('coefficients', coefficients.view(1, 1, -1))
56
+
57
+ def forward(self, input_tensor:torch.Tensor, format='btc'):
58
+ x = input_tensor.clone()
59
+ if format == 'btc':
60
+ B, T, C = x.shape
61
+ x = rearrange(x, 'b t c -> (b c) 1 t')
62
+ r = torch.nn.functional.conv1d(x, self.coefficients)
63
+ x[..., self.window_length//2:-(self.window_length//2)] = r
64
+ x = rearrange(x, '(b c) 1 t -> b t c', b=B, c=C)
65
+ elif format == 'bct':
66
+ B, C, T = x.shape
67
+ x = rearrange(x, 'b c t -> (b c) 1 t')
68
+ r = torch.nn.functional.conv1d(x, self.coefficients)
69
+ x[..., self.window_length//2:-(self.window_length//2)] = r
70
+ x = rearrange(x, '(b c) 1 t -> b c t', b=B, c=C)
71
+ else:
72
+ raise ValueError("Unsupported format. Use 'btc' or 'bct'.")
73
+ return x
74
+
75
+
76
+ if __name__ == '__main__':
77
+ coefficients = generate_savgol_coefficients(window_length=5, polyorder=2)
78
+ r = torch.nn.functional.conv1d(torch.ones(1, 2, 10), coefficients.view(1, 1, -1).expand(1, 2, -1))
79
+ print(r)
retrained_20261113/globaldiff_e630_all_cfg1p25/source/Scripts/FM/Net.py ADDED
The diff for this file is too large to render. See raw diff
 
retrained_20261113/globaldiff_e630_all_cfg1p25/source/Scripts/FM/ckpt/split/SimpleSpeechModel/best.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:187df39de64c7a20983904cfca3145e44bee1630fdbad6da018d23b1e0fedaf9
3
+ size 52982500
retrained_20261113/globaldiff_e630_all_cfg1p25/source/Scripts/PositionalEncoding.py ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ '''
3
+ Copyright (c) 2021, Alibaba Cloud and its affiliates;
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ '''
16
+
17
+
18
+
19
+ import torch.nn as nn
20
+ import torch.nn.functional as F
21
+ import torch
22
+
23
+ class RotaryPositionEmbedding(nn.Module):
24
+ def __init__(self, dim):
25
+ """
26
+ Rotary Position Embedding (RoPE)
27
+
28
+ 参数:
29
+ dim (int): 输入特征的维度(必须是偶数)
30
+ """
31
+ super().__init__()
32
+ assert dim % 2 == 0, "维度必须是偶数"
33
+ self.dim = dim
34
+
35
+ # 初始化频率参数 theta_i = 10000^(-2i/d)
36
+ inv_freq = 1.0 / (10000 ** (torch.arange(0, dim, 2).float() / dim))
37
+ self.register_buffer("inv_freq", inv_freq)
38
+
39
+ # 缓存cos和sin值
40
+ self.cos_cached = None
41
+ self.sin_cached = None
42
+ self.max_seq_len = None
43
+
44
+ def _update_cos_sin_cache(self, seq_len, device):
45
+ """更新cos和sin缓存"""
46
+ if self.max_seq_len is None or seq_len > self.max_seq_len:
47
+ self.max_seq_len = seq_len
48
+ # 生成位置索引 [0, 1, ..., seq_len-1]
49
+ t = torch.arange(seq_len, device=device).type_as(self.inv_freq)
50
+
51
+ # 计算频率矩阵 shape: (seq_len, dim//2)
52
+ freqs = torch.outer(t, self.inv_freq)
53
+
54
+ # 拼接相同频率用于后续广播 shape: (seq_len, dim)
55
+ emb = torch.cat((freqs, freqs), dim=-1)
56
+
57
+ # 缓存cos和sin值
58
+ self.cos_cached = emb.cos()[None, :, None, :] # 形状: (1, seq_len, 1, dim)
59
+ self.sin_cached = emb.sin()[None, :, None, :]
60
+
61
+ def rotate_half(self, x):
62
+ """将输入的后半部分旋转并取反"""
63
+ x = x.view(*x.shape[:-1], -1, 2) # 分组成二维向量
64
+ x1 = x[..., 0] # 前半部分
65
+ x2 = x[..., 1] # 后半部分
66
+ x_rot = torch.stack((-x2, x1), dim=-1) # 旋转操作
67
+ return x_rot.view(*x.shape[:-2], -1) # 恢复原始形状
68
+
69
+ def forward(self, x, offset=0):
70
+ """
71
+ 前向传播
72
+
73
+ 参数:
74
+ x (Tensor): 输入张量,形状为 (batch, seq_len, n_head, dim)
75
+ offset (int): 位置偏移量(用于增量解码)
76
+
77
+ 返回:
78
+ Tensor: 旋转后的张量
79
+ """
80
+ batch, seq_len, n_head, _ = x.size()
81
+ self._update_cos_sin_cache(seq_len + offset, x.device)
82
+
83
+ # 获取对应位置的cos和sin值
84
+ cos = self.cos_cached[:, offset:offset+seq_len]
85
+ sin = self.sin_cached[:, offset:offset+seq_len]
86
+
87
+ # 应用旋转位置编码
88
+ x_rot = (x * cos) + (self.rotate_half(x) * sin)
89
+ return x_rot
retrained_20261113/globaldiff_e630_all_cfg1p25/source/Scripts/SMPLXConfig.py ADDED
@@ -0,0 +1,1679 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ '''
3
+ Copyright (c) 2021, Alibaba Cloud and its affiliates;
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ '''
16
+
17
+ import numpy as np
18
+ # pose version fpsxx_trinity/japanese_joints(_xxx)
19
+ joints_list = {
20
+ "trinity_joints": {
21
+ 'Hips': [6, 6],
22
+ 'Spine': [3, 9],
23
+ 'Spine1': [3, 12],
24
+ 'Spine2': [3, 15],
25
+ 'Spine3': [3, 18],
26
+ 'Neck': [3, 21],
27
+ 'Neck1': [3, 24],
28
+ 'Head': [3, 27],
29
+ 'RShoulder': [3, 30],
30
+ 'RArm': [3, 33],
31
+ 'RArm1': [3, 36],
32
+ 'RHand': [3, 39],
33
+ 'RHandT1': [3, 42],
34
+ 'RHandT2': [3, 45],
35
+ 'RHandT3': [3, 48],
36
+ 'RHandI1': [3, 51],
37
+ 'RHandI2': [3, 54],
38
+ 'RHandI3': [3, 57],
39
+ 'RHandM1': [3, 60],
40
+ 'RHandM2': [3, 63],
41
+ 'RHandM3': [3, 66],
42
+ 'RHandR1': [3, 69],
43
+ 'RHandR2': [3, 72],
44
+ 'RHandR3': [3, 75],
45
+ 'RHandP1': [3, 78],
46
+ 'RHandP2': [3, 81],
47
+ 'RHandP3': [3, 84],
48
+ 'LShoulder': [3, 87],
49
+ 'LArm': [3, 90],
50
+ 'LArm1': [3, 93],
51
+ 'LHand': [3, 96],
52
+ 'LHandT1': [3, 99],
53
+ 'LHandT2': [3, 102],
54
+ 'LHandT3': [3, 105],
55
+ 'LHandI1': [3, 108],
56
+ 'LHandI2': [3, 111],
57
+ 'LHandI3': [3, 114],
58
+ 'LHandM1': [3, 117],
59
+ 'LHandM2': [3, 120],
60
+ 'LHandM3': [3, 123],
61
+ 'LHandR1': [3, 126],
62
+ 'LHandR2': [3, 129],
63
+ 'LHandR3': [3, 132],
64
+ 'LHandP1': [3, 135],
65
+ 'LHandP2': [3, 138],
66
+ 'LHandP3': [3, 141],
67
+ 'RUpLeg': [3, 144],
68
+ 'RLeg': [3, 147],
69
+ 'RFoot': [3, 150],
70
+ 'RFootF': [3, 153],
71
+ 'RToeBase': [3, 156],
72
+ 'LUpLeg': [3, 159],
73
+ 'LLeg': [3, 162],
74
+ 'LFoot': [3, 165],
75
+ 'LFootF': [3, 168],
76
+ 'LToeBase': [3, 171], },
77
+ "trinity_joints_123": {
78
+ 'Spine': 3,
79
+ 'Neck': 3,
80
+ 'Neck1': 3,
81
+ 'RShoulder': 3,
82
+ 'RArm': 3,
83
+ 'RArm1': 3,
84
+ 'RHand': 3,
85
+ 'RHandT1': 3,
86
+ 'RHandT2': 3,
87
+ 'RHandT3': 3,
88
+ 'RHandI1': 3,
89
+ 'RHandI2': 3,
90
+ 'RHandI3': 3,
91
+ 'RHandM1': 3,
92
+ 'RHandM2': 3,
93
+ 'RHandM3': 3,
94
+ 'RHandR1': 3,
95
+ 'RHandR2': 3,
96
+ 'RHandR3': 3,
97
+ 'RHandP1': 3,
98
+ 'RHandP2': 3,
99
+ 'RHandP3': 3,
100
+ 'LShoulder': 3,
101
+ 'LArm': 3,
102
+ 'LArm1': 3,
103
+ 'LHand': 3,
104
+ 'LHandT1': 3,
105
+ 'LHandT2': 3,
106
+ 'LHandT3': 3,
107
+ 'LHandI1': 3,
108
+ 'LHandI2': 3,
109
+ 'LHandI3': 3,
110
+ 'LHandM1': 3,
111
+ 'LHandM2': 3,
112
+ 'LHandM3': 3,
113
+ 'LHandR1': 3,
114
+ 'LHandR2': 3,
115
+ 'LHandR3': 3,
116
+ 'LHandP1': 3,
117
+ 'LHandP2': 3,
118
+ 'LHandP3': 3, },
119
+ "trinity_joints_168": {
120
+ 'Hips': 3,
121
+ 'Spine': 3,
122
+ 'Spine1': 3,
123
+ 'Spine2': 3,
124
+ 'Spine3': 3,
125
+ 'Neck': 3,
126
+ 'Neck1': 3,
127
+ 'Head': 3,
128
+ 'RShoulder': 3,
129
+ 'RArm': 3,
130
+ 'RArm1': 3,
131
+ 'RHand': 3,
132
+ 'RHandT1': 3,
133
+ 'RHandT2': 3,
134
+ 'RHandT3': 3,
135
+ 'RHandI1': 3,
136
+ 'RHandI2': 3,
137
+ 'RHandI3': 3,
138
+ 'RHandM1': 3,
139
+ 'RHandM2': 3,
140
+ 'RHandM3': 3,
141
+ 'RHandR1': 3,
142
+ 'RHandR2': 3,
143
+ 'RHandR3': 3,
144
+ 'RHandP1': 3,
145
+ 'RHandP2': 3,
146
+ 'RHandP3': 3,
147
+ 'LShoulder': 3,
148
+ 'LArm': 3,
149
+ 'LArm1': 3,
150
+ 'LHand': 3,
151
+ 'LHandT1': 3,
152
+ 'LHandT2': 3,
153
+ 'LHandT3': 3,
154
+ 'LHandI1': 3,
155
+ 'LHandI2': 3,
156
+ 'LHandI3': 3,
157
+ 'LHandM1': 3,
158
+ 'LHandM2': 3,
159
+ 'LHandM3': 3,
160
+ 'LHandR1': 3,
161
+ 'LHandR2': 3,
162
+ 'LHandR3': 3,
163
+ 'LHandP1': 3,
164
+ 'LHandP2': 3,
165
+ 'LHandP3': 3,
166
+ 'RUpLeg': 3,
167
+ 'RLeg': 3,
168
+ 'RFoot': 3,
169
+ 'RFootF': 3,
170
+ 'RToeBase': 3,
171
+ 'LUpLeg': 3,
172
+ 'LLeg': 3,
173
+ 'LFoot': 3,
174
+ 'LFootF': 3,
175
+ 'LToeBase': 3, },
176
+ "trinity_joints_138": {
177
+ "Hips": 3,
178
+ 'Spine': 3,
179
+ 'Spine1': 3,
180
+ 'Spine2': 3,
181
+ 'Spine3': 3,
182
+ 'Neck': 3,
183
+ 'Neck1': 3,
184
+ 'Head': 3,
185
+ 'RShoulder': 3,
186
+ 'RArm': 3,
187
+ 'RArm1': 3,
188
+ 'RHand': 3,
189
+ 'RHandT1': 3,
190
+ 'RHandT2': 3,
191
+ 'RHandT3': 3,
192
+ 'RHandI1': 3,
193
+ 'RHandI2': 3,
194
+ 'RHandI3': 3,
195
+ 'RHandM1': 3,
196
+ 'RHandM2': 3,
197
+ 'RHandM3': 3,
198
+ 'RHandR1': 3,
199
+ 'RHandR2': 3,
200
+ 'RHandR3': 3,
201
+ 'RHandP1': 3,
202
+ 'RHandP2': 3,
203
+ 'RHandP3': 3,
204
+ 'LShoulder': 3,
205
+ 'LArm': 3,
206
+ 'LArm1': 3,
207
+ 'LHand': 3,
208
+ 'LHandT1': 3,
209
+ 'LHandT2': 3,
210
+ 'LHandT3': 3,
211
+ 'LHandI1': 3,
212
+ 'LHandI2': 3,
213
+ 'LHandI3': 3,
214
+ 'LHandM1': 3,
215
+ 'LHandM2': 3,
216
+ 'LHandM3': 3,
217
+ 'LHandR1': 3,
218
+ 'LHandR2': 3,
219
+ 'LHandR3': 3,
220
+ 'LHandP1': 3,
221
+ 'LHandP2': 3,
222
+ 'LHandP3': 3, },
223
+ "beat_smplx_joints": {
224
+ 'pelvis': [3, 3],
225
+ 'left_hip': [3, 6],
226
+ 'right_hip': [3, 9],
227
+ 'spine1': [3, 12],
228
+ 'left_knee': [3, 15],
229
+ 'right_knee': [3, 18],
230
+ 'spine2': [3, 21],
231
+ 'left_ankle': [3, 24],
232
+ 'right_ankle': [3, 27],
233
+
234
+ 'spine3': [3, 30],
235
+ 'left_foot': [3, 33],
236
+ 'right_foot': [3, 36],
237
+ 'neck': [3, 39],
238
+ 'left_collar': [3, 42],
239
+ 'right_collar': [3, 45],
240
+ 'head': [3, 48],
241
+ 'left_shoulder': [3, 51],
242
+
243
+ 'right_shoulder': [3, 54],
244
+ 'left_elbow': [3, 57],
245
+ 'right_elbow': [3, 60],
246
+ 'left_wrist': [3, 63],
247
+ 'right_wrist': [3, 66],
248
+
249
+ 'jaw': [3, 69],
250
+ 'left_eye_smplhf': [3, 72],
251
+ 'right_eye_smplhf': [3, 75],
252
+ 'left_index1': [3, 78],
253
+ 'left_index2': [3, 81],
254
+
255
+ 'left_index3': [3, 84],
256
+ 'left_middle1': [3, 87],
257
+ 'left_middle2': [3, 90],
258
+ 'left_middle3': [3, 93],
259
+ 'left_pinky1': [3, 96],
260
+
261
+ 'left_pinky2': [3, 99],
262
+ 'left_pinky3': [3, 102],
263
+ 'left_ring1': [3, 105],
264
+ 'left_ring2': [3, 108],
265
+
266
+ 'left_ring3': [3, 111],
267
+ 'left_thumb1': [3, 114],
268
+ 'left_thumb2': [3, 117],
269
+ 'left_thumb3': [3, 120],
270
+ 'right_index1': [3, 123],
271
+ 'right_index2': [3, 126],
272
+ 'right_index3': [3, 129],
273
+ 'right_middle1': [3, 132],
274
+
275
+ 'right_middle2': [3, 135],
276
+ 'right_middle3': [3, 138],
277
+ 'right_pinky1': [3, 141],
278
+ 'right_pinky2': [3, 144],
279
+ 'right_pinky3': [3, 147],
280
+
281
+ 'right_ring1': [3, 150],
282
+ 'right_ring2': [3, 153],
283
+ 'right_ring3': [3, 156],
284
+ 'right_thumb1': [3, 159],
285
+ 'right_thumb2': [3, 162],
286
+ 'right_thumb3': [3, 165],
287
+
288
+ # 'nose': [3,168],
289
+ # 'right_eye': [3,171],
290
+ # 'left_eye': [3,174],
291
+ # 'right_ear': [3,177],
292
+
293
+ # 'left_ear': [3,180],
294
+ # 'left_big_toe': [3,183],
295
+ # 'left_small_toe': [3,186],
296
+ # 'left_heel': [3,189],
297
+
298
+ # 'right_big_toe': [3,192],
299
+ # 'right_small_toe': [3,195],
300
+ # 'right_heel': [3,198],
301
+ # 'left_thumb': [3,201],
302
+ # 'left_index': [3,204],
303
+ # 'left_middle': [3,207],
304
+
305
+ # 'left_ring': [3,210],
306
+ # 'left_pinky': [3,213],
307
+ # 'right_thumb': [3,216],
308
+ # 'right_index': [3,219],
309
+ # 'right_middle': [3,222],
310
+ # 'right_ring': [3,225],
311
+
312
+ # 'right_pinky': [3,228],
313
+ # 'right_eye_brow1': [3,231],
314
+ # 'right_eye_brow2': [3,234],
315
+ # 'right_eye_brow3': [3,237],
316
+
317
+ # 'right_eye_brow4': [3,240],
318
+ # 'right_eye_brow5': [3,243],
319
+ # 'left_eye_brow5': [3,246],
320
+ # 'left_eye_brow4': [3,249],
321
+
322
+ # 'left_eye_brow3': [3,252],
323
+ # 'left_eye_brow2': [3,255],
324
+ # 'left_eye_brow1': [3,258],
325
+ # 'nose1': [3,261],
326
+ # 'nose2': [3,264],
327
+ # 'nose3': [3,267],
328
+
329
+ # 'nose4': [3,270],
330
+ # 'right_nose_2': [3,273],
331
+ # 'right_nose_1': [3,276],
332
+ # 'nose_middle': [3,279],
333
+ # 'left_nose_1': [3,282],
334
+ # 'left_nose_2': [3,285],
335
+
336
+ # 'right_eye1': [3,288],
337
+ # 'right_eye2': [3,291],
338
+ # 'right_eye3': [3,294],
339
+ # 'right_eye4': [3,297],
340
+
341
+ # 'right_eye5': [3,300],
342
+ # 'right_eye6': [3,303],
343
+ # 'left_eye4': [3,306],
344
+ # 'left_eye3': [3,309],
345
+
346
+ # 'left_eye2': [3,312],
347
+ # 'left_eye1': [3,315],
348
+ # 'left_eye6': [3,318],
349
+ # 'left_eye5': [3,321],
350
+ # 'right_mouth_1': [3,324],
351
+ # 'right_mouth_2': [3,327],
352
+ # 'right_mouth_3': [3,330],
353
+ # 'mouth_top': [3,333],
354
+ # 'left_mouth_3': [3,336],
355
+ # 'left_mouth_2': [3,339],
356
+ # 'left_mouth_1': [3,342],
357
+ # 'left_mouth_5': [3,345],
358
+ # 'left_mouth_4': [3,348],
359
+ # 'mouth_bottom': [3,351],
360
+ # 'right_mouth_4': [3,354],
361
+ # 'right_mouth_5': [3,357],
362
+ # 'right_lip_1': [3,360],
363
+ # 'right_lip_2': [3,363],
364
+ # 'lip_top': [3,366],
365
+ # 'left_lip_2': [3,369],
366
+
367
+ # 'left_lip_1': [3,372],
368
+ # 'left_lip_3': [3,375],
369
+ # 'lip_bottom': [3,378],
370
+ # 'right_lip_3': [3,381],
371
+ # 'right_contour_1': [3,384],
372
+ # 'right_contour_2': [3,387],
373
+ # 'right_contour_3': [3,390],
374
+ # 'right_contour_4': [3,393],
375
+ # 'right_contour_5': [3,396],
376
+ # 'right_contour_6': [3,399],
377
+ # 'right_contour_7': [3,402],
378
+ # 'right_contour_8': [3,405],
379
+ # 'contour_middle': [3,408],
380
+ # 'left_contour_8': [3,411],
381
+ # 'left_contour_7': [3,414],
382
+ # 'left_contour_6': [3,417],
383
+ # 'left_contour_5': [3,420],
384
+ # 'left_contour_4': [3,423],
385
+ # 'left_contour_3': [3,426],
386
+ # 'left_contour_2': [3,429],
387
+ # 'left_contour_1': [3,432],
388
+ },
389
+ "beat_smplx_joints_6d": {
390
+ 'pelvis': [6, 6],
391
+ 'left_hip': [6, 12],
392
+ 'right_hip': [6, 18],
393
+ 'spine1': [6, 24],
394
+ 'left_knee': [6, 30],
395
+ 'right_knee': [6, 36],
396
+ 'spine2': [6, 42],
397
+ 'left_ankle': [6, 48],
398
+ 'right_ankle': [6, 54],
399
+
400
+ 'spine3': [6, 60],
401
+ 'left_foot': [6, 66],
402
+ 'right_foot': [6, 72],
403
+ 'neck': [6, 78],
404
+ 'left_collar': [6, 84],
405
+ 'right_collar': [6, 90],
406
+ 'head': [6, 96],
407
+ 'left_shoulder': [6, 102],
408
+
409
+ 'right_shoulder': [6, 108],
410
+ 'left_elbow': [6, 114],
411
+ 'right_elbow': [6, 120],
412
+ 'left_wrist': [6, 126],
413
+ 'right_wrist': [6, 132],
414
+
415
+ 'jaw': [6, 138],
416
+ 'left_eye_smplhf': [6, 144],
417
+ 'right_eye_smplhf': [6, 150],
418
+ 'left_index1': [6, 156],
419
+ 'left_index2': [6, 162],
420
+
421
+ 'left_index3': [6, 168],
422
+ 'left_middle1': [6, 174],
423
+ 'left_middle2': [6, 180],
424
+ 'left_middle3': [6, 186],
425
+ 'left_pinky1': [6, 192],
426
+
427
+ 'left_pinky2': [6, 198],
428
+ 'left_pinky3': [6, 204],
429
+ 'left_ring1': [6, 210],
430
+ 'left_ring2': [6, 216],
431
+
432
+ 'left_ring3': [6, 222],
433
+ 'left_thumb1': [6, 228],
434
+ 'left_thumb2': [6, 234],
435
+ 'left_thumb3': [6, 240],
436
+ 'right_index1': [6, 246],
437
+ 'right_index2': [6, 252],
438
+ 'right_index3': [6, 258],
439
+ 'right_middle1': [6, 264],
440
+
441
+ 'right_middle2': [6, 270],
442
+ 'right_middle3': [6, 276],
443
+ 'right_pinky1': [6, 282],
444
+ 'right_pinky2': [6, 288],
445
+ 'right_pinky3': [6, 294],
446
+
447
+ 'right_ring1': [6, 300],
448
+ 'right_ring2': [6, 306],
449
+ 'right_ring3': [6, 312],
450
+ 'right_thumb1': [6, 318],
451
+ 'right_thumb2': [6, 324],
452
+ 'right_thumb3': [6, 330],
453
+ },
454
+
455
+ "beat_smplx_no_eyes": {
456
+ "pelvis": 3,
457
+ "left_hip": 3,
458
+ "right_hip": 3,
459
+ "spine1": 3,
460
+ "left_knee": 3,
461
+ "right_knee": 3,
462
+ "spine2": 3,
463
+ "left_ankle": 3,
464
+ "right_ankle": 3,
465
+ "spine3": 3,
466
+ "left_foot": 3,
467
+ "right_foot": 3,
468
+ "neck": 3,
469
+ "left_collar": 3,
470
+ "right_collar": 3,
471
+ "head": 3,
472
+ "left_shoulder": 3,
473
+ "right_shoulder": 3,
474
+ "left_elbow": 3,
475
+ "right_elbow": 3,
476
+ "left_wrist": 3,
477
+ "right_wrist": 3,
478
+ "jaw": 3,
479
+ # "left_eye_smplhf":3,
480
+ # "right_eye_smplhf":3,
481
+ "left_index1": 3,
482
+ "left_index2": 3,
483
+ "left_index3": 3,
484
+ "left_middle1": 3,
485
+ "left_middle2": 3,
486
+ "left_middle3": 3,
487
+ "left_pinky1": 3,
488
+ "left_pinky2": 3,
489
+ "left_pinky3": 3,
490
+ "left_ring1": 3,
491
+ "left_ring2": 3,
492
+ "left_ring3": 3,
493
+ "left_thumb1": 3,
494
+ "left_thumb2": 3,
495
+ "left_thumb3": 3,
496
+ "right_index1": 3,
497
+ "right_index2": 3,
498
+ "right_index3": 3,
499
+ "right_middle1": 3,
500
+ "right_middle2": 3,
501
+ "right_middle3": 3,
502
+ "right_pinky1": 3,
503
+ "right_pinky2": 3,
504
+ "right_pinky3": 3,
505
+ "right_ring1": 3,
506
+ "right_ring2": 3,
507
+ "right_ring3": 3,
508
+ "right_thumb1": 3,
509
+ "right_thumb2": 3,
510
+ "right_thumb3": 3,
511
+ },
512
+
513
+ "beat_smplx_full": {
514
+ "pelvis": 3,
515
+ "left_hip": 3,
516
+ "right_hip": 3,
517
+ "spine1": 3,
518
+ "left_knee": 3,
519
+ "right_knee": 3,
520
+ "spine2": 3,
521
+ "left_ankle": 3,
522
+ "right_ankle": 3,
523
+ "spine3": 3,
524
+ "left_foot": 3,
525
+ "right_foot": 3,
526
+ "neck": 3,
527
+ "left_collar": 3,
528
+ "right_collar": 3,
529
+ "head": 3,
530
+ "left_shoulder": 3,
531
+ "right_shoulder": 3,
532
+ "left_elbow": 3,
533
+ "right_elbow": 3,
534
+ "left_wrist": 3,
535
+ "right_wrist": 3,
536
+ "jaw": 3,
537
+ "left_eye_smplhf": 3,
538
+ "right_eye_smplhf": 3,
539
+ "left_index1": 3,
540
+ "left_index2": 3,
541
+ "left_index3": 3,
542
+ "left_middle1": 3,
543
+ "left_middle2": 3,
544
+ "left_middle3": 3,
545
+ "left_pinky1": 3,
546
+ "left_pinky2": 3,
547
+ "left_pinky3": 3,
548
+ "left_ring1": 3,
549
+ "left_ring2": 3,
550
+ "left_ring3": 3,
551
+ "left_thumb1": 3,
552
+ "left_thumb2": 3,
553
+ "left_thumb3": 3,
554
+ "right_index1": 3,
555
+ "right_index2": 3,
556
+ "right_index3": 3,
557
+ "right_middle1": 3,
558
+ "right_middle2": 3,
559
+ "right_middle3": 3,
560
+ "right_pinky1": 3,
561
+ "right_pinky2": 3,
562
+ "right_pinky3": 3,
563
+ "right_ring1": 3,
564
+ "right_ring2": 3,
565
+ "right_ring3": 3,
566
+ "right_thumb1": 3,
567
+ "right_thumb2": 3,
568
+ "right_thumb3": 3,
569
+ },
570
+
571
+ "beat_smplx_upall": {
572
+ # "pelvis":3,
573
+ # "left_hip":3,
574
+ # "right_hip":3,
575
+ "spine1": 3,
576
+ # "left_knee":3,
577
+ # "right_knee":3,
578
+ "spine2": 3,
579
+ # "left_ankle":3,
580
+ # "right_ankle":3,
581
+ "spine3": 3,
582
+ # "left_foot":3,
583
+ # "right_foot":3,
584
+ "neck": 3,
585
+ "left_collar": 3,
586
+ "right_collar": 3,
587
+ "head": 3,
588
+ "left_shoulder": 3,
589
+ "right_shoulder": 3,
590
+ "left_elbow": 3,
591
+ "right_elbow": 3,
592
+ "left_wrist": 3,
593
+ "right_wrist": 3,
594
+ # "jaw":3,
595
+ # "left_eye_smplhf":3,
596
+ # "right_eye_smplhf":3,
597
+ "left_index1": 3,
598
+ "left_index2": 3,
599
+ "left_index3": 3,
600
+ "left_middle1": 3,
601
+ "left_middle2": 3,
602
+ "left_middle3": 3,
603
+ "left_pinky1": 3,
604
+ "left_pinky2": 3,
605
+ "left_pinky3": 3,
606
+ "left_ring1": 3,
607
+ "left_ring2": 3,
608
+ "left_ring3": 3,
609
+ "left_thumb1": 3,
610
+ "left_thumb2": 3,
611
+ "left_thumb3": 3,
612
+ "right_index1": 3,
613
+ "right_index2": 3,
614
+ "right_index3": 3,
615
+ "right_middle1": 3,
616
+ "right_middle2": 3,
617
+ "right_middle3": 3,
618
+ "right_pinky1": 3,
619
+ "right_pinky2": 3,
620
+ "right_pinky3": 3,
621
+ "right_ring1": 3,
622
+ "right_ring2": 3,
623
+ "right_ring3": 3,
624
+ "right_thumb1": 3,
625
+ "right_thumb2": 3,
626
+ "right_thumb3": 3,
627
+ },
628
+
629
+ "beat_smplx_upper": {
630
+ # "pelvis":3,
631
+ # "left_hip":3,
632
+ # "right_hip":3,
633
+ "spine1": 3,
634
+ # "left_knee":3,
635
+ # "right_knee":3,
636
+ "spine2": 3,
637
+ # "left_ankle":3,
638
+ # "right_ankle":3,
639
+ "spine3": 3,
640
+ # "left_foot":3,
641
+ # "right_foot":3,
642
+ "neck": 3,
643
+ "left_collar": 3,
644
+ "right_collar": 3,
645
+ "head": 3,
646
+ "left_shoulder": 3,
647
+ "right_shoulder": 3,
648
+ "left_elbow": 3,
649
+ "right_elbow": 3,
650
+ "left_wrist": 3,
651
+ "right_wrist": 3,
652
+ # "jaw":3,
653
+ # "left_eye_smplhf":3,
654
+ # "right_eye_smplhf":3,
655
+ # "left_index1":3,
656
+ # "left_index2":3,
657
+ # "left_index3":3,
658
+ # "left_middle1":3,
659
+ # "left_middle2":3,
660
+ # "left_middle3":3,
661
+ # "left_pinky1":3,
662
+ # "left_pinky2":3,
663
+ # "left_pinky3":3,
664
+ # "left_ring1":3,
665
+ # "left_ring2":3,
666
+ # "left_ring3":3,
667
+ # "left_thumb1":3,
668
+ # "left_thumb2":3,
669
+ # "left_thumb3":3,
670
+ # "right_index1":3,
671
+ # "right_index2":3,
672
+ # "right_index3":3,
673
+ # "right_middle1":3,
674
+ # "right_middle2":3,
675
+ # "right_middle3":3,
676
+ # "right_pinky1":3,
677
+ # "right_pinky2":3,
678
+ # "right_pinky3":3,
679
+ # "right_ring1":3,
680
+ # "right_ring2":3,
681
+ # "right_ring3":3,
682
+ # "right_thumb1":3,
683
+ # "right_thumb2":3,
684
+ # "right_thumb3":3,
685
+ },
686
+
687
+ "beat_smplx_hands": {
688
+ "left_index1": 3,
689
+ "left_index2": 3,
690
+ "left_index3": 3,
691
+ "left_middle1": 3,
692
+ "left_middle2": 3,
693
+ "left_middle3": 3,
694
+ "left_pinky1": 3,
695
+ "left_pinky2": 3,
696
+ "left_pinky3": 3,
697
+ "left_ring1": 3,
698
+ "left_ring2": 3,
699
+ "left_ring3": 3,
700
+ "left_thumb1": 3,
701
+ "left_thumb2": 3,
702
+ "left_thumb3": 3,
703
+ "right_index1": 3,
704
+ "right_index2": 3,
705
+ "right_index3": 3,
706
+ "right_middle1": 3,
707
+ "right_middle2": 3,
708
+ "right_middle3": 3,
709
+ "right_pinky1": 3,
710
+ "right_pinky2": 3,
711
+ "right_pinky3": 3,
712
+ "right_ring1": 3,
713
+ "right_ring2": 3,
714
+ "right_ring3": 3,
715
+ "right_thumb1": 3,
716
+ "right_thumb2": 3,
717
+ "right_thumb3": 3,
718
+ },
719
+ "beat_smplx_rhands": {
720
+ "right_index1": 3,
721
+ "right_index2": 3,
722
+ "right_index3": 3,
723
+ "right_middle1": 3,
724
+ "right_middle2": 3,
725
+ "right_middle3": 3,
726
+ "right_pinky1": 3,
727
+ "right_pinky2": 3,
728
+ "right_pinky3": 3,
729
+ "right_ring1": 3,
730
+ "right_ring2": 3,
731
+ "right_ring3": 3,
732
+ "right_thumb1": 3,
733
+ "right_thumb2": 3,
734
+ "right_thumb3": 3,
735
+ },
736
+ "beat_smplx_lhands": {
737
+ "left_index1": 3,
738
+ "left_index2": 3,
739
+ "left_index3": 3,
740
+ "left_middle1": 3,
741
+ "left_middle2": 3,
742
+ "left_middle3": 3,
743
+ "left_pinky1": 3,
744
+ "left_pinky2": 3,
745
+ "left_pinky3": 3,
746
+ "left_ring1": 3,
747
+ "left_ring2": 3,
748
+ "left_ring3": 3,
749
+ "left_thumb1": 3,
750
+ "left_thumb2": 3,
751
+ "left_thumb3": 3,
752
+ },
753
+ "beat_smplx_lower": {
754
+ "pelvis": 3,
755
+ "left_hip": 3,
756
+ "right_hip": 3,
757
+ # "spine1":3,
758
+ "left_knee": 3,
759
+ "right_knee": 3,
760
+ # "spine2":3,
761
+ "left_ankle": 3,
762
+ "right_ankle": 3,
763
+ # "spine3":3,
764
+ "left_foot": 3,
765
+ "right_foot": 3,
766
+ # "neck":3,
767
+ # "left_collar":3,
768
+ # "right_collar":3,
769
+ # "head":3,
770
+ # "left_shoulder":3,
771
+ # "right_shoulder":3,
772
+ # "left_elbow":3,
773
+ # "right_elbow":3,
774
+ # "left_wrist":3,
775
+ # "right_wrist":3,
776
+ # "jaw":3,
777
+ # "left_eye_smplhf":3,
778
+ # "right_eye_smplhf":3,
779
+ # "left_index1":3,
780
+ # "left_index2":3,
781
+ # "left_index3":3,
782
+ # "left_middle1":3,
783
+ # "left_middle2":3,
784
+ # "left_middle3":3,
785
+ # "left_pinky1":3,
786
+ # "left_pinky2":3,
787
+ # "left_pinky3":3,
788
+ # "left_ring1":3,
789
+ # "left_ring2":3,
790
+ # "left_ring3":3,
791
+ # "left_thumb1":3,
792
+ # "left_thumb2":3,
793
+ # "left_thumb3":3,
794
+ # "right_index1":3,
795
+ # "right_index2":3,
796
+ # "right_index3":3,
797
+ # "right_middle1":3,
798
+ # "right_middle2":3,
799
+ # "right_middle3":3,
800
+ # "right_pinky1":3,
801
+ # "right_pinky2":3,
802
+ # "right_pinky3":3,
803
+ # "right_ring1":3,
804
+ # "right_ring2":3,
805
+ # "right_ring3":3,
806
+ # "right_thumb1":3,
807
+ # "right_thumb2":3,
808
+ # "right_thumb3":3,
809
+ },
810
+
811
+ "beat_smplx_face": {
812
+ # "pelvis":3,
813
+ # "left_hip":3,
814
+ # "right_hip":3,
815
+ # # "spine1":3,
816
+ # "left_knee":3,
817
+ # "right_knee":3,
818
+ # # "spine2":3,
819
+ # "left_ankle":3,
820
+ # "right_ankle":3,
821
+ # # "spine3":3,
822
+ # "left_foot":3,
823
+ # "right_foot":3,
824
+ # "neck":3,
825
+ # "left_collar":3,
826
+ # "right_collar":3,
827
+ # "head":3,
828
+ # "left_shoulder":3,
829
+ # "right_shoulder":3,
830
+ # "left_elbow":3,
831
+ # "right_elbow":3,
832
+ # "left_wrist":3,
833
+ # "right_wrist":3,
834
+ "jaw": 3,
835
+ # "left_eye_smplhf":3,
836
+ # "right_eye_smplhf":3,
837
+ # "left_index1":3,
838
+ # "left_index2":3,
839
+ # "left_index3":3,
840
+ # "left_middle1":3,
841
+ # "left_middle2":3,
842
+ # "left_middle3":3,
843
+ # "left_pinky1":3,
844
+ # "left_pinky2":3,
845
+ # "left_pinky3":3,
846
+ # "left_ring1":3,
847
+ # "left_ring2":3,
848
+ # "left_ring3":3,
849
+ # "left_thumb1":3,
850
+ # "left_thumb2":3,
851
+ # "left_thumb3":3,
852
+ # "right_index1":3,
853
+ # "right_index2":3,
854
+ # "right_index3":3,
855
+ # "right_middle1":3,
856
+ # "right_middle2":3,
857
+ # "right_middle3":3,
858
+ # "right_pinky1":3,
859
+ # "right_pinky2":3,
860
+ # "right_pinky3":3,
861
+ # "right_ring1":3,
862
+ # "right_ring2":3,
863
+ # "right_ring3":3,
864
+ # "right_thumb1":3,
865
+ # "right_thumb2":3,
866
+ # "right_thumb3":3,
867
+ },
868
+
869
+ "beat_smplx_face_3": {
870
+ # "pelvis":3,
871
+ # "left_hip":3,
872
+ # "right_hip":3,
873
+ # # "spine1":3,
874
+ # "left_knee":3,
875
+ # "right_knee":3,
876
+ # # "spine2":3,
877
+ # "left_ankle":3,
878
+ # "right_ankle":3,
879
+ # # "spine3":3,
880
+ # "left_foot":3,
881
+ # "right_foot":3,
882
+ # "neck":3,
883
+ # "left_collar":3,
884
+ # "right_collar":3,
885
+ # "head":3,
886
+ # "left_shoulder":3,
887
+ # "right_shoulder":3,
888
+ # "left_elbow":3,
889
+ # "right_elbow":3,
890
+ # "left_wrist":3,
891
+ # "right_wrist":3,
892
+ "jaw": 3,
893
+ "left_eye_smplhf": 3,
894
+ "right_eye_smplhf": 3,
895
+ # "left_index1":3,
896
+ # "left_index2":3,
897
+ # "left_index3":3,
898
+ # "left_middle1":3,
899
+ # "left_middle2":3,
900
+ # "left_middle3":3,
901
+ # "left_pinky1":3,
902
+ # "left_pinky2":3,
903
+ # "left_pinky3":3,
904
+ # "left_ring1":3,
905
+ # "left_ring2":3,
906
+ # "left_ring3":3,
907
+ # "left_thumb1":3,
908
+ # "left_thumb2":3,
909
+ # "left_thumb3":3,
910
+ # "right_index1":3,
911
+ # "right_index2":3,
912
+ # "right_index3":3,
913
+ # "right_middle1":3,
914
+ # "right_middle2":3,
915
+ # "right_middle3":3,
916
+ # "right_pinky1":3,
917
+ # "right_pinky2":3,
918
+ # "right_pinky3":3,
919
+ # "right_ring1":3,
920
+ # "right_ring2":3,
921
+ # "right_ring3":3,
922
+ # "right_thumb1":3,
923
+ # "right_thumb2":3,
924
+ # "right_thumb3":3,
925
+ },
926
+ "beat_joints": {
927
+ 'Hips': [6, 6],
928
+ 'Spine': [3, 9],
929
+ 'Spine1': [3, 12],
930
+ 'Spine2': [3, 15],
931
+ 'Spine3': [3, 18],
932
+ 'Neck': [3, 21],
933
+ 'Neck1': [3, 24],
934
+ 'Head': [3, 27],
935
+ 'HeadEnd': [3, 30],
936
+
937
+ 'RShoulder': [3, 33],
938
+ 'RArm': [3, 36],
939
+ 'RArm1': [3, 39],
940
+ 'RHand': [3, 42],
941
+ 'RHandM1': [3, 45],
942
+ 'RHandM2': [3, 48],
943
+ 'RHandM3': [3, 51],
944
+ 'RHandM4': [3, 54],
945
+
946
+ 'RHandR': [3, 57],
947
+ 'RHandR1': [3, 60],
948
+ 'RHandR2': [3, 63],
949
+ 'RHandR3': [3, 66],
950
+ 'RHandR4': [3, 69],
951
+
952
+ 'RHandP': [3, 72],
953
+ 'RHandP1': [3, 75],
954
+ 'RHandP2': [3, 78],
955
+ 'RHandP3': [3, 81],
956
+ 'RHandP4': [3, 84],
957
+
958
+ 'RHandI': [3, 87],
959
+ 'RHandI1': [3, 90],
960
+ 'RHandI2': [3, 93],
961
+ 'RHandI3': [3, 96],
962
+ 'RHandI4': [3, 99],
963
+
964
+ 'RHandT1': [3, 102],
965
+ 'RHandT2': [3, 105],
966
+ 'RHandT3': [3, 108],
967
+ 'RHandT4': [3, 111],
968
+
969
+ 'LShoulder': [3, 114],
970
+ 'LArm': [3, 117],
971
+ 'LArm1': [3, 120],
972
+ 'LHand': [3, 123],
973
+ 'LHandM1': [3, 126],
974
+ 'LHandM2': [3, 129],
975
+ 'LHandM3': [3, 132],
976
+ 'LHandM4': [3, 135],
977
+
978
+ 'LHandR': [3, 138],
979
+ 'LHandR1': [3, 141],
980
+ 'LHandR2': [3, 144],
981
+ 'LHandR3': [3, 147],
982
+ 'LHandR4': [3, 150],
983
+
984
+ 'LHandP': [3, 153],
985
+ 'LHandP1': [3, 156],
986
+ 'LHandP2': [3, 159],
987
+ 'LHandP3': [3, 162],
988
+ 'LHandP4': [3, 165],
989
+
990
+ 'LHandI': [3, 168],
991
+ 'LHandI1': [3, 171],
992
+ 'LHandI2': [3, 174],
993
+ 'LHandI3': [3, 177],
994
+ 'LHandI4': [3, 180],
995
+
996
+ 'LHandT1': [3, 183],
997
+ 'LHandT2': [3, 186],
998
+ 'LHandT3': [3, 189],
999
+ 'LHandT4': [3, 192],
1000
+
1001
+ 'RUpLeg': [3, 195],
1002
+ 'RLeg': [3, 198],
1003
+ 'RFoot': [3, 201],
1004
+ 'RFootF': [3, 204],
1005
+ 'RToeBase': [3, 207],
1006
+ 'RToeBaseEnd': [3, 210],
1007
+
1008
+ 'LUpLeg': [3, 213],
1009
+ 'LLeg': [3, 216],
1010
+ 'LFoot': [3, 219],
1011
+ 'LFootF': [3, 222],
1012
+ 'LToeBase': [3, 225],
1013
+ 'LToeBaseEnd': [3, 228], },
1014
+
1015
+ "beat_full": {
1016
+ 'Hips': 3,
1017
+ 'Spine': 3,
1018
+ 'Spine1': 3,
1019
+ 'Spine2': 3,
1020
+ 'Spine3': 3,
1021
+ 'Neck': 3,
1022
+ 'Neck1': 3,
1023
+ 'Head': 3,
1024
+ 'HeadEnd': 3,
1025
+ 'RShoulder': 3,
1026
+ 'RArm': 3,
1027
+ 'RArm1': 3,
1028
+ 'RHand': 3,
1029
+ 'RHandM1': 3,
1030
+ 'RHandM2': 3,
1031
+ 'RHandM3': 3,
1032
+ 'RHandM4': 3,
1033
+ 'RHandR': 3,
1034
+ 'RHandR1': 3,
1035
+ 'RHandR2': 3,
1036
+ 'RHandR3': 3,
1037
+ 'RHandR4': 3,
1038
+ 'RHandP': 3,
1039
+ 'RHandP1': 3,
1040
+ 'RHandP2': 3,
1041
+ 'RHandP3': 3,
1042
+ 'RHandP4': 3,
1043
+ 'RHandI': 3,
1044
+ 'RHandI1': 3,
1045
+ 'RHandI2': 3,
1046
+ 'RHandI3': 3,
1047
+ 'RHandI4': 3,
1048
+ 'RHandT1': 3,
1049
+ 'RHandT2': 3,
1050
+ 'RHandT3': 3,
1051
+ 'RHandT4': 3,
1052
+ 'LShoulder': 3,
1053
+ 'LArm': 3,
1054
+ 'LArm1': 3,
1055
+ 'LHand': 3,
1056
+ 'LHandM1': 3,
1057
+ 'LHandM2': 3,
1058
+ 'LHandM3': 3,
1059
+ 'LHandM4': 3,
1060
+ 'LHandR': 3,
1061
+ 'LHandR1': 3,
1062
+ 'LHandR2': 3,
1063
+ 'LHandR3': 3,
1064
+ 'LHandR4': 3,
1065
+ 'LHandP': 3,
1066
+ 'LHandP1': 3,
1067
+ 'LHandP2': 3,
1068
+ 'LHandP3': 3,
1069
+ 'LHandP4': 3,
1070
+ 'LHandI': 3,
1071
+ 'LHandI1': 3,
1072
+ 'LHandI2': 3,
1073
+ 'LHandI3': 3,
1074
+ 'LHandI4': 3,
1075
+ 'LHandT1': 3,
1076
+ 'LHandT2': 3,
1077
+ 'LHandT3': 3,
1078
+ 'LHandT4': 3,
1079
+ 'RUpLeg': 3,
1080
+ 'RLeg': 3,
1081
+ 'RFoot': 3,
1082
+ 'RFootF': 3,
1083
+ 'RToeBase': 3,
1084
+ 'RToeBaseEnd': 3,
1085
+ 'LUpLeg': 3,
1086
+ 'LLeg': 3,
1087
+ 'LFoot': 3,
1088
+ 'LFootF': 3,
1089
+ 'LToeBase': 3,
1090
+ 'LToeBaseEnd': 3,
1091
+ },
1092
+
1093
+ "japanese_joints": {
1094
+ 'Hips': [6, 6],
1095
+ 'Spine': [6, 12],
1096
+ 'Spine1': [6, 18],
1097
+ 'Spine2': [6, 24],
1098
+ 'Spine3': [6, 30],
1099
+ 'Neck': [6, 36],
1100
+ 'Neck1': [6, 42],
1101
+ 'Head': [6, 48],
1102
+ 'RShoulder': [6, 54],
1103
+ 'RArm': [6, 60],
1104
+ 'RArm1': [6, 66],
1105
+ 'RHand': [6, 72],
1106
+ 'RHandM1': [6, 78],
1107
+ 'RHandM2': [6, 84],
1108
+ 'RHandM3': [6, 90],
1109
+ 'RHandR': [6, 96],
1110
+ 'RHandR1': [6, 102],
1111
+ 'RHandR2': [6, 108],
1112
+ 'RHandR3': [6, 114],
1113
+ 'RHandP': [6, 120],
1114
+ 'RHandP1': [6, 126],
1115
+ 'RHandP2': [6, 132],
1116
+ 'RHandP3': [6, 138],
1117
+ 'RHandI': [6, 144],
1118
+ 'RHandI1': [6, 150],
1119
+ 'RHandI2': [6, 156],
1120
+ 'RHandI3': [6, 162],
1121
+ 'RHandT1': [6, 168],
1122
+ 'RHandT2': [6, 174],
1123
+ 'RHandT3': [6, 180],
1124
+ 'LShoulder': [6, 186],
1125
+ 'LArm': [6, 192],
1126
+ 'LArm1': [6, 198],
1127
+ 'LHand': [6, 204],
1128
+ 'LHandM1': [6, 210],
1129
+ 'LHandM2': [6, 216],
1130
+ 'LHandM3': [6, 222],
1131
+ 'LHandR': [6, 228],
1132
+ 'LHandR1': [6, 234],
1133
+ 'LHandR2': [6, 240],
1134
+ 'LHandR3': [6, 246],
1135
+ 'LHandP': [6, 252],
1136
+ 'LHandP1': [6, 258],
1137
+ 'LHandP2': [6, 264],
1138
+ 'LHandP3': [6, 270],
1139
+ 'LHandI': [6, 276],
1140
+ 'LHandI1': [6, 282],
1141
+ 'LHandI2': [6, 288],
1142
+ 'LHandI3': [6, 294],
1143
+ 'LHandT1': [6, 300],
1144
+ 'LHandT2': [6, 306],
1145
+ 'LHandT3': [6, 312],
1146
+ 'RUpLeg': [6, 318],
1147
+ 'RLeg': [6, 324],
1148
+ 'RFoot': [6, 330],
1149
+ 'RFootF': [6, 336],
1150
+ 'RToeBase': [6, 342],
1151
+ 'LUpLeg': [6, 348],
1152
+ 'LLeg': [6, 354],
1153
+ 'LFoot': [6, 360],
1154
+ 'LFootF': [6, 366],
1155
+ 'LToeBase': [6, 372], },
1156
+
1157
+ "yostar": {
1158
+ 'Hips': [6, 6],
1159
+ 'Spine': [3, 9],
1160
+ 'Spine1': [3, 12],
1161
+ 'Bone040': [3, 15],
1162
+ 'Bone041': [3, 18],
1163
+
1164
+ 'Bone034': [3, 21],
1165
+ 'Bone035': [3, 24],
1166
+ 'Bone036': [3, 27],
1167
+ 'Bone037': [3, 30],
1168
+ 'Bone038': [3, 33],
1169
+ 'Bone039': [3, 36],
1170
+
1171
+ 'RibbonL1': [3, 39],
1172
+ 'RibbonL1_end': [3, 42],
1173
+
1174
+ 'Chest': [3, 45],
1175
+ 'L_eri': [3, 48],
1176
+ 'R_eri': [3, 51],
1177
+ 'Neck': [3, 54],
1178
+ 'Head': [3, 57],
1179
+ 'Head_end': [3, 60],
1180
+
1181
+ 'RBackHair_1': [3, 63],
1182
+ 'RBackHair_2': [3, 66],
1183
+ 'RBackHair_3': [3, 69],
1184
+ 'RBackHair_4': [3, 72],
1185
+ 'RBackHair_end': [3, 75],
1186
+
1187
+ 'RFrontHair': [3, 78],
1188
+ 'CFrontHair_1': [3, 81],
1189
+ 'CFrontHair_2': [3, 84],
1190
+ 'CFrontHair_3': [3, 87],
1191
+ 'CFrontHair_emd': [3, 90],
1192
+
1193
+ 'LFrontHair_1': [3, 93],
1194
+ 'LFrontHair_2': [3, 96],
1195
+ 'LFrontHair_3': [3, 99],
1196
+
1197
+ 'LBackHair_1': [3, 102],
1198
+ 'LBackHair_2': [3, 105],
1199
+ 'LBackHair_3': [3, 108],
1200
+ 'LBackHair_4': [3, 111],
1201
+ 'LBackHair_end': [3, 114],
1202
+
1203
+ 'LSideHair_1': [3, 117],
1204
+ 'LSideHair_2': [3, 120],
1205
+ 'LSideHair_3': [3, 123],
1206
+ 'LSideHair_4': [3, 126],
1207
+ 'LSideHair_5': [3, 129],
1208
+ 'LSideHair_6': [3, 132],
1209
+ 'LSideHair_7': [3, 135],
1210
+ 'LSideHair_end': [3, 138],
1211
+
1212
+ 'CBackHair_1': [3, 141],
1213
+ 'CBackHair_2': [3, 144],
1214
+ 'CBackHair_3': [3, 147],
1215
+ 'CBackHair_4': [3, 150],
1216
+ 'CBackHair_end': [3, 153],
1217
+
1218
+ 'RSideHair_1': [3, 156],
1219
+ 'RSideHair_2': [3, 159],
1220
+ 'RSideHair_3': [3, 162],
1221
+ 'RSideHair_4': [3, 165],
1222
+
1223
+ 'RibbonR_1': [3, 168],
1224
+ 'RibbonR_2': [3, 171],
1225
+ 'RibbonR_3': [3, 174],
1226
+
1227
+ 'RibbonL_1': [3, 177],
1228
+ 'RibbonL_2': [3, 180],
1229
+ 'RibbonL_3': [3, 183],
1230
+
1231
+ 'LeftEye': [3, 186],
1232
+ 'LeftEye_end': [3, 189],
1233
+ 'RightEye': [3, 192],
1234
+ 'RightEye_end': [3, 195],
1235
+
1236
+ 'LeftShoulder': [3, 198],
1237
+ 'LeftArm': [3, 201],
1238
+ 'LeftForearm': [3, 204],
1239
+ 'LeftHand': [3, 207],
1240
+ 'LeftHandThumb1': [3, 210],
1241
+ 'LeftHandThumb2': [3, 213],
1242
+ 'LeftHandThumb3': [3, 216],
1243
+ 'LeftHandThumb_end': [3, 219],
1244
+
1245
+ 'LeftHandIndex1': [3, 222],
1246
+ 'LeftHandIndex2': [3, 225],
1247
+ 'LeftHandIndex3': [3, 228],
1248
+ 'LeftHandIndex_end': [3, 231],
1249
+
1250
+ 'LeftHandMiddle1': [3, 234],
1251
+ 'LeftHandMiddle2': [3, 237],
1252
+ 'LeftHandMiddle3': [3, 240],
1253
+ 'LeftHandMiddle_end': [3, 243],
1254
+
1255
+ 'LeftHandRing1': [3, 246],
1256
+ 'LeftHandRing2': [3, 249],
1257
+ 'LeftHandRing3': [3, 252],
1258
+ 'LeftHandRing_end': [3, 255],
1259
+
1260
+ 'LeftHandPinky1': [3, 258],
1261
+ 'LeftHandPinky2': [3, 261],
1262
+ 'LeftHandPinky3': [3, 264],
1263
+ 'LeftHandPinky_end': [3, 267],
1264
+
1265
+ 'RightShoulder': [3, 270],
1266
+ 'RightArm': [3, 273],
1267
+ 'RightForearm': [3, 276],
1268
+ 'RightHand': [3, 279],
1269
+ 'RightHandThumb1': [3, 282],
1270
+ 'RightHandThumb2': [3, 285],
1271
+ 'RightHandThumb3': [3, 288],
1272
+ 'RightHandThumb_end': [3, 291],
1273
+
1274
+ 'RightHandIndex1': [3, 294],
1275
+ 'RightHandIndex2': [3, 297],
1276
+ 'RightHandIndex3': [3, 300],
1277
+ 'RightHandIndex_end': [3, 303],
1278
+
1279
+ 'RightHandMiddle1': [3, 306],
1280
+ 'RightHandMiddle2': [3, 309],
1281
+ 'RightHandMiddle3': [3, 312],
1282
+ 'RightHandMiddle_end': [3, 315],
1283
+
1284
+ 'RightHandRing1': [3, 318],
1285
+ 'RightHandRing2': [3, 321],
1286
+ 'RightHandRing3': [3, 324],
1287
+ 'RightHandRing_end': [3, 327],
1288
+
1289
+ 'RightHandPinky1': [3, 330],
1290
+ 'RightHandPinky2': [3, 333],
1291
+ 'RightHandPinky3': [3, 336],
1292
+ 'RightHandPinky_end': [3, 339],
1293
+
1294
+ 'RibbonR1': [3, 342],
1295
+ 'RibbonR1_end': [3, 345],
1296
+ 'RibbonR2': [3, 348],
1297
+ 'RibbonR2_end': [3, 351],
1298
+ 'RibbonL2': [3, 354],
1299
+ 'RibbonL2_end': [3, 357],
1300
+
1301
+ 'LeftUpLeg': [3, 360],
1302
+ 'LeftLeg': [3, 363],
1303
+ 'LeftFoot': [3, 366],
1304
+ 'LeftToe': [3, 369],
1305
+ 'LeftToe_end': [3, 372],
1306
+
1307
+ 'RightUpLeg': [3, 375],
1308
+ 'RightLEg': [3, 378],
1309
+ 'RightFoot': [3, 381],
1310
+ 'RightToe': [3, 384],
1311
+ 'RightToe_end': [3, 387],
1312
+
1313
+ 'bone_skirtF00': [3, 390],
1314
+ 'bone_skirtF01': [3, 393],
1315
+ 'bone_skirtF02': [3, 396],
1316
+ 'bone_skirtF03': [3, 399],
1317
+ 'Bone020': [3, 402],
1318
+ 'Bone026': [3, 405],
1319
+
1320
+ 'bone_skirtF_R_00': [3, 408],
1321
+ 'bone_skirtF_R_01': [3, 411],
1322
+ 'bone_skirtF_R_02': [3, 414],
1323
+ 'bone_skirtF_R_03': [3, 417],
1324
+ 'Bone019': [3, 420],
1325
+ 'Bone028': [3, 423],
1326
+
1327
+ 'bone_skirtR00': [3, 426],
1328
+ 'bone_skirtR01': [3, 429],
1329
+ 'bone_skirtR02': [3, 432],
1330
+ 'bone_skirtR03': [3, 435],
1331
+ 'Bone018': [3, 438],
1332
+ 'Bone029': [3, 441],
1333
+
1334
+ 'bone_skirtF_L_00': [3, 444],
1335
+ 'bone_skirtF_L_01': [3, 447],
1336
+ 'bone_skirtF_L_02': [3, 450],
1337
+ 'bone_skirtF_L_03': [3, 453],
1338
+ 'Bone021': [3, 456],
1339
+ 'Bone027': [3, 459],
1340
+
1341
+ 'bone_skirtL00': [3, 462],
1342
+ 'bone_skirtL01': [3, 465],
1343
+ 'bone_skirtL02': [3, 468],
1344
+ 'bone_skirtL03': [3, 471],
1345
+ 'Bone022': [3, 474],
1346
+ 'Bone033': [3, 477],
1347
+
1348
+ 'bone_skirtB_L_00': [3, 480],
1349
+ 'bone_skirtB_L_01': [3, 483],
1350
+ 'bone_skirtB_L_02': [3, 486],
1351
+ 'bone_skirtB_L_03': [3, 489],
1352
+ 'Bone023': [3, 492],
1353
+ 'Bone032': [3, 495],
1354
+
1355
+ 'bone_skirtB00': [3, 498],
1356
+ 'bone_skirtB01': [3, 501],
1357
+ 'bone_skirtB02': [3, 504],
1358
+ 'bone_skirtB03': [3, 507],
1359
+ 'Bone024': [3, 510],
1360
+ 'Bone031': [3, 513],
1361
+
1362
+ 'bone_skirtB_R_00': [3, 516],
1363
+ 'bone_skirtB_R_01': [3, 519],
1364
+ 'bone_skirtB_R_02': [3, 521],
1365
+ 'bone_skirtB_R_03': [3, 524],
1366
+ 'Bone025': [3, 527],
1367
+ 'Bone030': [3, 530],
1368
+ },
1369
+
1370
+ "yostar_fullbody_213": {
1371
+ 'Hips': 3,
1372
+ 'Spine': 3,
1373
+ 'Spine1': 3,
1374
+ 'Chest': 3,
1375
+ 'L_eri': 3,
1376
+ 'R_eri': 3,
1377
+ 'Neck': 3,
1378
+ 'Head': 3,
1379
+ 'Head_end': 3,
1380
+
1381
+ 'LeftEye': 3,
1382
+ 'LeftEye_end': 3,
1383
+ 'RightEye': 3,
1384
+ 'RightEye_end': 3,
1385
+
1386
+ 'LeftShoulder': 3,
1387
+ 'LeftArm': 3,
1388
+ 'LeftForearm': 3,
1389
+ 'LeftHand': 3,
1390
+ 'LeftHandThumb1': 3,
1391
+ 'LeftHandThumb2': 3,
1392
+ 'LeftHandThumb3': 3,
1393
+ 'LeftHandThumb_end': 3,
1394
+
1395
+ 'LeftHandIndex1': 3,
1396
+ 'LeftHandIndex2': 3,
1397
+ 'LeftHandIndex3': 3,
1398
+ 'LeftHandIndex_end': 3,
1399
+
1400
+ 'LeftHandMiddle1': 3,
1401
+ 'LeftHandMiddle2': 3,
1402
+ 'LeftHandMiddle3': 3,
1403
+ 'LeftHandMiddle_end': 3,
1404
+
1405
+ 'LeftHandRing1': 3,
1406
+ 'LeftHandRing2': 3,
1407
+ 'LeftHandRing3': 3,
1408
+ 'LeftHandRing_end': 3,
1409
+
1410
+ 'LeftHandPinky1': 3,
1411
+ 'LeftHandPinky2': 3,
1412
+ 'LeftHandPinky3': 3,
1413
+ 'LeftHandPinky_end': 3,
1414
+
1415
+ 'RightShoulder': 3,
1416
+ 'RightArm': 3,
1417
+ 'RightForearm': 3,
1418
+ 'RightHand': 3,
1419
+ 'RightHandThumb1': 3,
1420
+ 'RightHandThumb2': 3,
1421
+ 'RightHandThumb3': 3,
1422
+ 'RightHandThumb_end': 3,
1423
+
1424
+ 'RightHandIndex1': 3,
1425
+ 'RightHandIndex2': 3,
1426
+ 'RightHandIndex3': 3,
1427
+ 'RightHandIndex_end': 3,
1428
+
1429
+ 'RightHandMiddle1': 3,
1430
+ 'RightHandMiddle2': 3,
1431
+ 'RightHandMiddle3': 3,
1432
+ 'RightHandMiddle_end': 3,
1433
+
1434
+ 'RightHandRing1': 3,
1435
+ 'RightHandRing2': 3,
1436
+ 'RightHandRing3': 3,
1437
+ 'RightHandRing_end': 3,
1438
+
1439
+ 'RightHandPinky1': 3,
1440
+ 'RightHandPinky2': 3,
1441
+ 'RightHandPinky3': 3,
1442
+ 'RightHandPinky_end': 3,
1443
+
1444
+ 'LeftUpLeg': 3,
1445
+ 'LeftLeg': 3,
1446
+ 'LeftFoot': 3,
1447
+ 'LeftToe': 3,
1448
+ 'LeftToe_end': 3,
1449
+
1450
+ 'RightUpLeg': 3,
1451
+ 'RightLEg': 3,
1452
+ 'RightFoot': 3,
1453
+ 'RightToe': 3,
1454
+ 'RightToe_end': 3,
1455
+ },
1456
+ "yostar_mainbody_48": {
1457
+ # 'Hips': 3 ,
1458
+ 'Spine': 3,
1459
+ 'Spine1': 3,
1460
+ 'Chest': 3,
1461
+ 'L_eri': 3,
1462
+ 'R_eri': 3,
1463
+ 'Neck': 3,
1464
+ 'Head': 3,
1465
+ 'Head_end': 3,
1466
+
1467
+ 'LeftShoulder': 3,
1468
+ 'LeftArm': 3,
1469
+ 'LeftForearm': 3,
1470
+ 'LeftHand': 3,
1471
+
1472
+ 'RightShoulder': 3,
1473
+ 'RightArm': 3,
1474
+ 'RightForearm': 3,
1475
+ 'RightHand': 3,
1476
+ },
1477
+ "yostar_mainbody_69": {
1478
+ 'Hips': 3,
1479
+ 'Spine': 3,
1480
+ 'Spine1': 3,
1481
+ 'Chest': 3,
1482
+ 'L_eri': 3,
1483
+ 'R_eri': 3,
1484
+ 'Neck': 3,
1485
+ 'Head': 3,
1486
+ 'Head_end': 3,
1487
+
1488
+ 'LeftShoulder': 3,
1489
+ 'LeftArm': 3,
1490
+ 'LeftForearm': 3,
1491
+ 'LeftHand': 3,
1492
+
1493
+ 'RightShoulder': 3,
1494
+ 'RightArm': 3,
1495
+ 'RightForearm': 3,
1496
+ 'RightHand': 3,
1497
+
1498
+ 'LeftUpLeg': 3,
1499
+ 'LeftLeg': 3,
1500
+ 'LeftFoot': 3,
1501
+
1502
+ 'RightUpLeg': 3,
1503
+ 'RightLEg': 3,
1504
+ 'RightFoot': 3,
1505
+ },
1506
+
1507
+ "yostar_upbody_168": {
1508
+ # 'Hips': 3 ,
1509
+ 'Spine': 3,
1510
+ 'Spine1': 3,
1511
+ 'Chest': 3,
1512
+ 'L_eri': 3,
1513
+ 'R_eri': 3,
1514
+ 'Neck': 3,
1515
+ 'Head': 3,
1516
+ 'Head_end': 3,
1517
+
1518
+ 'LeftShoulder': 3,
1519
+ 'LeftArm': 3,
1520
+ 'LeftForearm': 3,
1521
+ 'LeftHand': 3,
1522
+ 'LeftHandThumb1': 3,
1523
+ 'LeftHandThumb2': 3,
1524
+ 'LeftHandThumb3': 3,
1525
+ 'LeftHandThumb_end': 3,
1526
+
1527
+ 'LeftHandIndex1': 3,
1528
+ 'LeftHandIndex2': 3,
1529
+ 'LeftHandIndex3': 3,
1530
+ 'LeftHandIndex_end': 3,
1531
+
1532
+ 'LeftHandMiddle1': 3,
1533
+ 'LeftHandMiddle2': 3,
1534
+ 'LeftHandMiddle3': 3,
1535
+ 'LeftHandMiddle_end': 3,
1536
+
1537
+ 'LeftHandRing1': 3,
1538
+ 'LeftHandRing2': 3,
1539
+ 'LeftHandRing3': 3,
1540
+ 'LeftHandRing_end': 3,
1541
+
1542
+ 'LeftHandPinky1': 3,
1543
+ 'LeftHandPinky2': 3,
1544
+ 'LeftHandPinky3': 3,
1545
+ 'LeftHandPinky_end': 3,
1546
+
1547
+ 'RightShoulder': 3,
1548
+ 'RightArm': 3,
1549
+ 'RightForearm': 3,
1550
+ 'RightHand': 3,
1551
+ 'RightHandThumb1': 3,
1552
+ 'RightHandThumb2': 3,
1553
+ 'RightHandThumb3': 3,
1554
+ 'RightHandThumb_end': 3,
1555
+
1556
+ 'RightHandIndex1': 3,
1557
+ 'RightHandIndex2': 3,
1558
+ 'RightHandIndex3': 3,
1559
+ 'RightHandIndex_end': 3,
1560
+
1561
+ 'RightHandMiddle1': 3,
1562
+ 'RightHandMiddle2': 3,
1563
+ 'RightHandMiddle3': 3,
1564
+ 'RightHandMiddle_end': 3,
1565
+
1566
+ 'RightHandRing1': 3,
1567
+ 'RightHandRing2': 3,
1568
+ 'RightHandRing3': 3,
1569
+ 'RightHandRing_end': 3,
1570
+
1571
+ 'RightHandPinky1': 3,
1572
+ 'RightHandPinky2': 3,
1573
+ 'RightHandPinky3': 3,
1574
+ 'RightHandPinky_end': 3,
1575
+ },
1576
+ "spine_neck_141": {
1577
+ 'Spine': 3,
1578
+ 'Neck': 3,
1579
+ 'Neck1': 3,
1580
+ 'RShoulder': 3,
1581
+ 'RArm': 3,
1582
+ 'RArm1': 3,
1583
+ 'RHand': 3,
1584
+ 'RHandM1': 3,
1585
+ 'RHandM2': 3,
1586
+ 'RHandM3': 3,
1587
+ 'RHandR': 3,
1588
+ 'RHandR1': 3,
1589
+ 'RHandR2': 3,
1590
+ 'RHandR3': 3,
1591
+ 'RHandP': 3,
1592
+ 'RHandP1': 3,
1593
+ 'RHandP2': 3,
1594
+ 'RHandP3': 3,
1595
+ 'RHandI': 3,
1596
+ 'RHandI1': 3,
1597
+ 'RHandI2': 3,
1598
+ 'RHandI3': 3,
1599
+ 'RHandT1': 3,
1600
+ 'RHandT2': 3,
1601
+ 'RHandT3': 3,
1602
+ 'LShoulder': 3,
1603
+ 'LArm': 3,
1604
+ 'LArm1': 3,
1605
+ 'LHand': 3,
1606
+ 'LHandM1': 3,
1607
+ 'LHandM2': 3,
1608
+ 'LHandM3': 3,
1609
+ 'LHandR': 3,
1610
+ 'LHandR1': 3,
1611
+ 'LHandR2': 3,
1612
+ 'LHandR3': 3,
1613
+ 'LHandP': 3,
1614
+ 'LHandP1': 3,
1615
+ 'LHandP2': 3,
1616
+ 'LHandP3': 3,
1617
+ 'LHandI': 3,
1618
+ 'LHandI1': 3,
1619
+ 'LHandI2': 3,
1620
+ 'LHandI3': 3,
1621
+ 'LHandT1': 3,
1622
+ 'LHandT2': 3,
1623
+ 'LHandT3': 3, },
1624
+ }
1625
+
1626
+
1627
+
1628
+
1629
+
1630
+
1631
+
1632
+
1633
+ def GetBodyPartIndices(part_name="upper", rotation_method='axisangle'):
1634
+ if part_name == "upper":
1635
+ part_name = "beat_smplx_upper"
1636
+ elif part_name == "lower":
1637
+ part_name = "beat_smplx_lower"
1638
+ elif part_name == "hand":
1639
+ part_name = "beat_smplx_hands"
1640
+ elif part_name == "face":
1641
+ part_name = "beat_smplx_face_3"
1642
+ elif part_name == "all":
1643
+ part_name = "beat_smplx_full"
1644
+ elif part_name == "lhand":
1645
+ part_name = "beat_smplx_lhands"
1646
+ elif part_name == "rhand":
1647
+ part_name = "beat_smplx_rhands"
1648
+ else:
1649
+ assert 0 == 1
1650
+ upper_names = joints_list[part_name].keys()
1651
+ upper_start_indices = [joints_list['beat_smplx_joints']
1652
+ [name][1] // 3 - 1 for name in upper_names]
1653
+ upper_indices = []
1654
+
1655
+ offset = 3
1656
+ if rotation_method == 'axisangle':
1657
+ offset = 3
1658
+ elif rotation_method == 'rot6d':
1659
+ offset = 6
1660
+ elif rotation_method == None:
1661
+ offset = 1
1662
+ else:
1663
+ assert 0 == 1
1664
+ for idx in upper_start_indices:
1665
+ upper_indices = upper_indices + \
1666
+ list(range(idx * offset, idx * offset+offset))
1667
+ return np.array(upper_indices)
1668
+
1669
+
1670
+
1671
+
1672
+ if __name__ == '__main__':
1673
+ print("#beat_smplx_upper", len(joints_list['beat_smplx_upper']))
1674
+ print("#beat_smplx_lower", len(joints_list['beat_smplx_lower']))
1675
+ print("#beat_smplx_hands", len(joints_list['beat_smplx_hands']))
1676
+ print("#beat_smplx_face_3", len(joints_list['beat_smplx_face_3']))
1677
+
1678
+
1679
+ print((GetBodyPartIndices("lower")[0::3]))
retrained_20261113/globaldiff_e630_all_cfg1p25/source/Scripts/SMPLX_Util.py ADDED
@@ -0,0 +1,278 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ '''
3
+ Copyright (c) 2021, Alibaba Cloud and its affiliates;
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ '''
16
+
17
+ import os
18
+
19
+ import smplx
20
+ import numpy as np
21
+ import torch
22
+ from typing import Optional, Dict
23
+
24
+ from Util import *
25
+
26
+ def _resolve_smplx_model_path(model_folder: Optional[str] = None):
27
+ if model_folder is not None:
28
+ return model_folder
29
+
30
+ env_path = os.environ.get("GLOBALDIFF_SMPLX_MODEL_PATH")
31
+ if env_path:
32
+ return env_path
33
+
34
+ candidate_paths = [
35
+ "/mnt/4TDisk/mm_data/mm/project/LargeMotionModel/Data/SMPLX_NEUTRAL_2020.npz",
36
+ os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "Data", "SMPLX_NEUTRAL_2020.npz")),
37
+ ]
38
+ for path in candidate_paths:
39
+ if os.path.exists(path):
40
+ return path
41
+
42
+ raise FileNotFoundError(
43
+ "SMPL-X model file not found. Set GLOBALDIFF_SMPLX_MODEL_PATH "
44
+ "or place SMPLX_NEUTRAL_2020.npz under Data/."
45
+ )
46
+
47
+
48
+ def GetSMPLXModel(model_folder: Optional[str] = None):
49
+ model_folder = _resolve_smplx_model_path(model_folder)
50
+ model = smplx.create(model_folder,
51
+ model_type="smplx",
52
+ gender="neutral",
53
+ use_face_contour=False,
54
+ num_betas=300,
55
+ num_expression_coeffs=100,
56
+ ext="npz",
57
+ use_pca=False,
58
+ flat_hand_mean=True)
59
+ return model
60
+
61
+
62
+
63
+ def SplitPosesIntoSmplxParams(poses):
64
+ params = {}
65
+ params["global_orient"] = poses[...,0:3]
66
+ params["body_pose"] = poses[...,3:63 + 3]
67
+ params["jaw_pose"] = poses[...,63 + 3:63 + 6]
68
+ params["leye_pose"] = poses[...,63 + 6:63 + 9]
69
+ params["reye_pose"] = poses[...,63 + 9:63 + 12]
70
+ params["left_hand_pose"] = poses[...,75:75 + 45]
71
+ params["right_hand_pose"] = poses[...,75 + 45:75 + 90]
72
+ return params
73
+
74
+
75
+
76
+ SMPLX_PARENTS = [-1, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 9, 12, 13, 14, 16, 17, 18, 19, 15, 15, 15, 20, 25, 26, 20, 28, 29, 20, 31, 32, 20, 34, 35, 20, 37, 38, 21, 40, 41, 21, 43, 44, 21, 46, 47, 21, 49, 50, 21, 52, 53]
77
+ def local_to_global_batch(local_rot, parents=SMPLX_PARENTS):
78
+ """
79
+ 將局部旋轉轉換為全局旋轉。
80
+
81
+ 參數:
82
+ local_rot (torch.Tensor): 局部旋轉矩陣,形狀為 (batch_size, num_joints, 3, 3)
83
+ parents (list[int]): 父節點索引列表,長度為 num_joints
84
+
85
+ 返回:
86
+ torch.Tensor: 全局旋轉矩陣,形狀同輸入
87
+ """
88
+ batch_size, num_joints, _, _ = local_rot.shape
89
+ xp = torch if isinstance(local_rot, torch.Tensor) else np
90
+ global_rot = xp.empty_like(local_rot)
91
+
92
+ for i in range(num_joints):
93
+ if parents[i] == -1:
94
+ # 根節點,直接使用局部旋轉
95
+ global_rot[:, i] = local_rot[:, i]
96
+ else:
97
+ # 獲取父節點的全局旋轉並與當前局部旋轉相乘
98
+ parent_rot = global_rot[:, parents[i]] # (B, 3, 3)
99
+ current_local = local_rot[:, i] # (B, 3, 3)
100
+ global_rot[:, i] = parent_rot @ current_local
101
+
102
+ return global_rot
103
+
104
+
105
+
106
+
107
+
108
+
109
+ def global_to_local_batch(global_rot, parents=SMPLX_PARENTS):
110
+ """
111
+ 將全局旋轉轉換為局部旋轉。
112
+
113
+ 參數:
114
+ global_rot (torch.Tensor): 全局旋轉矩陣,形狀為 (batch_size, num_joints, 3, 3)
115
+ parents (list[int]): 父節點索引列表,長度為 num_joints
116
+
117
+ 返回:
118
+ torch.Tensor: 局部旋轉矩陣,形狀同輸入
119
+ """
120
+ batch_size, num_joints, _, _ = global_rot.shape
121
+ xp = torch if isinstance(global_rot, torch.Tensor) else np
122
+ local_rot = xp.empty_like(global_rot)
123
+
124
+ for i in range(num_joints):
125
+ if parents[i] == -1:
126
+ # 根節點,局部旋轉等於全局旋轉
127
+ local_rot[:, i] = global_rot[:, i]
128
+ else:
129
+ # 計算父節點旋轉的逆矩陣(轉置,因旋轉矩陣正交)
130
+ parent_rot = global_rot[:, parents[i]] # (B, 3, 3)
131
+ if xp == torch:
132
+ inv_parent_rot = parent_rot.transpose(-1, -2) # (B, 3, 3)
133
+ else:
134
+ inv_parent_rot = np.transpose(parent_rot, axes=(0, 2, 1))
135
+ current_global = global_rot[:, i] # (B, 3, 3)
136
+ local_rot[:, i] = inv_parent_rot @ current_global
137
+
138
+ return local_rot
139
+
140
+
141
+ def LocalToGlobalAA(poses:np.ndarray):
142
+ L,C = poses.shape
143
+ mat = axis_angle_to_rotation_matrix(poses.reshape((-1, 3))).reshape((L,-1, 3,3))
144
+ mat = local_to_global_batch(mat)
145
+ aa = rotation_matrix_to_axis_angle(mat)
146
+ return aa.reshape((L, C))
147
+
148
+
149
+ def GlobalToLocalAA(poses:np.ndarray):
150
+ L,C = poses.shape
151
+ mat = axis_angle_to_rotation_matrix(poses.reshape((L, -1, 3)))
152
+ mat = global_to_local_batch(mat)
153
+ aa = rotation_matrix_to_axis_angle(mat)
154
+ return aa.reshape((L, C))
155
+
156
+
157
+
158
+ def MakeAdjacencyMatrix():
159
+ mask = np.zeros((55,55))
160
+ for i in range(0, len(SMPLX_PARENTS)):
161
+ parent_idx = SMPLX_PARENTS[i]
162
+ if parent_idx != -1:
163
+ mask[i, parent_idx] = 1
164
+ mask[parent_idx, i] = 1
165
+ mask[i,i] = 1
166
+ return mask < 0.5
167
+
168
+
169
+
170
+
171
+ def symmetrize_smplx_parameters(pose_params, trans):
172
+ """
173
+ 对称化 SMPLX 模型的姿态和形状参数
174
+
175
+ 参数:
176
+ pose_params: 姿态参数, shape (N, 165) 或 (165,)
177
+ beta_params: 形状参数, shape (N, 10) 或 (10,), 可选
178
+ left_right_pairs: 左右关节对的列表, 可选
179
+
180
+ 返回:
181
+ 对称化后的姿态参数和形状参数
182
+ """
183
+
184
+ # SMPLX 标准左右关节对 (0-based 索引)
185
+ left_right_pairs =( (1,2), (4,5), (7,8), (10,11), (13,14), (16,17), (18,19), (20,21), # body
186
+ (23,24), #eyes
187
+ (25,40), (26,41), (27,42), (28,43), (29,44), (30,45), (31,46), (32,47), (33,48), (34,49), (35,50), (36,51), (37,52), (38,53), (39,54) # hands
188
+ )
189
+
190
+ # 确保输入是 torch.Tensor
191
+ if not isinstance(pose_params, torch.Tensor):
192
+ pose_params = torch.tensor(pose_params, dtype=torch.float32)
193
+ if not isinstance(trans, torch.Tensor):
194
+ trans = torch.tensor(trans, dtype=torch.float32)
195
+
196
+
197
+ # 创建对称的姿态参数
198
+ sym_pose = pose_params.clone()
199
+
200
+ # 对每个左右对进行对称化
201
+ for left, right in left_right_pairs:
202
+ # 确保索引在有效范围内
203
+ if left*3+3 <= sym_pose.shape[1] and right*3+3 <= sym_pose.shape[1]:
204
+ # 交换左右参数并翻转旋转方向
205
+ left_rot = sym_pose[:, left*3:left*3+3].clone()
206
+ right_rot = sym_pose[:, right*3:right*3+3].clone()
207
+
208
+ # 对称化: 左右交换并翻转某些轴的旋转
209
+ sym_pose[:, left*3:left*3+3] = right_rot * torch.tensor([1, -1, -1], dtype=torch.float32)
210
+ sym_pose[:, right*3:right*3+3] = left_rot * torch.tensor([1, -1, -1], dtype=torch.float32)
211
+
212
+ sym_pose[:, 0:3] = pose_params[:, 0:3] * torch.tensor([1, -1, -1], dtype=torch.float32)
213
+ sym_trans = trans.clone()
214
+ sym_trans[...,0] *=-1
215
+ return sym_pose, sym_trans
216
+
217
+
218
+
219
+ if __name__ =="__main__":
220
+ # print(__path__)
221
+
222
+ def WriteObj(filename, verts, faces=None):
223
+ with open(filename, 'w') as fh:
224
+ for v in verts:
225
+ fh.write('v %f %f %f\n' % (v[0], v[1], v[2]))
226
+ if faces is not None:
227
+ for f in faces:
228
+ fh.write('f %d %d %d\n' % (f[0] + 1, f[1] + 1, f[2] + 1))
229
+
230
+
231
+ smplx_model = GetSMPLXModel().requires_grad_(False).eval().cuda()
232
+ from BEATXDataset import LMDBDataset
233
+ lmdb_path = "/mnt/4TDisk/mm_data/mm/data/BEAT/V2/seq_size_60_stride_size_20.lmdb"
234
+ lmdb_hubert = None
235
+ ds = LMDBDataset(lmdb_path, lmdb_hubert, rotation_method="axisangle",)
236
+ num_person = 0
237
+
238
+
239
+
240
+
241
+
242
+ rest_joints_state = {}
243
+ from tqdm import tqdm
244
+ for data_id in tqdm(range(0, len(ds)), total=len(ds)):
245
+ poses = ds[data_id]["poses"].cuda()
246
+ pid = int(ds[data_id]["pid"])
247
+ betas = ds[data_id]["betas"].cuda()
248
+ shape_betas = betas.reshape((1, -1)).repeat((len(poses), 1))
249
+ expressions = ds[data_id]["expressions"].cuda()
250
+ trans = ds[data_id]["trans"].cuda()
251
+ J = ds[data_id]["J"].cuda()
252
+
253
+ # smplx_params = SplitPosesIntoSmplxParams(poses)
254
+ # output = smplx_model(betas=None,
255
+ # global_orient=smplx_params["global_orient"],
256
+ # body_pose=smplx_params["body_pose"],
257
+ # expression=expressions,
258
+ # jaw_pose=smplx_params["jaw_pose"],
259
+ # leye_pose=smplx_params["leye_pose"],
260
+ # reye_pose=smplx_params["reye_pose"],
261
+ # left_hand_pose=smplx_params["left_hand_pose"],
262
+ # right_hand_pose=smplx_params["right_hand_pose"],
263
+ # transl=trans,
264
+ # return_verts=True)
265
+
266
+ output = smplx_model()
267
+ print(output['joints'].shape)
268
+ print(output['vertices'].shape)
269
+
270
+ # WriteObj("test.obj", output['vertices'][0].cpu().numpy(), smplx_model.faces)
271
+ print(output['joints'][0][:55].cpu().numpy()[0])
272
+ break
273
+ from scipy.io import loadmat
274
+
275
+ WriteObj("J.obj", J.cpu().numpy())
276
+
277
+
278
+
retrained_20261113/globaldiff_e630_all_cfg1p25/source/Scripts/Util.py ADDED
@@ -0,0 +1,569 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ '''
3
+ Copyright (c) 2021, Alibaba Cloud and its affiliates;
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ '''
16
+
17
+
18
+ import numpy as np
19
+ from scipy.spatial.transform import Rotation
20
+ import torch
21
+ import torch.nn.functional as F
22
+ # import kornia.geometry as G
23
+ from typing import Union
24
+ import math
25
+ import torch.nn as nn
26
+
27
+
28
+ def SplitIntoOverlapedWindows(seq, win_size, stride_step, keep_last=False):
29
+ assert stride_step <= win_size
30
+ overlap_size = win_size - stride_step
31
+ num = (len(seq) - win_size) // stride_step + 1
32
+ res = [seq[i * stride_step:i * stride_step + win_size] for i in range(num)]
33
+ if keep_last:
34
+ last_id = num * stride_step
35
+ if last_id < len(seq):
36
+ res.append(seq[last_id:])
37
+ return res
38
+
39
+
40
+ def matrix_to_rotation_6d(matrix):
41
+ return matrix[..., :2, :].reshape((matrix.shape[:-2] + (6,)))
42
+
43
+
44
+ def Normalize(x, eps=1e-12):
45
+ len = np.sqrt(np.sum(x * x, axis=-1, keepdims=True))
46
+ return x / (len + eps)
47
+
48
+
49
+ # def NormalizeToRot6d(d):
50
+ # origin_shape = d.shape
51
+ # d6 = d.reshape((-1, 6))
52
+ # a1, a2 = d6[..., :3], d6[..., 3:]
53
+ # b1 = F.normalize(a1, dim=-1)
54
+ # b2 = a2 - (b1 * a2).sum(-1, keepdim=True) * b1
55
+ # b2 = F.normalize(b2, dim=-1)
56
+ # d6 = torch.cat([b1, b2], dim=-1)
57
+ # return d6.reshape(origin_shape)
58
+
59
+
60
+ def rotation_6d_to_matrix_torch(d6: torch.Tensor) -> torch.Tensor:
61
+ """
62
+ Converts 6D rotation representation by Zhou et al. [1] to rotation matrix
63
+ using Gram--Schmidt orthogonalization per Section B of [1].
64
+ Args:
65
+ d6: 6D rotation representation, of size (*, 6)
66
+
67
+ Returns:
68
+ batch of rotation matrices of size (*, 3, 3)
69
+
70
+ [1] Zhou, Y., Barnes, C., Lu, J., Yang, J., & Li, H.
71
+ On the Continuity of Rotation Representations in Neural Networks.
72
+ IEEE Conference on Computer Vision and Pattern Recognition, 2019.
73
+ Retrieved from http://arxiv.org/abs/1812.07035
74
+ """
75
+
76
+ a1, a2 = d6[..., :3], d6[..., 3:]
77
+ b1 = F.normalize(a1, dim=-1)
78
+ b2 = a2 - (b1 * a2).sum(-1, keepdim=True) * b1
79
+ b2 = F.normalize(b2, dim=-1)
80
+ b3 = torch.cross(b1, b2, dim=-1)
81
+ return torch.stack((b1, b2, b3), dim=-2)
82
+
83
+
84
+ def rotation_6d_to_matrix_numpy(d6: torch.Tensor):
85
+ """
86
+ Converts 6D rotation representation by Zhou et al. [1] to rotation matrix
87
+ using Gram--Schmidt orthogonalization per Section B of [1].
88
+ Args:
89
+ d6: 6D rotation representation, of size (*, 6)
90
+
91
+ Returns:
92
+ batch of rotation matrices of size (*, 3, 3)
93
+
94
+ [1] Zhou, Y., Barnes, C., Lu, J., Yang, J., & Li, H.
95
+ On the Continuity of Rotation Representations in Neural Networks.
96
+ IEEE Conference on Computer Vision and Pattern Recognition, 2019.
97
+ Retrieved from http://arxiv.org/abs/1812.07035
98
+ """
99
+
100
+ a1, a2 = d6[..., :3], d6[..., 3:]
101
+ b1 = Normalize(a1)
102
+ b2 = a2 - (b1 * a2).sum(-1, keepdims=True) * b1
103
+ b2 = Normalize(b2)
104
+ b3 = np.cross(b1, b2, axis=-1)
105
+ return np.stack((b1, b2, b3), axis=-2)
106
+
107
+
108
+ def rotation_6d_to_matrix(d6: Union[torch.Tensor, np.ndarray]):
109
+ if isinstance(d6, torch.Tensor):
110
+ return rotation_6d_to_matrix_torch(d6=d6)
111
+ elif isinstance(d6, np.ndarray):
112
+ return rotation_6d_to_matrix_numpy(d6=d6)
113
+ else:
114
+ assert 0 == 1
115
+
116
+
117
+ def rotation_matrix_to_axis_angle_torch(rot_mat: torch.Tensor, eps: float = 1e-4) -> torch.Tensor:
118
+ """
119
+ 将旋转矩阵转换为轴角表示
120
+ Args:
121
+ rot_mat: (..., 3, 3) 旋转矩阵(必须有效正交矩阵)
122
+ eps: 数值稳定性阈值
123
+ Returns:
124
+ axis_angle: (..., 3) 轴角表示(轴方向为单位向量,角度为向量的模长)
125
+ """
126
+ # 确保输入是3x3矩阵
127
+ assert rot_mat.shape[-2:] == (3, 3), f"Invalid rotation matrix shape: {rot_mat.shape}"
128
+
129
+ # 计算旋转角度θ(通过矩阵的迹)
130
+ trace = rot_mat[..., 0, 0] + rot_mat[..., 1, 1] + rot_mat[..., 2, 2]
131
+ theta = torch.acos(torch.clamp((trace - 1) / 2, -1 + eps, 1 - eps))
132
+ # 计算轴方向
133
+ axis = torch.empty_like(rot_mat[..., 0])
134
+ # Case 1: θ ≈ 0(返回零向量)
135
+ zero_angle = theta < eps
136
+ axis[zero_angle] = torch.tensor([1.0, 0.0, 0.0], device=rot_mat.device) # 默认轴
137
+
138
+ # Case 2: θ ≈ π(需要特殊处理奇异性)
139
+ near_pi = theta > math.acos(-1 + 2*eps)
140
+ if torch.any(near_pi):
141
+ # 从对角线元素计算轴
142
+ r_diag = rot_mat[near_pi].diagonal(dim1=-2, dim2=-1)
143
+ axis_near_pi = torch.sqrt( torch.clip((r_diag + 1) / 2, min=0.0) )
144
+ # 符号需要根据非对角��素确定
145
+ mask_x = ((rot_mat[near_pi, 2, 1] - rot_mat[near_pi, 1, 2]) > 0) * 2 - 1
146
+ mask_y = ((rot_mat[near_pi, 0, 2] - rot_mat[near_pi, 2, 0]) > 0) * 2 - 1
147
+ mask_z = ((rot_mat[near_pi, 1, 0] - rot_mat[near_pi, 0, 1]) > 0) * 2 - 1
148
+ mask = torch.stack([mask_x, mask_y, mask_z], dim=-1)
149
+ axis[near_pi] = axis_near_pi * mask
150
+
151
+
152
+ # Case 3: 常规角度
153
+ normal_angle = ~(zero_angle | near_pi)
154
+ if torch.any(normal_angle):
155
+ rot_mat_normal = rot_mat[normal_angle]
156
+ axis[normal_angle] = torch.stack([
157
+ rot_mat_normal[..., 2, 1] - rot_mat_normal[..., 1, 2],
158
+ rot_mat_normal[..., 0, 2] - rot_mat_normal[..., 2, 0],
159
+ rot_mat_normal[..., 1, 0] - rot_mat_normal[..., 0, 1]
160
+ ], dim=-1) / (2 * torch.sin(theta[normal_angle].unsqueeze(-1)))
161
+
162
+ # 将角度编码为向量的模长
163
+ return axis * theta.unsqueeze(-1)
164
+
165
+
166
+
167
+ def rotation_matrix_to_axis_angle_np(matrix):
168
+ """
169
+ 將旋轉矩陣轉換為軸角表示
170
+ 輸入: (*, 3, 3) 的旋轉矩陣 (numpy.ndarray)
171
+ 輸出: (*, 3) 的軸角表示,其中向量的方向是旋轉軸,範數是旋轉角度(弧度)
172
+ """
173
+ # 確保輸入是 numpy.ndarray
174
+ if not isinstance(matrix, np.ndarray):
175
+ matrix = np.array(matrix, dtype=np.float32)
176
+
177
+ original_shape = matrix.shape[:-2]
178
+ matrix = matrix.reshape(-1, 3, 3) # 展平批次維度
179
+
180
+ # 計算旋轉角度
181
+ trace = np.trace(matrix, axis1=1, axis2=2)
182
+ angle = np.arccos(np.clip((trace - 1) / 2, -1, 1))
183
+
184
+ # 計算旋轉軸
185
+ axis = np.stack([
186
+ matrix[:, 2, 1] - matrix[:, 1, 2],
187
+ matrix[:, 0, 2] - matrix[:, 2, 0],
188
+ matrix[:, 1, 0] - matrix[:, 0, 1]
189
+ ], axis=1)
190
+
191
+ axis_norm = np.linalg.norm(axis, axis=1, keepdims=True)
192
+ # 處理角度接近0的情況(避免除以0)
193
+ mask = (angle > 1e-6).reshape(-1, 1)
194
+ axis = axis / (axis_norm + 1e-10) * mask + (1 - mask) * np.array([1., 0., 0.])
195
+
196
+ # 組合軸和角度
197
+ axis_angle = axis * angle.reshape(-1, 1)
198
+
199
+ # 恢復原始批次形狀
200
+ return axis_angle.reshape(*original_shape, 3)
201
+
202
+ def hat(v: torch.Tensor) -> torch.Tensor:
203
+ """
204
+ 将向量转换为反对称矩阵。
205
+ Args:
206
+ v: (..., 3), 李代数向量
207
+ Returns:
208
+ K: (..., 3, 3), 反对称矩阵
209
+ """
210
+ K = torch.zeros((*v.shape[:-1], 3, 3), device=v.device, dtype=v.dtype)
211
+ K[..., 0, 1] = -v[..., 2]
212
+ K[..., 0, 2] = v[..., 1]
213
+ K[..., 1, 0] = v[..., 2]
214
+ K[..., 1, 2] = -v[..., 0]
215
+ K[..., 2, 0] = -v[..., 1]
216
+ K[..., 2, 1] = v[..., 0]
217
+ return K
218
+
219
+ def axis_angle_to_rotation_matrix_torch(omega_vec, eps: float = 1e-6):
220
+ """
221
+ 将李代数向量转换为旋转矩阵。
222
+ Args:
223
+ omega_vec: (..., 3), 李代数向量
224
+ Returns:
225
+ R: (..., 3, 3), 旋转矩阵
226
+ """
227
+ theta = torch.norm(omega_vec, dim=-1, keepdim=True)
228
+ near_zero = theta.squeeze(-1) < eps
229
+ k = hat(omega_vec)
230
+ K = hat( omega_vec / (theta + 1e-12))
231
+ I = torch.eye(3, device=omega_vec.device, dtype=omega_vec.dtype).repeat(*omega_vec.shape[:-1], 1, 1)
232
+ theta_expanded = theta.unsqueeze(-1)
233
+ sin_theta = torch.sin(theta_expanded)
234
+ cos_theta = torch.cos(theta_expanded)
235
+
236
+ # Rodrigues公式
237
+ R = I + sin_theta * K + (1 - cos_theta) * (K @ K)
238
+
239
+ # 小角度近似
240
+ R_approx = I + k + 0.5 * (k @ k)
241
+ R = torch.where(near_zero[..., None, None], R_approx, R)
242
+ return R
243
+ # def axis_angle_to_rotation_matrix_torch(axis_angle):
244
+ # """
245
+ # 將軸角表示轉換為旋轉矩陣
246
+ # 輸入: (*, 3) 的軸角表示,其中向量的方向是旋轉軸,範數是旋轉角度(弧度)
247
+ # 輸出: (*, 3, 3) 的旋轉矩陣
248
+ # """
249
+ # # 確保輸入是torch.Tensor
250
+ # if not isinstance(axis_angle, torch.Tensor):
251
+ # axis_angle = torch.tensor(axis_angle, dtype=torch.float32)
252
+
253
+ # batch_shape = axis_angle.shape[:-1]
254
+ # axis_angle = axis_angle.view(-1, 3) # 展平批次維度
255
+
256
+ # angle = torch.norm(axis_angle, dim=1, keepdim=True)
257
+ # # 處理角度接近0的情況
258
+ # mask = (angle.squeeze() > 1e-6).float()
259
+ # axis = axis_angle / (angle + 1e-10)
260
+
261
+ # # 獲取軸的分量
262
+ # x = axis[:, 0]
263
+ # y = axis[:, 1]
264
+ # z = axis[:, 2]
265
+
266
+ # # 計算叉積矩陣
267
+ # zero = torch.zeros_like(x)
268
+ # cross_prod_mat = torch.stack([
269
+ # zero, -z, y,
270
+ # z, zero, -x,
271
+ # -y, x, zero
272
+ # ], dim=1).view(-1, 3, 3)
273
+
274
+ # # 計算外積
275
+ # outer_prod_mat = torch.bmm(axis.unsqueeze(2), axis.unsqueeze(1))
276
+
277
+ # # 計算旋轉矩陣: R = cosθI + (1-cosθ)aa^T + sinθ[a]×
278
+ # I = torch.eye(3, device=axis_angle.device).unsqueeze(0).expand(axis_angle.size(0), -1, -1)
279
+ # cos_theta = torch.cos(angle).unsqueeze(2)
280
+ # sin_theta = torch.sin(angle).unsqueeze(2)
281
+
282
+ # rotation_matrix = I * cos_theta + (1 - cos_theta) * outer_prod_mat + sin_theta * cross_prod_mat
283
+
284
+ # # 處理角度為0的情況
285
+ # rotation_matrix = rotation_matrix * mask.view(-1, 1, 1) + I * (1 - mask).view(-1, 1, 1)
286
+
287
+ # # 恢復原始批次形狀
288
+ # return rotation_matrix.view(*batch_shape, 3, 3)
289
+
290
+ def axis_angle_to_rotation_matrix_np(axis_angle):
291
+ aa = Rotation.from_rotvec(axis_angle, degrees=False)
292
+ aa = aa.as_matrix()
293
+ return aa
294
+
295
+ def rotation_matrix_to_axis_angle(m: Union[np.ndarray, torch.Tensor], eps: float = 1e-4):
296
+ ori_shape = m.shape
297
+ m = m.reshape((-1, 3, 3))
298
+ if isinstance(m, torch.Tensor):
299
+ res = rotation_matrix_to_axis_angle_torch(m, eps=eps)
300
+ elif isinstance(m, np.ndarray):
301
+ res = Rotation.from_matrix(m).as_rotvec(degrees=False)
302
+ else:
303
+ assert 0 == 1
304
+ res = res.reshape(ori_shape[:-1])
305
+ return res
306
+
307
+ def axis_angle_to_rotation_matrix(axis_angle: Union[np.ndarray, torch.Tensor], eps: float = 1e-4):
308
+ assert axis_angle.shape[-1] == 3
309
+ ori_shape = axis_angle.shape
310
+ axis_angle = axis_angle.reshape((-1, 3))
311
+ if isinstance(axis_angle, torch.Tensor):
312
+ res = axis_angle_to_rotation_matrix_torch(axis_angle, eps=eps)
313
+ elif isinstance(axis_angle, np.ndarray):
314
+ res = axis_angle_to_rotation_matrix_np(axis_angle)
315
+ else:
316
+ assert 0 == 1
317
+
318
+ res = res.reshape(ori_shape[:-1] + (3, 3))
319
+ return res
320
+
321
+
322
+ def rotation_6d_to_axis_angle(m: Union[np.ndarray, torch.Tensor], eps: float = 1e-4):
323
+ orig_shape = m.shape
324
+ m = rotation_6d_to_matrix(m.reshape((-1, 6)))
325
+ return rotation_matrix_to_axis_angle(m, eps=eps).reshape(orig_shape[:-1] + (orig_shape[-1] // 6 * 3,))
326
+
327
+
328
+ def axis_angle_to_rotation_6d(m: Union[np.ndarray, torch.Tensor]):
329
+ orig_shape = m.shape
330
+ m = axis_angle_to_rotation_matrix(m.reshape((-1, 3)))
331
+ return matrix_to_rotation_6d(m).reshape(orig_shape[:-1] + (orig_shape[-1] // 3 * 6,))
332
+
333
+ def NormalizeRot6d(m):
334
+ orig_shape = m.shape
335
+ d6 = m.reshape((-1, 6))
336
+ a1, a2 = d6[..., :3], d6[..., 3:]
337
+
338
+ if isinstance(m, np.ndarray):
339
+ b1 = Normalize(a1)
340
+ b2 = a2 - (b1 * a2).sum(-1, keepdims=True) * b1
341
+ b2 = Normalize(b2)
342
+ m = np.concatenate([b1, b2], axis=-1)
343
+ elif isinstance(m, torch.Tensor):
344
+ b1 = F.normalize(a1, dim=-1)
345
+ b2 = a2 - (b1 * a2).sum(-1, keepdim=True) * b1
346
+ b2 = F.normalize(b2, dim=-1)
347
+ m = torch.cat([b1, b2], dim=-1)
348
+
349
+ m = m.reshape(orig_shape)
350
+ return m
351
+
352
+
353
+
354
+
355
+
356
+ def rotation_matrix_to_quaternion_torch(matrix:torch.Tensor) -> torch.Tensor:
357
+ """
358
+ 将旋转矩阵转换为四元数(支持batch输入)
359
+
360
+ 参数:
361
+ matrix: (..., 3, 3) 旋转矩阵
362
+
363
+ 返回:
364
+ quaternion: (..., 4) 四元数 [w, x, y, z]
365
+ """
366
+ if matrix.size(-1) != 3 or matrix.size(-2) != 3:
367
+ raise ValueError(f"输入矩阵的最后两个维度必须是3x3,但得到的是{tuple(matrix.shape[-2:])}")
368
+
369
+ batch_dim = matrix.shape[:-2]
370
+ m = matrix.view(-1, 3, 3)
371
+
372
+ num_rot = m.shape[0]
373
+ quat = torch.zeros((num_rot, 4), dtype=matrix.dtype, device=matrix.device)
374
+
375
+ # 计算矩阵对角线元素的和
376
+ diag = torch.diagonal(m, dim1=-2, dim2=-1)
377
+ trace = diag.sum(dim=-1)
378
+
379
+ # 根据迹的大小选择不同的计算方式
380
+ case_mask = torch.zeros_like(trace, dtype=torch.long)
381
+ case_mask = torch.where(trace > 0,
382
+ torch.tensor(0, device=matrix.device),
383
+ case_mask)
384
+ case_mask = torch.where((diag[:, 0] > diag[:, 1]) &
385
+ (diag[:, 0] > diag[:, 2]) &
386
+ (trace <= 0),
387
+ torch.tensor(1, device=matrix.device),
388
+ case_mask)
389
+ case_mask = torch.where((diag[:, 1] > diag[:, 2]) &
390
+ (trace <= 0),
391
+ torch.tensor(2, device=matrix.device),
392
+ case_mask)
393
+ case_mask = torch.where(trace <= 0,
394
+ torch.tensor(3, device=matrix.device),
395
+ case_mask)
396
+
397
+ # 根据不同情况计算四元数
398
+ case0 = (case_mask == 0)
399
+ if case0.any():
400
+ s = torch.sqrt(trace[case0] + 1.0) * 2 # s = 4 * qw
401
+ quat[case0, 0] = 0.25 * s
402
+ quat[case0, 1] = (m[case0, 2, 1] - m[case0, 1, 2]) / s
403
+ quat[case0, 2] = (m[case0, 0, 2] - m[case0, 2, 0]) / s
404
+ quat[case0, 3] = (m[case0, 1, 0] - m[case0, 0, 1]) / s
405
+
406
+ case1 = (case_mask == 1)
407
+ if case1.any():
408
+ s = torch.sqrt(1.0 + m[case1, 0, 0] - m[case1, 1, 1] - m[case1, 2, 2]) * 2
409
+ quat[case1, 0] = (m[case1, 2, 1] - m[case1, 1, 2]) / s
410
+ quat[case1, 1] = 0.25 * s
411
+ quat[case1, 2] = (m[case1, 0, 1] + m[case1, 1, 0]) / s
412
+ quat[case1, 3] = (m[case1, 0, 2] + m[case1, 2, 0]) / s
413
+
414
+ case2 = (case_mask == 2)
415
+ if case2.any():
416
+ s = torch.sqrt(1.0 + m[case2, 1, 1] - m[case2, 0, 0] - m[case2, 2, 2]) * 2
417
+ quat[case2, 0] = (m[case2, 0, 2] - m[case2, 2, 0]) / s
418
+ quat[case2, 1] = (m[case2, 0, 1] + m[case2, 1, 0]) / s
419
+ quat[case2, 2] = 0.25 * s
420
+ quat[case2, 3] = (m[case2, 1, 2] + m[case2, 2, 1]) / s
421
+
422
+ case3 = (case_mask == 3)
423
+ if case3.any():
424
+ s = torch.sqrt(1.0 + m[case3, 2, 2] - m[case3, 0, 0] - m[case3, 1, 1]) * 2
425
+ quat[case3, 0] = (m[case3, 1, 0] - m[case3, 0, 1]) / s
426
+ quat[case3, 1] = (m[case3, 0, 2] + m[case3, 2, 0]) / s
427
+ quat[case3, 2] = (m[case3, 1, 2] + m[case3, 2, 1]) / s
428
+ quat[case3, 3] = 0.25 * s
429
+
430
+ # 归一化四元数
431
+ quat = nn.functional.normalize(quat, p=2, dim=-1)
432
+
433
+ # 恢复原始batch维度
434
+ quat = quat.view(*batch_dim, 4)
435
+
436
+ return quat
437
+
438
+
439
+ def slerp_torch(q0:torch.Tensor, q1:torch.Tensor, t:torch.Tensor):
440
+ """
441
+ 四元数球面线性插值(slerp),支持batch输入
442
+
443
+ 参数:
444
+ q0: (..., 4) 起始四元数 [w, x, y, z]
445
+ q1: (..., 4) 结束四元数 [w, x, y, z]
446
+ t: (...) 插值系数,范围[0, 1]
447
+
448
+ 返回:
449
+ q: (..., 4) 插值后的四元数 [w, x, y, z]
450
+ """
451
+ # 确保输入形状一致
452
+ assert q0.shape == q1.shape, "q0和q1的形状必须相同"
453
+
454
+ # 确保四元数是单位四元数
455
+ q0 = nn.functional.normalize(q0, p=2, dim=-1)
456
+ q1 = nn.functional.normalize(q1, p=2, dim=-1)
457
+
458
+ # 计算点积(即cos(omega))
459
+ dot = (q0 * q1).sum(dim=-1, keepdim=True) # (..., 1)
460
+
461
+ # 如果点积为负,取反其中一个四元数以保证走最短路径
462
+ neg_mask = dot < 0.0
463
+ q1 = torch.where(neg_mask, -q1, q1)
464
+ dot = torch.where(neg_mask, -dot, dot)
465
+
466
+ # 限制dot在[-1,1]范围内,防止数值误差
467
+ dot = torch.clamp(dot, -1.0, 1.0)
468
+
469
+ # 计算角度和sin(omega)
470
+ omega = torch.acos(dot)
471
+ sin_omega = torch.sin(omega)
472
+
473
+ # 处理sin(omega)接近0的情况
474
+ eps = 1e-8
475
+ small_mask = sin_omega < eps
476
+ sin_omega = torch.where(small_mask, torch.ones_like(sin_omega), sin_omega)
477
+
478
+ # 计算插值权重
479
+ t = t.unsqueeze(-1) # (..., 1)
480
+ w0 = torch.where(small_mask, 1.0 - t, torch.sin((1.0 - t) * omega) / sin_omega)
481
+ w1 = torch.where(small_mask, t, torch.sin(t * omega) / sin_omega)
482
+
483
+ # 线性组合
484
+ q = w0 * q0 + w1 * q1
485
+
486
+ # 归一化结果
487
+ q = nn.functional.normalize(q, p=2, dim=-1)
488
+
489
+ return q
490
+
491
+
492
+
493
+ def quaternion_to_matrix_torch(quaternions):
494
+ """
495
+ 将四元数转换为旋转矩阵(支持batch输入)
496
+
497
+ 参数:
498
+ quaternions: (..., 4) 四元数,格式为[w, x, y, z],其中w是实部
499
+
500
+ 返回:
501
+ rotation_matrix: (..., 3, 3) 对应的旋转矩阵
502
+ """
503
+ if quaternions.size(-1) != 4:
504
+ raise ValueError(f"输入四元数的最后一个维度必须是4,但得到的是{quaternions.shape[-1]}")
505
+
506
+ # 归一化四元数
507
+ quaternions = nn.functional.normalize(quaternions, p=2, dim=-1)
508
+
509
+ # 提取四元数分量
510
+ w, x, y, z = torch.unbind(quaternions, dim=-1)
511
+
512
+ # 计算平方项
513
+ x2 = x * x
514
+ y2 = y * y
515
+ z2 = z * z
516
+ w2 = w * w
517
+
518
+ # 计算交叉项
519
+ xy = x * y
520
+ xz = x * z
521
+ yz = y * z
522
+ wx = w * x
523
+ wy = w * y
524
+ wz = w * z
525
+
526
+ # 构建旋转矩阵
527
+ # 第一列
528
+ m00 = w2 + x2 - y2 - z2
529
+ m10 = 2 * (xy + wz)
530
+ m20 = 2 * (xz - wy)
531
+
532
+ # 第二列
533
+ m01 = 2 * (xy - wz)
534
+ m11 = w2 - x2 + y2 - z2
535
+ m21 = 2 * (yz + wx)
536
+
537
+ # 第三列
538
+ m02 = 2 * (xz + wy)
539
+ m12 = 2 * (yz - wx)
540
+ m22 = w2 - x2 - y2 + z2
541
+
542
+ # 组合成旋转矩阵
543
+ rotation_matrix = torch.stack([
544
+ torch.stack([m00, m01, m02], dim=-1),
545
+ torch.stack([m10, m11, m12], dim=-1),
546
+ torch.stack([m20, m21, m22], dim=-1)
547
+ ], dim=-2)
548
+
549
+ return rotation_matrix
550
+
551
+ if __name__ == '__main__':
552
+ import time
553
+ x = Rotation.from_euler('xyz', [0, 0, 180-0.1], degrees=True).as_matrix()[None].astype(np.float32)
554
+ x_tensor = torch.from_numpy(x)
555
+
556
+ aa_tensor = rotation_matrix_to_axis_angle(x_tensor)
557
+ print(aa_tensor)
558
+
559
+ aa = rotation_matrix_to_axis_angle(x)
560
+ print(aa)
561
+
562
+
563
+ r_tensor = axis_angle_to_rotation_matrix(aa_tensor)
564
+ r = axis_angle_to_rotation_matrix(aa)
565
+
566
+ d = r_tensor@torch.from_numpy(r).float()
567
+
568
+ d = rotation_matrix_to_axis_angle(d)
569
+ print(torch.linalg.norm(d, dim=-1) * 180 / math.pi)
retrained_20261113/globaldiff_e630_all_cfg1p25/verify_sha256.py ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from pathlib import Path
2
+ import hashlib,json
3
+ root=Path(__file__).resolve().parent
4
+ manifest=json.loads((root/'SHA256SUMS.json').read_text())
5
+ for name,expected in manifest.items():
6
+ path=root/name
7
+ h=hashlib.sha256()
8
+ with path.open('rb') as f:
9
+ for block in iter(lambda:f.read(8<<20),b''):h.update(block)
10
+ if path.stat().st_size!=expected['size'] or h.hexdigest()!=expected['sha256']:
11
+ raise SystemExit('Checksum mismatch: '+name)
12
+ print('Verified',len(manifest),'files')
retrained_20261113/globaldiff_e880_all_cfg1p25.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7966dd5f356f535f940d1497c9736083ef71db332e55ad315172bf1225dbbc1e
3
+ size 225631513
retrained_20261113/globaldiff_e880_all_cfg1p25/CONFIG.json ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "trained_person_ids": [
3
+ 1,
4
+ 2,
5
+ 3,
6
+ 4,
7
+ 5,
8
+ 6,
9
+ 7,
10
+ 9,
11
+ 10,
12
+ 11,
13
+ 12,
14
+ 13,
15
+ 15,
16
+ 16,
17
+ 17,
18
+ 18,
19
+ 20,
20
+ 21,
21
+ 22,
22
+ 23,
23
+ 24,
24
+ 25,
25
+ 27,
26
+ 28,
27
+ 30
28
+ ],
29
+ "source_commit": "0fece4fbf884198285769d12a9cc4bdb67185181",
30
+ "architecture": "DiffusionDITNetPartsFixedExpressions2PostNorm",
31
+ "hidden_size": 384,
32
+ "num_layers": 6,
33
+ "motion_channels": 333,
34
+ "expression_channels": 100,
35
+ "rotation_representation": "global row-6D rotations; native BEAT2 translations without normalization",
36
+ "parameters": 43081293,
37
+ "state_elements": 43081485,
38
+ "state_tensors": 249,
39
+ "generator_filename": "generator.pt",
40
+ "generator_sha256": "120bcedcffef8a268bb2bba92a8b70b21e174cedf4578778449cade638a89488",
41
+ "completed_epoch": 880,
42
+ "optimizer_step": 175120,
43
+ "training_scope": "All original BEAT2 English train CSV speakers",
44
+ "training_optimizer": {
45
+ "type": "Adam",
46
+ "parameter_groups": [
47
+ {
48
+ "lr": 0.0001,
49
+ "betas": [
50
+ 0.9,
51
+ 0.999
52
+ ],
53
+ "eps": 1e-08,
54
+ "weight_decay": 0,
55
+ "amsgrad": false,
56
+ "maximize": false,
57
+ "foreach": null,
58
+ "capturable": true,
59
+ "differentiable": false,
60
+ "fused": null,
61
+ "decoupled_weight_decay": false
62
+ }
63
+ ]
64
+ },
65
+ "precision_lineage": "Fresh own generator: epochs1-10 BF16 pilot, then own full-state continuation in FP32/TF32",
66
+ "initialization": "Random generator seed0; official frozen speech and VAE auxiliaries; no StreamTalk generator weights",
67
+ "inference": {
68
+ "wavlm_id": "patrickvonplaten/wavlm-libri-clean-100h-large",
69
+ "wavlm_revision": "e70e3a062ec399c46008ee55d1fb52c7ba338d5c",
70
+ "speech_checkpoint_sha256": "187df39de64c7a20983904cfca3145e44bee1630fdbad6da018d23b1e0fedaf9",
71
+ "n_seed": 8,
72
+ "persons": 31,
73
+ "sample_rate": 16000,
74
+ "fps": 30,
75
+ "window_frames": 60,
76
+ "audio_stride_samples": 27734,
77
+ "solver": "released five-step midpoint",
78
+ "steps": 5,
79
+ "cfg": 1.25,
80
+ "seed_pose": "8 local SMPL-X axis-angle frames [8,165] plus translations [8,3]; converted internally to global row-6D rotations",
81
+ "custom_wav_padding": "final partial window padded and output trimmed to WAV duration; benchmark retains the original keep_last=False convention"
82
+ },
83
+ "format_version": 2,
84
+ "release_date": "2026-11-13",
85
+ "label": "globaldiff_e880_all_cfg1p25",
86
+ "weight_origin": "Newly retrained GlobalDiff generator; not the original paper checkpoint",
87
+ "training": {
88
+ "dataset": "H-Liu1997/BEAT2 English v2.0.0, original training CSV",
89
+ "train_clips": 1093,
90
+ "train_windows": 102041,
91
+ "window_frames": 60,
92
+ "stride_frames": 20,
93
+ "epochs": 1000,
94
+ "global_batch": 512,
95
+ "batch_per_device": 128,
96
+ "devices": 4,
97
+ "checkpoint_every_epochs": 5,
98
+ "random_initialization_seed": 0,
99
+ "execution": "Frozen auxiliary targets cached; vectorized FK and CUDA graphs; FP32/TF32 after the first10 BF16 epochs"
100
+ },
101
+ "selection": "Lowest recorded seed0 all-speaker FGD",
102
+ "limitations": [
103
+ "Selected using the public test benchmark; not an untouched-test generalization estimate.",
104
+ "Both released checkpoints were trained on all training CSV speakers, not Speaker2-only training.",
105
+ "Exact equivalence to the original private paper training protocol is unverified.",
106
+ "Lower FGD does not imply improvement in every metric."
107
+ ]
108
+ }
retrained_20261113/globaldiff_e880_all_cfg1p25/METRICS.json ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "evaluation_scope": "265 original English BEAT2 test clips",
3
+ "protocol": "official full-clip AESK, clipwise min length then multiple 32, CPU FP32 batch1, epsilon1e-6",
4
+ "seed0": {
5
+ "FGD": 0.25583519134479715,
6
+ "clips": 265,
7
+ "frames": 554936,
8
+ "BA": 0.40268533924495015,
9
+ "BA_before_L1div_mutation": 0.4042058941014386,
10
+ "DIV": 7.683824100588148,
11
+ "facial_vertex_MSE": 4.0318737077334556e-08
12
+ },
13
+ "sampling_seeds": [
14
+ 0,
15
+ 1,
16
+ 2
17
+ ],
18
+ "sampling_FGD": {
19
+ "values": [
20
+ 0.25583519134479715,
21
+ 0.2601576319326693,
22
+ 0.2671707086430146
23
+ ],
24
+ "mean": 0.26105451064016033,
25
+ "population_std": 0.004670958621561532,
26
+ "min": 0.25583519134479715,
27
+ "max": 0.2671707086430146
28
+ },
29
+ "sampling_note": "Sampling variation of a single fixed checkpoint, not independent training runs.",
30
+ "paper_all_speakers": {
31
+ "FGD": 0.263,
32
+ "BA": 0.404,
33
+ "DIV": 8.24,
34
+ "facial_vertex_MSE": 4.144e-08
35
+ },
36
+ "public_prediction_calibration": {
37
+ "FGD": 0.2624656903227027,
38
+ "BA": 0.40586601635105224,
39
+ "DIV": 8.240758192266485,
40
+ "facial_vertex_MSE": 4.149304934655536e-08
41
+ },
42
+ "paper_url": "https://arxiv.org/abs/2511.10076",
43
+ "selection_caveats": [
44
+ "Selected using the public test benchmark; not an untouched-test generalization estimate.",
45
+ "Both released checkpoints were trained on all training CSV speakers, not Speaker2-only training.",
46
+ "Exact equivalence to the original private paper training protocol is unverified.",
47
+ "Lower FGD does not imply improvement in every metric."
48
+ ]
49
+ }
retrained_20261113/globaldiff_e880_all_cfg1p25/README.txt ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ GlobalDiff retrained motion generator: epoch 880, all speakers, CFG=1.25
2
+
3
+ These are newly retrained weights released on 2026-11-13. They are not the
4
+ original paper checkpoints. Both epoch880 and epoch630 use the original
5
+ 25-English-speaker BEAT2 training CSV. Speaker2-only training is not claimed.
6
+ The generator has249 native state tensors and43,081,293 trainable parameters.
7
+
8
+ Tested environment: Python3.12, PyTorch2.10.0; training/evaluation used CUDA12.8.
9
+ Install PyTorch for your platform, then:
10
+ python -m pip install -r requirements-inference.txt
11
+ python verify_sha256.py
12
+
13
+ From this extracted directory, generate parameters for your WAV:
14
+ python infer_wav.py --checkpoint generator.pt --wav input.wav --seed-pose seed_pose_speaker2.npz --pid 2 --out motion.npz --device cuda
15
+
16
+ CONFIG.json supplies CFG=1.25 automatically. Use --device cpu for CPU inference.
17
+ Use a new output filename for each invocation. --seed controls sampling noise.
18
+ The example uses eight frames from a Speaker2 training clip. For another
19
+ trained speaker/avatar, provide a matching seed NPZ with local axis-angle
20
+ poses[>=8,165] and trans[>=8,3], plus optional betas[300], and select its pid.
21
+ Trained IDs: [1, 2, 3, 4, 5, 6, 7, 9, 10, 11, 12, 13, 15, 16, 17, 18, 20, 21, 22, 23, 24, 25, 27, 28, 30]. ID0 is reserved for unconditional conditioning.
22
+
23
+ WavLM: patrickvonplaten/wavlm-libri-clean-100h-large
24
+ Fixed revision: e70e3a062ec399c46008ee55d1fb52c7ba338d5c
25
+ It downloads on first use. For offline use, pass --wavlm /path/to/the/snapshot;
26
+ the supplied WavLM manifest verifies the local snapshot's required files.
27
+
28
+ The script mixes channels to mono, resamples to16kHz, processes two-second
29
+ windows, uses eight seed frames and five midpoint steps, and returns30FPS.
30
+ The final partial window is padded and output is trimmed to the WAV duration.
31
+ Seed poses are converted internally from local axis-angle to global6D rotation.
32
+ Output: local SMPL-X poses[T,165], trans[T,3], expressions[T,100], betas, and FPS.
33
+ CPU FP32 and GPU FP16 sampling are not bitwise identical.
34
+
35
+ The official SimpleSpeechModel and source files are included. Training-only
36
+ VAEs and an SMPL-X mesh asset are not needed for parameter inference. Mesh
37
+ rendering requires the separately obtained SMPL-X model. Code and all
38
+ third-party data/assets remain subject to their respective terms; this bundle
39
+ does not grant new rights to those assets.
40
+
41
+ CONFIG.json records the matching architecture, inference and training settings.
42
+ METRICS.json reports seed0 metrics, three sampling seeds and the calibration
43
+ against the public predictions. Selection used the public test benchmark.
44
+ Epoch880 has lower FGD and lower diversity; epoch630 has diversity closer to
45
+ the paper reference. The release does not claim superiority on every metric.
46
+
47
+ Code: https://github.com/Xiangyue-Zhang/GlobalDiff
48
+ Source snapshot: 0fece4fbf884198285769d12a9cc4bdb67185181
49
+ Paper: https://arxiv.org/abs/2511.10076
retrained_20261113/globaldiff_e880_all_cfg1p25/SEED_PROVENANCE.json ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "dataset": "https://huggingface.co/datasets/H-Liu1997/BEAT2",
3
+ "source_train_clip": "2_scott_0_100_100",
4
+ "frames": [
5
+ 0,
6
+ 8
7
+ ],
8
+ "fps": 30,
9
+ "pid": 2,
10
+ "representation": "8 local SMPL-X axis-angle poses [8,165], translations [8,3], and source body shape",
11
+ "purpose": "Example initialization for new WAV inference; no test-sequence seed is included"
12
+ }
retrained_20261113/globaldiff_e880_all_cfg1p25/SHA256SUMS.json ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "CONFIG.json": {
3
+ "size": 3416,
4
+ "sha256": "13df420179d062db0ed655f31c6741d674e46334ec60d040eafae37be9f7b527"
5
+ },
6
+ "METRICS.json": {
7
+ "size": 1568,
8
+ "sha256": "da53223c1c1b26399e4153341b3d6b813eb7b5e8271d17568f5211022ae1bfe0"
9
+ },
10
+ "README.txt": {
11
+ "size": 2921,
12
+ "sha256": "12c243e23c13f17ed0132337bdef37ccec2ce60f9571187aa6d73a3778ba59e2"
13
+ },
14
+ "SEED_PROVENANCE.json": {
15
+ "size": 370,
16
+ "sha256": "297b826cefa1ac2db02f23cd12b447e9028eb673859a38d235a0de0ae5f986a0"
17
+ },
18
+ "VALIDATION.json": {
19
+ "size": 462,
20
+ "sha256": "61bd7c47ed481e6f7d399989dd7e51b1323cd1dc24f54088dde59567eef957cf"
21
+ },
22
+ "WAVLM_DOWNLOAD_COMPLETE.json": {
23
+ "size": 1567,
24
+ "sha256": "69ba38b21d7ebef08cbae69b7a6cd0c9afc9ccd5cbbb2fb8a7b35780076ef13f"
25
+ },
26
+ "generator.pt": {
27
+ "size": 172404427,
28
+ "sha256": "120bcedcffef8a268bb2bba92a8b70b21e174cedf4578778449cade638a89488"
29
+ },
30
+ "infer_wav.py": {
31
+ "size": 10807,
32
+ "sha256": "9ca0469945c4f0cfe19f3cf17e91cd68e253ac17fa4d3aaa2e9742997390b18a"
33
+ },
34
+ "requirements-inference.txt": {
35
+ "size": 166,
36
+ "sha256": "839228c977ace2994e269c5086b5e7f4520193bc7deeb535fe53db7de6ec0a3b"
37
+ },
38
+ "seed_pose_speaker2.npz": {
39
+ "size": 7420,
40
+ "sha256": "a0f8a79e60996a366a9659359ac91144bcbf5abf37d29782452c33bd5a65046c"
41
+ },
42
+ "source/Scripts/FM/Filter.py": {
43
+ "size": 3194,
44
+ "sha256": "bb524fd1fccbf45b45c5a9f42d31c6255175786e17f5e20c86a62065cc4c3d47"
45
+ },
46
+ "source/Scripts/FM/Net.py": {
47
+ "size": 126155,
48
+ "sha256": "ddf305fe001fa03b912361afe4bc7f92e67c71641fd9a2b1c794199e10b2ea6e"
49
+ },
50
+ "source/Scripts/FM/ckpt/split/SimpleSpeechModel/best.pt": {
51
+ "size": 52982500,
52
+ "sha256": "187df39de64c7a20983904cfca3145e44bee1630fdbad6da018d23b1e0fedaf9"
53
+ },
54
+ "source/Scripts/PositionalEncoding.py": {
55
+ "size": 3220,
56
+ "sha256": "f10b8c1aeb6068f1ee025811886535191a26a84dde4d4c9185fbcb5302059f4c"
57
+ },
58
+ "source/Scripts/SMPLXConfig.py": {
59
+ "size": 48003,
60
+ "sha256": "13999c52b99056ad7895eda955e78b3a156bc02266213e400cd90b3e532002e6"
61
+ },
62
+ "source/Scripts/SMPLX_Util.py": {
63
+ "size": 9840,
64
+ "sha256": "b604fe04f657b9a29586c5da3eaafeafc4919aaae84668c62e79c4e19eb95837"
65
+ },
66
+ "source/Scripts/Util.py": {
67
+ "size": 19180,
68
+ "sha256": "8e0fa2e1b149c66c7238b78ba28ef8593ad4e99f9fcb64220c5738d2dd98f773"
69
+ },
70
+ "verify_sha256.py": {
71
+ "size": 496,
72
+ "sha256": "8ac7f85467754a66a9f6a48b914b104bced75e86322de539c3e16b1c164e9ffd"
73
+ }
74
+ }
retrained_20261113/globaldiff_e880_all_cfg1p25/VALIDATION.json ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "generator_sha256": "120bcedcffef8a268bb2bba92a8b70b21e174cedf4578778449cade638a89488",
3
+ "native_state_dictionary_tensors": 249,
4
+ "full_training_state_and_optimizer_verified": true,
5
+ "source_files_and_inference_settings_unchanged": true,
6
+ "original_packaged_cpu_smoke_test": {
7
+ "input_seconds": 4,
8
+ "output_frames": 120,
9
+ "finite": true
10
+ },
11
+ "public_release_verification": "See release-level verification receipt for public download checks"
12
+ }
retrained_20261113/globaldiff_e880_all_cfg1p25/WAVLM_DOWNLOAD_COMPLETE.json ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "train_results.json": {
3
+ "bytes": 196,
4
+ "sha256": "5c7980ba296a96bf6ff95d0932d755059552afa4a287af8c621047e32d9bb289"
5
+ },
6
+ "preprocessor_config.json": {
7
+ "bytes": 214,
8
+ "sha256": "60ca5a31e13f69ee2fbf147504c8676db5f6398fd7a6b12294341dff838edfcf"
9
+ },
10
+ "eval_results.json": {
11
+ "bytes": 223,
12
+ "sha256": "dacc5c722deddf383e0885ce21abc3893735980163408e9ac1d499e49e8e9a36"
13
+ },
14
+ "pytorch_model.bin": {
15
+ "bytes": 1262130157,
16
+ "sha256": "4fb4e34572862ffa9bc01483e2065fecead1fda4941fb7fbd166d574afeae5fc"
17
+ },
18
+ "added_tokens.json": {
19
+ "bytes": 23,
20
+ "sha256": "a078eb364da8305a28070ed844edf5792449ef165d67ffdad3c128ec6a7fa422"
21
+ },
22
+ "training_args.bin": {
23
+ "bytes": 2991,
24
+ "sha256": "16a69eb1dc7d0fd6fbada6d6bbfd9e4b781eb0c64524b8c51d51d08eeedb0251"
25
+ },
26
+ "vocab.json": {
27
+ "bytes": 259,
28
+ "sha256": "a935095e5968d3e329ff178c249515d06780ff76e2067a2434617106bd756330"
29
+ },
30
+ "special_tokens_map.json": {
31
+ "bytes": 309,
32
+ "sha256": "fe9499f3f127cf340419ded12d4175b3a28a58c99c949bf3f8343a6f6b9fa872"
33
+ },
34
+ "config.json": {
35
+ "bytes": 2196,
36
+ "sha256": "2cd56602937a33bcaf9eed0fac2ad69dc2d3e98ae5299ea7d60bc2ca850a7473"
37
+ },
38
+ "trainer_state.json": {
39
+ "bytes": 322429,
40
+ "sha256": "2995eb823b0f2dca21d44fb88fef7489ea64da93f31db93d3390cea843ba7d90"
41
+ },
42
+ "all_results.json": {
43
+ "bytes": 399,
44
+ "sha256": "6f5390d53b6fff38af00c5d93b410cc41857b29152ee0d96804ddcf940ec584a"
45
+ },
46
+ "tokenizer_config.json": {
47
+ "bytes": 293,
48
+ "sha256": "e8fd48231bd72bccec02ca42ab49a4b7d51622be5d55b0f91fc11c35a4ef3a27"
49
+ }
50
+ }
retrained_20261113/globaldiff_e880_all_cfg1p25/generator.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:120bcedcffef8a268bb2bba92a8b70b21e174cedf4578778449cade638a89488
3
+ size 172404427
retrained_20261113/globaldiff_e880_all_cfg1p25/infer_wav.py ADDED
@@ -0,0 +1,198 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Generate SMPL-X parameters for one WAV using a released GlobalDiff weight.
2
+
3
+ No SMPL-X mesh asset is needed for parameter inference. Use the original
4
+ GlobalDiff source tree, the matching SimpleSpeechModel, and fixed WavLM revision.
5
+ The final partial window is padded so custom audio is covered to its last frame.
6
+ """
7
+ import argparse
8
+ import contextlib
9
+ import hashlib
10
+ import json
11
+ import math
12
+ import os
13
+ from pathlib import Path
14
+ import sys
15
+ import time
16
+
17
+ os.environ.setdefault('USE_TF', '0')
18
+ os.environ.setdefault('TRANSFORMERS_NO_TF', '1')
19
+ WAVLM_ID = 'patrickvonplaten/wavlm-libri-clean-100h-large'
20
+ WAVLM_REVISION = 'e70e3a062ec399c46008ee55d1fb52c7ba338d5c'
21
+
22
+
23
+ def sha(path):
24
+ h = hashlib.sha256()
25
+ with Path(path).open('rb') as f:
26
+ for block in iter(lambda: f.read(16 << 20), b''):
27
+ h.update(block)
28
+ return h.hexdigest()
29
+
30
+
31
+ def main():
32
+ p = argparse.ArgumentParser(description=__doc__)
33
+ p.add_argument('--repo', type=Path, default=Path(__file__).parent/'source')
34
+ p.add_argument('--checkpoint', type=Path, required=True)
35
+ p.add_argument('--speech', type=Path)
36
+ p.add_argument('--wavlm', default=WAVLM_ID, help='Fixed model id or a local snapshot directory')
37
+ p.add_argument('--wav', type=Path, required=True)
38
+ p.add_argument('--seed-pose', type=Path, required=True, help='SMPL-X NPZ: poses [>=8,165] local axis-angle, trans [>=8,3]')
39
+ p.add_argument('--pid', type=int, default=2)
40
+ p.add_argument('--out', type=Path, required=True)
41
+ p.add_argument('--cfg', type=float, default=None, help='Defaults to matching CONFIG.json, otherwise 0')
42
+ p.add_argument('--seed', type=int, default=0)
43
+ p.add_argument('--device', choices=['cpu','cuda'], default='cuda')
44
+ p.add_argument('--threads', type=int, default=4)
45
+ p.add_argument('--feature-batch', type=int, default=16)
46
+ a = p.parse_args()
47
+ if a.out.suffix != '.npz':
48
+ p.error('--out must end in .npz')
49
+ if not 0 <= a.pid <= 30:
50
+ p.error('--pid must be 0..30; 0 is the unconditional identity')
51
+ if a.out.exists() or a.out.with_suffix('.json').exists():
52
+ p.error('Output already exists; select a new path')
53
+ config = None
54
+ config_path = a.checkpoint.parent/'CONFIG.json'
55
+ if config_path.exists():
56
+ config = json.loads(config_path.read_text())
57
+ if sha(a.checkpoint) != config['generator_sha256']:
58
+ p.error('Checkpoint SHA does not match the accompanying CONFIG.json')
59
+ if a.pid != 0 and a.pid not in config['trained_person_ids']:
60
+ p.error('Unsupported person ID; trained IDs: '+str(config['trained_person_ids']))
61
+ if a.cfg is None:
62
+ a.cfg = config['inference']['cfg']
63
+ if a.cfg is None:
64
+ a.cfg = 0
65
+ speech_path = a.speech or a.repo/'Scripts/FM/ckpt/split/SimpleSpeechModel/best.pt'
66
+ if config and sha(speech_path) != config['inference']['speech_checkpoint_sha256']:
67
+ p.error('Speech checkpoint SHA does not match CONFIG.json')
68
+ if Path(a.wavlm).is_dir():
69
+ manifest_path = a.checkpoint.parent/'WAVLM_DOWNLOAD_COMPLETE.json'
70
+ if manifest_path.exists():
71
+ manifest = json.loads(manifest_path.read_text())
72
+ for name in ['pytorch_model.bin','config.json','preprocessor_config.json',
73
+ 'tokenizer_config.json','vocab.json','special_tokens_map.json','added_tokens.json']:
74
+ path = Path(a.wavlm)/name
75
+ if not path.is_file() or sha(path) != manifest[name]['sha256']:
76
+ p.error('Local WavLM snapshot does not match the fixed release: '+name)
77
+ elif a.wavlm != WAVLM_ID:
78
+ p.error('Use the fixed WavLM model ID or its verified local snapshot')
79
+ for path in [a.repo/'Scripts', a.repo/'Scripts/FM']:
80
+ sys.path.insert(0, str(path.resolve()))
81
+ import numpy as np
82
+ import soundfile as sf
83
+ import torch
84
+ import torch.nn.functional as F
85
+ from scipy.signal import resample_poly
86
+ from transformers import Wav2Vec2Processor, WavLMModel
87
+ from Net import DiffusionDITNetPartsFixedExpressions2PostNorm, SimpleSpeechModel
88
+ from SMPLXConfig import GetBodyPartIndices
89
+ from SMPLX_Util import LocalToGlobalAA, global_to_local_batch
90
+ from Util import axis_angle_to_rotation_6d, NormalizeRot6d, rotation_6d_to_matrix, rotation_matrix_to_axis_angle
91
+ from Filter import Filter1D
92
+
93
+ torch.set_num_threads(a.threads)
94
+ torch.manual_seed(a.seed)
95
+ np.random.seed(a.seed)
96
+ device = torch.device(a.device)
97
+ if device.type == 'cuda':
98
+ torch.backends.cuda.matmul.allow_tf32 = True
99
+ torch.backends.cudnn.allow_tf32 = True
100
+ started = time.monotonic()
101
+ audio, source_sr = sf.read(a.wav, dtype='float32', always_2d=True)
102
+ audio = audio.mean(axis=1)
103
+ if source_sr != 16000:
104
+ gcd = math.gcd(source_sr,16000)
105
+ audio = resample_poly(audio,16000//gcd,source_sr//gcd).astype(np.float32)
106
+ if not len(audio) or not np.isfinite(audio).all():
107
+ p.error('WAV must contain finite, nonempty audio')
108
+ frames = max(1, int(len(audio)*30/16000))
109
+ count = max(1, math.ceil(max(0,len(audio)-32000)/27734)+1)
110
+ # Integer audio strides accumulate a sub-frame offset on long recordings.
111
+ # Ensure the stitched 52-frame strides also cover the requested output.
112
+ count = max(count, math.ceil(max(0, frames-60)/52)+1)
113
+ padded = np.pad(audio,(0,32000+(count-1)*27734-len(audio)))
114
+ windows = [padded[i*27734:i*27734+32000] for i in range(count)]
115
+ kwargs = dict(local_files_only=True) if Path(a.wavlm).is_dir() else dict(revision=WAVLM_REVISION)
116
+ processor = Wav2Vec2Processor.from_pretrained(a.wavlm,**kwargs)
117
+ values = processor(windows,sampling_rate=16000,return_tensors='pt').input_values
118
+ wavlm = WavLMModel.from_pretrained(a.wavlm,**kwargs).eval().requires_grad_(False).to(device)
119
+ speech = SimpleSpeechModel().eval().requires_grad_(False).to(device)
120
+ speech.load_state_dict(torch.load(speech_path,map_location='cpu',weights_only=True),strict=True)
121
+ net = DiffusionDITNetPartsFixedExpressions2PostNorm(n_seed=8,num_person=31).eval().requires_grad_(False).to(device)
122
+ net.load_state_dict(torch.load(a.checkpoint,map_location='cpu',weights_only=True),strict=True)
123
+ with np.load(a.seed_pose,allow_pickle=False) as data:
124
+ local = data['poses'].astype(np.float32)[:8]
125
+ trans = data['trans'].astype(np.float32)[:8]
126
+ betas = data['betas'].astype(np.float32) if 'betas' in data else np.zeros(300,dtype=np.float32)
127
+ if local.shape != (8,165) or trans.shape != (8,3):
128
+ p.error('Seed pose requires eight local SMPL-X axis-angle frames and translations')
129
+ seed = np.concatenate([axis_angle_to_rotation_6d(LocalToGlobalAA(local)),trans],axis=-1)
130
+ if not np.isfinite(seed).all():
131
+ p.error('Seed pose contains nonfinite values')
132
+ seed = torch.from_numpy(seed.astype(np.float32)).unsqueeze(0).to(device)
133
+ indices = {k+'_indices':GetBodyPartIndices(k,'rot6d') for k in ['hand','upper','lower']}
134
+ indices['lower_indices'] = np.concatenate([indices['lower_indices'],np.arange(330,333)])
135
+ face = GetBodyPartIndices('face','rot6d')
136
+ indices['face_joint_indices'] = face
137
+ indices['face_indices'] = np.concatenate([face,np.arange(333,433)])
138
+ pid = torch.tensor([a.pid],device=device)
139
+ filt = Filter1D(window_length=7,polyorder=2).to(device)
140
+ amp = lambda: torch.autocast('cuda',dtype=torch.float16) if device.type == 'cuda' else contextlib.nullcontext()
141
+ feature_rows = []
142
+ with torch.inference_mode():
143
+ for start in range(0,count,a.feature_batch):
144
+ with amp():
145
+ value = wavlm(values[start:start+a.feature_batch].to(device)).last_hidden_state
146
+ value = F.interpolate(value.transpose(1,2),60,mode='linear',align_corners=True).transpose(1,2)
147
+ feature_rows.append(value.float())
148
+ features = torch.cat(feature_rows)
149
+ del wavlm
150
+ expressions = speech(features,pid.expand(count))
151
+ motions = []
152
+ # Each call has its own documented sampling seed, independent of model initialization.
153
+ torch.manual_seed(a.seed)
154
+ for n in range(count):
155
+ cond = dict(pid=pid,seed_poses=seed,hubert=features[n:n+1],expressions=expressions[n:n+1],**indices)
156
+ noise = torch.randn(1,60,333,device=device)
157
+ xt = noise
158
+ times = torch.linspace(0,1,6,device=device)
159
+ for i in range(5):
160
+ ts,te = times[i],times[i+1]
161
+ middle = (ts+te)/2
162
+ for t,next_t in [(ts,middle),(middle,te)]:
163
+ with amp():
164
+ pred = net(xt,t.expand(1),**cond)
165
+ if a.cfg > 0:
166
+ uncond = net(xt,t.expand(1),**dict(cond,pid=torch.zeros_like(pid)))
167
+ pred = (pred-uncond)*a.cfg+uncond
168
+ pred[:,:8] = (seed+pred[:,:8])/2
169
+ xt = (1-next_t)*noise+next_t*pred
170
+ xt[:,5:] = filt(xt[:,5:])
171
+ xt[...,:330] = NormalizeRot6d(xt[...,:330])
172
+ seed = xt[:,-8:]
173
+ motions.append(torch.cat([xt,expressions[n:n+1]],-1))
174
+ for n in range(1,len(motions)):
175
+ motions[n-1][:,-8:] = (motions[n-1][:,-8:]+motions[n][:,:8])/2
176
+ motions[n] = motions[n][:,8:]
177
+ motion = torch.cat(motions,1)[:,:frames]
178
+ matrices = rotation_6d_to_matrix(motion[...,:330].reshape(-1,55,6))
179
+ poses = rotation_matrix_to_axis_angle(global_to_local_batch(matrices)).reshape(-1,165).cpu().numpy()
180
+ translations = motion[0,:,330:333].cpu().numpy()
181
+ expression = motion[0,:,333:].cpu().numpy()
182
+ assert len(poses)==frames and all(np.isfinite(v).all() for v in [poses,translations,expression])
183
+ a.out.parent.mkdir(parents=True,exist_ok=True)
184
+ np.savez(a.out,poses=poses,trans=translations,expressions=expression,betas=betas,
185
+ mocap_frame_rate=np.array(30),model=np.array('smplx2020'),gender=np.array('neutral'))
186
+ meta = dict(checkpoint_sha256=sha(a.checkpoint),speech_sha256=sha(speech_path),wav_sha256=sha(a.wav),
187
+ seed_pose_sha256=sha(a.seed_pose),wavlm_id=WAVLM_ID,wavlm_revision=WAVLM_REVISION,
188
+ pid=a.pid,seed=a.seed,cfg=a.cfg,n_seed=8,steps=5,window_frames=60,audio_stride=27734,
189
+ input_sample_rate=source_sr,processed_sample_rate=16000,frames=frames,
190
+ padding='pad final partial audio window and trim to audio length; custom WAV mode',
191
+ precision='FP16 WavLM/generator, FP32 speech' if device.type=='cuda' else 'CPU FP32',
192
+ source_commit='0fece4fbf884198285769d12a9cc4bdb67185181',elapsed=time.monotonic()-started)
193
+ a.out.with_suffix('.json').write_text(json.dumps(meta,indent=2)+'\n')
194
+ print(json.dumps(meta),flush=True)
195
+
196
+
197
+ if __name__=='__main__':
198
+ main()
retrained_20261113/globaldiff_e880_all_cfg1p25/requirements-inference.txt ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ numpy==1.26.4
2
+ scipy==1.16.3
3
+ soundfile==0.13.0
4
+ einops==0.8.1
5
+ smplx==0.1.28
6
+ transformers==4.57.1
7
+ safetensors==0.7.0
8
+ huggingface-hub==0.36.2
9
+ positional-encodings==6.0.4
retrained_20261113/globaldiff_e880_all_cfg1p25/seed_pose_speaker2.npz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a0f8a79e60996a366a9659359ac91144bcbf5abf37d29782452c33bd5a65046c
3
+ size 7420
retrained_20261113/globaldiff_e880_all_cfg1p25/source/Scripts/FM/Filter.py ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ '''
3
+ Copyright (c) 2021, Alibaba Cloud and its affiliates;
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ '''
16
+
17
+ import torch
18
+ from einops import rearrange
19
+
20
+ def generate_savgol_matrix(window_length: int=5, polyorder: int=2, dtype=torch.float32) -> torch.Tensor:
21
+ """
22
+ Generate the Savitzky-Golay design matrix X for polynomial fitting.
23
+
24
+ Args:
25
+ window_length (int): Length of the filter window (must be odd).
26
+ polyorder (int): Order of the polynomial fit.
27
+ dtype (torch.dtype): Data type of the output tensor.
28
+
29
+ Returns:
30
+ torch.Tensor: Design matrix X of shape (window_length, polyorder + 1).
31
+ """
32
+ if window_length % 2 != 1:
33
+ raise ValueError("window_length must be odd.")
34
+
35
+ m = (window_length - 1) // 2 # Half-width of the window
36
+ x = torch.arange(-m, m + 1, dtype=dtype) # [-m, -m+1, ..., m]
37
+
38
+ # Construct Vandermonde matrix: each row is [1, x, x^2, ..., x^K]
39
+ X = x.unsqueeze(1).pow(torch.arange(polyorder + 1, dtype=dtype))
40
+
41
+ return X
42
+
43
+ def generate_savgol_coefficients(window_length: int=5, polyorder: int=2, dtype=torch.float32):
44
+ X = generate_savgol_matrix(window_length, polyorder, dtype)
45
+ XT = X.transpose(0, 1)
46
+ mat = torch.linalg.inv(XT @ X) @ XT
47
+ return mat[0, :] # Return the first row of the inverse matrix
48
+
49
+
50
+ class Filter1D(torch.nn.Module):
51
+ def __init__(self, window_length:int = 7, polyorder:int =2):
52
+ super().__init__()
53
+ self.window_length =window_length
54
+ coefficients = generate_savgol_coefficients(window_length=window_length, polyorder=polyorder)
55
+ self.register_buffer('coefficients', coefficients.view(1, 1, -1))
56
+
57
+ def forward(self, input_tensor:torch.Tensor, format='btc'):
58
+ x = input_tensor.clone()
59
+ if format == 'btc':
60
+ B, T, C = x.shape
61
+ x = rearrange(x, 'b t c -> (b c) 1 t')
62
+ r = torch.nn.functional.conv1d(x, self.coefficients)
63
+ x[..., self.window_length//2:-(self.window_length//2)] = r
64
+ x = rearrange(x, '(b c) 1 t -> b t c', b=B, c=C)
65
+ elif format == 'bct':
66
+ B, C, T = x.shape
67
+ x = rearrange(x, 'b c t -> (b c) 1 t')
68
+ r = torch.nn.functional.conv1d(x, self.coefficients)
69
+ x[..., self.window_length//2:-(self.window_length//2)] = r
70
+ x = rearrange(x, '(b c) 1 t -> b c t', b=B, c=C)
71
+ else:
72
+ raise ValueError("Unsupported format. Use 'btc' or 'bct'.")
73
+ return x
74
+
75
+
76
+ if __name__ == '__main__':
77
+ coefficients = generate_savgol_coefficients(window_length=5, polyorder=2)
78
+ r = torch.nn.functional.conv1d(torch.ones(1, 2, 10), coefficients.view(1, 1, -1).expand(1, 2, -1))
79
+ print(r)
retrained_20261113/globaldiff_e880_all_cfg1p25/source/Scripts/FM/Net.py ADDED
The diff for this file is too large to render. See raw diff
 
retrained_20261113/globaldiff_e880_all_cfg1p25/source/Scripts/FM/ckpt/split/SimpleSpeechModel/best.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:187df39de64c7a20983904cfca3145e44bee1630fdbad6da018d23b1e0fedaf9
3
+ size 52982500
retrained_20261113/globaldiff_e880_all_cfg1p25/source/Scripts/PositionalEncoding.py ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ '''
3
+ Copyright (c) 2021, Alibaba Cloud and its affiliates;
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ '''
16
+
17
+
18
+
19
+ import torch.nn as nn
20
+ import torch.nn.functional as F
21
+ import torch
22
+
23
+ class RotaryPositionEmbedding(nn.Module):
24
+ def __init__(self, dim):
25
+ """
26
+ Rotary Position Embedding (RoPE)
27
+
28
+ 参数:
29
+ dim (int): 输入特征的维度(必须是偶数)
30
+ """
31
+ super().__init__()
32
+ assert dim % 2 == 0, "维度必须是偶数"
33
+ self.dim = dim
34
+
35
+ # 初始化频率参数 theta_i = 10000^(-2i/d)
36
+ inv_freq = 1.0 / (10000 ** (torch.arange(0, dim, 2).float() / dim))
37
+ self.register_buffer("inv_freq", inv_freq)
38
+
39
+ # 缓存cos和sin值
40
+ self.cos_cached = None
41
+ self.sin_cached = None
42
+ self.max_seq_len = None
43
+
44
+ def _update_cos_sin_cache(self, seq_len, device):
45
+ """更新cos和sin缓存"""
46
+ if self.max_seq_len is None or seq_len > self.max_seq_len:
47
+ self.max_seq_len = seq_len
48
+ # 生成位置索引 [0, 1, ..., seq_len-1]
49
+ t = torch.arange(seq_len, device=device).type_as(self.inv_freq)
50
+
51
+ # 计算频率矩阵 shape: (seq_len, dim//2)
52
+ freqs = torch.outer(t, self.inv_freq)
53
+
54
+ # 拼接相同频率用于后续广播 shape: (seq_len, dim)
55
+ emb = torch.cat((freqs, freqs), dim=-1)
56
+
57
+ # 缓存cos和sin值
58
+ self.cos_cached = emb.cos()[None, :, None, :] # 形状: (1, seq_len, 1, dim)
59
+ self.sin_cached = emb.sin()[None, :, None, :]
60
+
61
+ def rotate_half(self, x):
62
+ """将输入的后半部分旋转并取反"""
63
+ x = x.view(*x.shape[:-1], -1, 2) # 分组成二维向量
64
+ x1 = x[..., 0] # 前半部分
65
+ x2 = x[..., 1] # 后半部分
66
+ x_rot = torch.stack((-x2, x1), dim=-1) # 旋转操作
67
+ return x_rot.view(*x.shape[:-2], -1) # 恢复原始形状
68
+
69
+ def forward(self, x, offset=0):
70
+ """
71
+ 前向传播
72
+
73
+ 参数:
74
+ x (Tensor): 输入张量,形状为 (batch, seq_len, n_head, dim)
75
+ offset (int): 位置偏移量(用于增量解码)
76
+
77
+ 返回:
78
+ Tensor: 旋转后的张量
79
+ """
80
+ batch, seq_len, n_head, _ = x.size()
81
+ self._update_cos_sin_cache(seq_len + offset, x.device)
82
+
83
+ # 获取对应位置的cos和sin值
84
+ cos = self.cos_cached[:, offset:offset+seq_len]
85
+ sin = self.sin_cached[:, offset:offset+seq_len]
86
+
87
+ # 应用旋转位置编码
88
+ x_rot = (x * cos) + (self.rotate_half(x) * sin)
89
+ return x_rot
retrained_20261113/globaldiff_e880_all_cfg1p25/source/Scripts/SMPLXConfig.py ADDED
@@ -0,0 +1,1679 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ '''
3
+ Copyright (c) 2021, Alibaba Cloud and its affiliates;
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ '''
16
+
17
+ import numpy as np
18
+ # pose version fpsxx_trinity/japanese_joints(_xxx)
19
+ joints_list = {
20
+ "trinity_joints": {
21
+ 'Hips': [6, 6],
22
+ 'Spine': [3, 9],
23
+ 'Spine1': [3, 12],
24
+ 'Spine2': [3, 15],
25
+ 'Spine3': [3, 18],
26
+ 'Neck': [3, 21],
27
+ 'Neck1': [3, 24],
28
+ 'Head': [3, 27],
29
+ 'RShoulder': [3, 30],
30
+ 'RArm': [3, 33],
31
+ 'RArm1': [3, 36],
32
+ 'RHand': [3, 39],
33
+ 'RHandT1': [3, 42],
34
+ 'RHandT2': [3, 45],
35
+ 'RHandT3': [3, 48],
36
+ 'RHandI1': [3, 51],
37
+ 'RHandI2': [3, 54],
38
+ 'RHandI3': [3, 57],
39
+ 'RHandM1': [3, 60],
40
+ 'RHandM2': [3, 63],
41
+ 'RHandM3': [3, 66],
42
+ 'RHandR1': [3, 69],
43
+ 'RHandR2': [3, 72],
44
+ 'RHandR3': [3, 75],
45
+ 'RHandP1': [3, 78],
46
+ 'RHandP2': [3, 81],
47
+ 'RHandP3': [3, 84],
48
+ 'LShoulder': [3, 87],
49
+ 'LArm': [3, 90],
50
+ 'LArm1': [3, 93],
51
+ 'LHand': [3, 96],
52
+ 'LHandT1': [3, 99],
53
+ 'LHandT2': [3, 102],
54
+ 'LHandT3': [3, 105],
55
+ 'LHandI1': [3, 108],
56
+ 'LHandI2': [3, 111],
57
+ 'LHandI3': [3, 114],
58
+ 'LHandM1': [3, 117],
59
+ 'LHandM2': [3, 120],
60
+ 'LHandM3': [3, 123],
61
+ 'LHandR1': [3, 126],
62
+ 'LHandR2': [3, 129],
63
+ 'LHandR3': [3, 132],
64
+ 'LHandP1': [3, 135],
65
+ 'LHandP2': [3, 138],
66
+ 'LHandP3': [3, 141],
67
+ 'RUpLeg': [3, 144],
68
+ 'RLeg': [3, 147],
69
+ 'RFoot': [3, 150],
70
+ 'RFootF': [3, 153],
71
+ 'RToeBase': [3, 156],
72
+ 'LUpLeg': [3, 159],
73
+ 'LLeg': [3, 162],
74
+ 'LFoot': [3, 165],
75
+ 'LFootF': [3, 168],
76
+ 'LToeBase': [3, 171], },
77
+ "trinity_joints_123": {
78
+ 'Spine': 3,
79
+ 'Neck': 3,
80
+ 'Neck1': 3,
81
+ 'RShoulder': 3,
82
+ 'RArm': 3,
83
+ 'RArm1': 3,
84
+ 'RHand': 3,
85
+ 'RHandT1': 3,
86
+ 'RHandT2': 3,
87
+ 'RHandT3': 3,
88
+ 'RHandI1': 3,
89
+ 'RHandI2': 3,
90
+ 'RHandI3': 3,
91
+ 'RHandM1': 3,
92
+ 'RHandM2': 3,
93
+ 'RHandM3': 3,
94
+ 'RHandR1': 3,
95
+ 'RHandR2': 3,
96
+ 'RHandR3': 3,
97
+ 'RHandP1': 3,
98
+ 'RHandP2': 3,
99
+ 'RHandP3': 3,
100
+ 'LShoulder': 3,
101
+ 'LArm': 3,
102
+ 'LArm1': 3,
103
+ 'LHand': 3,
104
+ 'LHandT1': 3,
105
+ 'LHandT2': 3,
106
+ 'LHandT3': 3,
107
+ 'LHandI1': 3,
108
+ 'LHandI2': 3,
109
+ 'LHandI3': 3,
110
+ 'LHandM1': 3,
111
+ 'LHandM2': 3,
112
+ 'LHandM3': 3,
113
+ 'LHandR1': 3,
114
+ 'LHandR2': 3,
115
+ 'LHandR3': 3,
116
+ 'LHandP1': 3,
117
+ 'LHandP2': 3,
118
+ 'LHandP3': 3, },
119
+ "trinity_joints_168": {
120
+ 'Hips': 3,
121
+ 'Spine': 3,
122
+ 'Spine1': 3,
123
+ 'Spine2': 3,
124
+ 'Spine3': 3,
125
+ 'Neck': 3,
126
+ 'Neck1': 3,
127
+ 'Head': 3,
128
+ 'RShoulder': 3,
129
+ 'RArm': 3,
130
+ 'RArm1': 3,
131
+ 'RHand': 3,
132
+ 'RHandT1': 3,
133
+ 'RHandT2': 3,
134
+ 'RHandT3': 3,
135
+ 'RHandI1': 3,
136
+ 'RHandI2': 3,
137
+ 'RHandI3': 3,
138
+ 'RHandM1': 3,
139
+ 'RHandM2': 3,
140
+ 'RHandM3': 3,
141
+ 'RHandR1': 3,
142
+ 'RHandR2': 3,
143
+ 'RHandR3': 3,
144
+ 'RHandP1': 3,
145
+ 'RHandP2': 3,
146
+ 'RHandP3': 3,
147
+ 'LShoulder': 3,
148
+ 'LArm': 3,
149
+ 'LArm1': 3,
150
+ 'LHand': 3,
151
+ 'LHandT1': 3,
152
+ 'LHandT2': 3,
153
+ 'LHandT3': 3,
154
+ 'LHandI1': 3,
155
+ 'LHandI2': 3,
156
+ 'LHandI3': 3,
157
+ 'LHandM1': 3,
158
+ 'LHandM2': 3,
159
+ 'LHandM3': 3,
160
+ 'LHandR1': 3,
161
+ 'LHandR2': 3,
162
+ 'LHandR3': 3,
163
+ 'LHandP1': 3,
164
+ 'LHandP2': 3,
165
+ 'LHandP3': 3,
166
+ 'RUpLeg': 3,
167
+ 'RLeg': 3,
168
+ 'RFoot': 3,
169
+ 'RFootF': 3,
170
+ 'RToeBase': 3,
171
+ 'LUpLeg': 3,
172
+ 'LLeg': 3,
173
+ 'LFoot': 3,
174
+ 'LFootF': 3,
175
+ 'LToeBase': 3, },
176
+ "trinity_joints_138": {
177
+ "Hips": 3,
178
+ 'Spine': 3,
179
+ 'Spine1': 3,
180
+ 'Spine2': 3,
181
+ 'Spine3': 3,
182
+ 'Neck': 3,
183
+ 'Neck1': 3,
184
+ 'Head': 3,
185
+ 'RShoulder': 3,
186
+ 'RArm': 3,
187
+ 'RArm1': 3,
188
+ 'RHand': 3,
189
+ 'RHandT1': 3,
190
+ 'RHandT2': 3,
191
+ 'RHandT3': 3,
192
+ 'RHandI1': 3,
193
+ 'RHandI2': 3,
194
+ 'RHandI3': 3,
195
+ 'RHandM1': 3,
196
+ 'RHandM2': 3,
197
+ 'RHandM3': 3,
198
+ 'RHandR1': 3,
199
+ 'RHandR2': 3,
200
+ 'RHandR3': 3,
201
+ 'RHandP1': 3,
202
+ 'RHandP2': 3,
203
+ 'RHandP3': 3,
204
+ 'LShoulder': 3,
205
+ 'LArm': 3,
206
+ 'LArm1': 3,
207
+ 'LHand': 3,
208
+ 'LHandT1': 3,
209
+ 'LHandT2': 3,
210
+ 'LHandT3': 3,
211
+ 'LHandI1': 3,
212
+ 'LHandI2': 3,
213
+ 'LHandI3': 3,
214
+ 'LHandM1': 3,
215
+ 'LHandM2': 3,
216
+ 'LHandM3': 3,
217
+ 'LHandR1': 3,
218
+ 'LHandR2': 3,
219
+ 'LHandR3': 3,
220
+ 'LHandP1': 3,
221
+ 'LHandP2': 3,
222
+ 'LHandP3': 3, },
223
+ "beat_smplx_joints": {
224
+ 'pelvis': [3, 3],
225
+ 'left_hip': [3, 6],
226
+ 'right_hip': [3, 9],
227
+ 'spine1': [3, 12],
228
+ 'left_knee': [3, 15],
229
+ 'right_knee': [3, 18],
230
+ 'spine2': [3, 21],
231
+ 'left_ankle': [3, 24],
232
+ 'right_ankle': [3, 27],
233
+
234
+ 'spine3': [3, 30],
235
+ 'left_foot': [3, 33],
236
+ 'right_foot': [3, 36],
237
+ 'neck': [3, 39],
238
+ 'left_collar': [3, 42],
239
+ 'right_collar': [3, 45],
240
+ 'head': [3, 48],
241
+ 'left_shoulder': [3, 51],
242
+
243
+ 'right_shoulder': [3, 54],
244
+ 'left_elbow': [3, 57],
245
+ 'right_elbow': [3, 60],
246
+ 'left_wrist': [3, 63],
247
+ 'right_wrist': [3, 66],
248
+
249
+ 'jaw': [3, 69],
250
+ 'left_eye_smplhf': [3, 72],
251
+ 'right_eye_smplhf': [3, 75],
252
+ 'left_index1': [3, 78],
253
+ 'left_index2': [3, 81],
254
+
255
+ 'left_index3': [3, 84],
256
+ 'left_middle1': [3, 87],
257
+ 'left_middle2': [3, 90],
258
+ 'left_middle3': [3, 93],
259
+ 'left_pinky1': [3, 96],
260
+
261
+ 'left_pinky2': [3, 99],
262
+ 'left_pinky3': [3, 102],
263
+ 'left_ring1': [3, 105],
264
+ 'left_ring2': [3, 108],
265
+
266
+ 'left_ring3': [3, 111],
267
+ 'left_thumb1': [3, 114],
268
+ 'left_thumb2': [3, 117],
269
+ 'left_thumb3': [3, 120],
270
+ 'right_index1': [3, 123],
271
+ 'right_index2': [3, 126],
272
+ 'right_index3': [3, 129],
273
+ 'right_middle1': [3, 132],
274
+
275
+ 'right_middle2': [3, 135],
276
+ 'right_middle3': [3, 138],
277
+ 'right_pinky1': [3, 141],
278
+ 'right_pinky2': [3, 144],
279
+ 'right_pinky3': [3, 147],
280
+
281
+ 'right_ring1': [3, 150],
282
+ 'right_ring2': [3, 153],
283
+ 'right_ring3': [3, 156],
284
+ 'right_thumb1': [3, 159],
285
+ 'right_thumb2': [3, 162],
286
+ 'right_thumb3': [3, 165],
287
+
288
+ # 'nose': [3,168],
289
+ # 'right_eye': [3,171],
290
+ # 'left_eye': [3,174],
291
+ # 'right_ear': [3,177],
292
+
293
+ # 'left_ear': [3,180],
294
+ # 'left_big_toe': [3,183],
295
+ # 'left_small_toe': [3,186],
296
+ # 'left_heel': [3,189],
297
+
298
+ # 'right_big_toe': [3,192],
299
+ # 'right_small_toe': [3,195],
300
+ # 'right_heel': [3,198],
301
+ # 'left_thumb': [3,201],
302
+ # 'left_index': [3,204],
303
+ # 'left_middle': [3,207],
304
+
305
+ # 'left_ring': [3,210],
306
+ # 'left_pinky': [3,213],
307
+ # 'right_thumb': [3,216],
308
+ # 'right_index': [3,219],
309
+ # 'right_middle': [3,222],
310
+ # 'right_ring': [3,225],
311
+
312
+ # 'right_pinky': [3,228],
313
+ # 'right_eye_brow1': [3,231],
314
+ # 'right_eye_brow2': [3,234],
315
+ # 'right_eye_brow3': [3,237],
316
+
317
+ # 'right_eye_brow4': [3,240],
318
+ # 'right_eye_brow5': [3,243],
319
+ # 'left_eye_brow5': [3,246],
320
+ # 'left_eye_brow4': [3,249],
321
+
322
+ # 'left_eye_brow3': [3,252],
323
+ # 'left_eye_brow2': [3,255],
324
+ # 'left_eye_brow1': [3,258],
325
+ # 'nose1': [3,261],
326
+ # 'nose2': [3,264],
327
+ # 'nose3': [3,267],
328
+
329
+ # 'nose4': [3,270],
330
+ # 'right_nose_2': [3,273],
331
+ # 'right_nose_1': [3,276],
332
+ # 'nose_middle': [3,279],
333
+ # 'left_nose_1': [3,282],
334
+ # 'left_nose_2': [3,285],
335
+
336
+ # 'right_eye1': [3,288],
337
+ # 'right_eye2': [3,291],
338
+ # 'right_eye3': [3,294],
339
+ # 'right_eye4': [3,297],
340
+
341
+ # 'right_eye5': [3,300],
342
+ # 'right_eye6': [3,303],
343
+ # 'left_eye4': [3,306],
344
+ # 'left_eye3': [3,309],
345
+
346
+ # 'left_eye2': [3,312],
347
+ # 'left_eye1': [3,315],
348
+ # 'left_eye6': [3,318],
349
+ # 'left_eye5': [3,321],
350
+ # 'right_mouth_1': [3,324],
351
+ # 'right_mouth_2': [3,327],
352
+ # 'right_mouth_3': [3,330],
353
+ # 'mouth_top': [3,333],
354
+ # 'left_mouth_3': [3,336],
355
+ # 'left_mouth_2': [3,339],
356
+ # 'left_mouth_1': [3,342],
357
+ # 'left_mouth_5': [3,345],
358
+ # 'left_mouth_4': [3,348],
359
+ # 'mouth_bottom': [3,351],
360
+ # 'right_mouth_4': [3,354],
361
+ # 'right_mouth_5': [3,357],
362
+ # 'right_lip_1': [3,360],
363
+ # 'right_lip_2': [3,363],
364
+ # 'lip_top': [3,366],
365
+ # 'left_lip_2': [3,369],
366
+
367
+ # 'left_lip_1': [3,372],
368
+ # 'left_lip_3': [3,375],
369
+ # 'lip_bottom': [3,378],
370
+ # 'right_lip_3': [3,381],
371
+ # 'right_contour_1': [3,384],
372
+ # 'right_contour_2': [3,387],
373
+ # 'right_contour_3': [3,390],
374
+ # 'right_contour_4': [3,393],
375
+ # 'right_contour_5': [3,396],
376
+ # 'right_contour_6': [3,399],
377
+ # 'right_contour_7': [3,402],
378
+ # 'right_contour_8': [3,405],
379
+ # 'contour_middle': [3,408],
380
+ # 'left_contour_8': [3,411],
381
+ # 'left_contour_7': [3,414],
382
+ # 'left_contour_6': [3,417],
383
+ # 'left_contour_5': [3,420],
384
+ # 'left_contour_4': [3,423],
385
+ # 'left_contour_3': [3,426],
386
+ # 'left_contour_2': [3,429],
387
+ # 'left_contour_1': [3,432],
388
+ },
389
+ "beat_smplx_joints_6d": {
390
+ 'pelvis': [6, 6],
391
+ 'left_hip': [6, 12],
392
+ 'right_hip': [6, 18],
393
+ 'spine1': [6, 24],
394
+ 'left_knee': [6, 30],
395
+ 'right_knee': [6, 36],
396
+ 'spine2': [6, 42],
397
+ 'left_ankle': [6, 48],
398
+ 'right_ankle': [6, 54],
399
+
400
+ 'spine3': [6, 60],
401
+ 'left_foot': [6, 66],
402
+ 'right_foot': [6, 72],
403
+ 'neck': [6, 78],
404
+ 'left_collar': [6, 84],
405
+ 'right_collar': [6, 90],
406
+ 'head': [6, 96],
407
+ 'left_shoulder': [6, 102],
408
+
409
+ 'right_shoulder': [6, 108],
410
+ 'left_elbow': [6, 114],
411
+ 'right_elbow': [6, 120],
412
+ 'left_wrist': [6, 126],
413
+ 'right_wrist': [6, 132],
414
+
415
+ 'jaw': [6, 138],
416
+ 'left_eye_smplhf': [6, 144],
417
+ 'right_eye_smplhf': [6, 150],
418
+ 'left_index1': [6, 156],
419
+ 'left_index2': [6, 162],
420
+
421
+ 'left_index3': [6, 168],
422
+ 'left_middle1': [6, 174],
423
+ 'left_middle2': [6, 180],
424
+ 'left_middle3': [6, 186],
425
+ 'left_pinky1': [6, 192],
426
+
427
+ 'left_pinky2': [6, 198],
428
+ 'left_pinky3': [6, 204],
429
+ 'left_ring1': [6, 210],
430
+ 'left_ring2': [6, 216],
431
+
432
+ 'left_ring3': [6, 222],
433
+ 'left_thumb1': [6, 228],
434
+ 'left_thumb2': [6, 234],
435
+ 'left_thumb3': [6, 240],
436
+ 'right_index1': [6, 246],
437
+ 'right_index2': [6, 252],
438
+ 'right_index3': [6, 258],
439
+ 'right_middle1': [6, 264],
440
+
441
+ 'right_middle2': [6, 270],
442
+ 'right_middle3': [6, 276],
443
+ 'right_pinky1': [6, 282],
444
+ 'right_pinky2': [6, 288],
445
+ 'right_pinky3': [6, 294],
446
+
447
+ 'right_ring1': [6, 300],
448
+ 'right_ring2': [6, 306],
449
+ 'right_ring3': [6, 312],
450
+ 'right_thumb1': [6, 318],
451
+ 'right_thumb2': [6, 324],
452
+ 'right_thumb3': [6, 330],
453
+ },
454
+
455
+ "beat_smplx_no_eyes": {
456
+ "pelvis": 3,
457
+ "left_hip": 3,
458
+ "right_hip": 3,
459
+ "spine1": 3,
460
+ "left_knee": 3,
461
+ "right_knee": 3,
462
+ "spine2": 3,
463
+ "left_ankle": 3,
464
+ "right_ankle": 3,
465
+ "spine3": 3,
466
+ "left_foot": 3,
467
+ "right_foot": 3,
468
+ "neck": 3,
469
+ "left_collar": 3,
470
+ "right_collar": 3,
471
+ "head": 3,
472
+ "left_shoulder": 3,
473
+ "right_shoulder": 3,
474
+ "left_elbow": 3,
475
+ "right_elbow": 3,
476
+ "left_wrist": 3,
477
+ "right_wrist": 3,
478
+ "jaw": 3,
479
+ # "left_eye_smplhf":3,
480
+ # "right_eye_smplhf":3,
481
+ "left_index1": 3,
482
+ "left_index2": 3,
483
+ "left_index3": 3,
484
+ "left_middle1": 3,
485
+ "left_middle2": 3,
486
+ "left_middle3": 3,
487
+ "left_pinky1": 3,
488
+ "left_pinky2": 3,
489
+ "left_pinky3": 3,
490
+ "left_ring1": 3,
491
+ "left_ring2": 3,
492
+ "left_ring3": 3,
493
+ "left_thumb1": 3,
494
+ "left_thumb2": 3,
495
+ "left_thumb3": 3,
496
+ "right_index1": 3,
497
+ "right_index2": 3,
498
+ "right_index3": 3,
499
+ "right_middle1": 3,
500
+ "right_middle2": 3,
501
+ "right_middle3": 3,
502
+ "right_pinky1": 3,
503
+ "right_pinky2": 3,
504
+ "right_pinky3": 3,
505
+ "right_ring1": 3,
506
+ "right_ring2": 3,
507
+ "right_ring3": 3,
508
+ "right_thumb1": 3,
509
+ "right_thumb2": 3,
510
+ "right_thumb3": 3,
511
+ },
512
+
513
+ "beat_smplx_full": {
514
+ "pelvis": 3,
515
+ "left_hip": 3,
516
+ "right_hip": 3,
517
+ "spine1": 3,
518
+ "left_knee": 3,
519
+ "right_knee": 3,
520
+ "spine2": 3,
521
+ "left_ankle": 3,
522
+ "right_ankle": 3,
523
+ "spine3": 3,
524
+ "left_foot": 3,
525
+ "right_foot": 3,
526
+ "neck": 3,
527
+ "left_collar": 3,
528
+ "right_collar": 3,
529
+ "head": 3,
530
+ "left_shoulder": 3,
531
+ "right_shoulder": 3,
532
+ "left_elbow": 3,
533
+ "right_elbow": 3,
534
+ "left_wrist": 3,
535
+ "right_wrist": 3,
536
+ "jaw": 3,
537
+ "left_eye_smplhf": 3,
538
+ "right_eye_smplhf": 3,
539
+ "left_index1": 3,
540
+ "left_index2": 3,
541
+ "left_index3": 3,
542
+ "left_middle1": 3,
543
+ "left_middle2": 3,
544
+ "left_middle3": 3,
545
+ "left_pinky1": 3,
546
+ "left_pinky2": 3,
547
+ "left_pinky3": 3,
548
+ "left_ring1": 3,
549
+ "left_ring2": 3,
550
+ "left_ring3": 3,
551
+ "left_thumb1": 3,
552
+ "left_thumb2": 3,
553
+ "left_thumb3": 3,
554
+ "right_index1": 3,
555
+ "right_index2": 3,
556
+ "right_index3": 3,
557
+ "right_middle1": 3,
558
+ "right_middle2": 3,
559
+ "right_middle3": 3,
560
+ "right_pinky1": 3,
561
+ "right_pinky2": 3,
562
+ "right_pinky3": 3,
563
+ "right_ring1": 3,
564
+ "right_ring2": 3,
565
+ "right_ring3": 3,
566
+ "right_thumb1": 3,
567
+ "right_thumb2": 3,
568
+ "right_thumb3": 3,
569
+ },
570
+
571
+ "beat_smplx_upall": {
572
+ # "pelvis":3,
573
+ # "left_hip":3,
574
+ # "right_hip":3,
575
+ "spine1": 3,
576
+ # "left_knee":3,
577
+ # "right_knee":3,
578
+ "spine2": 3,
579
+ # "left_ankle":3,
580
+ # "right_ankle":3,
581
+ "spine3": 3,
582
+ # "left_foot":3,
583
+ # "right_foot":3,
584
+ "neck": 3,
585
+ "left_collar": 3,
586
+ "right_collar": 3,
587
+ "head": 3,
588
+ "left_shoulder": 3,
589
+ "right_shoulder": 3,
590
+ "left_elbow": 3,
591
+ "right_elbow": 3,
592
+ "left_wrist": 3,
593
+ "right_wrist": 3,
594
+ # "jaw":3,
595
+ # "left_eye_smplhf":3,
596
+ # "right_eye_smplhf":3,
597
+ "left_index1": 3,
598
+ "left_index2": 3,
599
+ "left_index3": 3,
600
+ "left_middle1": 3,
601
+ "left_middle2": 3,
602
+ "left_middle3": 3,
603
+ "left_pinky1": 3,
604
+ "left_pinky2": 3,
605
+ "left_pinky3": 3,
606
+ "left_ring1": 3,
607
+ "left_ring2": 3,
608
+ "left_ring3": 3,
609
+ "left_thumb1": 3,
610
+ "left_thumb2": 3,
611
+ "left_thumb3": 3,
612
+ "right_index1": 3,
613
+ "right_index2": 3,
614
+ "right_index3": 3,
615
+ "right_middle1": 3,
616
+ "right_middle2": 3,
617
+ "right_middle3": 3,
618
+ "right_pinky1": 3,
619
+ "right_pinky2": 3,
620
+ "right_pinky3": 3,
621
+ "right_ring1": 3,
622
+ "right_ring2": 3,
623
+ "right_ring3": 3,
624
+ "right_thumb1": 3,
625
+ "right_thumb2": 3,
626
+ "right_thumb3": 3,
627
+ },
628
+
629
+ "beat_smplx_upper": {
630
+ # "pelvis":3,
631
+ # "left_hip":3,
632
+ # "right_hip":3,
633
+ "spine1": 3,
634
+ # "left_knee":3,
635
+ # "right_knee":3,
636
+ "spine2": 3,
637
+ # "left_ankle":3,
638
+ # "right_ankle":3,
639
+ "spine3": 3,
640
+ # "left_foot":3,
641
+ # "right_foot":3,
642
+ "neck": 3,
643
+ "left_collar": 3,
644
+ "right_collar": 3,
645
+ "head": 3,
646
+ "left_shoulder": 3,
647
+ "right_shoulder": 3,
648
+ "left_elbow": 3,
649
+ "right_elbow": 3,
650
+ "left_wrist": 3,
651
+ "right_wrist": 3,
652
+ # "jaw":3,
653
+ # "left_eye_smplhf":3,
654
+ # "right_eye_smplhf":3,
655
+ # "left_index1":3,
656
+ # "left_index2":3,
657
+ # "left_index3":3,
658
+ # "left_middle1":3,
659
+ # "left_middle2":3,
660
+ # "left_middle3":3,
661
+ # "left_pinky1":3,
662
+ # "left_pinky2":3,
663
+ # "left_pinky3":3,
664
+ # "left_ring1":3,
665
+ # "left_ring2":3,
666
+ # "left_ring3":3,
667
+ # "left_thumb1":3,
668
+ # "left_thumb2":3,
669
+ # "left_thumb3":3,
670
+ # "right_index1":3,
671
+ # "right_index2":3,
672
+ # "right_index3":3,
673
+ # "right_middle1":3,
674
+ # "right_middle2":3,
675
+ # "right_middle3":3,
676
+ # "right_pinky1":3,
677
+ # "right_pinky2":3,
678
+ # "right_pinky3":3,
679
+ # "right_ring1":3,
680
+ # "right_ring2":3,
681
+ # "right_ring3":3,
682
+ # "right_thumb1":3,
683
+ # "right_thumb2":3,
684
+ # "right_thumb3":3,
685
+ },
686
+
687
+ "beat_smplx_hands": {
688
+ "left_index1": 3,
689
+ "left_index2": 3,
690
+ "left_index3": 3,
691
+ "left_middle1": 3,
692
+ "left_middle2": 3,
693
+ "left_middle3": 3,
694
+ "left_pinky1": 3,
695
+ "left_pinky2": 3,
696
+ "left_pinky3": 3,
697
+ "left_ring1": 3,
698
+ "left_ring2": 3,
699
+ "left_ring3": 3,
700
+ "left_thumb1": 3,
701
+ "left_thumb2": 3,
702
+ "left_thumb3": 3,
703
+ "right_index1": 3,
704
+ "right_index2": 3,
705
+ "right_index3": 3,
706
+ "right_middle1": 3,
707
+ "right_middle2": 3,
708
+ "right_middle3": 3,
709
+ "right_pinky1": 3,
710
+ "right_pinky2": 3,
711
+ "right_pinky3": 3,
712
+ "right_ring1": 3,
713
+ "right_ring2": 3,
714
+ "right_ring3": 3,
715
+ "right_thumb1": 3,
716
+ "right_thumb2": 3,
717
+ "right_thumb3": 3,
718
+ },
719
+ "beat_smplx_rhands": {
720
+ "right_index1": 3,
721
+ "right_index2": 3,
722
+ "right_index3": 3,
723
+ "right_middle1": 3,
724
+ "right_middle2": 3,
725
+ "right_middle3": 3,
726
+ "right_pinky1": 3,
727
+ "right_pinky2": 3,
728
+ "right_pinky3": 3,
729
+ "right_ring1": 3,
730
+ "right_ring2": 3,
731
+ "right_ring3": 3,
732
+ "right_thumb1": 3,
733
+ "right_thumb2": 3,
734
+ "right_thumb3": 3,
735
+ },
736
+ "beat_smplx_lhands": {
737
+ "left_index1": 3,
738
+ "left_index2": 3,
739
+ "left_index3": 3,
740
+ "left_middle1": 3,
741
+ "left_middle2": 3,
742
+ "left_middle3": 3,
743
+ "left_pinky1": 3,
744
+ "left_pinky2": 3,
745
+ "left_pinky3": 3,
746
+ "left_ring1": 3,
747
+ "left_ring2": 3,
748
+ "left_ring3": 3,
749
+ "left_thumb1": 3,
750
+ "left_thumb2": 3,
751
+ "left_thumb3": 3,
752
+ },
753
+ "beat_smplx_lower": {
754
+ "pelvis": 3,
755
+ "left_hip": 3,
756
+ "right_hip": 3,
757
+ # "spine1":3,
758
+ "left_knee": 3,
759
+ "right_knee": 3,
760
+ # "spine2":3,
761
+ "left_ankle": 3,
762
+ "right_ankle": 3,
763
+ # "spine3":3,
764
+ "left_foot": 3,
765
+ "right_foot": 3,
766
+ # "neck":3,
767
+ # "left_collar":3,
768
+ # "right_collar":3,
769
+ # "head":3,
770
+ # "left_shoulder":3,
771
+ # "right_shoulder":3,
772
+ # "left_elbow":3,
773
+ # "right_elbow":3,
774
+ # "left_wrist":3,
775
+ # "right_wrist":3,
776
+ # "jaw":3,
777
+ # "left_eye_smplhf":3,
778
+ # "right_eye_smplhf":3,
779
+ # "left_index1":3,
780
+ # "left_index2":3,
781
+ # "left_index3":3,
782
+ # "left_middle1":3,
783
+ # "left_middle2":3,
784
+ # "left_middle3":3,
785
+ # "left_pinky1":3,
786
+ # "left_pinky2":3,
787
+ # "left_pinky3":3,
788
+ # "left_ring1":3,
789
+ # "left_ring2":3,
790
+ # "left_ring3":3,
791
+ # "left_thumb1":3,
792
+ # "left_thumb2":3,
793
+ # "left_thumb3":3,
794
+ # "right_index1":3,
795
+ # "right_index2":3,
796
+ # "right_index3":3,
797
+ # "right_middle1":3,
798
+ # "right_middle2":3,
799
+ # "right_middle3":3,
800
+ # "right_pinky1":3,
801
+ # "right_pinky2":3,
802
+ # "right_pinky3":3,
803
+ # "right_ring1":3,
804
+ # "right_ring2":3,
805
+ # "right_ring3":3,
806
+ # "right_thumb1":3,
807
+ # "right_thumb2":3,
808
+ # "right_thumb3":3,
809
+ },
810
+
811
+ "beat_smplx_face": {
812
+ # "pelvis":3,
813
+ # "left_hip":3,
814
+ # "right_hip":3,
815
+ # # "spine1":3,
816
+ # "left_knee":3,
817
+ # "right_knee":3,
818
+ # # "spine2":3,
819
+ # "left_ankle":3,
820
+ # "right_ankle":3,
821
+ # # "spine3":3,
822
+ # "left_foot":3,
823
+ # "right_foot":3,
824
+ # "neck":3,
825
+ # "left_collar":3,
826
+ # "right_collar":3,
827
+ # "head":3,
828
+ # "left_shoulder":3,
829
+ # "right_shoulder":3,
830
+ # "left_elbow":3,
831
+ # "right_elbow":3,
832
+ # "left_wrist":3,
833
+ # "right_wrist":3,
834
+ "jaw": 3,
835
+ # "left_eye_smplhf":3,
836
+ # "right_eye_smplhf":3,
837
+ # "left_index1":3,
838
+ # "left_index2":3,
839
+ # "left_index3":3,
840
+ # "left_middle1":3,
841
+ # "left_middle2":3,
842
+ # "left_middle3":3,
843
+ # "left_pinky1":3,
844
+ # "left_pinky2":3,
845
+ # "left_pinky3":3,
846
+ # "left_ring1":3,
847
+ # "left_ring2":3,
848
+ # "left_ring3":3,
849
+ # "left_thumb1":3,
850
+ # "left_thumb2":3,
851
+ # "left_thumb3":3,
852
+ # "right_index1":3,
853
+ # "right_index2":3,
854
+ # "right_index3":3,
855
+ # "right_middle1":3,
856
+ # "right_middle2":3,
857
+ # "right_middle3":3,
858
+ # "right_pinky1":3,
859
+ # "right_pinky2":3,
860
+ # "right_pinky3":3,
861
+ # "right_ring1":3,
862
+ # "right_ring2":3,
863
+ # "right_ring3":3,
864
+ # "right_thumb1":3,
865
+ # "right_thumb2":3,
866
+ # "right_thumb3":3,
867
+ },
868
+
869
+ "beat_smplx_face_3": {
870
+ # "pelvis":3,
871
+ # "left_hip":3,
872
+ # "right_hip":3,
873
+ # # "spine1":3,
874
+ # "left_knee":3,
875
+ # "right_knee":3,
876
+ # # "spine2":3,
877
+ # "left_ankle":3,
878
+ # "right_ankle":3,
879
+ # # "spine3":3,
880
+ # "left_foot":3,
881
+ # "right_foot":3,
882
+ # "neck":3,
883
+ # "left_collar":3,
884
+ # "right_collar":3,
885
+ # "head":3,
886
+ # "left_shoulder":3,
887
+ # "right_shoulder":3,
888
+ # "left_elbow":3,
889
+ # "right_elbow":3,
890
+ # "left_wrist":3,
891
+ # "right_wrist":3,
892
+ "jaw": 3,
893
+ "left_eye_smplhf": 3,
894
+ "right_eye_smplhf": 3,
895
+ # "left_index1":3,
896
+ # "left_index2":3,
897
+ # "left_index3":3,
898
+ # "left_middle1":3,
899
+ # "left_middle2":3,
900
+ # "left_middle3":3,
901
+ # "left_pinky1":3,
902
+ # "left_pinky2":3,
903
+ # "left_pinky3":3,
904
+ # "left_ring1":3,
905
+ # "left_ring2":3,
906
+ # "left_ring3":3,
907
+ # "left_thumb1":3,
908
+ # "left_thumb2":3,
909
+ # "left_thumb3":3,
910
+ # "right_index1":3,
911
+ # "right_index2":3,
912
+ # "right_index3":3,
913
+ # "right_middle1":3,
914
+ # "right_middle2":3,
915
+ # "right_middle3":3,
916
+ # "right_pinky1":3,
917
+ # "right_pinky2":3,
918
+ # "right_pinky3":3,
919
+ # "right_ring1":3,
920
+ # "right_ring2":3,
921
+ # "right_ring3":3,
922
+ # "right_thumb1":3,
923
+ # "right_thumb2":3,
924
+ # "right_thumb3":3,
925
+ },
926
+ "beat_joints": {
927
+ 'Hips': [6, 6],
928
+ 'Spine': [3, 9],
929
+ 'Spine1': [3, 12],
930
+ 'Spine2': [3, 15],
931
+ 'Spine3': [3, 18],
932
+ 'Neck': [3, 21],
933
+ 'Neck1': [3, 24],
934
+ 'Head': [3, 27],
935
+ 'HeadEnd': [3, 30],
936
+
937
+ 'RShoulder': [3, 33],
938
+ 'RArm': [3, 36],
939
+ 'RArm1': [3, 39],
940
+ 'RHand': [3, 42],
941
+ 'RHandM1': [3, 45],
942
+ 'RHandM2': [3, 48],
943
+ 'RHandM3': [3, 51],
944
+ 'RHandM4': [3, 54],
945
+
946
+ 'RHandR': [3, 57],
947
+ 'RHandR1': [3, 60],
948
+ 'RHandR2': [3, 63],
949
+ 'RHandR3': [3, 66],
950
+ 'RHandR4': [3, 69],
951
+
952
+ 'RHandP': [3, 72],
953
+ 'RHandP1': [3, 75],
954
+ 'RHandP2': [3, 78],
955
+ 'RHandP3': [3, 81],
956
+ 'RHandP4': [3, 84],
957
+
958
+ 'RHandI': [3, 87],
959
+ 'RHandI1': [3, 90],
960
+ 'RHandI2': [3, 93],
961
+ 'RHandI3': [3, 96],
962
+ 'RHandI4': [3, 99],
963
+
964
+ 'RHandT1': [3, 102],
965
+ 'RHandT2': [3, 105],
966
+ 'RHandT3': [3, 108],
967
+ 'RHandT4': [3, 111],
968
+
969
+ 'LShoulder': [3, 114],
970
+ 'LArm': [3, 117],
971
+ 'LArm1': [3, 120],
972
+ 'LHand': [3, 123],
973
+ 'LHandM1': [3, 126],
974
+ 'LHandM2': [3, 129],
975
+ 'LHandM3': [3, 132],
976
+ 'LHandM4': [3, 135],
977
+
978
+ 'LHandR': [3, 138],
979
+ 'LHandR1': [3, 141],
980
+ 'LHandR2': [3, 144],
981
+ 'LHandR3': [3, 147],
982
+ 'LHandR4': [3, 150],
983
+
984
+ 'LHandP': [3, 153],
985
+ 'LHandP1': [3, 156],
986
+ 'LHandP2': [3, 159],
987
+ 'LHandP3': [3, 162],
988
+ 'LHandP4': [3, 165],
989
+
990
+ 'LHandI': [3, 168],
991
+ 'LHandI1': [3, 171],
992
+ 'LHandI2': [3, 174],
993
+ 'LHandI3': [3, 177],
994
+ 'LHandI4': [3, 180],
995
+
996
+ 'LHandT1': [3, 183],
997
+ 'LHandT2': [3, 186],
998
+ 'LHandT3': [3, 189],
999
+ 'LHandT4': [3, 192],
1000
+
1001
+ 'RUpLeg': [3, 195],
1002
+ 'RLeg': [3, 198],
1003
+ 'RFoot': [3, 201],
1004
+ 'RFootF': [3, 204],
1005
+ 'RToeBase': [3, 207],
1006
+ 'RToeBaseEnd': [3, 210],
1007
+
1008
+ 'LUpLeg': [3, 213],
1009
+ 'LLeg': [3, 216],
1010
+ 'LFoot': [3, 219],
1011
+ 'LFootF': [3, 222],
1012
+ 'LToeBase': [3, 225],
1013
+ 'LToeBaseEnd': [3, 228], },
1014
+
1015
+ "beat_full": {
1016
+ 'Hips': 3,
1017
+ 'Spine': 3,
1018
+ 'Spine1': 3,
1019
+ 'Spine2': 3,
1020
+ 'Spine3': 3,
1021
+ 'Neck': 3,
1022
+ 'Neck1': 3,
1023
+ 'Head': 3,
1024
+ 'HeadEnd': 3,
1025
+ 'RShoulder': 3,
1026
+ 'RArm': 3,
1027
+ 'RArm1': 3,
1028
+ 'RHand': 3,
1029
+ 'RHandM1': 3,
1030
+ 'RHandM2': 3,
1031
+ 'RHandM3': 3,
1032
+ 'RHandM4': 3,
1033
+ 'RHandR': 3,
1034
+ 'RHandR1': 3,
1035
+ 'RHandR2': 3,
1036
+ 'RHandR3': 3,
1037
+ 'RHandR4': 3,
1038
+ 'RHandP': 3,
1039
+ 'RHandP1': 3,
1040
+ 'RHandP2': 3,
1041
+ 'RHandP3': 3,
1042
+ 'RHandP4': 3,
1043
+ 'RHandI': 3,
1044
+ 'RHandI1': 3,
1045
+ 'RHandI2': 3,
1046
+ 'RHandI3': 3,
1047
+ 'RHandI4': 3,
1048
+ 'RHandT1': 3,
1049
+ 'RHandT2': 3,
1050
+ 'RHandT3': 3,
1051
+ 'RHandT4': 3,
1052
+ 'LShoulder': 3,
1053
+ 'LArm': 3,
1054
+ 'LArm1': 3,
1055
+ 'LHand': 3,
1056
+ 'LHandM1': 3,
1057
+ 'LHandM2': 3,
1058
+ 'LHandM3': 3,
1059
+ 'LHandM4': 3,
1060
+ 'LHandR': 3,
1061
+ 'LHandR1': 3,
1062
+ 'LHandR2': 3,
1063
+ 'LHandR3': 3,
1064
+ 'LHandR4': 3,
1065
+ 'LHandP': 3,
1066
+ 'LHandP1': 3,
1067
+ 'LHandP2': 3,
1068
+ 'LHandP3': 3,
1069
+ 'LHandP4': 3,
1070
+ 'LHandI': 3,
1071
+ 'LHandI1': 3,
1072
+ 'LHandI2': 3,
1073
+ 'LHandI3': 3,
1074
+ 'LHandI4': 3,
1075
+ 'LHandT1': 3,
1076
+ 'LHandT2': 3,
1077
+ 'LHandT3': 3,
1078
+ 'LHandT4': 3,
1079
+ 'RUpLeg': 3,
1080
+ 'RLeg': 3,
1081
+ 'RFoot': 3,
1082
+ 'RFootF': 3,
1083
+ 'RToeBase': 3,
1084
+ 'RToeBaseEnd': 3,
1085
+ 'LUpLeg': 3,
1086
+ 'LLeg': 3,
1087
+ 'LFoot': 3,
1088
+ 'LFootF': 3,
1089
+ 'LToeBase': 3,
1090
+ 'LToeBaseEnd': 3,
1091
+ },
1092
+
1093
+ "japanese_joints": {
1094
+ 'Hips': [6, 6],
1095
+ 'Spine': [6, 12],
1096
+ 'Spine1': [6, 18],
1097
+ 'Spine2': [6, 24],
1098
+ 'Spine3': [6, 30],
1099
+ 'Neck': [6, 36],
1100
+ 'Neck1': [6, 42],
1101
+ 'Head': [6, 48],
1102
+ 'RShoulder': [6, 54],
1103
+ 'RArm': [6, 60],
1104
+ 'RArm1': [6, 66],
1105
+ 'RHand': [6, 72],
1106
+ 'RHandM1': [6, 78],
1107
+ 'RHandM2': [6, 84],
1108
+ 'RHandM3': [6, 90],
1109
+ 'RHandR': [6, 96],
1110
+ 'RHandR1': [6, 102],
1111
+ 'RHandR2': [6, 108],
1112
+ 'RHandR3': [6, 114],
1113
+ 'RHandP': [6, 120],
1114
+ 'RHandP1': [6, 126],
1115
+ 'RHandP2': [6, 132],
1116
+ 'RHandP3': [6, 138],
1117
+ 'RHandI': [6, 144],
1118
+ 'RHandI1': [6, 150],
1119
+ 'RHandI2': [6, 156],
1120
+ 'RHandI3': [6, 162],
1121
+ 'RHandT1': [6, 168],
1122
+ 'RHandT2': [6, 174],
1123
+ 'RHandT3': [6, 180],
1124
+ 'LShoulder': [6, 186],
1125
+ 'LArm': [6, 192],
1126
+ 'LArm1': [6, 198],
1127
+ 'LHand': [6, 204],
1128
+ 'LHandM1': [6, 210],
1129
+ 'LHandM2': [6, 216],
1130
+ 'LHandM3': [6, 222],
1131
+ 'LHandR': [6, 228],
1132
+ 'LHandR1': [6, 234],
1133
+ 'LHandR2': [6, 240],
1134
+ 'LHandR3': [6, 246],
1135
+ 'LHandP': [6, 252],
1136
+ 'LHandP1': [6, 258],
1137
+ 'LHandP2': [6, 264],
1138
+ 'LHandP3': [6, 270],
1139
+ 'LHandI': [6, 276],
1140
+ 'LHandI1': [6, 282],
1141
+ 'LHandI2': [6, 288],
1142
+ 'LHandI3': [6, 294],
1143
+ 'LHandT1': [6, 300],
1144
+ 'LHandT2': [6, 306],
1145
+ 'LHandT3': [6, 312],
1146
+ 'RUpLeg': [6, 318],
1147
+ 'RLeg': [6, 324],
1148
+ 'RFoot': [6, 330],
1149
+ 'RFootF': [6, 336],
1150
+ 'RToeBase': [6, 342],
1151
+ 'LUpLeg': [6, 348],
1152
+ 'LLeg': [6, 354],
1153
+ 'LFoot': [6, 360],
1154
+ 'LFootF': [6, 366],
1155
+ 'LToeBase': [6, 372], },
1156
+
1157
+ "yostar": {
1158
+ 'Hips': [6, 6],
1159
+ 'Spine': [3, 9],
1160
+ 'Spine1': [3, 12],
1161
+ 'Bone040': [3, 15],
1162
+ 'Bone041': [3, 18],
1163
+
1164
+ 'Bone034': [3, 21],
1165
+ 'Bone035': [3, 24],
1166
+ 'Bone036': [3, 27],
1167
+ 'Bone037': [3, 30],
1168
+ 'Bone038': [3, 33],
1169
+ 'Bone039': [3, 36],
1170
+
1171
+ 'RibbonL1': [3, 39],
1172
+ 'RibbonL1_end': [3, 42],
1173
+
1174
+ 'Chest': [3, 45],
1175
+ 'L_eri': [3, 48],
1176
+ 'R_eri': [3, 51],
1177
+ 'Neck': [3, 54],
1178
+ 'Head': [3, 57],
1179
+ 'Head_end': [3, 60],
1180
+
1181
+ 'RBackHair_1': [3, 63],
1182
+ 'RBackHair_2': [3, 66],
1183
+ 'RBackHair_3': [3, 69],
1184
+ 'RBackHair_4': [3, 72],
1185
+ 'RBackHair_end': [3, 75],
1186
+
1187
+ 'RFrontHair': [3, 78],
1188
+ 'CFrontHair_1': [3, 81],
1189
+ 'CFrontHair_2': [3, 84],
1190
+ 'CFrontHair_3': [3, 87],
1191
+ 'CFrontHair_emd': [3, 90],
1192
+
1193
+ 'LFrontHair_1': [3, 93],
1194
+ 'LFrontHair_2': [3, 96],
1195
+ 'LFrontHair_3': [3, 99],
1196
+
1197
+ 'LBackHair_1': [3, 102],
1198
+ 'LBackHair_2': [3, 105],
1199
+ 'LBackHair_3': [3, 108],
1200
+ 'LBackHair_4': [3, 111],
1201
+ 'LBackHair_end': [3, 114],
1202
+
1203
+ 'LSideHair_1': [3, 117],
1204
+ 'LSideHair_2': [3, 120],
1205
+ 'LSideHair_3': [3, 123],
1206
+ 'LSideHair_4': [3, 126],
1207
+ 'LSideHair_5': [3, 129],
1208
+ 'LSideHair_6': [3, 132],
1209
+ 'LSideHair_7': [3, 135],
1210
+ 'LSideHair_end': [3, 138],
1211
+
1212
+ 'CBackHair_1': [3, 141],
1213
+ 'CBackHair_2': [3, 144],
1214
+ 'CBackHair_3': [3, 147],
1215
+ 'CBackHair_4': [3, 150],
1216
+ 'CBackHair_end': [3, 153],
1217
+
1218
+ 'RSideHair_1': [3, 156],
1219
+ 'RSideHair_2': [3, 159],
1220
+ 'RSideHair_3': [3, 162],
1221
+ 'RSideHair_4': [3, 165],
1222
+
1223
+ 'RibbonR_1': [3, 168],
1224
+ 'RibbonR_2': [3, 171],
1225
+ 'RibbonR_3': [3, 174],
1226
+
1227
+ 'RibbonL_1': [3, 177],
1228
+ 'RibbonL_2': [3, 180],
1229
+ 'RibbonL_3': [3, 183],
1230
+
1231
+ 'LeftEye': [3, 186],
1232
+ 'LeftEye_end': [3, 189],
1233
+ 'RightEye': [3, 192],
1234
+ 'RightEye_end': [3, 195],
1235
+
1236
+ 'LeftShoulder': [3, 198],
1237
+ 'LeftArm': [3, 201],
1238
+ 'LeftForearm': [3, 204],
1239
+ 'LeftHand': [3, 207],
1240
+ 'LeftHandThumb1': [3, 210],
1241
+ 'LeftHandThumb2': [3, 213],
1242
+ 'LeftHandThumb3': [3, 216],
1243
+ 'LeftHandThumb_end': [3, 219],
1244
+
1245
+ 'LeftHandIndex1': [3, 222],
1246
+ 'LeftHandIndex2': [3, 225],
1247
+ 'LeftHandIndex3': [3, 228],
1248
+ 'LeftHandIndex_end': [3, 231],
1249
+
1250
+ 'LeftHandMiddle1': [3, 234],
1251
+ 'LeftHandMiddle2': [3, 237],
1252
+ 'LeftHandMiddle3': [3, 240],
1253
+ 'LeftHandMiddle_end': [3, 243],
1254
+
1255
+ 'LeftHandRing1': [3, 246],
1256
+ 'LeftHandRing2': [3, 249],
1257
+ 'LeftHandRing3': [3, 252],
1258
+ 'LeftHandRing_end': [3, 255],
1259
+
1260
+ 'LeftHandPinky1': [3, 258],
1261
+ 'LeftHandPinky2': [3, 261],
1262
+ 'LeftHandPinky3': [3, 264],
1263
+ 'LeftHandPinky_end': [3, 267],
1264
+
1265
+ 'RightShoulder': [3, 270],
1266
+ 'RightArm': [3, 273],
1267
+ 'RightForearm': [3, 276],
1268
+ 'RightHand': [3, 279],
1269
+ 'RightHandThumb1': [3, 282],
1270
+ 'RightHandThumb2': [3, 285],
1271
+ 'RightHandThumb3': [3, 288],
1272
+ 'RightHandThumb_end': [3, 291],
1273
+
1274
+ 'RightHandIndex1': [3, 294],
1275
+ 'RightHandIndex2': [3, 297],
1276
+ 'RightHandIndex3': [3, 300],
1277
+ 'RightHandIndex_end': [3, 303],
1278
+
1279
+ 'RightHandMiddle1': [3, 306],
1280
+ 'RightHandMiddle2': [3, 309],
1281
+ 'RightHandMiddle3': [3, 312],
1282
+ 'RightHandMiddle_end': [3, 315],
1283
+
1284
+ 'RightHandRing1': [3, 318],
1285
+ 'RightHandRing2': [3, 321],
1286
+ 'RightHandRing3': [3, 324],
1287
+ 'RightHandRing_end': [3, 327],
1288
+
1289
+ 'RightHandPinky1': [3, 330],
1290
+ 'RightHandPinky2': [3, 333],
1291
+ 'RightHandPinky3': [3, 336],
1292
+ 'RightHandPinky_end': [3, 339],
1293
+
1294
+ 'RibbonR1': [3, 342],
1295
+ 'RibbonR1_end': [3, 345],
1296
+ 'RibbonR2': [3, 348],
1297
+ 'RibbonR2_end': [3, 351],
1298
+ 'RibbonL2': [3, 354],
1299
+ 'RibbonL2_end': [3, 357],
1300
+
1301
+ 'LeftUpLeg': [3, 360],
1302
+ 'LeftLeg': [3, 363],
1303
+ 'LeftFoot': [3, 366],
1304
+ 'LeftToe': [3, 369],
1305
+ 'LeftToe_end': [3, 372],
1306
+
1307
+ 'RightUpLeg': [3, 375],
1308
+ 'RightLEg': [3, 378],
1309
+ 'RightFoot': [3, 381],
1310
+ 'RightToe': [3, 384],
1311
+ 'RightToe_end': [3, 387],
1312
+
1313
+ 'bone_skirtF00': [3, 390],
1314
+ 'bone_skirtF01': [3, 393],
1315
+ 'bone_skirtF02': [3, 396],
1316
+ 'bone_skirtF03': [3, 399],
1317
+ 'Bone020': [3, 402],
1318
+ 'Bone026': [3, 405],
1319
+
1320
+ 'bone_skirtF_R_00': [3, 408],
1321
+ 'bone_skirtF_R_01': [3, 411],
1322
+ 'bone_skirtF_R_02': [3, 414],
1323
+ 'bone_skirtF_R_03': [3, 417],
1324
+ 'Bone019': [3, 420],
1325
+ 'Bone028': [3, 423],
1326
+
1327
+ 'bone_skirtR00': [3, 426],
1328
+ 'bone_skirtR01': [3, 429],
1329
+ 'bone_skirtR02': [3, 432],
1330
+ 'bone_skirtR03': [3, 435],
1331
+ 'Bone018': [3, 438],
1332
+ 'Bone029': [3, 441],
1333
+
1334
+ 'bone_skirtF_L_00': [3, 444],
1335
+ 'bone_skirtF_L_01': [3, 447],
1336
+ 'bone_skirtF_L_02': [3, 450],
1337
+ 'bone_skirtF_L_03': [3, 453],
1338
+ 'Bone021': [3, 456],
1339
+ 'Bone027': [3, 459],
1340
+
1341
+ 'bone_skirtL00': [3, 462],
1342
+ 'bone_skirtL01': [3, 465],
1343
+ 'bone_skirtL02': [3, 468],
1344
+ 'bone_skirtL03': [3, 471],
1345
+ 'Bone022': [3, 474],
1346
+ 'Bone033': [3, 477],
1347
+
1348
+ 'bone_skirtB_L_00': [3, 480],
1349
+ 'bone_skirtB_L_01': [3, 483],
1350
+ 'bone_skirtB_L_02': [3, 486],
1351
+ 'bone_skirtB_L_03': [3, 489],
1352
+ 'Bone023': [3, 492],
1353
+ 'Bone032': [3, 495],
1354
+
1355
+ 'bone_skirtB00': [3, 498],
1356
+ 'bone_skirtB01': [3, 501],
1357
+ 'bone_skirtB02': [3, 504],
1358
+ 'bone_skirtB03': [3, 507],
1359
+ 'Bone024': [3, 510],
1360
+ 'Bone031': [3, 513],
1361
+
1362
+ 'bone_skirtB_R_00': [3, 516],
1363
+ 'bone_skirtB_R_01': [3, 519],
1364
+ 'bone_skirtB_R_02': [3, 521],
1365
+ 'bone_skirtB_R_03': [3, 524],
1366
+ 'Bone025': [3, 527],
1367
+ 'Bone030': [3, 530],
1368
+ },
1369
+
1370
+ "yostar_fullbody_213": {
1371
+ 'Hips': 3,
1372
+ 'Spine': 3,
1373
+ 'Spine1': 3,
1374
+ 'Chest': 3,
1375
+ 'L_eri': 3,
1376
+ 'R_eri': 3,
1377
+ 'Neck': 3,
1378
+ 'Head': 3,
1379
+ 'Head_end': 3,
1380
+
1381
+ 'LeftEye': 3,
1382
+ 'LeftEye_end': 3,
1383
+ 'RightEye': 3,
1384
+ 'RightEye_end': 3,
1385
+
1386
+ 'LeftShoulder': 3,
1387
+ 'LeftArm': 3,
1388
+ 'LeftForearm': 3,
1389
+ 'LeftHand': 3,
1390
+ 'LeftHandThumb1': 3,
1391
+ 'LeftHandThumb2': 3,
1392
+ 'LeftHandThumb3': 3,
1393
+ 'LeftHandThumb_end': 3,
1394
+
1395
+ 'LeftHandIndex1': 3,
1396
+ 'LeftHandIndex2': 3,
1397
+ 'LeftHandIndex3': 3,
1398
+ 'LeftHandIndex_end': 3,
1399
+
1400
+ 'LeftHandMiddle1': 3,
1401
+ 'LeftHandMiddle2': 3,
1402
+ 'LeftHandMiddle3': 3,
1403
+ 'LeftHandMiddle_end': 3,
1404
+
1405
+ 'LeftHandRing1': 3,
1406
+ 'LeftHandRing2': 3,
1407
+ 'LeftHandRing3': 3,
1408
+ 'LeftHandRing_end': 3,
1409
+
1410
+ 'LeftHandPinky1': 3,
1411
+ 'LeftHandPinky2': 3,
1412
+ 'LeftHandPinky3': 3,
1413
+ 'LeftHandPinky_end': 3,
1414
+
1415
+ 'RightShoulder': 3,
1416
+ 'RightArm': 3,
1417
+ 'RightForearm': 3,
1418
+ 'RightHand': 3,
1419
+ 'RightHandThumb1': 3,
1420
+ 'RightHandThumb2': 3,
1421
+ 'RightHandThumb3': 3,
1422
+ 'RightHandThumb_end': 3,
1423
+
1424
+ 'RightHandIndex1': 3,
1425
+ 'RightHandIndex2': 3,
1426
+ 'RightHandIndex3': 3,
1427
+ 'RightHandIndex_end': 3,
1428
+
1429
+ 'RightHandMiddle1': 3,
1430
+ 'RightHandMiddle2': 3,
1431
+ 'RightHandMiddle3': 3,
1432
+ 'RightHandMiddle_end': 3,
1433
+
1434
+ 'RightHandRing1': 3,
1435
+ 'RightHandRing2': 3,
1436
+ 'RightHandRing3': 3,
1437
+ 'RightHandRing_end': 3,
1438
+
1439
+ 'RightHandPinky1': 3,
1440
+ 'RightHandPinky2': 3,
1441
+ 'RightHandPinky3': 3,
1442
+ 'RightHandPinky_end': 3,
1443
+
1444
+ 'LeftUpLeg': 3,
1445
+ 'LeftLeg': 3,
1446
+ 'LeftFoot': 3,
1447
+ 'LeftToe': 3,
1448
+ 'LeftToe_end': 3,
1449
+
1450
+ 'RightUpLeg': 3,
1451
+ 'RightLEg': 3,
1452
+ 'RightFoot': 3,
1453
+ 'RightToe': 3,
1454
+ 'RightToe_end': 3,
1455
+ },
1456
+ "yostar_mainbody_48": {
1457
+ # 'Hips': 3 ,
1458
+ 'Spine': 3,
1459
+ 'Spine1': 3,
1460
+ 'Chest': 3,
1461
+ 'L_eri': 3,
1462
+ 'R_eri': 3,
1463
+ 'Neck': 3,
1464
+ 'Head': 3,
1465
+ 'Head_end': 3,
1466
+
1467
+ 'LeftShoulder': 3,
1468
+ 'LeftArm': 3,
1469
+ 'LeftForearm': 3,
1470
+ 'LeftHand': 3,
1471
+
1472
+ 'RightShoulder': 3,
1473
+ 'RightArm': 3,
1474
+ 'RightForearm': 3,
1475
+ 'RightHand': 3,
1476
+ },
1477
+ "yostar_mainbody_69": {
1478
+ 'Hips': 3,
1479
+ 'Spine': 3,
1480
+ 'Spine1': 3,
1481
+ 'Chest': 3,
1482
+ 'L_eri': 3,
1483
+ 'R_eri': 3,
1484
+ 'Neck': 3,
1485
+ 'Head': 3,
1486
+ 'Head_end': 3,
1487
+
1488
+ 'LeftShoulder': 3,
1489
+ 'LeftArm': 3,
1490
+ 'LeftForearm': 3,
1491
+ 'LeftHand': 3,
1492
+
1493
+ 'RightShoulder': 3,
1494
+ 'RightArm': 3,
1495
+ 'RightForearm': 3,
1496
+ 'RightHand': 3,
1497
+
1498
+ 'LeftUpLeg': 3,
1499
+ 'LeftLeg': 3,
1500
+ 'LeftFoot': 3,
1501
+
1502
+ 'RightUpLeg': 3,
1503
+ 'RightLEg': 3,
1504
+ 'RightFoot': 3,
1505
+ },
1506
+
1507
+ "yostar_upbody_168": {
1508
+ # 'Hips': 3 ,
1509
+ 'Spine': 3,
1510
+ 'Spine1': 3,
1511
+ 'Chest': 3,
1512
+ 'L_eri': 3,
1513
+ 'R_eri': 3,
1514
+ 'Neck': 3,
1515
+ 'Head': 3,
1516
+ 'Head_end': 3,
1517
+
1518
+ 'LeftShoulder': 3,
1519
+ 'LeftArm': 3,
1520
+ 'LeftForearm': 3,
1521
+ 'LeftHand': 3,
1522
+ 'LeftHandThumb1': 3,
1523
+ 'LeftHandThumb2': 3,
1524
+ 'LeftHandThumb3': 3,
1525
+ 'LeftHandThumb_end': 3,
1526
+
1527
+ 'LeftHandIndex1': 3,
1528
+ 'LeftHandIndex2': 3,
1529
+ 'LeftHandIndex3': 3,
1530
+ 'LeftHandIndex_end': 3,
1531
+
1532
+ 'LeftHandMiddle1': 3,
1533
+ 'LeftHandMiddle2': 3,
1534
+ 'LeftHandMiddle3': 3,
1535
+ 'LeftHandMiddle_end': 3,
1536
+
1537
+ 'LeftHandRing1': 3,
1538
+ 'LeftHandRing2': 3,
1539
+ 'LeftHandRing3': 3,
1540
+ 'LeftHandRing_end': 3,
1541
+
1542
+ 'LeftHandPinky1': 3,
1543
+ 'LeftHandPinky2': 3,
1544
+ 'LeftHandPinky3': 3,
1545
+ 'LeftHandPinky_end': 3,
1546
+
1547
+ 'RightShoulder': 3,
1548
+ 'RightArm': 3,
1549
+ 'RightForearm': 3,
1550
+ 'RightHand': 3,
1551
+ 'RightHandThumb1': 3,
1552
+ 'RightHandThumb2': 3,
1553
+ 'RightHandThumb3': 3,
1554
+ 'RightHandThumb_end': 3,
1555
+
1556
+ 'RightHandIndex1': 3,
1557
+ 'RightHandIndex2': 3,
1558
+ 'RightHandIndex3': 3,
1559
+ 'RightHandIndex_end': 3,
1560
+
1561
+ 'RightHandMiddle1': 3,
1562
+ 'RightHandMiddle2': 3,
1563
+ 'RightHandMiddle3': 3,
1564
+ 'RightHandMiddle_end': 3,
1565
+
1566
+ 'RightHandRing1': 3,
1567
+ 'RightHandRing2': 3,
1568
+ 'RightHandRing3': 3,
1569
+ 'RightHandRing_end': 3,
1570
+
1571
+ 'RightHandPinky1': 3,
1572
+ 'RightHandPinky2': 3,
1573
+ 'RightHandPinky3': 3,
1574
+ 'RightHandPinky_end': 3,
1575
+ },
1576
+ "spine_neck_141": {
1577
+ 'Spine': 3,
1578
+ 'Neck': 3,
1579
+ 'Neck1': 3,
1580
+ 'RShoulder': 3,
1581
+ 'RArm': 3,
1582
+ 'RArm1': 3,
1583
+ 'RHand': 3,
1584
+ 'RHandM1': 3,
1585
+ 'RHandM2': 3,
1586
+ 'RHandM3': 3,
1587
+ 'RHandR': 3,
1588
+ 'RHandR1': 3,
1589
+ 'RHandR2': 3,
1590
+ 'RHandR3': 3,
1591
+ 'RHandP': 3,
1592
+ 'RHandP1': 3,
1593
+ 'RHandP2': 3,
1594
+ 'RHandP3': 3,
1595
+ 'RHandI': 3,
1596
+ 'RHandI1': 3,
1597
+ 'RHandI2': 3,
1598
+ 'RHandI3': 3,
1599
+ 'RHandT1': 3,
1600
+ 'RHandT2': 3,
1601
+ 'RHandT3': 3,
1602
+ 'LShoulder': 3,
1603
+ 'LArm': 3,
1604
+ 'LArm1': 3,
1605
+ 'LHand': 3,
1606
+ 'LHandM1': 3,
1607
+ 'LHandM2': 3,
1608
+ 'LHandM3': 3,
1609
+ 'LHandR': 3,
1610
+ 'LHandR1': 3,
1611
+ 'LHandR2': 3,
1612
+ 'LHandR3': 3,
1613
+ 'LHandP': 3,
1614
+ 'LHandP1': 3,
1615
+ 'LHandP2': 3,
1616
+ 'LHandP3': 3,
1617
+ 'LHandI': 3,
1618
+ 'LHandI1': 3,
1619
+ 'LHandI2': 3,
1620
+ 'LHandI3': 3,
1621
+ 'LHandT1': 3,
1622
+ 'LHandT2': 3,
1623
+ 'LHandT3': 3, },
1624
+ }
1625
+
1626
+
1627
+
1628
+
1629
+
1630
+
1631
+
1632
+
1633
+ def GetBodyPartIndices(part_name="upper", rotation_method='axisangle'):
1634
+ if part_name == "upper":
1635
+ part_name = "beat_smplx_upper"
1636
+ elif part_name == "lower":
1637
+ part_name = "beat_smplx_lower"
1638
+ elif part_name == "hand":
1639
+ part_name = "beat_smplx_hands"
1640
+ elif part_name == "face":
1641
+ part_name = "beat_smplx_face_3"
1642
+ elif part_name == "all":
1643
+ part_name = "beat_smplx_full"
1644
+ elif part_name == "lhand":
1645
+ part_name = "beat_smplx_lhands"
1646
+ elif part_name == "rhand":
1647
+ part_name = "beat_smplx_rhands"
1648
+ else:
1649
+ assert 0 == 1
1650
+ upper_names = joints_list[part_name].keys()
1651
+ upper_start_indices = [joints_list['beat_smplx_joints']
1652
+ [name][1] // 3 - 1 for name in upper_names]
1653
+ upper_indices = []
1654
+
1655
+ offset = 3
1656
+ if rotation_method == 'axisangle':
1657
+ offset = 3
1658
+ elif rotation_method == 'rot6d':
1659
+ offset = 6
1660
+ elif rotation_method == None:
1661
+ offset = 1
1662
+ else:
1663
+ assert 0 == 1
1664
+ for idx in upper_start_indices:
1665
+ upper_indices = upper_indices + \
1666
+ list(range(idx * offset, idx * offset+offset))
1667
+ return np.array(upper_indices)
1668
+
1669
+
1670
+
1671
+
1672
+ if __name__ == '__main__':
1673
+ print("#beat_smplx_upper", len(joints_list['beat_smplx_upper']))
1674
+ print("#beat_smplx_lower", len(joints_list['beat_smplx_lower']))
1675
+ print("#beat_smplx_hands", len(joints_list['beat_smplx_hands']))
1676
+ print("#beat_smplx_face_3", len(joints_list['beat_smplx_face_3']))
1677
+
1678
+
1679
+ print((GetBodyPartIndices("lower")[0::3]))
retrained_20261113/globaldiff_e880_all_cfg1p25/source/Scripts/SMPLX_Util.py ADDED
@@ -0,0 +1,278 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ '''
3
+ Copyright (c) 2021, Alibaba Cloud and its affiliates;
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ '''
16
+
17
+ import os
18
+
19
+ import smplx
20
+ import numpy as np
21
+ import torch
22
+ from typing import Optional, Dict
23
+
24
+ from Util import *
25
+
26
+ def _resolve_smplx_model_path(model_folder: Optional[str] = None):
27
+ if model_folder is not None:
28
+ return model_folder
29
+
30
+ env_path = os.environ.get("GLOBALDIFF_SMPLX_MODEL_PATH")
31
+ if env_path:
32
+ return env_path
33
+
34
+ candidate_paths = [
35
+ "/mnt/4TDisk/mm_data/mm/project/LargeMotionModel/Data/SMPLX_NEUTRAL_2020.npz",
36
+ os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "Data", "SMPLX_NEUTRAL_2020.npz")),
37
+ ]
38
+ for path in candidate_paths:
39
+ if os.path.exists(path):
40
+ return path
41
+
42
+ raise FileNotFoundError(
43
+ "SMPL-X model file not found. Set GLOBALDIFF_SMPLX_MODEL_PATH "
44
+ "or place SMPLX_NEUTRAL_2020.npz under Data/."
45
+ )
46
+
47
+
48
+ def GetSMPLXModel(model_folder: Optional[str] = None):
49
+ model_folder = _resolve_smplx_model_path(model_folder)
50
+ model = smplx.create(model_folder,
51
+ model_type="smplx",
52
+ gender="neutral",
53
+ use_face_contour=False,
54
+ num_betas=300,
55
+ num_expression_coeffs=100,
56
+ ext="npz",
57
+ use_pca=False,
58
+ flat_hand_mean=True)
59
+ return model
60
+
61
+
62
+
63
+ def SplitPosesIntoSmplxParams(poses):
64
+ params = {}
65
+ params["global_orient"] = poses[...,0:3]
66
+ params["body_pose"] = poses[...,3:63 + 3]
67
+ params["jaw_pose"] = poses[...,63 + 3:63 + 6]
68
+ params["leye_pose"] = poses[...,63 + 6:63 + 9]
69
+ params["reye_pose"] = poses[...,63 + 9:63 + 12]
70
+ params["left_hand_pose"] = poses[...,75:75 + 45]
71
+ params["right_hand_pose"] = poses[...,75 + 45:75 + 90]
72
+ return params
73
+
74
+
75
+
76
+ SMPLX_PARENTS = [-1, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 9, 12, 13, 14, 16, 17, 18, 19, 15, 15, 15, 20, 25, 26, 20, 28, 29, 20, 31, 32, 20, 34, 35, 20, 37, 38, 21, 40, 41, 21, 43, 44, 21, 46, 47, 21, 49, 50, 21, 52, 53]
77
+ def local_to_global_batch(local_rot, parents=SMPLX_PARENTS):
78
+ """
79
+ 將局部旋轉轉換為全局旋轉。
80
+
81
+ 參數:
82
+ local_rot (torch.Tensor): 局部旋轉矩陣,形狀為 (batch_size, num_joints, 3, 3)
83
+ parents (list[int]): 父節點索引列表,長度為 num_joints
84
+
85
+ 返回:
86
+ torch.Tensor: 全局旋轉矩陣,形狀同輸入
87
+ """
88
+ batch_size, num_joints, _, _ = local_rot.shape
89
+ xp = torch if isinstance(local_rot, torch.Tensor) else np
90
+ global_rot = xp.empty_like(local_rot)
91
+
92
+ for i in range(num_joints):
93
+ if parents[i] == -1:
94
+ # 根節點,直接使用局部旋轉
95
+ global_rot[:, i] = local_rot[:, i]
96
+ else:
97
+ # 獲取父節點的全局旋轉並與當前局部旋轉相乘
98
+ parent_rot = global_rot[:, parents[i]] # (B, 3, 3)
99
+ current_local = local_rot[:, i] # (B, 3, 3)
100
+ global_rot[:, i] = parent_rot @ current_local
101
+
102
+ return global_rot
103
+
104
+
105
+
106
+
107
+
108
+
109
+ def global_to_local_batch(global_rot, parents=SMPLX_PARENTS):
110
+ """
111
+ 將全局旋轉轉換為局部旋轉。
112
+
113
+ 參數:
114
+ global_rot (torch.Tensor): 全局旋轉矩陣,形狀為 (batch_size, num_joints, 3, 3)
115
+ parents (list[int]): 父節點索引列表,長度為 num_joints
116
+
117
+ 返回:
118
+ torch.Tensor: 局部旋轉矩陣,形狀同輸入
119
+ """
120
+ batch_size, num_joints, _, _ = global_rot.shape
121
+ xp = torch if isinstance(global_rot, torch.Tensor) else np
122
+ local_rot = xp.empty_like(global_rot)
123
+
124
+ for i in range(num_joints):
125
+ if parents[i] == -1:
126
+ # 根節點,局部旋轉等於全局旋轉
127
+ local_rot[:, i] = global_rot[:, i]
128
+ else:
129
+ # 計算父節點旋轉的逆矩陣(轉置,因旋轉矩陣正交)
130
+ parent_rot = global_rot[:, parents[i]] # (B, 3, 3)
131
+ if xp == torch:
132
+ inv_parent_rot = parent_rot.transpose(-1, -2) # (B, 3, 3)
133
+ else:
134
+ inv_parent_rot = np.transpose(parent_rot, axes=(0, 2, 1))
135
+ current_global = global_rot[:, i] # (B, 3, 3)
136
+ local_rot[:, i] = inv_parent_rot @ current_global
137
+
138
+ return local_rot
139
+
140
+
141
+ def LocalToGlobalAA(poses:np.ndarray):
142
+ L,C = poses.shape
143
+ mat = axis_angle_to_rotation_matrix(poses.reshape((-1, 3))).reshape((L,-1, 3,3))
144
+ mat = local_to_global_batch(mat)
145
+ aa = rotation_matrix_to_axis_angle(mat)
146
+ return aa.reshape((L, C))
147
+
148
+
149
+ def GlobalToLocalAA(poses:np.ndarray):
150
+ L,C = poses.shape
151
+ mat = axis_angle_to_rotation_matrix(poses.reshape((L, -1, 3)))
152
+ mat = global_to_local_batch(mat)
153
+ aa = rotation_matrix_to_axis_angle(mat)
154
+ return aa.reshape((L, C))
155
+
156
+
157
+
158
+ def MakeAdjacencyMatrix():
159
+ mask = np.zeros((55,55))
160
+ for i in range(0, len(SMPLX_PARENTS)):
161
+ parent_idx = SMPLX_PARENTS[i]
162
+ if parent_idx != -1:
163
+ mask[i, parent_idx] = 1
164
+ mask[parent_idx, i] = 1
165
+ mask[i,i] = 1
166
+ return mask < 0.5
167
+
168
+
169
+
170
+
171
+ def symmetrize_smplx_parameters(pose_params, trans):
172
+ """
173
+ 对称化 SMPLX 模型的姿态和形状参数
174
+
175
+ 参数:
176
+ pose_params: 姿态参数, shape (N, 165) 或 (165,)
177
+ beta_params: 形状参数, shape (N, 10) 或 (10,), 可选
178
+ left_right_pairs: 左右关节对的列表, 可选
179
+
180
+ 返回:
181
+ 对称化后的姿态参数和形状参数
182
+ """
183
+
184
+ # SMPLX 标准左右关节对 (0-based 索引)
185
+ left_right_pairs =( (1,2), (4,5), (7,8), (10,11), (13,14), (16,17), (18,19), (20,21), # body
186
+ (23,24), #eyes
187
+ (25,40), (26,41), (27,42), (28,43), (29,44), (30,45), (31,46), (32,47), (33,48), (34,49), (35,50), (36,51), (37,52), (38,53), (39,54) # hands
188
+ )
189
+
190
+ # 确保输入是 torch.Tensor
191
+ if not isinstance(pose_params, torch.Tensor):
192
+ pose_params = torch.tensor(pose_params, dtype=torch.float32)
193
+ if not isinstance(trans, torch.Tensor):
194
+ trans = torch.tensor(trans, dtype=torch.float32)
195
+
196
+
197
+ # 创建对称的姿态参数
198
+ sym_pose = pose_params.clone()
199
+
200
+ # 对每个左右对进行对称化
201
+ for left, right in left_right_pairs:
202
+ # 确保索引在有效范围内
203
+ if left*3+3 <= sym_pose.shape[1] and right*3+3 <= sym_pose.shape[1]:
204
+ # 交换左右参数并翻转旋转方向
205
+ left_rot = sym_pose[:, left*3:left*3+3].clone()
206
+ right_rot = sym_pose[:, right*3:right*3+3].clone()
207
+
208
+ # 对称化: 左右交换并翻转某些轴的旋转
209
+ sym_pose[:, left*3:left*3+3] = right_rot * torch.tensor([1, -1, -1], dtype=torch.float32)
210
+ sym_pose[:, right*3:right*3+3] = left_rot * torch.tensor([1, -1, -1], dtype=torch.float32)
211
+
212
+ sym_pose[:, 0:3] = pose_params[:, 0:3] * torch.tensor([1, -1, -1], dtype=torch.float32)
213
+ sym_trans = trans.clone()
214
+ sym_trans[...,0] *=-1
215
+ return sym_pose, sym_trans
216
+
217
+
218
+
219
+ if __name__ =="__main__":
220
+ # print(__path__)
221
+
222
+ def WriteObj(filename, verts, faces=None):
223
+ with open(filename, 'w') as fh:
224
+ for v in verts:
225
+ fh.write('v %f %f %f\n' % (v[0], v[1], v[2]))
226
+ if faces is not None:
227
+ for f in faces:
228
+ fh.write('f %d %d %d\n' % (f[0] + 1, f[1] + 1, f[2] + 1))
229
+
230
+
231
+ smplx_model = GetSMPLXModel().requires_grad_(False).eval().cuda()
232
+ from BEATXDataset import LMDBDataset
233
+ lmdb_path = "/mnt/4TDisk/mm_data/mm/data/BEAT/V2/seq_size_60_stride_size_20.lmdb"
234
+ lmdb_hubert = None
235
+ ds = LMDBDataset(lmdb_path, lmdb_hubert, rotation_method="axisangle",)
236
+ num_person = 0
237
+
238
+
239
+
240
+
241
+
242
+ rest_joints_state = {}
243
+ from tqdm import tqdm
244
+ for data_id in tqdm(range(0, len(ds)), total=len(ds)):
245
+ poses = ds[data_id]["poses"].cuda()
246
+ pid = int(ds[data_id]["pid"])
247
+ betas = ds[data_id]["betas"].cuda()
248
+ shape_betas = betas.reshape((1, -1)).repeat((len(poses), 1))
249
+ expressions = ds[data_id]["expressions"].cuda()
250
+ trans = ds[data_id]["trans"].cuda()
251
+ J = ds[data_id]["J"].cuda()
252
+
253
+ # smplx_params = SplitPosesIntoSmplxParams(poses)
254
+ # output = smplx_model(betas=None,
255
+ # global_orient=smplx_params["global_orient"],
256
+ # body_pose=smplx_params["body_pose"],
257
+ # expression=expressions,
258
+ # jaw_pose=smplx_params["jaw_pose"],
259
+ # leye_pose=smplx_params["leye_pose"],
260
+ # reye_pose=smplx_params["reye_pose"],
261
+ # left_hand_pose=smplx_params["left_hand_pose"],
262
+ # right_hand_pose=smplx_params["right_hand_pose"],
263
+ # transl=trans,
264
+ # return_verts=True)
265
+
266
+ output = smplx_model()
267
+ print(output['joints'].shape)
268
+ print(output['vertices'].shape)
269
+
270
+ # WriteObj("test.obj", output['vertices'][0].cpu().numpy(), smplx_model.faces)
271
+ print(output['joints'][0][:55].cpu().numpy()[0])
272
+ break
273
+ from scipy.io import loadmat
274
+
275
+ WriteObj("J.obj", J.cpu().numpy())
276
+
277
+
278
+
retrained_20261113/globaldiff_e880_all_cfg1p25/source/Scripts/Util.py ADDED
@@ -0,0 +1,569 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ '''
3
+ Copyright (c) 2021, Alibaba Cloud and its affiliates;
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ '''
16
+
17
+
18
+ import numpy as np
19
+ from scipy.spatial.transform import Rotation
20
+ import torch
21
+ import torch.nn.functional as F
22
+ # import kornia.geometry as G
23
+ from typing import Union
24
+ import math
25
+ import torch.nn as nn
26
+
27
+
28
+ def SplitIntoOverlapedWindows(seq, win_size, stride_step, keep_last=False):
29
+ assert stride_step <= win_size
30
+ overlap_size = win_size - stride_step
31
+ num = (len(seq) - win_size) // stride_step + 1
32
+ res = [seq[i * stride_step:i * stride_step + win_size] for i in range(num)]
33
+ if keep_last:
34
+ last_id = num * stride_step
35
+ if last_id < len(seq):
36
+ res.append(seq[last_id:])
37
+ return res
38
+
39
+
40
+ def matrix_to_rotation_6d(matrix):
41
+ return matrix[..., :2, :].reshape((matrix.shape[:-2] + (6,)))
42
+
43
+
44
+ def Normalize(x, eps=1e-12):
45
+ len = np.sqrt(np.sum(x * x, axis=-1, keepdims=True))
46
+ return x / (len + eps)
47
+
48
+
49
+ # def NormalizeToRot6d(d):
50
+ # origin_shape = d.shape
51
+ # d6 = d.reshape((-1, 6))
52
+ # a1, a2 = d6[..., :3], d6[..., 3:]
53
+ # b1 = F.normalize(a1, dim=-1)
54
+ # b2 = a2 - (b1 * a2).sum(-1, keepdim=True) * b1
55
+ # b2 = F.normalize(b2, dim=-1)
56
+ # d6 = torch.cat([b1, b2], dim=-1)
57
+ # return d6.reshape(origin_shape)
58
+
59
+
60
+ def rotation_6d_to_matrix_torch(d6: torch.Tensor) -> torch.Tensor:
61
+ """
62
+ Converts 6D rotation representation by Zhou et al. [1] to rotation matrix
63
+ using Gram--Schmidt orthogonalization per Section B of [1].
64
+ Args:
65
+ d6: 6D rotation representation, of size (*, 6)
66
+
67
+ Returns:
68
+ batch of rotation matrices of size (*, 3, 3)
69
+
70
+ [1] Zhou, Y., Barnes, C., Lu, J., Yang, J., & Li, H.
71
+ On the Continuity of Rotation Representations in Neural Networks.
72
+ IEEE Conference on Computer Vision and Pattern Recognition, 2019.
73
+ Retrieved from http://arxiv.org/abs/1812.07035
74
+ """
75
+
76
+ a1, a2 = d6[..., :3], d6[..., 3:]
77
+ b1 = F.normalize(a1, dim=-1)
78
+ b2 = a2 - (b1 * a2).sum(-1, keepdim=True) * b1
79
+ b2 = F.normalize(b2, dim=-1)
80
+ b3 = torch.cross(b1, b2, dim=-1)
81
+ return torch.stack((b1, b2, b3), dim=-2)
82
+
83
+
84
+ def rotation_6d_to_matrix_numpy(d6: torch.Tensor):
85
+ """
86
+ Converts 6D rotation representation by Zhou et al. [1] to rotation matrix
87
+ using Gram--Schmidt orthogonalization per Section B of [1].
88
+ Args:
89
+ d6: 6D rotation representation, of size (*, 6)
90
+
91
+ Returns:
92
+ batch of rotation matrices of size (*, 3, 3)
93
+
94
+ [1] Zhou, Y., Barnes, C., Lu, J., Yang, J., & Li, H.
95
+ On the Continuity of Rotation Representations in Neural Networks.
96
+ IEEE Conference on Computer Vision and Pattern Recognition, 2019.
97
+ Retrieved from http://arxiv.org/abs/1812.07035
98
+ """
99
+
100
+ a1, a2 = d6[..., :3], d6[..., 3:]
101
+ b1 = Normalize(a1)
102
+ b2 = a2 - (b1 * a2).sum(-1, keepdims=True) * b1
103
+ b2 = Normalize(b2)
104
+ b3 = np.cross(b1, b2, axis=-1)
105
+ return np.stack((b1, b2, b3), axis=-2)
106
+
107
+
108
+ def rotation_6d_to_matrix(d6: Union[torch.Tensor, np.ndarray]):
109
+ if isinstance(d6, torch.Tensor):
110
+ return rotation_6d_to_matrix_torch(d6=d6)
111
+ elif isinstance(d6, np.ndarray):
112
+ return rotation_6d_to_matrix_numpy(d6=d6)
113
+ else:
114
+ assert 0 == 1
115
+
116
+
117
+ def rotation_matrix_to_axis_angle_torch(rot_mat: torch.Tensor, eps: float = 1e-4) -> torch.Tensor:
118
+ """
119
+ 将旋转矩阵转换为轴角表示
120
+ Args:
121
+ rot_mat: (..., 3, 3) 旋转矩阵(必须有效正交矩阵)
122
+ eps: 数值稳定性阈值
123
+ Returns:
124
+ axis_angle: (..., 3) 轴角表示(轴方向为单位向量,角度为向量的模长)
125
+ """
126
+ # 确保输入是3x3矩阵
127
+ assert rot_mat.shape[-2:] == (3, 3), f"Invalid rotation matrix shape: {rot_mat.shape}"
128
+
129
+ # 计算旋转角度θ(通过矩阵的迹)
130
+ trace = rot_mat[..., 0, 0] + rot_mat[..., 1, 1] + rot_mat[..., 2, 2]
131
+ theta = torch.acos(torch.clamp((trace - 1) / 2, -1 + eps, 1 - eps))
132
+ # 计算轴方向
133
+ axis = torch.empty_like(rot_mat[..., 0])
134
+ # Case 1: θ ≈ 0(返回零向量)
135
+ zero_angle = theta < eps
136
+ axis[zero_angle] = torch.tensor([1.0, 0.0, 0.0], device=rot_mat.device) # 默认轴
137
+
138
+ # Case 2: θ ≈ π(需要特殊处理奇异性)
139
+ near_pi = theta > math.acos(-1 + 2*eps)
140
+ if torch.any(near_pi):
141
+ # 从对角线元素计算轴
142
+ r_diag = rot_mat[near_pi].diagonal(dim1=-2, dim2=-1)
143
+ axis_near_pi = torch.sqrt( torch.clip((r_diag + 1) / 2, min=0.0) )
144
+ # 符号需要根据非对角��素确定
145
+ mask_x = ((rot_mat[near_pi, 2, 1] - rot_mat[near_pi, 1, 2]) > 0) * 2 - 1
146
+ mask_y = ((rot_mat[near_pi, 0, 2] - rot_mat[near_pi, 2, 0]) > 0) * 2 - 1
147
+ mask_z = ((rot_mat[near_pi, 1, 0] - rot_mat[near_pi, 0, 1]) > 0) * 2 - 1
148
+ mask = torch.stack([mask_x, mask_y, mask_z], dim=-1)
149
+ axis[near_pi] = axis_near_pi * mask
150
+
151
+
152
+ # Case 3: 常规角度
153
+ normal_angle = ~(zero_angle | near_pi)
154
+ if torch.any(normal_angle):
155
+ rot_mat_normal = rot_mat[normal_angle]
156
+ axis[normal_angle] = torch.stack([
157
+ rot_mat_normal[..., 2, 1] - rot_mat_normal[..., 1, 2],
158
+ rot_mat_normal[..., 0, 2] - rot_mat_normal[..., 2, 0],
159
+ rot_mat_normal[..., 1, 0] - rot_mat_normal[..., 0, 1]
160
+ ], dim=-1) / (2 * torch.sin(theta[normal_angle].unsqueeze(-1)))
161
+
162
+ # 将角度编码为向量的模长
163
+ return axis * theta.unsqueeze(-1)
164
+
165
+
166
+
167
+ def rotation_matrix_to_axis_angle_np(matrix):
168
+ """
169
+ 將旋轉矩陣轉換為軸角表示
170
+ 輸入: (*, 3, 3) 的旋轉矩陣 (numpy.ndarray)
171
+ 輸出: (*, 3) 的軸角表示,其中向量的方向是旋轉軸,範數是旋轉角度(弧度)
172
+ """
173
+ # 確保輸入是 numpy.ndarray
174
+ if not isinstance(matrix, np.ndarray):
175
+ matrix = np.array(matrix, dtype=np.float32)
176
+
177
+ original_shape = matrix.shape[:-2]
178
+ matrix = matrix.reshape(-1, 3, 3) # 展平批次維度
179
+
180
+ # 計算旋轉角度
181
+ trace = np.trace(matrix, axis1=1, axis2=2)
182
+ angle = np.arccos(np.clip((trace - 1) / 2, -1, 1))
183
+
184
+ # 計算旋轉軸
185
+ axis = np.stack([
186
+ matrix[:, 2, 1] - matrix[:, 1, 2],
187
+ matrix[:, 0, 2] - matrix[:, 2, 0],
188
+ matrix[:, 1, 0] - matrix[:, 0, 1]
189
+ ], axis=1)
190
+
191
+ axis_norm = np.linalg.norm(axis, axis=1, keepdims=True)
192
+ # 處理角度接近0的情況(避免除以0)
193
+ mask = (angle > 1e-6).reshape(-1, 1)
194
+ axis = axis / (axis_norm + 1e-10) * mask + (1 - mask) * np.array([1., 0., 0.])
195
+
196
+ # 組合軸和角度
197
+ axis_angle = axis * angle.reshape(-1, 1)
198
+
199
+ # 恢復原始批次形狀
200
+ return axis_angle.reshape(*original_shape, 3)
201
+
202
+ def hat(v: torch.Tensor) -> torch.Tensor:
203
+ """
204
+ 将向量转换为反对称矩阵。
205
+ Args:
206
+ v: (..., 3), 李代数向量
207
+ Returns:
208
+ K: (..., 3, 3), 反对称矩阵
209
+ """
210
+ K = torch.zeros((*v.shape[:-1], 3, 3), device=v.device, dtype=v.dtype)
211
+ K[..., 0, 1] = -v[..., 2]
212
+ K[..., 0, 2] = v[..., 1]
213
+ K[..., 1, 0] = v[..., 2]
214
+ K[..., 1, 2] = -v[..., 0]
215
+ K[..., 2, 0] = -v[..., 1]
216
+ K[..., 2, 1] = v[..., 0]
217
+ return K
218
+
219
+ def axis_angle_to_rotation_matrix_torch(omega_vec, eps: float = 1e-6):
220
+ """
221
+ 将李代数向量转换为旋转矩阵。
222
+ Args:
223
+ omega_vec: (..., 3), 李代数向量
224
+ Returns:
225
+ R: (..., 3, 3), 旋转矩阵
226
+ """
227
+ theta = torch.norm(omega_vec, dim=-1, keepdim=True)
228
+ near_zero = theta.squeeze(-1) < eps
229
+ k = hat(omega_vec)
230
+ K = hat( omega_vec / (theta + 1e-12))
231
+ I = torch.eye(3, device=omega_vec.device, dtype=omega_vec.dtype).repeat(*omega_vec.shape[:-1], 1, 1)
232
+ theta_expanded = theta.unsqueeze(-1)
233
+ sin_theta = torch.sin(theta_expanded)
234
+ cos_theta = torch.cos(theta_expanded)
235
+
236
+ # Rodrigues公式
237
+ R = I + sin_theta * K + (1 - cos_theta) * (K @ K)
238
+
239
+ # 小角度近似
240
+ R_approx = I + k + 0.5 * (k @ k)
241
+ R = torch.where(near_zero[..., None, None], R_approx, R)
242
+ return R
243
+ # def axis_angle_to_rotation_matrix_torch(axis_angle):
244
+ # """
245
+ # 將軸角表示轉換為旋轉矩陣
246
+ # 輸入: (*, 3) 的軸角表示,其中向量的方向是旋轉軸,範數是旋轉角度(弧度)
247
+ # 輸出: (*, 3, 3) 的旋轉矩陣
248
+ # """
249
+ # # 確保輸入是torch.Tensor
250
+ # if not isinstance(axis_angle, torch.Tensor):
251
+ # axis_angle = torch.tensor(axis_angle, dtype=torch.float32)
252
+
253
+ # batch_shape = axis_angle.shape[:-1]
254
+ # axis_angle = axis_angle.view(-1, 3) # 展平批次維度
255
+
256
+ # angle = torch.norm(axis_angle, dim=1, keepdim=True)
257
+ # # 處理角度接近0的情況
258
+ # mask = (angle.squeeze() > 1e-6).float()
259
+ # axis = axis_angle / (angle + 1e-10)
260
+
261
+ # # 獲取軸的分量
262
+ # x = axis[:, 0]
263
+ # y = axis[:, 1]
264
+ # z = axis[:, 2]
265
+
266
+ # # 計算叉積矩陣
267
+ # zero = torch.zeros_like(x)
268
+ # cross_prod_mat = torch.stack([
269
+ # zero, -z, y,
270
+ # z, zero, -x,
271
+ # -y, x, zero
272
+ # ], dim=1).view(-1, 3, 3)
273
+
274
+ # # 計算外積
275
+ # outer_prod_mat = torch.bmm(axis.unsqueeze(2), axis.unsqueeze(1))
276
+
277
+ # # 計算旋轉矩陣: R = cosθI + (1-cosθ)aa^T + sinθ[a]×
278
+ # I = torch.eye(3, device=axis_angle.device).unsqueeze(0).expand(axis_angle.size(0), -1, -1)
279
+ # cos_theta = torch.cos(angle).unsqueeze(2)
280
+ # sin_theta = torch.sin(angle).unsqueeze(2)
281
+
282
+ # rotation_matrix = I * cos_theta + (1 - cos_theta) * outer_prod_mat + sin_theta * cross_prod_mat
283
+
284
+ # # 處理角度為0的情況
285
+ # rotation_matrix = rotation_matrix * mask.view(-1, 1, 1) + I * (1 - mask).view(-1, 1, 1)
286
+
287
+ # # 恢復原始批次形狀
288
+ # return rotation_matrix.view(*batch_shape, 3, 3)
289
+
290
+ def axis_angle_to_rotation_matrix_np(axis_angle):
291
+ aa = Rotation.from_rotvec(axis_angle, degrees=False)
292
+ aa = aa.as_matrix()
293
+ return aa
294
+
295
+ def rotation_matrix_to_axis_angle(m: Union[np.ndarray, torch.Tensor], eps: float = 1e-4):
296
+ ori_shape = m.shape
297
+ m = m.reshape((-1, 3, 3))
298
+ if isinstance(m, torch.Tensor):
299
+ res = rotation_matrix_to_axis_angle_torch(m, eps=eps)
300
+ elif isinstance(m, np.ndarray):
301
+ res = Rotation.from_matrix(m).as_rotvec(degrees=False)
302
+ else:
303
+ assert 0 == 1
304
+ res = res.reshape(ori_shape[:-1])
305
+ return res
306
+
307
+ def axis_angle_to_rotation_matrix(axis_angle: Union[np.ndarray, torch.Tensor], eps: float = 1e-4):
308
+ assert axis_angle.shape[-1] == 3
309
+ ori_shape = axis_angle.shape
310
+ axis_angle = axis_angle.reshape((-1, 3))
311
+ if isinstance(axis_angle, torch.Tensor):
312
+ res = axis_angle_to_rotation_matrix_torch(axis_angle, eps=eps)
313
+ elif isinstance(axis_angle, np.ndarray):
314
+ res = axis_angle_to_rotation_matrix_np(axis_angle)
315
+ else:
316
+ assert 0 == 1
317
+
318
+ res = res.reshape(ori_shape[:-1] + (3, 3))
319
+ return res
320
+
321
+
322
+ def rotation_6d_to_axis_angle(m: Union[np.ndarray, torch.Tensor], eps: float = 1e-4):
323
+ orig_shape = m.shape
324
+ m = rotation_6d_to_matrix(m.reshape((-1, 6)))
325
+ return rotation_matrix_to_axis_angle(m, eps=eps).reshape(orig_shape[:-1] + (orig_shape[-1] // 6 * 3,))
326
+
327
+
328
+ def axis_angle_to_rotation_6d(m: Union[np.ndarray, torch.Tensor]):
329
+ orig_shape = m.shape
330
+ m = axis_angle_to_rotation_matrix(m.reshape((-1, 3)))
331
+ return matrix_to_rotation_6d(m).reshape(orig_shape[:-1] + (orig_shape[-1] // 3 * 6,))
332
+
333
+ def NormalizeRot6d(m):
334
+ orig_shape = m.shape
335
+ d6 = m.reshape((-1, 6))
336
+ a1, a2 = d6[..., :3], d6[..., 3:]
337
+
338
+ if isinstance(m, np.ndarray):
339
+ b1 = Normalize(a1)
340
+ b2 = a2 - (b1 * a2).sum(-1, keepdims=True) * b1
341
+ b2 = Normalize(b2)
342
+ m = np.concatenate([b1, b2], axis=-1)
343
+ elif isinstance(m, torch.Tensor):
344
+ b1 = F.normalize(a1, dim=-1)
345
+ b2 = a2 - (b1 * a2).sum(-1, keepdim=True) * b1
346
+ b2 = F.normalize(b2, dim=-1)
347
+ m = torch.cat([b1, b2], dim=-1)
348
+
349
+ m = m.reshape(orig_shape)
350
+ return m
351
+
352
+
353
+
354
+
355
+
356
+ def rotation_matrix_to_quaternion_torch(matrix:torch.Tensor) -> torch.Tensor:
357
+ """
358
+ 将旋转矩阵转换为四元数(支持batch输入)
359
+
360
+ 参数:
361
+ matrix: (..., 3, 3) 旋转矩阵
362
+
363
+ 返回:
364
+ quaternion: (..., 4) 四元数 [w, x, y, z]
365
+ """
366
+ if matrix.size(-1) != 3 or matrix.size(-2) != 3:
367
+ raise ValueError(f"输入矩阵的最后两个维度必须是3x3,但得到的是{tuple(matrix.shape[-2:])}")
368
+
369
+ batch_dim = matrix.shape[:-2]
370
+ m = matrix.view(-1, 3, 3)
371
+
372
+ num_rot = m.shape[0]
373
+ quat = torch.zeros((num_rot, 4), dtype=matrix.dtype, device=matrix.device)
374
+
375
+ # 计算矩阵对角线元素的和
376
+ diag = torch.diagonal(m, dim1=-2, dim2=-1)
377
+ trace = diag.sum(dim=-1)
378
+
379
+ # 根据迹的大小选择不同的计算方式
380
+ case_mask = torch.zeros_like(trace, dtype=torch.long)
381
+ case_mask = torch.where(trace > 0,
382
+ torch.tensor(0, device=matrix.device),
383
+ case_mask)
384
+ case_mask = torch.where((diag[:, 0] > diag[:, 1]) &
385
+ (diag[:, 0] > diag[:, 2]) &
386
+ (trace <= 0),
387
+ torch.tensor(1, device=matrix.device),
388
+ case_mask)
389
+ case_mask = torch.where((diag[:, 1] > diag[:, 2]) &
390
+ (trace <= 0),
391
+ torch.tensor(2, device=matrix.device),
392
+ case_mask)
393
+ case_mask = torch.where(trace <= 0,
394
+ torch.tensor(3, device=matrix.device),
395
+ case_mask)
396
+
397
+ # 根据不同情况计算四元数
398
+ case0 = (case_mask == 0)
399
+ if case0.any():
400
+ s = torch.sqrt(trace[case0] + 1.0) * 2 # s = 4 * qw
401
+ quat[case0, 0] = 0.25 * s
402
+ quat[case0, 1] = (m[case0, 2, 1] - m[case0, 1, 2]) / s
403
+ quat[case0, 2] = (m[case0, 0, 2] - m[case0, 2, 0]) / s
404
+ quat[case0, 3] = (m[case0, 1, 0] - m[case0, 0, 1]) / s
405
+
406
+ case1 = (case_mask == 1)
407
+ if case1.any():
408
+ s = torch.sqrt(1.0 + m[case1, 0, 0] - m[case1, 1, 1] - m[case1, 2, 2]) * 2
409
+ quat[case1, 0] = (m[case1, 2, 1] - m[case1, 1, 2]) / s
410
+ quat[case1, 1] = 0.25 * s
411
+ quat[case1, 2] = (m[case1, 0, 1] + m[case1, 1, 0]) / s
412
+ quat[case1, 3] = (m[case1, 0, 2] + m[case1, 2, 0]) / s
413
+
414
+ case2 = (case_mask == 2)
415
+ if case2.any():
416
+ s = torch.sqrt(1.0 + m[case2, 1, 1] - m[case2, 0, 0] - m[case2, 2, 2]) * 2
417
+ quat[case2, 0] = (m[case2, 0, 2] - m[case2, 2, 0]) / s
418
+ quat[case2, 1] = (m[case2, 0, 1] + m[case2, 1, 0]) / s
419
+ quat[case2, 2] = 0.25 * s
420
+ quat[case2, 3] = (m[case2, 1, 2] + m[case2, 2, 1]) / s
421
+
422
+ case3 = (case_mask == 3)
423
+ if case3.any():
424
+ s = torch.sqrt(1.0 + m[case3, 2, 2] - m[case3, 0, 0] - m[case3, 1, 1]) * 2
425
+ quat[case3, 0] = (m[case3, 1, 0] - m[case3, 0, 1]) / s
426
+ quat[case3, 1] = (m[case3, 0, 2] + m[case3, 2, 0]) / s
427
+ quat[case3, 2] = (m[case3, 1, 2] + m[case3, 2, 1]) / s
428
+ quat[case3, 3] = 0.25 * s
429
+
430
+ # 归一化四元数
431
+ quat = nn.functional.normalize(quat, p=2, dim=-1)
432
+
433
+ # 恢复原始batch维度
434
+ quat = quat.view(*batch_dim, 4)
435
+
436
+ return quat
437
+
438
+
439
+ def slerp_torch(q0:torch.Tensor, q1:torch.Tensor, t:torch.Tensor):
440
+ """
441
+ 四元数球面线性插值(slerp),支持batch输入
442
+
443
+ 参数:
444
+ q0: (..., 4) 起始四元数 [w, x, y, z]
445
+ q1: (..., 4) 结束四元数 [w, x, y, z]
446
+ t: (...) 插值系数,范围[0, 1]
447
+
448
+ 返回:
449
+ q: (..., 4) 插值后的四元数 [w, x, y, z]
450
+ """
451
+ # 确保输入形状一致
452
+ assert q0.shape == q1.shape, "q0和q1的形状必须相同"
453
+
454
+ # 确保四元数是单位四元数
455
+ q0 = nn.functional.normalize(q0, p=2, dim=-1)
456
+ q1 = nn.functional.normalize(q1, p=2, dim=-1)
457
+
458
+ # 计算点积(即cos(omega))
459
+ dot = (q0 * q1).sum(dim=-1, keepdim=True) # (..., 1)
460
+
461
+ # 如果点积为负,取反其中一个四元数以保证走最短路径
462
+ neg_mask = dot < 0.0
463
+ q1 = torch.where(neg_mask, -q1, q1)
464
+ dot = torch.where(neg_mask, -dot, dot)
465
+
466
+ # 限制dot在[-1,1]范围内,防止数值误差
467
+ dot = torch.clamp(dot, -1.0, 1.0)
468
+
469
+ # 计算角度和sin(omega)
470
+ omega = torch.acos(dot)
471
+ sin_omega = torch.sin(omega)
472
+
473
+ # 处理sin(omega)接近0的情况
474
+ eps = 1e-8
475
+ small_mask = sin_omega < eps
476
+ sin_omega = torch.where(small_mask, torch.ones_like(sin_omega), sin_omega)
477
+
478
+ # 计算插值权重
479
+ t = t.unsqueeze(-1) # (..., 1)
480
+ w0 = torch.where(small_mask, 1.0 - t, torch.sin((1.0 - t) * omega) / sin_omega)
481
+ w1 = torch.where(small_mask, t, torch.sin(t * omega) / sin_omega)
482
+
483
+ # 线性组合
484
+ q = w0 * q0 + w1 * q1
485
+
486
+ # 归一化结果
487
+ q = nn.functional.normalize(q, p=2, dim=-1)
488
+
489
+ return q
490
+
491
+
492
+
493
+ def quaternion_to_matrix_torch(quaternions):
494
+ """
495
+ 将四元数转换为旋转矩阵(支持batch输入)
496
+
497
+ 参数:
498
+ quaternions: (..., 4) 四元数,格式为[w, x, y, z],其中w是实部
499
+
500
+ 返回:
501
+ rotation_matrix: (..., 3, 3) 对应的旋转矩阵
502
+ """
503
+ if quaternions.size(-1) != 4:
504
+ raise ValueError(f"输入四元数的最后一个维度必须是4,但得到的是{quaternions.shape[-1]}")
505
+
506
+ # 归一化四元数
507
+ quaternions = nn.functional.normalize(quaternions, p=2, dim=-1)
508
+
509
+ # 提取四元数分量
510
+ w, x, y, z = torch.unbind(quaternions, dim=-1)
511
+
512
+ # 计算平方项
513
+ x2 = x * x
514
+ y2 = y * y
515
+ z2 = z * z
516
+ w2 = w * w
517
+
518
+ # 计算交叉项
519
+ xy = x * y
520
+ xz = x * z
521
+ yz = y * z
522
+ wx = w * x
523
+ wy = w * y
524
+ wz = w * z
525
+
526
+ # 构建旋转矩阵
527
+ # 第一列
528
+ m00 = w2 + x2 - y2 - z2
529
+ m10 = 2 * (xy + wz)
530
+ m20 = 2 * (xz - wy)
531
+
532
+ # 第二列
533
+ m01 = 2 * (xy - wz)
534
+ m11 = w2 - x2 + y2 - z2
535
+ m21 = 2 * (yz + wx)
536
+
537
+ # 第三列
538
+ m02 = 2 * (xz + wy)
539
+ m12 = 2 * (yz - wx)
540
+ m22 = w2 - x2 - y2 + z2
541
+
542
+ # 组合成旋转矩阵
543
+ rotation_matrix = torch.stack([
544
+ torch.stack([m00, m01, m02], dim=-1),
545
+ torch.stack([m10, m11, m12], dim=-1),
546
+ torch.stack([m20, m21, m22], dim=-1)
547
+ ], dim=-2)
548
+
549
+ return rotation_matrix
550
+
551
+ if __name__ == '__main__':
552
+ import time
553
+ x = Rotation.from_euler('xyz', [0, 0, 180-0.1], degrees=True).as_matrix()[None].astype(np.float32)
554
+ x_tensor = torch.from_numpy(x)
555
+
556
+ aa_tensor = rotation_matrix_to_axis_angle(x_tensor)
557
+ print(aa_tensor)
558
+
559
+ aa = rotation_matrix_to_axis_angle(x)
560
+ print(aa)
561
+
562
+
563
+ r_tensor = axis_angle_to_rotation_matrix(aa_tensor)
564
+ r = axis_angle_to_rotation_matrix(aa)
565
+
566
+ d = r_tensor@torch.from_numpy(r).float()
567
+
568
+ d = rotation_matrix_to_axis_angle(d)
569
+ print(torch.linalg.norm(d, dim=-1) * 180 / math.pi)
retrained_20261113/globaldiff_e880_all_cfg1p25/verify_sha256.py ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from pathlib import Path
2
+ import hashlib,json
3
+ root=Path(__file__).resolve().parent
4
+ manifest=json.loads((root/'SHA256SUMS.json').read_text())
5
+ for name,expected in manifest.items():
6
+ path=root/name
7
+ h=hashlib.sha256()
8
+ with path.open('rb') as f:
9
+ for block in iter(lambda:f.read(8<<20),b''):h.update(block)
10
+ if path.stat().st_size!=expected['size'] or h.hexdigest()!=expected['sha256']:
11
+ raise SystemExit('Checksum mismatch: '+name)
12
+ print('Verified',len(manifest),'files')