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
Add ASL fingerspelling recognition worker with Docker setup and dependencies
nirholasd7c03d042665
diff --git a/workers/model-asl-recognition/Dockerfile b/workers/model-asl-recognition/Dockerfilenew file mode 100644index 000000000..7c8fe3fc2--- /dev/null+++ b/workers/model-asl-recognition/Dockerfile@@ -0,0 +1,31 @@+FROM python:3.11-slim++ENV PYTHONDONTWRITEBYTECODE=1 \+ PYTHONUNBUFFERED=1 \+ PIP_NO_CACHE_DIR=1++RUN apt-get update && apt-get install -y --no-install-recommends \+ curl unzip \+ && rm -rf /var/lib/apt/lists/*++COPY requirements.txt /app/requirements.txt+RUN pip install -r /app/requirements.txt++# Kaggle ASLFR 1st-place model (Apache-2.0, Christof Henkel; trained on+# Google's FSboard corpus, CC BY 4.0). Baked into the image so the service+# cold-starts ready with no weights-bucket dependency.+RUN mkdir -p /models \+ && curl -fsSL -o /tmp/weights.zip \+ https://github.com/ChristofHenkel/kaggle-asl-fingerspelling-1st-place-solution/releases/download/v0.0.1-alpha/weights.zip \+ && unzip -o -q /tmp/weights.zip 'cfg_2/fold-1/model.tflite' -d /tmp/aslfr \+ && mv /tmp/aslfr/cfg_2/fold-1/model.tflite /models/model.tflite \+ && rm -rf /tmp/weights.zip /tmp/aslfr++WORKDIR /app+COPY inference_args.json /app/inference_args.json+COPY character_to_prediction_index.json /app/character_to_prediction_index.json+COPY decode.py /app/decode.py+COPY main.py /app/main.py++EXPOSE 8080+CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8080", "--workers", "1"]diff --git a/workers/model-asl-recognition/README.md b/workers/model-asl-recognition/README.mdnew file mode 100644index 000000000..8e17d0977--- /dev/null+++ b/workers/model-asl-recognition/README.md@@ -0,0 +1,77 @@+# model-asl-recognition++Webcam ASL fingerspelling → **text**. A CPU-only FastAPI worker that turns a+stream of MediaPipe landmarks into transcribed text, so a user can sign into+their camera and talk to the platform's chat. The reverse direction of+[sign speech](../../docs/sign-language.md) (avatars signing replies).++## The model (and why it is legally clean)++The recognizer is the **1st-place solution of Google's 2023 ASL Fingerspelling+Recognition Kaggle competition** by Christof Henkel: an improved-Squeezeformer+encoder + transformer decoder, exported to TFLite, run here on CPU via LiteRT.++- Code and released weights: **Apache-2.0**+ (github.com/ChristofHenkel/kaggle-asl-fingerspelling-1st-place-solution).+- Training corpus: Google's **FSboard** (3M+ fingerspelled characters by 147+ Deaf signers), released **CC BY 4.0** explicitly for academic AND industry+ use. Attribution: FSboard (Google / Deaf Professional Arts Network).++This is the rare ASL stack with clean commercial provenance end to end; most+alternatives (WLASL, How2Sign, ASL Citizen derivatives) are research-only and+must not be shipped. It reads continuous fingerspelling — words, names, URLs,+phone numbers — not just static letter poses. Realistic webcam accuracy is a+10–20% character error rate; the chat LLM downstream is robust to that.++## API++Bearer auth on everything but `/health` (`Authorization: Bearer $API_KEY`,+the shared `avatar-reconstruction-key` secret).++```+GET /health → { ok, model_loaded }+GET /schema → { columns: [390 names], max_frames, min_frames }+POST /transcribe { frames: [[390 numbers|null]…] } → { text, frames, ms }+```++`frames` is a per-video-frame matrix of the landmark coordinates named by+`/schema`, in order (`x_face_0 … z_pose_21` — the competition's selected+MediaPipe Holistic columns; `inference_args.json` is the source of truth).+`null` marks a missing landmark (NaN to the model, which was trained for it).+The browser extracts landmarks client-side with MediaPipe tasks-vision, so no+video ever leaves the user's machine — only pose coordinates.++## Local run++```bash+cd workers/model-asl-recognition+pip install -r requirements.txt+# fetch cfg_2/fold-1/model.tflite from the release zip, then:+MODEL_PATH=./model.tflite API_KEY= uvicorn main:app --port 8087+python -m pytest test_decode.py -q # pure decode/schema tests, no model+```++## Deploy++```bash+gcloud builds submit --config workers/model-asl-recognition/cloudbuild.yaml \+ --region us-central1 --project aerial-vehicle-466722-p5 \+ --substitutions=SHORT_SHA=manual$(date +%s)+```++Then point the API at it:++```bash+gcloud run services update three-ws-api --region us-central1 \+ --update-env-vars GCP_ASL_RECOGNITION_URL=<service url>+```++The model (40 MB) is baked into the image from the pinned GitHub release, so+instances cold-start ready and the service scales to zero (recognition runs+inside the request, sub-second per utterance).++## Roadmap++Word-level recognition (250 everyday signs) comes from retraining the MIT+Kaggle ISLR 1st-place architecture on the PopSign ASL v1.0 corpus (CC BY 4.0)+— a one-GPU-day job — and compiling both models behind this same endpoint.diff --git a/workers/model-asl-recognition/character_to_prediction_index.json b/workers/model-asl-recognition/character_to_prediction_index.jsonnew file mode 100644index 000000000..1d41449d3--- /dev/null+++ b/workers/model-asl-recognition/character_to_prediction_index.json@@ -0,0 +1 @@+{" ":0,"!":1,"#":2,"$":3,"%":4,"&":5,"'":6,"(":7,")":8,"*":9,"+":10,",":11,"-":12,".":13,"\/":14,"0":15,"1":16,"2":17,"3":18,"4":19,"5":20,"6":21,"7":22,"8":23,"9":24,":":25,";":26,"=":27,"?":28,"@":29,"[":30,"_":31,"a":32,"b":33,"c":34,"d":35,"e":36,"f":37,"g":38,"h":39,"i":40,"j":41,"k":42,"l":43,"m":44,"n":45,"o":46,"p":47,"q":48,"r":49,"s":50,"t":51,"u":52,"v":53,"w":54,"x":55,"y":56,"z":57,"~":58}\ No newline at end of filediff --git a/workers/model-asl-recognition/cloudbuild.yaml b/workers/model-asl-recognition/cloudbuild.yamlnew file mode 100644index 000000000..8cc4f3efa--- /dev/null+++ b/workers/model-asl-recognition/cloudbuild.yaml@@ -0,0 +1,61 @@+serviceAccount: projects/aerial-vehicle-466722-p5/serviceAccounts/[email protected]++substitutions:+ _REGION: us-central1+ _RUN_SA: avatar-reconstruction-sa@aerial-vehicle-466722-p5.iam.gserviceaccount.com+ _SERVICE: model-asl-recognition+ _REPO: model-asl-recognition++steps:+ - id: build+ name: gcr.io/cloud-builders/docker+ dir: workers/model-asl-recognition+ args:+ - build+ - --tag+ - ${_REGION}-docker.pkg.dev/$PROJECT_ID/${_REPO}/server:$SHORT_SHA+ - --tag+ - ${_REGION}-docker.pkg.dev/$PROJECT_ID/${_REPO}/server:latest+ - --cache-from+ - ${_REGION}-docker.pkg.dev/$PROJECT_ID/${_REPO}/server:latest+ - .++ - id: push+ name: gcr.io/cloud-builders/docker+ args:+ - push+ - --all-tags+ - ${_REGION}-docker.pkg.dev/$PROJECT_ID/${_REPO}/server++ # Recognition runs inside the request (sub-second on CPU), so plain+ # request-based billing and scale-to-zero are correct here — unlike the+ # video2motion worker's background-task shape.+ - id: deploy+ name: gcr.io/google.com/cloudsdktool/cloud-sdk:slim+ entrypoint: gcloud+ args:+ - run+ - deploy+ - ${_SERVICE}+ - --image=${_REGION}-docker.pkg.dev/$PROJECT_ID/${_REPO}/server:$SHORT_SHA+ - --region=${_REGION}+ - --service-account=${_RUN_SA}+ - --platform=managed+ - --port=8080+ - --cpu=4+ - --memory=4Gi+ - --min-instances=0+ - --max-instances=4+ - --timeout=60+ - --allow-unauthenticated+ - --set-secrets=API_KEY=avatar-reconstruction-key:latest++images:+ - ${_REGION}-docker.pkg.dev/$PROJECT_ID/${_REPO}/server:$SHORT_SHA+ - ${_REGION}-docker.pkg.dev/$PROJECT_ID/${_REPO}/server:latest++options:+ machineType: E2_HIGHCPU_8+ logging: CLOUD_LOGGING_ONLY++timeout: 3600sdiff --git a/workers/model-asl-recognition/decode.py b/workers/model-asl-recognition/decode.pynew file mode 100644index 000000000..a167d17cf--- /dev/null+++ b/workers/model-asl-recognition/decode.py@@ -0,0 +1,72 @@+"""Feature schema + output decoding for the ASL fingerspelling recognizer.++The model is the Google ASL Fingerspelling (Kaggle 2023) 1st-place TFLite+export (Apache-2.0, Christof Henkel), trained on Google's FSboard corpus+(CC BY 4.0). Input is a (frames, 390) float32 matrix of selected MediaPipe+landmark coordinates (the exact column order ships in inference_args.json);+output is (tokens, 63) logits over the competition character set+(character_to_prediction_index.json, 59 printable characters + specials).++Pure NumPy + stdlib so decoding is unit-tested without the model runtime.+"""++from __future__ import annotations++import json+from pathlib import Path++import numpy as np++_HERE = Path(__file__).parent++with open(_HERE / "inference_args.json", "r", encoding="utf-8") as f:+ FEATURE_COLUMNS: list[str] = json.load(f)["selected_columns"]++with open(_HERE / "character_to_prediction_index.json", "r", encoding="utf-8") as f:+ _CHAR_TO_ID: dict[str, int] = json.load(f)++ID_TO_CHAR: dict[int, str] = {i: c for c, i in _CHAR_TO_ID.items()}++N_FEATURES = len(FEATURE_COLUMNS) # 390++# Practical caps: ~50s of 30fps signing per request keeps payloads sane.+MAX_FRAMES = 1500+MIN_FRAMES = 8+++def decode_logits(logits: np.ndarray) -> str:+ """(tokens, vocab) logits → text. Ids outside the printable character map+ (BOS/EOS/PAD) terminate or are dropped, matching the competition decode."""+ logits = np.asarray(logits)+ if logits.ndim != 2:+ raise ValueError(f"logits must be 2D (tokens, vocab); got {logits.shape}")+ ids = np.argmax(logits, axis=-1)+ chars = []+ for i in ids:+ ch = ID_TO_CHAR.get(int(i))+ if ch is None:+ # First special token after any output ends the sequence; leading+ # specials are skipped so a BOS never truncates the whole decode.+ if chars:+ break+ continue+ chars.append(ch)+ return "".join(chars).strip()+++def validate_frames(frames) -> np.ndarray:+ """Request payload → (T, 390) float32 with None mapped to NaN (missing+ landmarks — the model was trained to handle NaN natively)."""+ if not isinstance(frames, list) or not frames:+ raise ValueError("frames must be a non-empty list")+ if len(frames) > MAX_FRAMES:+ raise ValueError(f"too many frames (max {MAX_FRAMES})")+ if len(frames) < MIN_FRAMES:+ raise ValueError(f"too few frames for recognition (min {MIN_FRAMES})")+ arr = np.array(+ [[np.nan if v is None else float(v) for v in row] for row in frames],+ dtype=np.float32,+ )+ if arr.shape[1] != N_FEATURES:+ raise ValueError(f"each frame must have {N_FEATURES} values; got {arr.shape[1]}")+ return arrdiff --git a/workers/model-asl-recognition/inference_args.json b/workers/model-asl-recognition/inference_args.jsonnew file mode 100644index 000000000..a3bd14e5c--- /dev/null+++ b/workers/model-asl-recognition/inference_args.json@@ -0,0 +1 @@+{"selected_columns": ["x_face_0", "x_face_61", "x_face_185", "x_face_40", "x_face_39", "x_face_37", "x_face_267", "x_face_269", "x_face_270", "x_face_409", "x_face_291", "x_face_146", "x_face_91", "x_face_181", "x_face_84", "x_face_17", "x_face_314", "x_face_405", "x_face_321", "x_face_375", "x_face_78", "x_face_191", "x_face_80", "x_face_81", "x_face_82", "x_face_13", "x_face_312", "x_face_311", "x_face_310", "x_face_415", "x_face_95", "x_face_88", "x_face_178", "x_face_87", "x_face_14", "x_face_317", "x_face_402", "x_face_318", "x_face_324", "x_face_308", "x_left_hand_0", "x_left_hand_1", "x_left_hand_2", "x_left_hand_3", "x_left_hand_4", "x_left_hand_5", "x_left_hand_6", "x_left_hand_7", "x_left_hand_8", "x_left_hand_9", "x_left_hand_10", "x_left_hand_11", "x_left_hand_12", "x_left_hand_13", "x_left_hand_14", "x_left_hand_15", "x_left_hand_16", "x_left_hand_17", "x_left_hand_18", "x_left_hand_19", "x_left_hand_20", "x_right_hand_0", "x_right_hand_1", "x_right_hand_2", "x_right_hand_3", "x_right_hand_4", "x_right_hand_5", "x_right_hand_6", "x_right_hand_7", "x_right_hand_8", "x_right_hand_9", "x_right_hand_10", "x_right_hand_11", "x_right_hand_12", "x_right_hand_13", "x_right_hand_14", "x_right_hand_15", "x_right_hand_16", "x_right_hand_17", "x_right_hand_18", "x_right_hand_19", "x_right_hand_20", "x_face_1", "x_face_2", "x_face_98", "x_face_327", "x_face_33", "x_face_7", "x_face_163", "x_face_144", "x_face_145", "x_face_153", "x_face_154", "x_face_155", "x_face_133", "x_face_246", "x_face_161", "x_face_160", "x_face_159", "x_face_158", "x_face_157", "x_face_173", "x_face_263", "x_face_249", "x_face_390", "x_face_373", "x_face_374", "x_face_380", "x_face_381", "x_face_382", "x_face_362", "x_face_466", "x_face_388", "x_face_387", "x_face_386", "x_face_385", "x_face_384", "x_face_398", "x_pose_12", "x_pose_14", "x_pose_16", "x_pose_18", "x_pose_20", "x_pose_22", "x_pose_11", "x_pose_13", "x_pose_15", "x_pose_17", "x_pose_19", "x_pose_21", "y_face_0", "y_face_61", "y_face_185", "y_face_40", "y_face_39", "y_face_37", "y_face_267", "y_face_269", "y_face_270", "y_face_409", "y_face_291", "y_face_146", "y_face_91", "y_face_181", "y_face_84", "y_face_17", "y_face_314", "y_face_405", "y_face_321", "y_face_375", "y_face_78", "y_face_191", "y_face_80", "y_face_81", "y_face_82", "y_face_13", "y_face_312", "y_face_311", "y_face_310", "y_face_415", "y_face_95", "y_face_88", "y_face_178", "y_face_87", "y_face_14", "y_face_317", "y_face_402", "y_face_318", "y_face_324", "y_face_308", "y_left_hand_0", "y_left_hand_1", "y_left_hand_2", "y_left_hand_3", "y_left_hand_4", "y_left_hand_5", "y_left_hand_6", "y_left_hand_7", "y_left_hand_8", "y_left_hand_9", "y_left_hand_10", "y_left_hand_11", "y_left_hand_12", "y_left_hand_13", "y_left_hand_14", "y_left_hand_15", "y_left_hand_16", "y_left_hand_17", "y_left_hand_18", "y_left_hand_19", "y_left_hand_20", "y_right_hand_0", "y_right_hand_1", "y_right_hand_2", "y_right_hand_3", "y_right_hand_4", "y_right_hand_5", "y_right_hand_6", "y_right_hand_7", "y_right_hand_8", "y_right_hand_9", "y_right_hand_10", "y_right_hand_11", "y_right_hand_12", "y_right_hand_13", "y_right_hand_14", "y_right_hand_15", "y_right_hand_16", "y_right_hand_17", "y_right_hand_18", "y_right_hand_19", "y_right_hand_20", "y_face_1", "y_face_2", "y_face_98", "y_face_327", "y_face_33", "y_face_7", "y_face_163", "y_face_144", "y_face_145", "y_face_153", "y_face_154", "y_face_155", "y_face_133", "y_face_246", "y_face_161", "y_face_160", "y_face_159", "y_face_158", "y_face_157", "y_face_173", "y_face_263", "y_face_249", "y_face_390", "y_face_373", "y_face_374", "y_face_380", "y_face_381", "y_face_382", "y_face_362", "y_face_466", "y_face_388", "y_face_387", "y_face_386", "y_face_385", "y_face_384", "y_face_398", "y_pose_12", "y_pose_14", "y_pose_16", "y_pose_18", "y_pose_20", "y_pose_22", "y_pose_11", "y_pose_13", "y_pose_15", "y_pose_17", "y_pose_19", "y_pose_21", "z_face_0", "z_face_61", "z_face_185", "z_face_40", "z_face_39", "z_face_37", "z_face_267", "z_face_269", "z_face_270", "z_face_409", "z_face_291", "z_face_146", "z_face_91", "z_face_181", "z_face_84", "z_face_17", "z_face_314", "z_face_405", "z_face_321", "z_face_375", "z_face_78", "z_face_191", "z_face_80", "z_face_81", "z_face_82", "z_face_13", "z_face_312", "z_face_311", "z_face_310", "z_face_415", "z_face_95", "z_face_88", "z_face_178", "z_face_87", "z_face_14", "z_face_317", "z_face_402", "z_face_318", "z_face_324", "z_face_308", "z_left_hand_0", "z_left_hand_1", "z_left_hand_2", "z_left_hand_3", "z_left_hand_4", "z_left_hand_5", "z_left_hand_6", "z_left_hand_7", "z_left_hand_8", "z_left_hand_9", "z_left_hand_10", "z_left_hand_11", "z_left_hand_12", "z_left_hand_13", "z_left_hand_14", "z_left_hand_15", "z_left_hand_16", "z_left_hand_17", "z_left_hand_18", "z_left_hand_19", "z_left_hand_20", "z_right_hand_0", "z_right_hand_1", "z_right_hand_2", "z_right_hand_3", "z_right_hand_4", "z_right_hand_5", "z_right_hand_6", "z_right_hand_7", "z_right_hand_8", "z_right_hand_9", "z_right_hand_10", "z_right_hand_11", "z_right_hand_12", "z_right_hand_13", "z_right_hand_14", "z_right_hand_15", "z_right_hand_16", "z_right_hand_17", "z_right_hand_18", "z_right_hand_19", "z_right_hand_20", "z_face_1", "z_face_2", "z_face_98", "z_face_327", "z_face_33", "z_face_7", "z_face_163", "z_face_144", "z_face_145", "z_face_153", "z_face_154", "z_face_155", "z_face_133", "z_face_246", "z_face_161", "z_face_160", "z_face_159", "z_face_158", "z_face_157", "z_face_173", "z_face_263", "z_face_249", "z_face_390", "z_face_373", "z_face_374", "z_face_380", "z_face_381", "z_face_382", "z_face_362", "z_face_466", "z_face_388", "z_face_387", "z_face_386", "z_face_385", "z_face_384", "z_face_398", "z_pose_12", "z_pose_14", "z_pose_16", "z_pose_18", "z_pose_20", "z_pose_22", "z_pose_11", "z_pose_13", "z_pose_15", "z_pose_17", "z_pose_19", "z_pose_21"]}\ No newline at end of filediff --git a/workers/model-asl-recognition/main.py b/workers/model-asl-recognition/main.pynew file mode 100644index 000000000..057015e09--- /dev/null+++ b/workers/model-asl-recognition/main.py@@ -0,0 +1,90 @@+"""ASL fingerspelling recognition worker.++Turns webcam signing into text: the browser extracts MediaPipe landmarks+client-side (tasks-vision), assembles the 390-column feature rows published by+GET /schema, and POSTs the frame matrix here; the worker runs the Kaggle-2023+1st-place fingerspelling model (Apache-2.0 weights, FSboard CC BY 4.0 corpus)+on CPU via LiteRT and returns the decoded text. Recognition is in-request+(sub-second for a typical utterance), so the service scales to zero.++API (bearer auth via API_KEY, same secret family as the reconstruction lanes):+ GET /health → { ok, model_loaded }+ GET /schema → { columns: [390 names], max_frames, min_frames }+ POST /transcribe { frames: [[390 floats|null]...], } → { text, frames, ms }+"""++from __future__ import annotations++import asyncio+import os+import time+from contextlib import asynccontextmanager++import numpy as np+from fastapi import FastAPI, HTTPException, Request+from pydantic import BaseModel++from decode import FEATURE_COLUMNS, MAX_FRAMES, MIN_FRAMES, decode_logits, validate_frames++MODEL_PATH = os.environ.get("MODEL_PATH", "/models/model.tflite")+API_KEY = os.environ.get("API_KEY", "")++_runner = None+_input_name = None+_lock = asyncio.Lock()+++@asynccontextmanager+async def lifespan(_app: FastAPI):+ global _runner, _input_name+ from ai_edge_litert.interpreter import Interpreter++ interp = Interpreter(model_path=MODEL_PATH)+ _runner = interp.get_signature_runner()+ _input_name = list(_runner.get_input_details().keys())[0]+ yield+++app = FastAPI(lifespan=lifespan)+++def _check_auth(request: Request) -> None:+ if not API_KEY:+ return+ header = request.headers.get("authorization", "")+ if header != f"Bearer {API_KEY}":+ raise HTTPException(status_code=401, detail="unauthorized")+++class TranscribeBody(BaseModel):+ frames: list[list[float | None]]++[email protected]("/health")+async def health():+ return {"ok": True, "model_loaded": _runner is not None}++[email protected]("/schema")+async def schema(request: Request):+ _check_auth(request)+ return {"columns": FEATURE_COLUMNS, "max_frames": MAX_FRAMES, "min_frames": MIN_FRAMES}++[email protected]("/transcribe")+async def transcribe(body: TranscribeBody, request: Request):+ _check_auth(request)+ try:+ arr = validate_frames(body.frames)+ except ValueError as e:+ raise HTTPException(status_code=400, detail=str(e))+ t0 = time.time()+ async with _lock:+ logits = await asyncio.to_thread(_infer, arr)+ text = decode_logits(logits)+ return {"text": text, "frames": int(arr.shape[0]), "ms": int((time.time() - t0) * 1000)}+++def _infer(arr: np.ndarray) -> np.ndarray:+ out = _runner(**{_input_name: arr})+ return next(iter(out.values()))diff --git a/workers/model-asl-recognition/requirements.txt b/workers/model-asl-recognition/requirements.txtnew file mode 100644index 000000000..45b2010df--- /dev/null+++ b/workers/model-asl-recognition/requirements.txt@@ -0,0 +1,5 @@+fastapi==0.115.5+uvicorn[standard]==0.32.1+numpy==1.26.4+ai-edge-litert==1.1.2+pydantic==2.10.3diff --git a/workers/model-asl-recognition/test_decode.py b/workers/model-asl-recognition/test_decode.pynew file mode 100644index 000000000..5da9719a2--- /dev/null+++ b/workers/model-asl-recognition/test_decode.py@@ -0,0 +1,76 @@+"""Unit tests for the decode/schema layer — pure NumPy, no model runtime."""++import numpy as np+import pytest++from decode import (+ FEATURE_COLUMNS,+ ID_TO_CHAR,+ MAX_FRAMES,+ N_FEATURES,+ decode_logits,+ validate_frames,+)+++def one_hot(ids, vocab=63):+ out = np.full((len(ids), vocab), -10.0, dtype=np.float32)+ for row, i in enumerate(ids):+ out[row, i] = 10.0+ return out+++def ids_for(text):+ char_to_id = {c: i for i, c in ID_TO_CHAR.items()}+ return [char_to_id[c] for c in text]+++def test_schema_shape():+ assert N_FEATURES == 390+ assert len(FEATURE_COLUMNS) == 390+ assert FEATURE_COLUMNS[0].startswith("x_")+ # Hands are present in the selection — the whole point of the model.+ assert any("hand" in c for c in FEATURE_COLUMNS)+++def test_decode_plain_text():+ assert decode_logits(one_hot(ids_for("hello"))) == "hello"+++def test_decode_stops_at_special_after_output():+ ids = ids_for("hi") + [62, *ids_for("junk")]+ assert decode_logits(one_hot(ids)) == "hi"+++def test_decode_skips_leading_specials():+ ids = [60, *ids_for("ok")]+ assert decode_logits(one_hot(ids)) == "ok"+++def test_decode_rejects_bad_shape():+ with pytest.raises(ValueError):+ decode_logits(np.zeros(63))+++def test_validate_frames_happy_path():+ frames = [[0.1] * N_FEATURES for _ in range(10)]+ arr = validate_frames(frames)+ assert arr.shape == (10, N_FEATURES)+ assert arr.dtype == np.float32+++def test_validate_frames_null_becomes_nan():+ frames = [[None] * N_FEATURES for _ in range(10)]+ arr = validate_frames(frames)+ assert np.isnan(arr).all()+++def test_validate_frames_caps():+ with pytest.raises(ValueError):+ validate_frames([[0.0] * N_FEATURES] * (MAX_FRAMES + 1))+ with pytest.raises(ValueError):+ validate_frames([[0.0] * N_FEATURES] * 2)+ with pytest.raises(ValueError):+ validate_frames([[0.0] * 10 for _ in range(10)])+ with pytest.raises(ValueError):+ validate_frames([])