Skip to content

Turn any video into a Mixamo-rig animation - GVHMR estimator, spec-driven retarget, FK apply in Blender via MCP. Works with any Mixamo character; built to be operated end-to-end by an AI agent.

docs: the SMPL-X path

Sachaed72023ae798
diff --git a/README.md b/README.md
index 603d416..9e192c5 100644
--- a/README.md
+++ b/README.md
@@ -27,6 +27,37 @@ the performers actually stood, measured from the footage.*
## How it works
+The default path transfers the estimator's SMPL-X **joint rotations**
+and runs without the Blender UI:
+
+```
+video plate (locked camera)
+ │
+ ├─ 1. estimate_pose_gvhmr.py --smplx-only GVHMR → SMPL-X parameters, refined on the plate's 2D keypoints (+ heels/toes)
+ ├─ 2. retarget_smplx.py rotations → your Mixamo rig; floor, foot locks, camera-true trajectory
+ ├─ 3. bl_motion.py (blender -b) key the action in bulk and save it, or render — no MCP session
+ ├─ 4. render_review.py 2×2 review video: plate | overlay on the plate / before | after
+ └─ 5. eval_fidelity.py limb and head angles vs the video's keypoints, foot slide, jitter
+```
+
+- **Twist is real.** Forearm roll, spine curve and head orientation come
+ from SMPL-X instead of being re-derived from positions.
+- **Extremes survive.** GVHMR flattens fast limbs; a SMPLify-style fit on
+ the plate's own ViTPose keypoints puts a head-high kick back at head
+ height.
+- **Feet point where the performer's point.** Heel and toe keypoints
+ (MediaPipe) join the fit, and the rig's foot is aligned on the foot's
+ real axis — toe-out, heel raises and pivots come from the video.
+- **Feet stay down.** Contacts from GVHMR's detector, the floor, and the
+ image itself (a foot still on screen is planted); planted feet lock
+ flat or pivot on the point that carries the weight.
+- **The trajectory is the camera's.** The plate's static camera is
+ recovered; height drift is removed continuously and horizontal drift
+ one footfall at a time, so the character ends on its mark.
+
+The original landmark path below is still available for existing
+specs and the two-character tooling:
+
```
video plate (locked camera, T-pose bookends)
│
@@ -115,7 +146,21 @@ airborne beats), when fists close, where the clip locks back to rest.
blender --background --python pipeline\setup_rig.py -- --fbx ybot.fbx --out ybot_rest.blend
```
-3. **Run a plate** (Blender open on the scene; plate rules in
+3. **Run a plate — SMPL-X path** (headless, no Blender window needed):
+
+ ```
+ tools\GVHMR\.venv\Scripts\python.exe pipeline\estimate_pose_gvhmr.py --video plates\<name>\<name>.mp4 --out plates\<name>\landmarks.json --smplx-only
+ python pipeline\retarget_smplx.py --spec action_specs\<name>.json
+ blender -b ybot_rest.blend -P pipeline\bl_motion.py -- apply --motion clips\<clip>\motion.npz --save clips\<clip>\<clip>.blend
+ python pipeline\render_review.py --spec action_specs\<name>.json --clip clips\<clip>
+ python pipeline\eval_fidelity.py --spec action_specs\<name>.json --clip clips\<clip>
+ ```
+
+ A spec needs only `name`, `action_name`, `clip_dir`, `landmarks` and
+ the fps; `fists`, rest blends and `arm_overrides` are optional.
+ Details: [docs/PIPELINE.md](docs/PIPELINE.md) section S.
+
+ **Or the landmark path** (Blender open on the scene; plate rules in
[docs/PROMPTING.md](docs/PROMPTING.md)):
```
@@ -146,7 +191,7 @@ airborne beats), when fists close, where the clip locks back to rest.
|---|---|---|
| **A Mixamo character — any model** | [mixamo.com](https://www.mixamo.com) → Characters → download FBX Binary, T-pose | Adobe's terms don't allow redistributing them; `setup_rig.py` builds and validates the scene from your download |
| **Blender 5.1+** | [blender.org](https://www.blender.org/download/) | |
-| **Blender MCP add-on** (official, Blender Lab) | [blender.org/lab/mcp-server](https://www.blender.org/lab/mcp-server/) | enable *Allow Online Access*; the apply talks to its socket |
+| **Blender MCP add-on** (official, Blender Lab) — landmark path only | [blender.org/lab/mcp-server](https://www.blender.org/lab/mcp-server/) | enable *Allow Online Access*; the legacy apply talks to its socket. The SMPL-X path runs `blender -b` and needs no add-on |
| **GVHMR** (the pose estimator — **not in this repo**) | [github.com/zju3dv/GVHMR](https://github.com/zju3dv/GVHMR) | clone into `tools/GVHMR`; install per [docs/INSTALL.md](docs/INSTALL.md) — including a working Windows recipe (`docs/requirements_gvhmr_windows.txt` + prebuilt pytorch3d wheel) |
| **GVHMR checkpoints** (~5 GB) | HuggingFace mirror | exact `curl` commands in [docs/INSTALL.md](docs/INSTALL.md) |
| **SMPL-X body model** | [smpl-x.is.tue.mpg.de](https://smpl-x.is.tue.mpg.de/) | free research registration → download *SMPL-X v1.1*, place `SMPLX_NEUTRAL.npz` as shown in [docs/INSTALL.md](docs/INSTALL.md) |
diff --git a/docs/INSTALL.md b/docs/INSTALL.md
index a6df571..c10ccfa 100644
--- a/docs/INSTALL.md
+++ b/docs/INSTALL.md
@@ -61,6 +61,14 @@ claude mcp add blender -s user -- uvx --from "git+https://projects.blender.org/l
and use `pipeline\blender_exec.py <script.py> [timeout]`, which speaks
the add-on's socket protocol directly.
+## 2b. MediaPipe (foot keypoints for the SMPL-X path)
+
+`detect_feet.py` needs `mediapipe` and `opencv-python` in any Python on
+the machine (not the GVHMR venv): `pip install mediapipe opencv-python`.
+The Pose Landmarker model (`pose_landmarker_heavy.task`, ~30 MB) is
+downloaded to `tools/models/` on first use. Without MediaPipe the
+estimator still runs; the refinement then fits no heel/toe points.
+
## 3. GVHMR (the estimator)
```
diff --git a/docs/PIPELINE.md b/docs/PIPELINE.md
index df5f453..e25e58c 100644
--- a/docs/PIPELINE.md
+++ b/docs/PIPELINE.md
@@ -1,8 +1,173 @@
# The pipeline, operationally
How a video becomes a Y Bot clip, stage by stage, with the decision
-rules an operator (human or AI) needs. Everything here was validated on
-the two shipped clips.
+rules an operator (human or AI) needs.
+
+There are two retarget paths. **The SMPL-X path (section S, below) is
+the default**: it transfers the estimator's joint rotations, solves the
+floor, foot contacts and trajectory from the video, and runs entirely
+headless. The **landmark path** (sections 1–10) is the original one:
+positions only, corrected by hand with spec fields over review passes.
+It is kept for existing clips and for its two-character tooling.
+
+## S. The SMPL-X path
+
+```
+plate.mp4
+ └─ estimate_pose_gvhmr.py --smplx-only → smplx.npz (+ smplx_raw.npz)
+ └─ retarget_smplx.py --spec ... → <clip_dir>/motion.npz, curves.json
+ ├─ bl_motion.py apply|render (blender -b: keys / renders, no MCP)
+ ├─ render_review.py → review_<view>.mp4 (2×2 grid)
+ └─ eval_fidelity.py → fidelity.json
+```
+
+```
+tools\GVHMR\.venv\Scripts\python.exe pipeline\estimate_pose_gvhmr.py --video plates\<p>\<p>.mp4 --out plates\<p>\landmarks.json --smplx-only
+ (runs detect_feet.py for heel/toe keypoints, then the 2D refinement)
+python pipeline\retarget_smplx.py --spec action_specs\<motion>.json --rig-profile rig_profiles\ybot.json
+blender -b ybot_rest.blend -P pipeline\bl_motion.py -- apply --motion clips\<clip>\motion.npz --save clips\<clip>\<clip>.blend
+python pipeline\render_review.py --spec action_specs\<motion>.json --clip clips\<clip> [--legacy clips\<old_clip>]
+python pipeline\eval_fidelity.py --spec action_specs\<motion>.json --clip clips\<clip> [--vs clips\<old_clip>]
+```
+
+The rig profile must carry the bone table: `setup_rig.py` writes it; for
+an older profile run
+`blender -b <rig>_rest.blend -P pipeline\bl_motion.py -- dump-rig --profile <profile.json>`.
+
+### S.1 Estimate (and refine)
+
+`estimate_pose_gvhmr.py` now keeps what GVHMR computes instead of
+reducing it to 33 points: `smplx.npz` holds the SMPL-X parameters in the
+world frame and in the camera frame, the camera intrinsics, the
+performer's shaped rest skeleton and foot geometry, GVHMR's per-frame
+contact confidences and the ViTPose 2D keypoints.
+
+- `--postproc feet` (default) keeps GVHMR's foot clean-up but never
+ treats a wrist as static: `full`, GVHMR's demo behaviour, can hold a
+ fist back at the apex of a punch.
+- **Foot keypoints** (`detect_feet.py`, run automatically). COCO-17
+ stops at the ankle, so nothing in GVHMR's input says which way a foot
+ points or whether its heel is up. MediaPipe's Pose Landmarker tracks the
+ heel and the toe tip of each foot; `feet2d.npz` is cached next to the
+ plate. MediaPipe is not in the GVHMR venv: the estimator calls
+ `detect_feet.py` with a Python that has it (`--feet-python`, else
+ `python` on PATH) and refines without feet if none is found. The model
+ file is downloaded to `tools/models/` on first use.
+- **Refinement** (`refine_smplx.py`, on by default, `--no-refine` to
+ skip). GVHMR regresses toward typical motion and flattens extremes:
+ the fight kick apex came out 35–65 px (0.10–0.18 m) below where
+ ViTPose sees the ankle in the same frames. The body pose is optimised
+ so the model's COCO-17 keypoints (the same mesh-based definition as the
+ detector's) and its heel/toe vertices land on the detections, with a
+ prior toward GVHMR's pose, a smooth correction, low weight on the tiny
+ face points, a strong prior on head and neck, and one physical rule: when
+ GVHMR has both feet planted, their lowest points share one height (a 2D
+ fit cannot see depth and otherwise tilts a wide stance). Keypoint error
+ at the subject goes 2–4 cm → ~1 cm, heel/toe 2.5–6 cm → ~1 cm. The raw
+ estimate is kept as `smplx_raw.npz`.
+
+### S.2 Retarget
+
+`retarget_smplx.py` reads the same action_spec as the legacy lift and
+uses only what a video cannot know:
+
+| Spec field | Used for |
+|---|---|
+| `smplx` (optional) | the parameters file (default: `smplx.npz` next to `landmarks`) |
+| `rig_profile`, `action_name`, `clip_dir`, `dst_fps` | as before |
+| `fists` | fist windows; hands hold a relaxed curl elsewhere |
+| `rest_blend_start` / `rest_blend_end` | settle the **upper body** into the rig's exact T-pose; legs and root keep the performer's real stance |
+| `arm_overrides` | authored wrist/elbow targets for an arm the estimator could not see (same schema, two-bone solve, the hand rides along) |
+| `smplx_retarget` | tuning block, below |
+
+`plant`, `smooth`, `reach`, `arm_pose`, `arm_follow`, `leg_pose`,
+`head_look` and `root_offset` belong to the landmark lift and are
+ignored: contacts, head orientation and extension come from the video.
+
+What the stage does, in order:
+
+1. **Resample** 24 → 30 fps: local rotations on a C1 spline of unrolled
+ quaternions (linear interpolation leaves a velocity kink at every
+ plate frame).
+2. **Camera-consistent trajectory.** The static camera is fitted from the
+ world and camera-frame roots over the first frames. Height is taken
+ from the camera continuously (GVHMR's world track drifts 5–15 cm
+ vertically); horizontal drift (up to 0.45 m on these plates) is
+ applied one footfall at a time, so a planted foot never slides to pay
+ for it.
+3. **Contacts.** Three kinds of evidence, any of which plants a foot
+ that is low: GVHMR's static confidence (validated by foot speed and
+ height), a still sole on the floor once the floor is known, and a foot
+ that does not move **on screen** (ankle, heel and toe keypoints; the
+ camera is static, so still in the image is still in the world). Runs of
+ the same foot separated by a confidence dip, with the foot unmoved,
+ are joined.
+4. **Planted feet stay put**: where a foot is flagged, the body's
+ horizontal translation absorbs the foot's motion (the refinement
+ changes the legs frame by frame; this is GVHMR's own rule, re-applied
+ on the refined pose, anchored on the stillest foot).
+5. **Floor**: on planted frames the lowest sole goes on the floor.
+6. **Camera footfalls**: each footfall takes the camera correction
+ measured when it lands; later disagreement while it stays planted is
+ the camera's depth estimate breathing with the pose.
+7. **Rotation copy**: `P_b = S_j · A_b · B_b` in armature space (the
+ Mixamo armature's own axes are SMPL-X's). `A_b` aligns rest
+ directions for thighs, shins, upper arms and forearms; feet are
+ aligned in yaw only, measured heel-to-toes on the SMPL-X mesh (the
+ ankle→ball joint direction reads 15° more toe-out than the foot
+ has). Hands and toes inherit their parent's. Spine, neck, head and
+ collars are not aligned: there the skeletons differ in proportion,
+ not pose.
+8. **Root and legs**: the pelvis trajectory is scaled by the leg-length
+ ratio; each leg is re-solved so the ankle lands where the performer's
+ scaled leg puts it, knee in the source's plane.
+9. **Foot locks**: heel and ball down locks the ankle and lays the rig's
+ own flat foot at the stance's median heading — the heading of the
+ source foot laid flat, so a foot the estimate rolls onto its edge keeps
+ the direction it points in; otherwise the foot pivots on whichever
+ point is lower (ball for a raised heel, heel for a toe-up plant) and
+ keeps its real pitch. A toe-up heel plant held longer than 0.5 s is
+ laid flat: heel strikes and turns on the heel are brief, and GVHMR
+ returns the planted rear foot of a long stance toes-up (see
+ PITFALLS 55). Toes lie on the floor on flat and ball contacts. A lock
+ only holds while the planted point is still: stretches where it slides
+ are left to follow the source smoothly, and a lock that drifts more
+ than 4 cm is cut. Ramps of 4 frames. A lock a leg cannot reach lowers
+ the hips, at most 5 cm.
+10. Hands, rest blends, then local quaternions for every bone and the
+ Hips location, plus the plate camera (for the overlay) and QA numbers.
+
+`smplx_retarget` keys (defaults): `contact_threshold` 0.5,
+`contact_max_speed` 0.3 m/s, `contact_max_height` 0.06 m,
+`contact_heel_height` 0.03 m, `contact_geo_height` 0.025 m,
+`contact_geo_speed` 0.2 m/s, `contact_still_px` 15 px/s,
+`contact_slide_speed` 0.12 m/s, `contact_max_drift` 0.04 m,
+`contact_heel_max_s` 0.5 s, `contact_ramp` 4, `max_hips_drop` 0.05 m,
+`ground_sigma` 3, `hand_relaxed` 0.3, `pin_static_feet` true,
+`camera_root` true, `camera_fit_frames` 12, `camera_landing_frames` 6,
+and an optional
+`smooth: {"min_cutoff": 3, "beta": 8}` (One-Euro). Smoothing is **off**
+by default: even the gentlest setting cost 3–5 % of punch extension and
+3 cm of kick height on the fight plate.
+
+### S.3 Review and measure
+
+`render_review.py` renders headlessly and writes one 2×2 video per view:
+the plate, the clip rendered through the plate's recovered camera and
+composited over it, and (with `--legacy`) the old clip next to the new
+one with the same camera and look. The overlay is the check to trust:
+where character and performer disagree, it is visible.
+
+`eval_fidelity.py` projects the clip through that camera and compares
+every limb's on-screen angle with the ViTPose keypoints on every plate
+frame, each foot's ankle→toe line with MediaPipe's, and reports
+planted-foot slide (on the frames GVHMR flags, not the clip's own
+locks), sole height and jerk. Read the angles as relative: joint centres
+and COCO keypoints are different anatomical points (GVHMR's own
+skeleton scores ~5.9° on the fight plate), and the foot line of a rig
+with a higher ankle and a longer foot than the performer's differs from
+MediaPipe's ankle→big-toe line by a few degrees on its own — treat the
+foot number as ±5° and judge finer differences on the overlay.
## 0. The plate (source video)
diff --git a/docs/PITFALLS.md b/docs/PITFALLS.md
index e826cad..d90fa17 100644
--- a/docs/PITFALLS.md
+++ b/docs/PITFALLS.md
@@ -248,3 +248,112 @@ touching a clip a human has partially signed off.
the frames where contact is the point — separate an intended
contact from an unintended one by asking what the source video
does at that frame.
+
+## The SMPL-X path
+
+39. **Positions cannot carry twist.** The landmark lift rebuilt the
+ skeleton from 33 points and had to invent forearm roll, spine curve
+ and head orientation. The estimator had already solved all three:
+ transfer SMPL-X joint *rotations* (`retarget_smplx.py`), and align
+ rest poses only where they differ in pose (limbs), never where the
+ skeletons differ in proportion (spine, neck, head, collars).
+40. **GVHMR's world trajectory drifts, in all three axes.** Measured on
+ whole takes that end where they began: 0.3 m in depth (fight),
+ 0.4 m sideways (kung-fu), 5–15 cm vertically (feet "planted" 15 cm
+ above the floor mid-clip). The camera-frame root is noisy but does
+ not drift. Take height from the camera continuously; apply the
+ horizontal correction per footfall, or it drags planted feet.
+41. **The network's contact confidence can be confidently wrong.** On the
+ kung-fu plate the right foot slides 0.2 m back under the body while
+ `static_conf` stays near 1; a lock there left the character in a
+ frog stance for the whole closing T-pose. On the spin plate it stays
+ under 0.4 for 200 frames of footwork with the feet on the floor.
+ Check every contact against foot speed and height, and add a
+ geometric pass once the floor is known.
+42. **A regressor flattens extremes.** GVHMR put the fight kick apex
+ 0.10–0.18 m below where ViTPose saw the ankle in the frames it was
+ given. Refine the pose on the plate's own 2D keypoints
+ (`refine_smplx.py`) instead of sizing `leg_pose` corrections by hand.
+43. **Face keypoints are too small to steer a head.** At 4.7 m the face
+ spans ~25 px: a 3 px detection error is a 10° head turn. Refining
+ with full-weight face points rotated the head 17° on average; low
+ weight plus a strong head/neck prior brought it to 2°.
+44. **Linear resampling stutters.** Interpolating 24 fps samples linearly
+ to 30 fps puts a velocity kink at every source frame, a jerk spike
+ every fourth frame. Use a C1 spline on unrolled quaternions.
+45. **Smoothing a faithful retarget costs amplitude.** The raw GVHMR
+ rotations were not noisy; the legacy pre-filter was eating strikes
+ (fist speed 3.5 m/s vs 5–6 m/s). Even a gentle One-Euro filter cost
+ 3–5 % of punch extension, so it is off by default.
+46. **Rest blends must not touch the legs.** Blending the whole body to
+ the rig's T-pose while the performer stands in a wide stance drags
+ both planted feet across the floor at up to 0.8 m/s. Settle the upper
+ body only.
+47. **A flat foot is the rig's flat foot.** Aligning the foot bone to the
+ SMPL-X ankle→ball direction carries SMPL-X foot geometry (a different
+ pitch) and lifts the ball 5 mm off the floor. For a planted foot keep
+ only the yaw of the alignment and lock that yaw for the whole stance,
+ or the toes swing around the locked ankle.
+48. **Joint centres are not keypoints.** A SMPL-X hip joint projects
+ ~8 cm below the COCO hip keypoint. Fit and compare with the same
+ definition (GVHMR's mesh-based COCO-17 regressor), and treat angle
+ metrics between different definitions as relative.
+49. **The ankle→ball joint line is not the foot.** On the SMPL-X template
+ it reads 18–22° of toe-out where the heel-to-toes line of the mesh
+ reads 5–6°. Aligning the rig's foot on the joint line turned every
+ retargeted foot out by ~15°. Measure the foot on the mesh, align yaw
+ only.
+50. **A 2D fit un-plants feet.** Refining the pose frame by frame on
+ detections moved feet GVHMR had pinned (planted-foot speed 0.3 →
+ 3.5 cm/s median, 12 cm of creep over 0.8 s on the kung-fu plate) —
+ still in the image, sliding in the world. Re-pin the flagged feet
+ after refining, anchored on the stillest one (an average lets a foot
+ starting to lift drag the other).
+51. **A camera correction averaged over a stance is not the footfall's.**
+ During a 6 s deep stance the camera-frame depth drifted 0.2 m with the
+ pose; averaging it moved a planted foot 12 cm at the moment the other
+ foot lifted. Measure each footfall's correction when it lands.
+52. **The image is the best contact detector.** The camera is static: a
+ foot that does not move on screen is planted. GVHMR's flag missed
+ such feet for dozens of frames on the kung-fu plate (where the 3D
+ track crept), and the network flags some genuine slides as static.
+ Plant a low foot that is still on screen, lock only while the planted
+ point is still, and let a real slide follow the source.
+53. **A static heel can be up.** The rear foot of a boxing stance is
+ perfectly still on its ball. "Static" is not "flat": flat needs heel
+ AND ball near the floor; otherwise pivot on the lower point and keep
+ the real pitch.
+54. **Check a model file before trusting it.** The Pose Landmarker model
+ restored from shadow copy into `local/bible` starts with zeros — the
+ same damage as the plates noted in the video-mocap docs. A `.task` is
+ a zip: `detect_feet.py` checks for `PK` and downloads a fresh copy.
+55. **A long heel plant is the estimator's, not the performer's.** GVHMR
+ returns the planted rear foot of the kung-fu bow stance (4 s, leg
+ straight) with its toes 20° up and rolled 37° onto its edge; the 2D
+ refinement, pulled by a MediaPipe heel that lands mid-foot when the
+ foot faces the camera, takes it to 29°. The video shows it flat. The
+ image cannot arbitrate — a toe-up foot and a flat one turned 12°
+ project within a pixel of each other — but weight-bearing can: heel
+ strikes and turns on the heel last a fraction of a second, so a heel
+ plant held longer is laid flat.
+56. **A tilted foot's heading is not its axis's heading.** The heading of
+ a foot rolled 37° onto its edge, read off its tilted forward axis,
+ was 6° off the direction it points in once laid flat. Flatten first
+ (minimal rotation to the floor), then read the heading.
+57. **A planted foot's heading cannot be fitted to 2D keypoints.** Seen
+ from the side, turning a foot moves its toes in depth: 1 cm of error
+ in where the detector puts the ankle or the toe (MediaPipe's toe is
+ the big toe tip, its heel sits 3-4 cm up the back of the heel) is
+ ~15° of heading. Seen from the front it is the heights that dominate.
+ Tried and dropped: a per-stance yaw fit to the ankle→toe line gave
+ sub-degree residuals and moved feet 5-17° in both directions; which
+ way depended on the landmark definition chosen. Keep the source's
+ heading, and treat foot-angle metrics against MediaPipe as ±5°.
+58. **GVHMR's gravity is a few degrees off the plate's floor.** On all
+ five plates the up vector of feet GVHMR itself flags as planted, and
+ the plane through their soles, lean 2-10° (mostly in pitch) from the
+ world up GVHMR reports. The whole take is then leaning by that much
+ relative to the floor it stands on — invisible from the plate's own
+ camera, visible from the side. Not corrected yet: re-levelling the
+ world on the planted soles is the next step.
+