Spaces:
Running on Zero
Running on Zero
updateg
Browse files- CLAUDE.md +56 -0
- requirements.txt +0 -1
CLAUDE.md
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# CLAUDE.md
|
| 2 |
+
|
| 3 |
+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
| 4 |
+
|
| 5 |
+
## Project Overview
|
| 6 |
+
|
| 7 |
+
Human-to-G1 robot motion retargeting web demo. Takes human motion capture data (SMPL-X/AMASS NPZ format), runs it through a LLaMA-style transformer model, and outputs Unitree G1 humanoid robot joint angles with 3D skeleton visualization. Deployed on Hugging Face Spaces.
|
| 8 |
+
|
| 9 |
+
## Running the App
|
| 10 |
+
|
| 11 |
+
```bash
|
| 12 |
+
pip install -r requirements.txt
|
| 13 |
+
python app.py # Launches Gradio UI
|
| 14 |
+
```
|
| 15 |
+
|
| 16 |
+
No test suite exists. Manual testing via the Gradio UI with `examples/sample_motion.npz`.
|
| 17 |
+
|
| 18 |
+
## Architecture
|
| 19 |
+
|
| 20 |
+
**Three-layer design:**
|
| 21 |
+
- **app.py** β Gradio web UI. Calls `load_all()` on startup, exposes `predict()` endpoint
|
| 22 |
+
- **inference.py** β Core ML pipeline: data loading, preprocessing, chunked inference, postprocessing
|
| 23 |
+
- **visualize.py** β Pinocchio forward kinematics + Plotly 3D skeleton animation
|
| 24 |
+
|
| 25 |
+
**Inference data flow:**
|
| 26 |
+
```
|
| 27 |
+
AMASS NPZ β SMPL-X (22 joints) β (T,140) features β VQVAE encoder β LLaMA transformer (non-AR) β upsample β (T,217) β postprocess β 29-DOF G1 robot motion
|
| 28 |
+
```
|
| 29 |
+
|
| 30 |
+
**Chunked inference strategy:** 120-frame chunks, 32-frame overlap, linear blending. Yaw-canonicalized per chunk.
|
| 31 |
+
|
| 32 |
+
## Model Architecture (src/)
|
| 33 |
+
|
| 34 |
+
All models use **MMEngine's MODELS registry** (`@MODELS.register_module()`). Built via `MODELS.build(cfg_dict)` in `inference.py`.
|
| 35 |
+
|
| 36 |
+
- **src/models/transformers/retarget_model_ablation.py** β Main model (`RetargetTransformerPredMotion_no_smplvq`, 70M params). Composes VQVAE encoder + LLaMA forward transformer + upsampler + projection head
|
| 37 |
+
- **src/models/transformers/llama_fwd.py** β Forward-only LLaMA (non-autoregressive), inherits from `llama_ar.py`
|
| 38 |
+
- **src/models/tokenizers/vqvae.py** β VQ-VAE with FSQ quantizer for motion compression
|
| 39 |
+
- **src/models/tokenizers/encdoc/** β Conv1D + ResNet1D encoder/decoder with attention
|
| 40 |
+
- **src/models/tokenizers/quantizer/fsq.py** β Finite Scalar Quantization (levels [8,8,6,5])
|
| 41 |
+
|
| 42 |
+
## Key Data Formats
|
| 43 |
+
|
| 44 |
+
- **Input:** AMASS NPZ with `poses` (SMPL-X body params), `trans`, `betas`, `gender`, `mocap_frame_rate`
|
| 45 |
+
- **Output:** PKL dict with `dof` (T,29), `root_trans` (T,3), `root_rot_quat` (T,4 wxyz)
|
| 46 |
+
- **Normalization stats:** 4 `.npy` files in `weights/` (smplx_mean/std, gmr_mean/std)
|
| 47 |
+
|
| 48 |
+
## Large Files
|
| 49 |
+
|
| 50 |
+
Git LFS tracks model weights and assets. The checkpoint `weights/epoch_30.pth` is 542MB, `assets/SMPLX_NEUTRAL.npz` is 103MB.
|
| 51 |
+
|
| 52 |
+
## Coordinate Conventions
|
| 53 |
+
|
| 54 |
+
- Internal processing uses **Y-up**. AMASS data (Z-up) is auto-converted
|
| 55 |
+
- Robot quaternions are **wxyz** format
|
| 56 |
+
- Rotations use **6D representation** internally, converted at boundaries
|
requirements.txt
CHANGED
|
@@ -5,6 +5,5 @@ pin
|
|
| 5 |
numpy
|
| 6 |
scipy
|
| 7 |
joblib
|
| 8 |
-
pyaudioop
|
| 9 |
gradio>=4.0
|
| 10 |
plotly
|
|
|
|
| 5 |
numpy
|
| 6 |
scipy
|
| 7 |
joblib
|
|
|
|
| 8 |
gradio>=4.0
|
| 9 |
plotly
|