Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
feat: update avatar fidelity program and evaluation documentation; improve clarity on measurement tracks and ISE limitations
nirholasf70c71bb5da4
diff --git a/docs/avatar-fidelity-program.md b/docs/avatar-fidelity-program.mdindex fbf7ab553..854a0ebc1 100644--- a/docs/avatar-fidelity-program.md+++ b/docs/avatar-fidelity-program.md@@ -66,27 +66,64 @@ Not money. Two things:Tracks 1-3 are independent and can run in parallel. Track 0 gates the claims ofall of them.-### Track 0 — Measurement `[done, needs a reference set]`--The ISE metric, batch runner, revision comparator and property tests. Built and-passing. What remains is the reference set itself: 30-50 frontal selfies-spanning skin tone, age, face shape, facial hair, glasses, head covering and-lighting, mirrored to `gs://three-ws-avatar-reconstructions/eval-refs/` so every-agent scores against an identical set. Photos are never committed.--### Track 1 — Ship the morph that is already written `[in flight]`--`face_geometry.py` (Phase 2 head-shape morph) is written, tested, and has never-been deployed: production `/health` reports `face_texture_transfer_v1` and omits-the `geometry_morph` field entirely, so the running image predates the work.-Production is texture-only today — a person's face painted on a generic skull.--Deploying it is one build. Then: baseline v1 vs v2 on the reference set, and-tune `strength` / `falloff` / `max_displacement_frac` against ISE rather than-against taste.--Cost: negligible. Expected to be the single largest fidelity jump per unit of-effort in the whole program, because the work is already paid for.+### Track 0 — Measurement `[done]`++The ISE metric, batch runner, revision comparator, parameter tuner and property+tests, plus a 40-face reference set generated by+[`eval/make_refs.py`](../workers/avatar-reconstruction/eval/make_refs.py) over a+deterministic grid of the platform's diversity matrix and mirrored to+`gs://three-ws-avatar-reconstructions/eval-refs/`.++Faces are synthesised rather than collected: no real person's biometrics in a+benchmark that gets copied between machines, no licensing terms, and any agent+can rebuild the identical set.++**The remaining gap is adversarial samples.** Every reference face is a clean+frontal portrait, so the set contains no landmark mis-detections and is blind to+everything the outlier machinery exists for. Blurry, off-angle, occluded,+low-light and low-resolution samples are the single most valuable addition, and+until they exist, any parameter governing robustness has to be set on physical+grounds rather than by the sweep (see Track 1).++### Track 1 — Ship the morph that is already written `[done]`++`face_geometry.py` (Phase 2 head-shape morph) had been written, tested and never+deployed: production `/health` reported `face_texture_transfer_v1` and omitted+`geometry_morph` entirely, so the running image predated the work. Production was+texture-only — a person's face painted on a generic skull. It now reports+`face_texture_transfer_v2` with `geometry_morph: true`.++Deploying it surfaced two things worth more than the deploy:++**A latent correctness bug.** `landmarks_to_array` passed MediaPipe's raw+normalised landmarks straight into the morph. MediaPipe divides x by image width+and y by image *height*, so on any non-square photo the point cloud is+anisotropically stretched; Umeyama fits one uniform scale and cannot undo that,+so the stretch survived alignment and was consumed as facial identity. The+camera's aspect ratio was being baked into the avatar's skull — the same person+at 3:4 and 1:1 got head shapes differing by 3.07% of head size, and 3:4 is+exactly what the selfie page recommends. Fixed by scaling to an isotropic pixel+frame; drift is now 0. Pinned by a test that fails on the old path.++**Defaults that had never been measured.** A sweep over the 40-face set+([`eval/tune_morph.py`](../workers/avatar-reconstruction/eval/tune_morph.py))+moved `strength` / `max_displacement_frac` from 0.75 / 0.18 to **0.6 / 0.45**:+mean ISE 0.2947 → 0.1684, i.e. from 26% to 58% below the texture-only floor, a+43% cut, with **no face made worse**. The old clamp permitted only ~1.9 cm of+travel per control point and was throttling genuine facial variation rather than+rejecting outliers.++The sweep's own optimum was looser still (0.65, ~6.7 cm, 60.2% below floor) and+was **deliberately not shipped**. Every reference face is a clean portrait, so+the benchmark contains nothing for the clamp to reject and will always push it+toward zero clamping; 6.7 cm exceeds plausible human facial variation and would+pass a mis-detection straight through to the mesh. 0.45 takes nearly all the+measurable gain while keeping real outlier rejection. This is the concrete case+for the adversarial samples called for in Track 0 — until they exist, this+parameter cannot be tuned honestly.++Cost: negligible. As predicted, the largest fidelity gain per unit of effort in+the program, because the work was already paid for.### Track 2 — Full-head photoreal texture (Vertex AI Imagen)@@ -176,6 +213,26 @@ is already parameterised by template), transfer the ARKit-52 expression set withICT-FaceKit (MIT) since the Anny base does not ship visemes, and re-baselineevery ISE report — scores are only comparable within one template.+**This track also owns the `body_type` dead path.** `POST /reconstruct` accepts+`male | female | neutral` and the selfie page offers the choice, but+[`face_pipeline._load_template`](../workers/avatar-reconstruction/face_pipeline.py)+looks for `templates/male.glb` and `female.glb`, neither of which exists, so every+request silently falls back to `default.glb`. The parameter has never done+anything.++Staging the existing RPM bases as those two files is the obvious patch and is the+wrong move. `public/avatars/realistic-male.glb` is topology-compatible (same 2162-+vertex `Wolf3D_Head`) but carries only 60 morph targets against `default.glb`'s+67, so it would silently drop seven expressions. `realistic-female.glb` is a+different head entirely (1531 vertices, mesh names stripped), so it needs its own+precomputed map and a `_find_head_prim` that does not key on a mesh name — and it+would still leave two more templates to maintain in lockstep.++The parametric base dissolves the problem: body type stops being a discrete+template swap and becomes slider values (gender, muscle, weight, height, hips) on+one mesh with one skeleton, one UV map and one blendshape set. Fix it here, not+by adding template files.+## Where the credits go| Line | Rough monthly | Notes |diff --git a/workers/avatar-reconstruction/eval/README.md b/workers/avatar-reconstruction/eval/README.mdindex ed925d86b..19f09f34d 100644--- a/workers/avatar-reconstruction/eval/README.md+++ b/workers/avatar-reconstruction/eval/README.md@@ -40,6 +40,25 @@ Two numbers give it meaning:A region breakdown (oval / nose / cheeks / brow / jaw) says *where* the shape iswrong, which is what decides where the next fidelity push goes.+### What ISE cannot see++- **Anything off the face.** The metric samples the head only at the 468 landmark+ correspondence vertices, which are exactly the morph's control points. The+ scalp, ears, neck and back of the head are never measured, so `falloff` — which+ governs how the displacement decays away from the face — is invisible to ISE by+ construction. Never tune `falloff` against this score; the back-of-head+ assertions in [`test_face_geometry.py`](../test_face_geometry.py) are what guard+ that region.+- **Texture.** By design. A texture change scores identically. Track 2 in+ [the program plan](../../../docs/avatar-fidelity-program.md) needs its own+ metric.+- **Failure modes absent from the reference set.** The set is clean frontal+ portraits, so it contains no landmark mis-detections and cannot tell you+ anything about outlier rejection. This is why `max_displacement_frac` is set on+ physical grounds rather than at the sweep's numerical optimum, and why+ adversarial samples (blurry, off-angle, occluded, low-light) are the most+ valuable addition to the reference set.+## Score one reconstruction```bash@@ -86,21 +105,45 @@ individual face that got worse**. A change can improve the mean while wrecking asubset of faces; the mean alone hides exactly the regression that matters. Exitsnon-zero when the mean did not improve, so it works as a gate.+## Tune the morph against the score++```bash+python -m eval.tune_morph --photos eval/refs --detail+```++Sweeps `strength` x `max_displacement_frac` over every reference face and reports+the best mean ISE, the worst individual face, and how many faces a setting makes+worse than the shipped default. Runs offline — landmarks are detected once, then+each combination is applied in-process — so a full grid is minutes, not a day of+job submissions. This is how the current 0.6 / 0.45 defaults were chosen.++Read its output with the blind spots above in mind. The sweep's numerical optimum+is not automatically the right ship: a benchmark of clean portraits will always+push `max_displacement_frac` toward "no clamping at all", because it contains+nothing for the clamp to reject.+## The reference set-`--photos` is a directory of frontal selfies, one file per sample. Choose faces-that span what the pipeline must handle: skin tone, age, face shape, facial-hair, glasses, head covering, lighting, camera quality. A mean over a narrow set-hides the failures that matter most.+`--photos` is a directory of frontal faces, one file per sample, spanning what+the pipeline must handle: skin tone, age, face shape, facial hair, glasses, head+covering, lighting, camera quality. A mean over a narrow set hides the failures+that matter most.++Build it with:++```bash+python -m eval.make_refs --out eval/refs --upload+```-Reference photos are **not committed** — they are either real people's faces or-licensed stock, and neither belongs in git. Keep them in-`eval/refs/` (gitignored) and mirror the set to-`gs://three-ws-avatar-reconstructions/eval-refs/` so every agent and every CI run-scores against an identical set:+The faces are **synthesised, not collected** ([`make_refs.py`](make_refs.py)) over+a deterministic grid of the platform's own diversity matrix. That keeps real+people's biometrics out of a benchmark that gets copied between machines and+uploaded to buckets, avoids any licensing question, and lets any agent rebuild+the identical set. They stay gitignored regardless — 40 PNGs do not belong in+git — and mirror to `gs://three-ws-avatar-reconstructions/eval-refs/`:```bash-gsutil -m rsync -r gs://three-ws-avatar-reconstructions/eval-refs eval/refs+gcloud storage rsync -r gs://three-ws-avatar-reconstructions/eval-refs eval/refs```A score is only comparable to another score taken on the same reference set.diff --git a/workers/garment-forge/README.md b/workers/garment-forge/README.mdindex b4bb97666..da067dae5 100644--- a/workers/garment-forge/README.md+++ b/workers/garment-forge/README.md@@ -4,8 +4,9 @@ Turns "a white oxford cotton dress shirt" into an asset the additive wardrobecan put on **any** humanoid avatar: a garment GLB skinned to the three.wscanonical skeleton, a manifest that passes every validation rule in[specs/GARMENT_MANIFEST.md](../../specs/GARMENT_MANIFEST.md), and a thumbnail,-published to the immutable catalog layout in-`gs://three-ws-model-weights/garments/`.+published to the immutable catalog layout in `gs://three-ws-garments/garments/`+(the public bucket [src/garment-catalog.js](../../src/garment-catalog.js)+serves the wardrobe closet from).The runtime consumer is `attachGarment()` in[src/avatar-garment.js](../../src/avatar-garment.js): it rebinds the garment's@@ -109,12 +110,11 @@ as every build in this project must.One-time infra the service depends on (already applied):-- `avatar-reconstruction-sa@` has `roles/storage.objectAdmin` on- `three-ws-model-weights` (writes garments/**, jobs, catalog) and- `roles/aiplatform.user` on the project (Vertex image lane).-- `three-ws-model-weights` carries a CORS policy allowing `GET` from any- origin, so published garment GLBs are readable by the viewer, per the- manifest spec's CORS requirement.+- `avatar-reconstruction-sa@` has project-level `roles/storage.objectAdmin`+ (writes to both buckets) and `roles/aiplatform.user` (Vertex image lane).+- `three-ws-garments` is uniformly public-read with a permissive GET CORS+ policy, satisfying the manifest spec's CORS requirement; job records and+ rig staging stay in `three-ws-avatar-reconstructions`.## Local tests (no GPU, no network)@@ -132,7 +132,8 @@ suite runs inside `docker build`, so a regression cannot ship.| Var | Default | Meaning ||---|---|---|| `API_KEY` | (secret) | shared bearer secret (`avatar-reconstruction-key`); also sent to the mesh/rig workers |-| `GCS_BUCKET` | (required) | bucket holding `garments/**` (`three-ws-model-weights`) |+| `GCS_BUCKET` | (required) | job records + rig staging (`three-ws-avatar-reconstructions`) |+| `PUBLISH_BUCKET` | (required) | public catalog bucket (`three-ws-garments`) || `MESH_WORKER_URLS` | (required) | comma-separated `/infer`-contract mesh workers, priority order || `RIG_URL` | (required) | `model-rig` base URL || `REFBODY_PATH` | `/app/assets/refbody.glb` | reference body baked into the image |diff --git a/workers/garment-forge/cloudbuild.yaml b/workers/garment-forge/cloudbuild.yamlindex 5728ca4d4..fc99e5662 100644--- a/workers/garment-forge/cloudbuild.yaml+++ b/workers/garment-forge/cloudbuild.yaml@@ -3,9 +3,11 @@ substitutions:_RUN_SA: avatar-reconstruction-sa@aerial-vehicle-466722-p5.iam.gserviceaccount.com_SERVICE: garment-forge_REPO: garment-forge- # Garment assets, catalog, and job records live in the weights bucket, per- # the storage layout pinned in specs/GARMENT_MANIFEST.md.- _GCS_BUCKET: three-ws-model-weights+ # Job records + rig staging share the fleet's worker-artifact bucket;+ # published garments + catalog go to the public bucket the runtime consumer+ # (src/garment-catalog.js) reads.+ _GCS_BUCKET: three-ws-avatar-reconstructions+ _PUBLISH_BUCKET: three-ws-garments# Mesh generation failover chain, priority order: warm RTX 2.1 primary,# L4 2.1 fallback, TRELLIS last (different model, always-compatible API)._MESH_WORKER_URLS: https://model-hunyuan3d-21-rtx-lp642k3kpa-uc.a.run.app,https://model-hunyuan3d-21-lp642k3kpa-uc.a.run.app,https://model-trellis-lp642k3kpa-uc.a.run.app@@ -61,7 +63,7 @@ steps:- --max-instances=2- --timeout=600- --allow-unauthenticated- - --set-env-vars=^;^GCS_BUCKET=${_GCS_BUCKET};MESH_WORKER_URLS=${_MESH_WORKER_URLS};RIG_URL=${_RIG_URL};GOOGLE_CLOUD_PROJECT=$PROJECT_ID;VERTEX_IMAGEN_MODEL=gemini-2.5-flash-image;VERTEX_IMAGEN_LOCATION=global;VERTEX_IMAGE_SIZE=2K;MAX_CONCURRENT=2+ - --set-env-vars=^;^GCS_BUCKET=${_GCS_BUCKET};PUBLISH_BUCKET=${_PUBLISH_BUCKET};MESH_WORKER_URLS=${_MESH_WORKER_URLS};RIG_URL=${_RIG_URL};GOOGLE_CLOUD_PROJECT=$PROJECT_ID;VERTEX_IMAGEN_MODEL=gemini-2.5-flash-image;VERTEX_IMAGEN_LOCATION=global;VERTEX_IMAGE_SIZE=2K;MAX_CONCURRENT=2- --set-secrets=API_KEY=avatar-reconstruction-key:latestimages: