mirror of
https://github.com/ruvnet/RuView
synced 2026-08-09 20:21:43 +00:00
fix: WebSocket race condition, data source indicators, auto-start pose detection (#96)
* feat: RVF training pipeline & UI integration (ADR-036) Implement full model training, management, and inference pipeline: Backend (Rust): - recording.rs: CSI recording API (start/stop/list/download/delete) - model_manager.rs: RVF model loading, LoRA profile switching, model library - training_api.rs: Training API with WebSocket progress streaming, simulated training mode with realistic loss curves, auto-RVF export on completion - main.rs: Wire new modules, recording hooks in all CSI paths, data dirs UI (new components): - ModelPanel.js: Dark-mode model library with load/unload, LoRA dropdown - TrainingPanel.js: Recording controls, training config, live Canvas charts - model.service.js: Model REST API client with events - training.service.js: Training + recording API client with WebSocket progress UI (enhancements): - LiveDemoTab: Model selector, LoRA profile switcher, A/B split view toggle, training quick-panel with 60s recording shortcut - SettingsPanel: Full dark mode conversion (issue #92), model configuration (device, threads, auto-load), training configuration (epochs, LR, patience) - PoseDetectionCanvas: 10-frame pose trail with ghost keypoints and motion trajectory lines, cyan trail toggle button - pose.service.js: Model-inference confidence thresholds UI (plumbing): - index.html: Training tab (8th tab) - app.js: Panel initialization and tab routing - style.css: ~250 lines of training/model panel dark-mode styles 191 Rust tests pass, 0 failures. Closes #92. Refs: ADR-036, #93 Co-Authored-By: claude-flow <ruv@ruv.net> * fix: real RuVector training pipeline + UI service fixes Training pipeline (training_api.rs): - Replace simulated training with real signal-based training loop - Load actual CSI data from .csi.jsonl recordings or live frame history - Extract 180 features per frame: subcarrier amplitudes, temporal variance, Goertzel frequency analysis (9 bands), motion gradients, global stats - Train calibrated linear CSI-to-pose mapping via mini-batch gradient descent with L2 regularization (ridge regression), Xavier init, cosine LR decay - Self-supervised: teacher targets from derive_pose_from_sensing() heuristics - Real validation metrics: MSE and PCK@0.2 on 80/20 train/val split - Export trained .rvf with real weights, feature normalization stats, witness - Add infer_pose_from_model() for live inference from trained model - 16 new tests covering features, training, inference, serialization UI fixes: - Fix double-URL bug in model.service.js and training.service.js (buildApiUrl was called twice — once in service, once in apiService) - Fix route paths to match Rust backend (/api/v1/train/*, /api/v1/recording/*) - Fix request body formats (session_name, nested config object) - Fix top-level await in LiveDemoTab.js blocking module graph - Dynamic imports for ModelPanel/TrainingPanel in app.js - Center nav tabs with flex-wrap for 8-tab layout Co-Authored-By: claude-flow <ruv@ruv.net> * fix: WebSocket onOpen race condition, data source indicators, auto-start pose detection - Fix WebSocket onOpen race condition in websocket.service.js where setupEventHandlers replaced onopen after socket was already open, preventing pose service from receiving connection signal - Add 4-state data source indicator (LIVE/SIMULATED/RECONNECTING/OFFLINE) across Dashboard, Sensing, and Live Demo tabs via sensing.service.js - Add hot-plug ESP32 auto-detection in sensing server (auto mode runs both UDP listener and simulation, switches on ESP32_TIMEOUT) - Auto-start pose detection when backend is reachable - Hide duplicate PoseDetectionCanvas controls when enableControls=false - Add standalone Demo button in LiveDemoTab for offline animated demo - Add data source banner and status styling Co-Authored-By: claude-flow <ruv@ruv.net>
This commit is contained in:
@@ -21,13 +21,17 @@ export class PoseService {
|
||||
};
|
||||
this.validationErrors = [];
|
||||
this.logger = this.createLogger();
|
||||
|
||||
|
||||
// Model inference mode tracking
|
||||
this.modelActive = false;
|
||||
|
||||
// Configuration
|
||||
this.config = {
|
||||
enableValidation: true,
|
||||
enablePerformanceTracking: true,
|
||||
maxValidationErrors: 10,
|
||||
confidenceThreshold: 0.3,
|
||||
confidenceThresholdModelInference: 0.15,
|
||||
maxPersons: 10,
|
||||
timeoutMs: 5000
|
||||
};
|
||||
@@ -127,9 +131,14 @@ export class PoseService {
|
||||
throw new Error(`Invalid stream options: ${validationResult.errors.join(', ')}`);
|
||||
}
|
||||
|
||||
// Use a lower confidence threshold when model inference is active
|
||||
const defaultThreshold = this.modelActive
|
||||
? this.config.confidenceThresholdModelInference
|
||||
: this.config.confidenceThreshold;
|
||||
|
||||
const params = {
|
||||
zone_ids: options.zoneIds?.join(','),
|
||||
min_confidence: options.minConfidence || this.config.confidenceThreshold,
|
||||
min_confidence: options.minConfidence || defaultThreshold,
|
||||
max_fps: options.maxFps || 30,
|
||||
token: options.token || apiService.authToken
|
||||
};
|
||||
@@ -494,9 +503,18 @@ export class PoseService {
|
||||
};
|
||||
}
|
||||
|
||||
// Extract persons from zone data
|
||||
const persons = zoneData.pose.persons || [];
|
||||
console.log('👥 Extracted persons:', persons);
|
||||
// Determine the pose source for this message
|
||||
const poseSource = originalMessage.pose_source || zoneData.pose_source || null;
|
||||
|
||||
// Choose confidence threshold based on pose source
|
||||
const threshold = (poseSource === 'model_inference' || this.modelActive)
|
||||
? this.config.confidenceThresholdModelInference
|
||||
: this.config.confidenceThreshold;
|
||||
|
||||
// Extract persons from zone data, applying source-aware filtering
|
||||
const rawPersons = zoneData.pose.persons || [];
|
||||
const persons = rawPersons.filter(p => p.confidence === undefined || p.confidence >= threshold);
|
||||
console.log('Extracted persons:', persons.length, '/', rawPersons.length, '(threshold:', threshold, ')');
|
||||
|
||||
// Create zone summary
|
||||
const zoneSummary = {};
|
||||
@@ -511,7 +529,7 @@ export class PoseService {
|
||||
persons: persons,
|
||||
zone_summary: zoneSummary,
|
||||
processing_time_ms: zoneData.metadata?.processing_time_ms || 0,
|
||||
pose_source: originalMessage.pose_source || zoneData.pose_source || null,
|
||||
pose_source: poseSource,
|
||||
metadata: {
|
||||
mock_data: false,
|
||||
source: 'websocket',
|
||||
@@ -653,6 +671,14 @@ export class PoseService {
|
||||
this.logger.info('Configuration updated', { config: this.config });
|
||||
}
|
||||
|
||||
// Enable or disable model inference mode.
|
||||
// When active, confidence thresholds are lowered because model inference
|
||||
// produces more reliable detections than raw signal-derived heuristics.
|
||||
setModelMode(active) {
|
||||
this.modelActive = !!active;
|
||||
this.logger.info('Model mode updated', { modelActive: this.modelActive });
|
||||
}
|
||||
|
||||
// Health check
|
||||
async healthCheck() {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user