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 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376
| """ PULSE: Doppler Prompting for Stable mmWave HPE ================================================ 论文: arXiv:2605.13233, ICML 2026 代码: github.com/DandongExpress/Doppler-Prompting-for-Stable-mmWave-based-Human-Pose-Estimation
核心思想: 1. 从RAD张量中分离空间幅度和Doppler签名 2. 将Doppler通过置信度筛选模块去除非人体Doppler 3. 将筛选后的Doppler作为"运动提示"注入空间幅度推理 """
import torch import torch.nn as nn import torch.nn.functional as F from typing import Tuple
class PULSE(nn.Module): """ PULSE: Doppler Prompting框架 输入: RAD tensor (B, R, A, D) 输出: 3D human pose (B, J, 3) where J=num_joints 架构: 1. Spatial Encoder: 从|RAD|提取空间特征 2. Doppler Screener: 从angle(RAD)提取并筛选Doppler提示 3. Prompt Injector: 将筛选后的Doppler提示注入空间特征 4. Pose Decoder: 输出3D关节坐标 """ def __init__(self, config: dict = None): super().__init__() config = config or {} self.range_bins = config.get("range_bins", 64) self.angle_bins = config.get("angle_bins", 64) self.doppler_bins = config.get("doppler_bins", 16) self.num_joints = config.get("num_joints", 17) self.spatial_encoder = SpatialEncoder( range_bins=self.range_bins, angle_bins=self.angle_bins, doppler_bins=self.doppler_bins, embed_dim=256, ) self.doppler_screener = DopplerScreener( range_bins=self.range_bins, angle_bins=self.angle_bins, doppler_bins=self.doppler_bins, embed_dim=128, confidence_threshold=config.get("confidence_threshold", 0.5), ) self.prompt_injector = PromptInjector( spatial_dim=256, prompt_dim=128, num_heads=config.get("num_heads", 4), ) self.pose_decoder = PoseDecoder( embed_dim=256, num_joints=self.num_joints, hidden_dim=512, ) def forward(self, rad_tensor: torch.Tensor) -> Tuple[torch.Tensor, dict]: """ 前向传播 Args: rad_tensor: (B, R, A, D) Range-Angle-Doppler张量 Returns: poses: (B, J, 3) 3D关节坐标 aux: 辅助信息(Doppler置信度、筛选掩码等) """ B, R, A, D = rad_tensor.shape spatial_mag = torch.abs(rad_tensor) doppler_phase = torch.angle(rad_tensor) spatial_feat = self.spatial_encoder(spatial_mag) doppler_prompts, confidence = self.doppler_screener( doppler_phase, spatial_mag ) fused_feat = self.prompt_injector(spatial_feat, doppler_prompts, confidence) poses = self.pose_decoder(fused_feat) aux = { "doppler_confidence": confidence, "doppler_prompts": doppler_prompts, "spatial_features": spatial_feat, } return poses, aux
class SpatialEncoder(nn.Module): """从空间幅度|RAD|提取空间特征""" def __init__(self, range_bins, angle_bins, doppler_bins, embed_dim): super().__init__() self.doppler_conv = nn.Sequential( nn.Conv2d(1, 32, kernel_size=(3, 3), padding=1), nn.BatchNorm2d(32), nn.ReLU(), nn.Conv2d(32, 64, kernel_size=(3, 3), padding=1), nn.BatchNorm2d(64), nn.ReLU(), nn.AdaptiveAvgPool2d((1, embed_dim)), ) self.ra_encoder = nn.Sequential( nn.Linear(range_bins * 64, embed_dim), nn.LayerNorm(embed_dim), nn.ReLU(), nn.Linear(embed_dim, embed_dim), nn.LayerNorm(embed_dim), ) self.pos_embed = nn.Parameter( torch.randn(1, angle_bins, embed_dim) * 0.02 ) def forward(self, spatial_mag: torch.Tensor) -> torch.Tensor: """ Args: spatial_mag: (B, R, A, D) Returns: features: (B, A, embed_dim) """ B, R, A, D = spatial_mag.shape x = spatial_mag.permute(0, 3, 1, 2) x = x.reshape(B * D, 1, R, A) x = self.doppler_conv(x) x = x.reshape(B, D, 64, -1) x = x.mean(dim=1) x = x.permute(0, 2, 1) x = x.reshape(B, -1) x = self.ra_encoder(x) features = x.unsqueeze(1).expand(-1, A, -1) features = features + self.pos_embed return features
class DopplerScreener(nn.Module): """从Doppler签名中筛选人体运动提示""" def __init__(self, range_bins, angle_bins, doppler_bins, embed_dim, confidence_threshold=0.5): super().__init__() self.confidence_threshold = confidence_threshold self.doppler_encoder = nn.Sequential( nn.Linear(doppler_bins, 64), nn.ReLU(), nn.Linear(64, embed_dim), ) self.confidence_net = nn.Sequential( nn.Linear(embed_dim * 2, 64), nn.ReLU(), nn.Linear(64, 1), nn.Sigmoid(), ) self.prompt_generator = nn.Sequential( nn.Linear(embed_dim, embed_dim), nn.LayerNorm(embed_dim), nn.GELU(), nn.Linear(embed_dim, embed_dim), ) def forward(self, doppler_phase: torch.Tensor, spatial_mag: torch.Tensor) -> Tuple[torch.Tensor, torch.Tensor]: """ Args: doppler_phase: (B, R, A, D) - Doppler签名 spatial_mag: (B, R, A, D) - 空间幅度(用于辅助判断) Returns: prompts: (B, A, embed_dim) - 筛选后的Doppler提示 confidence: (B, A, 1) - 每个角度bin的Doppler置信度 """ B, R, A, D = doppler_phase.shape doppler_feat = doppler_phase.mean(dim=1) spatial_feat = spatial_mag.mean(dim=1) doppler_emb = self.doppler_encoder(doppler_feat) spatial_emb = self.doppler_encoder(spatial_feat) combined = torch.cat([doppler_emb, spatial_emb], dim=-1) confidence = self.confidence_net(combined) prompts = self.prompt_generator(doppler_emb) mask = (confidence > self.confidence_threshold).float() prompts = prompts * mask return prompts, confidence
class PromptInjector(nn.Module): """将Doppler提示注入空间特征""" def __init__(self, spatial_dim, prompt_dim, num_heads=4): super().__init__() self.num_heads = num_heads self.spatial_proj = nn.Linear(spatial_dim, spatial_dim) self.prompt_proj = nn.Linear(prompt_dim, spatial_dim) self.cross_attn = nn.MultiheadAttention( embed_dim=spatial_dim, num_heads=num_heads, batch_first=True, ) self.ffn = nn.Sequential( nn.Linear(spatial_dim, spatial_dim * 4), nn.GELU(), nn.Linear(spatial_dim * 4, spatial_dim), ) self.norm1 = nn.LayerNorm(spatial_dim) self.norm2 = nn.LayerNorm(spatial_dim) def forward(self, spatial_feat, prompts, confidence): """ Args: spatial_feat: (B, N, spatial_dim) prompts: (B, N, prompt_dim) confidence: (B, N, 1) Returns: fused: (B, N, spatial_dim) """ s = self.spatial_proj(spatial_feat) p = self.prompt_proj(prompts) * confidence attn_out, _ = self.cross_attn(p, s, s) x = self.norm1(s + attn_out) x = self.norm2(x + self.ffn(x)) return x
class PoseDecoder(nn.Module): """从融合特征解码3D关节坐标""" def __init__(self, embed_dim, num_joints, hidden_dim): super().__init__() self.num_joints = num_joints self.decoder = nn.Sequential( nn.Linear(embed_dim, hidden_dim), nn.LayerNorm(hidden_dim), nn.GELU(), nn.Linear(hidden_dim, hidden_dim), nn.LayerNorm(hidden_dim), nn.GELU(), nn.Linear(hidden_dim, num_joints * 3), ) self.joint_queries = nn.Parameter( torch.randn(1, num_joints, embed_dim) * 0.02 ) def forward(self, features: torch.Tensor) -> torch.Tensor: """ Args: features: (B, N, embed_dim) Returns: poses: (B, J, 3) """ B = features.shape[0] global_feat = features.mean(dim=1) queries = self.joint_queries.expand(B, -1, -1) global_feat = global_feat.unsqueeze(1) coords = self.decoder(global_feat.squeeze(1)) poses = coords.reshape(B, self.num_joints, 3) return poses
if __name__ == "__main__": config = { "range_bins": 64, "angle_bins": 64, "doppler_bins": 16, "num_joints": 17, "num_heads": 4, "confidence_threshold": 0.5, } model = PULSE(config) real_part = torch.randn(2, 64, 64, 16) imag_part = torch.randn(2, 64, 64, 16) rad_tensor = torch.complex(real_part, imag_part) poses, aux = model(rad_tensor) print("=== PULSE模型测试 ===") print(f"输入: RAD tensor shape = {rad_tensor.shape}") print(f"输出: poses shape = {poses.shape}") print(f" batch_size = {poses.shape[0]}") print(f" num_joints = {poses.shape[1]}") print(f" coords = {poses.shape[2]} (x, y, z)") print(f"\nDoppler置信度:") print(f" shape = {aux['doppler_confidence'].shape}") print(f" mean = {aux['doppler_confidence'].mean().item():.4f}") print(f" >0.5 ratio = {(aux['doppler_confidence'] > 0.5).float().mean().item():.2%}") total_params = sum(p.numel() for p in model.parameters()) trainable_params = sum(p.numel() for p in model.parameters() if p.requires_grad) print(f"\n模型参数:") print(f" 总参数: {total_params:,}") print(f" 可训练: {trainable_params:,}") print(f" 大小: {total_params * 4 / 1024 / 1024:.2f} MB")
|