Nekochu commited on
Commit
ebf1dc0
·
verified ·
1 Parent(s): 0a0672e

Add inline quaternion functions into app_new.py

Browse files
Files changed (2) hide show
  1. README.md +13 -1
  2. app_new.py +22 -3
README.md CHANGED
@@ -12,4 +12,16 @@ python_version: "3.10"
12
 
13
  # MoMask: Text-to-Motion Generation
14
 
15
- Generate 3D human skeleton animations from text descriptions.
 
 
 
 
 
 
 
 
 
 
 
 
 
12
 
13
  # MoMask: Text-to-Motion Generation
14
 
15
+ Generate 3D human skeleton animations from text descriptions using [MoMask](https://github.com/EricGuo5513/momask-codes).
16
+
17
+ ## Model Architecture (ONNX INT8, ~151MB total)
18
+ | Model | Size | Precision |
19
+ |-------|------|-----------|
20
+ | CLIP Text Encoder | 62MB | INT8 |
21
+ | Mask Transformer | 20MB | INT8 |
22
+ | Residual Transformer | 20MB | INT8 |
23
+ | VQ-VAE Decoder | 44MB | FP32 |
24
+ | Length Estimator | 441KB | INT8 |
25
+
26
+ ## Usage
27
+ Enter a text description and click Generate.
app_new.py CHANGED
@@ -17,9 +17,28 @@ from matplotlib.animation import FuncAnimation
17
  import mpl_toolkits.mplot3d.axes3d as p3
18
  from mpl_toolkits.mplot3d.art3d import Poly3DCollection
19
  from pathlib import Path
20
- # Add parent to path for imports
21
- sys.path.insert(0, str(Path(__file__).parent))
22
- from common.quaternion import qinv, qrot
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
 
24
  # ============ Configuration ============
25
  ONNX_DIR = Path(__file__).parent / "onnx_models"
 
17
  import mpl_toolkits.mplot3d.axes3d as p3
18
  from mpl_toolkits.mplot3d.art3d import Poly3DCollection
19
  from pathlib import Path
20
+ # ============ Quaternion Operations ============
21
+ def qinv(q):
22
+ """Invert quaternion"""
23
+ assert q.shape[-1] == 4
24
+ mask = torch.ones_like(q)
25
+ mask[..., 1:] = -mask[..., 1:]
26
+ return q * mask
27
+
28
+ def qrot(q, v):
29
+ """Rotate vector(s) v by quaternion(s) q"""
30
+ assert q.shape[-1] == 4
31
+ assert v.shape[-1] == 3
32
+ assert q.shape[:-1] == v.shape[:-1]
33
+
34
+ original_shape = list(v.shape)
35
+ q = q.contiguous().view(-1, 4)
36
+ v = v.contiguous().view(-1, 3)
37
+
38
+ qvec = q[:, 1:]
39
+ uv = torch.cross(qvec, v, dim=1)
40
+ uuv = torch.cross(qvec, uv, dim=1)
41
+ return (v + 2 * (q[:, :1] * uv + uuv)).view(original_shape)
42
 
43
  # ============ Configuration ============
44
  ONNX_DIR = Path(__file__).parent / "onnx_models"