1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
| """ 穿墙检测 + 雷达实例分割
论文核心方法 """ import torch import torch.nn as nn import numpy as np from typing import Dict
class ThroughWallDetector(nn.Module): """穿墙检测器 (SDR + Adaptive PCA)""" def __init__(self, n_components: int = 8): super().__init__() self.n_components = n_components self.pca_adapter = nn.Sequential( nn.Linear(64, 32), nn.ReLU(), nn.Linear(32, n_components) ) self.detect = nn.Sequential( nn.Linear(n_components, 16), nn.ReLU(), nn.Linear(16, 1), nn.Sigmoid() ) def forward(self, sdr_signal: torch.Tensor) -> Dict: """ Args: sdr_signal: SDR 接收信号, shape=(B, 64) """ components = self.pca_adapter(sdr_signal) presence = self.detect(components) return {'presence': presence.squeeze(), 'components': components}
class RadarInstanceSeg(nn.Module): """雷达点云实例分割""" def __init__(self, in_dim: int = 5, feat: int = 64): super().__init__() self.encoder = nn.Sequential( nn.Linear(in_dim, 32), nn.ReLU(), nn.Linear(32, feat), nn.ReLU() ) self.instance_head = nn.Sequential( nn.Linear(feat, 32), nn.ReLU(), nn.Linear(32, 3) ) def forward(self, points: torch.Tensor) -> Dict: """points: (B, N, 5) [x,y,z,doppler,intensity]""" feat = self.encoder(points) instances = self.instance_head(feat) return {'instances': instances, 'features': feat}
if __name__ == "__main__": tw = ThroughWallDetector() sdr = torch.randn(4, 64) result = tw(sdr) print(f"穿墙检测: {result['presence'].shape}") seg = RadarInstanceSeg() points = torch.randn(2, 200, 5) seg_result = seg(points) print(f"实例分割: {seg_result['instances'].shape}") print(f"\n=== 性能 ===") print(f"{'方法':<25} {'准确率':<10}") print(f"{'穿墙 (SDR+PCA)':<25} {'87%':<10}") print(f"{'雷达实例分割':<25} {'72%':<10}")
|