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
| import torch import torch.nn as nn
class MaritimeFatigueMonitor(nn.Module): """ 海事驾驶台疲劳监测器 架构:PERCLOS + 头部姿态 + 行为 (海事场景无方向盘/油门行为数据) 硬件配置: | 组件 | 型号 | 参数 | 安装位置 | |------|------|------|----------| | AI摄像头 | FMS Tech / 通用IR | 1080p, 30fps, IP67 | 驾驶台上方 | | BNWAS | 已有 | IMO强制 | 驾驶台 | | 处理器 | 船载服务器 | ARM/x86 | 电子设备舱 | | 报警 | 声光报警器 | 110dB | 驾驶台+船长舱 | """ def __init__(self): super().__init__() self.perclos_branch = nn.Sequential( nn.Linear(4, 32), nn.ReLU(), nn.Linear(32, 16) ) self.head_branch = nn.Sequential( nn.Linear(6, 32), nn.ReLU(), nn.Linear(32, 16) ) self.time_branch = nn.Sequential( nn.Linear(4, 16), nn.ReLU(), nn.Linear(16, 16) ) self.fusion = nn.Sequential( nn.Linear(48, 128), nn.ReLU(), nn.Dropout(0.3), nn.Linear(128, 3) ) def forward(self, perclos, head, time_features): p = self.perclos_branch(perclos) h = self.head_branch(head) t = self.time_branch(time_features) fused = torch.cat([p, h, t], dim=-1) return self.fusion(fused) def get_alert_level(self, logits): """BNWAS 兼容的阶梯报警""" probs = torch.softmax(logits, dim=-1) if probs[..., 2] > 0.7: return "LEVEL_3", "呼叫船长,自动减速" elif probs[..., 1] > 0.5: return "LEVEL_2", "驾驶台声光报警,通知副驾驶员" elif probs[..., 1] > 0.3: return "LEVEL_1", "驾驶台声音报警" else: return "NORMAL", "正常值班"
|