9740bc64c9
Continuous Deployment / Deploy to Production (push) Blocked by required conditions
Continuous Deployment / Rollback Deployment (push) Blocked by required conditions
Continuous Deployment / Post-deployment Monitoring (push) Blocked by required conditions
Continuous Deployment / Notify Deployment Status (push) Blocked by required conditions
Firmware QEMU Tests (ADR-061) / QEMU Test (edge-tier1) (push) Has been skipped
Firmware QEMU Tests (ADR-061) / QEMU Test (full-adr060) (push) Has been skipped
Firmware QEMU Tests (ADR-061) / QEMU Test (tdm-3node) (push) Has been skipped
Firmware QEMU Tests (ADR-061) / Swarm Test (ADR-062) (push) Has been skipped
npm packages / tools/ruview-mcp (node 22) (push) Failing after 1s
nvsim-server → ghcr.io / build-and-publish (push) Failing after 1s
ruview-swarm CI guard / tests (full+train) (push) Failing after 2s
Bench Regression Guard / bench compile-verify (--no-run) (push) Failing after 0s
Bench Regression Guard / bench fast-run (informational, non-gating) (push) Has been skipped
Firmware CI / Verify version.txt matches release tag (push) Has been skipped
Dashboard a11y + cross-browser / a11y (push) Failing after 0s
nvsim Dashboard → GitHub Pages / build-and-deploy (push) Failing after 2s
Firmware CI / Build firmware (esp32s3 / 4mb) (push) Failing after 15s
Firmware QEMU Tests (ADR-061) / Build Espressif QEMU (push) Failing after 1s
Firmware QEMU Tests (ADR-061) / Fuzz Testing (ADR-061 Layer 6) (push) Failing after 1s
Continuous Deployment / Pre-deployment Checks (push) Has been skipped
Continuous Deployment / Deploy to Staging (push) Waiting to run
Firmware CI / Build firmware (esp32c6 / c6-4mb) (push) Failing after 15s
Firmware CI / Build firmware (esp32s3 / 8mb) (push) Failing after 15s
Firmware QEMU Tests (ADR-061) / QEMU Test (boundary-max) (push) Has been skipped
Firmware QEMU Tests (ADR-061) / QEMU Test (boundary-min) (push) Has been skipped
Firmware QEMU Tests (ADR-061) / QEMU Test (default) (push) Has been skipped
Firmware QEMU Tests (ADR-061) / QEMU Test (edge-tier0) (push) Has been skipped
Firmware QEMU Tests (ADR-061) / NVS Matrix Generation (push) Failing after 1s
Security Scanning / Security Policy Compliance (push) Failing after 0s
Security Scanning / Security Report (push) Waiting to run
Security Scanning / Dependency Vulnerability Scan (push) Failing after 0s
Security Scanning / Static Application Security Testing (push) Failing after 1s
Security Scanning / Infrastructure Security Scan (push) Failing after 1s
Security Scanning / Secret Scanning (push) Failing after 1s
npm packages / harness/ruview (node 22) (push) Failing after 17s
Security Scanning / License Compliance Scan (push) Failing after 1s
Security Scanning / Container Security Scan (push) Failing after 4s
three.js demos → GitHub Pages / build-and-deploy (push) Failing after 1s
Verify Pipeline Determinism / Verify Pipeline Determinism (3.11) (push) Failing after 1s
Fix-Marker Regression Guard / Verify fix markers (push) Failing after 1s
ADR-115 MQTT integration tests / mqtt-integration (push) Failing after 1s
npm packages / harness/ruview (node 20) (push) Failing after 1s
npm packages / tools/ruview-mcp (node 20) (push) Failing after 1s
npm packages / tools/ruview-cli (node 20) (push) Failing after 1s
npm packages / tools/ruview-cli (node 22) (push) Failing after 1s
BFLD MQTT Integration / cargo test --features mqtt (live mosquitto) (push) Failing after 29s
ruview-swarm CI guard / build train_marl bin (push) Failing after 2s
ruview-swarm CI guard / clippy (-D warnings, --no-deps) (push) Failing after 3s
ruview-swarm CI guard / tests (ruflo) (push) Failing after 1s
ruview-swarm CI guard / tests (train) (push) Failing after 2s
ruview-swarm CI guard / tests (default) (push) Failing after 2s
Point Cloud Viewer → GitHub Pages / build-and-deploy (push) Failing after 8s
ruview-swarm CI guard / ITAR / publish guard (push) Failing after 0s
wifi-densepose sensing-server → Docker Hub + ghcr.io / build · push · smoke-test (push) Failing after 1s
311 lines
11 KiB
Python
311 lines
11 KiB
Python
# Transfer Learning System for WiFi DensePose
|
|
# Based on the teacher-student learning approach from the paper
|
|
|
|
import numpy as np
|
|
from typing import Dict, List, Tuple, Optional
|
|
|
|
class TransferLearningSystem:
|
|
"""
|
|
Implements transfer learning from image-based DensePose to WiFi-based DensePose
|
|
"""
|
|
|
|
def __init__(self, lambda_tr=0.1):
|
|
self.lambda_tr = lambda_tr # Transfer learning loss weight
|
|
self.teacher_features = {}
|
|
self.student_features = {}
|
|
|
|
print(f"Initialized Transfer Learning System:")
|
|
print(f" Transfer learning weight (λ_tr): {lambda_tr}")
|
|
|
|
def extract_teacher_features(self, image_input):
|
|
"""
|
|
Extract multi-level features from image-based teacher network
|
|
"""
|
|
# Simulate teacher network (image-based DensePose) feature extraction
|
|
features = {}
|
|
|
|
# Simulate ResNet features at different levels
|
|
features['P2'] = np.random.rand(1, 256, 180, 320) # 1/4 scale
|
|
features['P3'] = np.random.rand(1, 256, 90, 160) # 1/8 scale
|
|
features['P4'] = np.random.rand(1, 256, 45, 80) # 1/16 scale
|
|
features['P5'] = np.random.rand(1, 256, 23, 40) # 1/32 scale
|
|
|
|
self.teacher_features = features
|
|
return features
|
|
|
|
def extract_student_features(self, wifi_features):
|
|
"""
|
|
Extract corresponding features from WiFi-based student network
|
|
"""
|
|
# Simulate student network feature extraction from WiFi features
|
|
features = {}
|
|
|
|
# Process the WiFi features to match teacher feature dimensions
|
|
# In practice, these would come from the modality translation network
|
|
features['P2'] = np.random.rand(1, 256, 180, 320)
|
|
features['P3'] = np.random.rand(1, 256, 90, 160)
|
|
features['P4'] = np.random.rand(1, 256, 45, 80)
|
|
features['P5'] = np.random.rand(1, 256, 23, 40)
|
|
|
|
self.student_features = features
|
|
return features
|
|
|
|
def compute_mse_loss(self, teacher_feature, student_feature):
|
|
"""
|
|
Compute Mean Squared Error between teacher and student features
|
|
"""
|
|
return np.mean((teacher_feature - student_feature) ** 2)
|
|
|
|
def compute_transfer_loss(self):
|
|
"""
|
|
Compute transfer learning loss as sum of MSE at different levels
|
|
L_tr = MSE(P2, P2*) + MSE(P3, P3*) + MSE(P4, P4*) + MSE(P5, P5*)
|
|
"""
|
|
if not self.teacher_features or not self.student_features:
|
|
raise ValueError("Both teacher and student features must be extracted first")
|
|
|
|
total_loss = 0.0
|
|
feature_losses = {}
|
|
|
|
for level in ['P2', 'P3', 'P4', 'P5']:
|
|
teacher_feat = self.teacher_features[level]
|
|
student_feat = self.student_features[level]
|
|
|
|
level_loss = self.compute_mse_loss(teacher_feat, student_feat)
|
|
feature_losses[level] = level_loss
|
|
total_loss += level_loss
|
|
|
|
return total_loss, feature_losses
|
|
|
|
def adapt_features(self, student_features, learning_rate=0.001):
|
|
"""
|
|
Adapt student features to be more similar to teacher features
|
|
"""
|
|
adapted_features = {}
|
|
|
|
for level in ['P2', 'P3', 'P4', 'P5']:
|
|
teacher_feat = self.teacher_features[level]
|
|
student_feat = student_features[level]
|
|
|
|
# Compute gradient (simplified as difference)
|
|
gradient = teacher_feat - student_feat
|
|
|
|
# Update student features
|
|
adapted_features[level] = student_feat + learning_rate * gradient
|
|
|
|
return adapted_features
|
|
|
|
class TrainingPipeline:
|
|
"""
|
|
Complete training pipeline with transfer learning
|
|
"""
|
|
|
|
def __init__(self):
|
|
self.transfer_system = TransferLearningSystem()
|
|
self.losses = {
|
|
'classification': [],
|
|
'bbox_regression': [],
|
|
'densepose': [],
|
|
'keypoint': [],
|
|
'transfer': []
|
|
}
|
|
|
|
print("Initialized Training Pipeline with transfer learning")
|
|
|
|
def compute_classification_loss(self, predictions, targets):
|
|
"""
|
|
Compute classification loss (cross-entropy for person detection)
|
|
"""
|
|
# Simplified cross-entropy loss simulation
|
|
return np.random.uniform(0.1, 2.0)
|
|
|
|
def compute_bbox_regression_loss(self, pred_boxes, target_boxes):
|
|
"""
|
|
Compute bounding box regression loss (smooth L1)
|
|
"""
|
|
# Simplified smooth L1 loss simulation
|
|
return np.random.uniform(0.05, 1.0)
|
|
|
|
def compute_densepose_loss(self, pred_parts, pred_uv, target_parts, target_uv):
|
|
"""
|
|
Compute DensePose loss (part classification + UV regression)
|
|
"""
|
|
# Part classification loss
|
|
part_loss = np.random.uniform(0.2, 1.5)
|
|
|
|
# UV coordinate regression loss
|
|
uv_loss = np.random.uniform(0.1, 1.0)
|
|
|
|
return part_loss + uv_loss
|
|
|
|
def compute_keypoint_loss(self, pred_keypoints, target_keypoints):
|
|
"""
|
|
Compute keypoint detection loss
|
|
"""
|
|
return np.random.uniform(0.1, 0.8)
|
|
|
|
def train_step(self, wifi_data, image_data, targets):
|
|
"""
|
|
Perform one training step with synchronized WiFi and image data
|
|
"""
|
|
# Extract teacher features from image
|
|
teacher_features = self.transfer_system.extract_teacher_features(image_data)
|
|
|
|
# Process WiFi data through student network (simulated)
|
|
student_features = self.transfer_system.extract_student_features(wifi_data)
|
|
|
|
# Compute individual losses
|
|
cls_loss = self.compute_classification_loss(None, targets)
|
|
box_loss = self.compute_bbox_regression_loss(None, targets)
|
|
dp_loss = self.compute_densepose_loss(None, None, targets, targets)
|
|
kp_loss = self.compute_keypoint_loss(None, targets)
|
|
|
|
# Compute transfer learning loss
|
|
tr_loss, feature_losses = self.transfer_system.compute_transfer_loss()
|
|
|
|
# Total loss with weights
|
|
total_loss = (cls_loss + box_loss +
|
|
0.6 * dp_loss + # λ_dp = 0.6
|
|
0.3 * kp_loss + # λ_kp = 0.3
|
|
0.1 * tr_loss) # λ_tr = 0.1
|
|
|
|
# Store losses
|
|
self.losses['classification'].append(cls_loss)
|
|
self.losses['bbox_regression'].append(box_loss)
|
|
self.losses['densepose'].append(dp_loss)
|
|
self.losses['keypoint'].append(kp_loss)
|
|
self.losses['transfer'].append(tr_loss)
|
|
|
|
return {
|
|
'total_loss': total_loss,
|
|
'cls_loss': cls_loss,
|
|
'box_loss': box_loss,
|
|
'dp_loss': dp_loss,
|
|
'kp_loss': kp_loss,
|
|
'tr_loss': tr_loss,
|
|
'feature_losses': feature_losses
|
|
}
|
|
|
|
def train_epochs(self, num_epochs=10):
|
|
"""
|
|
Simulate training for multiple epochs
|
|
"""
|
|
print(f"\nTraining WiFi DensePose with transfer learning...")
|
|
print(f"Target epochs: {num_epochs}")
|
|
|
|
for epoch in range(num_epochs):
|
|
# Simulate training data
|
|
wifi_data = np.random.rand(3, 720, 1280)
|
|
image_data = np.random.rand(3, 720, 1280)
|
|
targets = {"dummy": "target"}
|
|
|
|
# Training step
|
|
losses = self.train_step(wifi_data, image_data, targets)
|
|
|
|
if epoch % 2 == 0 or epoch == num_epochs - 1:
|
|
print(f"Epoch {epoch+1}/{num_epochs}:")
|
|
print(f" Total Loss: {losses['total_loss']:.4f}")
|
|
print(f" Classification: {losses['cls_loss']:.4f}")
|
|
print(f" BBox Regression: {losses['box_loss']:.4f}")
|
|
print(f" DensePose: {losses['dp_loss']:.4f}")
|
|
print(f" Keypoint: {losses['kp_loss']:.4f}")
|
|
print(f" Transfer: {losses['tr_loss']:.4f}")
|
|
print(f" Feature losses: P2={losses['feature_losses']['P2']:.4f}, "
|
|
f"P3={losses['feature_losses']['P3']:.4f}, "
|
|
f"P4={losses['feature_losses']['P4']:.4f}, "
|
|
f"P5={losses['feature_losses']['P5']:.4f}")
|
|
|
|
return self.losses
|
|
|
|
class PerformanceEvaluator:
|
|
"""
|
|
Evaluates the performance of the WiFi DensePose system
|
|
"""
|
|
|
|
def __init__(self):
|
|
print("Initialized Performance Evaluator")
|
|
|
|
def compute_gps(self, pred_vertices, target_vertices, kappa=0.255):
|
|
"""
|
|
Compute Geodesic Point Similarity (GPS)
|
|
"""
|
|
# Simplified GPS computation
|
|
distances = np.random.uniform(0, 0.5, len(pred_vertices))
|
|
gps_scores = np.exp(-distances**2 / (2 * kappa**2))
|
|
return np.mean(gps_scores)
|
|
|
|
def compute_gpsm(self, gps_score, pred_mask, target_mask):
|
|
"""
|
|
Compute masked Geodesic Point Similarity (GPSm)
|
|
"""
|
|
# Compute IoU of masks
|
|
intersection = np.sum(pred_mask & target_mask)
|
|
union = np.sum(pred_mask | target_mask)
|
|
iou = intersection / union if union > 0 else 0
|
|
|
|
# GPSm = sqrt(GPS * IoU)
|
|
return np.sqrt(gps_score * iou)
|
|
|
|
def evaluate_system(self, predictions, ground_truth):
|
|
"""
|
|
Evaluate the complete system performance
|
|
"""
|
|
# Simulate evaluation metrics
|
|
ap_metrics = {
|
|
'AP': np.random.uniform(25, 45),
|
|
'AP@50': np.random.uniform(50, 90),
|
|
'AP@75': np.random.uniform(20, 50),
|
|
'AP-m': np.random.uniform(20, 40),
|
|
'AP-l': np.random.uniform(25, 50)
|
|
}
|
|
|
|
densepose_metrics = {
|
|
'dpAP_GPS': np.random.uniform(20, 50),
|
|
'dpAP_GPS@50': np.random.uniform(45, 80),
|
|
'dpAP_GPS@75': np.random.uniform(20, 50),
|
|
'dpAP_GPSm': np.random.uniform(20, 45),
|
|
'dpAP_GPSm@50': np.random.uniform(40, 75),
|
|
'dpAP_GPSm@75': np.random.uniform(20, 50)
|
|
}
|
|
|
|
return {
|
|
'bbox_detection': ap_metrics,
|
|
'densepose': densepose_metrics
|
|
}
|
|
|
|
# Demonstrate the transfer learning system
|
|
print("="*60)
|
|
print("TRANSFER LEARNING DEMONSTRATION")
|
|
print("="*60)
|
|
|
|
# Initialize training pipeline
|
|
trainer = TrainingPipeline()
|
|
|
|
# Run training simulation
|
|
training_losses = trainer.train_epochs(num_epochs=10)
|
|
|
|
# Evaluate performance
|
|
evaluator = PerformanceEvaluator()
|
|
dummy_predictions = {"dummy": "pred"}
|
|
dummy_ground_truth = {"dummy": "gt"}
|
|
|
|
performance = evaluator.evaluate_system(dummy_predictions, dummy_ground_truth)
|
|
|
|
print(f"\nFinal Performance Metrics:")
|
|
print(f"Bounding Box Detection:")
|
|
for metric, value in performance['bbox_detection'].items():
|
|
print(f" {metric}: {value:.1f}")
|
|
|
|
print(f"\nDensePose Estimation:")
|
|
for metric, value in performance['densepose'].items():
|
|
print(f" {metric}: {value:.1f}")
|
|
|
|
print(f"\nTransfer Learning Benefits:")
|
|
print(f"✓ Reduces training time from ~80 hours to ~58 hours")
|
|
print(f"✓ Improves convergence stability")
|
|
print(f"✓ Leverages rich supervision from image-based models")
|
|
print(f"✓ Better feature alignment between domains")
|
|
|
|
print("\nTransfer learning demonstration completed!")
|
|
print("This approach enables effective knowledge transfer from image-based")
|
|
print("DensePose models to WiFi-based models, improving training efficiency.") |