docs/adr/ADR-036-rvf-training-pipeline-ui.md
Proposed
2026-03-02
The wifi-densepose system currently operates in signal-derived mode — derive_pose_from_sensing() maps aggregate CSI features (motion power, breathing rate, variance) to keypoint positions using deterministic math. This gives whole-body presence and gross motion but cannot track individual limbs.
The infrastructure for model inference mode exists but is disconnected:
RVF container format (rvf_container.rs, 1,102 lines) — a 64-byte-aligned binary format supporting model weights (SEG_VEC), metadata (SEG_MANIFEST), quantization (SEG_QUANT), LoRA profiles (SEG_LORA), contrastive embeddings (SEG_EMBED), and witness audit trails (SEG_WITNESS). Builder and reader are fully implemented with CRC32 integrity checks.
Training crate (wifi-densepose-train) — AdamW optimizer, [email protected]/OKS metrics, LR scheduling with warmup, early stopping, CSV logging, and checkpoint export. Supports CsiDataset trait with planned MM-Fi (114→56 subcarrier interpolation) and Wi-Pose (30→56 zero-pad) loaders per ADR-015.
NN inference crate (wifi-densepose-nn) — ONNX Runtime backend with CPU/GPU support, dynamic tensor shapes, thread-safe OnnxBackend wrapper, model info inspection, and warmup.
Sensing server CLI (--model <path>, --train, --pretrain, --embed) — flags exist for model loading, training mode, and embedding extraction, but the end-to-end path from raw CSI → trained .rvf → live inference is not wired together.
UI gaps — No model management, training progress visualization, LoRA profile switching, or embedding inspection. The Settings panel lacks model configuration. The Live Demo has no way to load a trained model or compare signal-derived vs model-inference output side-by-side.
Add REST endpoints to the sensing server:
POST /api/v1/recording/start { duration_secs, label?, session_name }
POST /api/v1/recording/stop
GET /api/v1/recording/list
GET /api/v1/recording/download/:id
DELETE /api/v1/recording/:id
.csi.jsonl files..rvf container with SEG_EMBED + SEG_VEC segments.POST /api/v1/train/pretrain { dataset_ids[], epochs, lr }.ruvector-solver sparse least-squares..csi.jsonl from Phase 1 recording + camera-generated labels.CsiDataset trait and produce (amplitude[B,T*links,56], phase[B,T*links,56], keypoints[B,17,2], visibility[B,17]).POST /api/v1/train/start {
dataset_ids: string[],
config: {
epochs: 100,
batch_size: 32,
learning_rate: 3e-4,
weight_decay: 1e-4,
early_stopping_patience: 15,
warmup_epochs: 5,
pretrained_rvf?: string, // Base model for fine-tuning
lora_profile?: string, // Environment-specific LoRA
}
}
POST /api/v1/train/stop
GET /api/v1/train/status // { epoch, train_loss, val_pck, val_oks, lr, eta_secs }
WS /ws/train/progress // Real-time streaming of training metrics
On training completion:
.rvf with SEG_VEC (weights), SEG_MANIFEST (metadata), SEG_WITNESS (training hash + final metrics), and optional SEG_QUANT (INT8 quantization).data/models/ directory, indexed by model ID.GET /api/v1/models lists available models; POST /api/v1/models/load { model_id } hot-loads into inference..rvf model, fine-tune only LoRA adapter weights (rank 4-16) on environment-specific recordings..rvf via SEG_LORA segment.POST /api/v1/train/lora { base_model_id, dataset_ids[], profile_name, rank: 8, epochs: 20 }.POST /api/v1/models/lora/activate { model_id, profile_name } — hot-swap LoRA weights without reloading base model.ui/components/ModelPanel.js).rvf models with metadata (version, dataset, PCK score, size, created date).ui/components/TrainingPanel.js).rvf from browser..rvf models.All new panels follow the dark mode established in ADR-035 (#0d1117 backgrounds, #e0e0e0 text, translucent dark panels with colored accents).
When a .rvf model is loaded:
input[1, T*links, 56] → output[1, 17, 4] (x, y, z, conf).pose_tracker.rs.pose_source: "model_inference"..rvf model downloadable from releases (trained on MM-Fi + Wi-Pose).SEG_QUANT) reduces model size 4x and speeds inference ~2x on CPU.| Phase | Effort | Dependencies | Priority |
|---|---|---|---|
| 1.1 CSI Recording API | 2-3 days | sensing server | High |
| 1.2 Contrastive Pretraining | 3-5 days | ADR-024, recording API | High |
| 2.1 Dataset Integration | 3-5 days | ADR-015, CsiDataset trait | High |
| 2.2 Training API | 2-3 days | training crate, dataset loaders | High |
| 2.3 RVF Export | 1-2 days | RvfBuilder | Medium |
| 3.1 LoRA Fine-Tuning | 3-5 days | base trained model | Medium |
| 3.2 Profile Switching | 1 day | LoRA in RVF | Medium |
| 4.1 Model Panel UI | 2-3 days | models API | High |
| 4.2 Training Dashboard UI | 3-4 days | training API + WS | High |
| 4.3 Live Demo Enhancements | 2-3 days | model loading | Medium |
| 4.4 Settings Extensions | 1 day | model/training APIs | Low |
| 4.5 Dark Mode | 0.5 days | new panels | Low |
| 5.1 Inference Wiring | 3-5 days | ONNX backend, pose tracker | High |
| 5.2 Progressive Loading | 2-3 days | ADR-031 | Medium |
Total estimate: 4-6 weeks (phases can overlap; 1+2 parallel with 4).
ui/components/ModelPanel.js — Model library, inspector, load/unload controlsui/components/TrainingPanel.js — Recording controls, training progress, metric chartsrust-port/.../sensing-server/src/recording.rs — CSI recording API handlersrust-port/.../sensing-server/src/training_api.rs — Training API handlers + WS progress streamrust-port/.../sensing-server/src/model_manager.rs — Model loading, hot-swap, 32LoRA activationdata/models/ — Default model storage directoryrust-port/.../sensing-server/src/main.rs — Wire recording, training, and model APIsrust-port/.../train/src/trainer.rs — Add WebSocket progress callback, LoRA training moderust-port/.../train/src/dataset.rs — MM-Fi and Wi-Pose dataset loadersrust-port/.../nn/src/onnx.rs — LoRA weight injection, INT8 quantization supportui/components/LiveDemoTab.js — Model selector, LoRA dropdown, A/B spsplit viewui/components/SettingsPanel.js — Model and training configuration sectionsui/components/PoseDetectionCanvas.js — Pose trail rendering, confidence heatmap overlayui/services/pose.service.js — Model-inference keypoint processingui/index.html — Add Training tabheeui/style.css — Styles for new panelscrates/wifi-densepose-sensing-server/src/rvf_container.rscrates/wifi-densepose-train/src/trainer.rscrates/wifi-densepose-nn/src/onnx.rs