FastKAN-DDD:35KB模型99.94%准确率——TinyML极限部署的驾驶员疲劳检测

论文信息

项目 内容
标题 FastKAN-DDD: A novel fast Kolmogorov-Arnold network-based approach for driver drowsiness detection optimized for TinyML deployment
作者 Siham Essahraui, Ismail Lamaakal, Yassine Maleh, Khalid El Makkaoui, Mouncef Filali Bouami, Ibrahim Ouahbi, Hela Elmannai, Ahmed A. Abd El-Latif
期刊 PLOS ONE, 20(11): e0332577
发表 2025年11月5日
DOI 10.1371/journal.pone.0332577
代码 https://github.com/sihamess/driver_drowsiness_detection_TinyML
数据集 UTA-RLDD (Real-Life Drowsiness Dataset)

核心突破

指标 FastKAN-DDD 传统CNN YOLOv8n MobileNetV2
准确率 99.94% 95-98% 96% 94%
模型大小 35 KB 5-50 MB 6.2 MB 14 MB
推理延迟 0.04 ms 10-50 ms 8 ms 15 ms
量化 INT8 FP32 FP16 FP32
部署平台 微控制器(MCU) GPU GPU/嵌入式 嵌入式

这是目前已知的最小DMS模型——35KB可在STM32等微控制器上运行。


方法详解

1. Kolmogorov-Arnold网络(KAN)原理

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
import torch
import torch.nn as nn
import numpy as np

class FastKANLayer(nn.Module):
"""
Fast KAN层:用径向基函数(RBF)替代传统权重矩阵

核心思想(Kolmogorov-Arnold表示定理):
任意多变量连续函数可表示为单变量函数的有限组合

优势:
- 用可学习的非线性激活替代固定激活+权重
- 参数量极小(RBF只需中心和宽度参数)
- 天然可解释
"""

def __init__(self, in_features, out_features, num_centers=5):
super().__init__()
self.in_features = in_features
self.out_features = out_features
self.num_centers = num_centers

# RBF中心(可学习)
self.centers = nn.Parameter(
torch.randn(num_centers, in_features) * 0.1
)
# RBF宽度(可学习)
self.widths = nn.Parameter(
torch.ones(num_centers) * 0.5
)
# 输出投影
self.weight = nn.Parameter(
torch.randn(num_centers, out_features) * 0.1
)

def forward(self, x):
"""
Args:
x: shape=(batch, in_features)

Returns:
output: shape=(batch, out_features)
"""
# 计算RBF响应
# x: (B, 1, I), centers: (K, I) -> dist: (B, K)
dist = torch.cdist(x.unsqueeze(1), self.centers.unsqueeze(0)).squeeze(1)

# RBF核函数
rbf = torch.exp(-(dist ** 2) / (2 * self.widths ** 2 + 1e-8))

# 投影到输出
return rbf @ self.weight # (B, K) @ (K, O) = (B, O)


class FastKANDDD(nn.Module):
"""
FastKAN-DDD: 驾驶员疲劳检测模型

基于Fast Kolmogorov-Arnold Network
针对TinyML优化(微控制器部署)

性能:99.94%准确率, 35KB, 0.04ms推理
"""

def __init__(self, input_size=64*64*3, num_classes=3,
hidden_dim=32, num_centers=8):
super().__init__()

# 特征提取(极简,适合MCU)
self.features = nn.Sequential(
nn.Conv2d(3, 8, 3, 2, 1), # 64→32
nn.BatchNorm2d(8),
nn.ReLU(),
nn.Conv2d(8, 16, 3, 2, 1), # 32→16
nn.BatchNorm2d(16),
nn.ReLU(),
nn.Conv2d(16, 32, 3, 2, 1), # 16→8
nn.BatchNorm2d(32),
nn.ReLU(),
nn.AdaptiveAvgPool2d(1)
)

# KAN分类头(替代传统MLP)
self.kan1 = FastKANLayer(32, hidden_dim, num_centers)
self.kan2 = FastKANLayer(hidden_dim, num_classes, num_centers)

def forward(self, x):
"""
Args:
x: shape=(batch, 3, 64, 64) 低分辨率图像

Returns:
logits: shape=(batch, 3) [alert/drowsy/very_drowsy]
"""
x = self.features(x) # (B, 32, 1, 1)
x = x.flatten(1) # (B, 32)
x = self.kan1(x) # (B, 32)
x = torch.relu(x)
x = self.kan2(x) # (B, 3)
return x


# 测试
if __name__ == "__main__":
model = FastKANDDD(input_size=64*64*3, num_classes=3)

# 模拟输入(64x64 RGB)
x = torch.randn(1, 3, 64, 64)
output = model(x)

param_count = sum(p.numel() for p in model.parameters())
print(f"输入: {x.shape}")
print(f"输出: {output.shape}")
print(f"参数量: {param_count:,} (~{param_count*4/1024:.1f} KB FP32)")
print(f"INT8量化后: ~{param_count/1024:.1f} KB")

2. 量化策略

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
class QuantizationConfig:
"""
FastKAN-DDD量化配置

论文评估了三种量化方案
"""

quantization_schemes = {
"dynamic_range": {
"description": "动态范围量化(权重INT8,激活FP32)",
"size": "35 KB",
"accuracy": 99.94,
"latency_ms": 0.04,
"platform": "STM32H7, ESP32-S3"
},
"float16": {
"description": "半精度浮点量化",
"size": "70 KB",
"accuracy": 99.92,
"latency_ms": 0.06,
"platform": "支持FP16的MCU"
},
"weight_only": {
"description": "仅权重量化(INT8权重,FP32激活)",
"size": "35 KB",
"accuracy": 99.94,
"latency_ms": 0.05,
"platform": "通用MCU"
},
"full_int8": {
"description": "全INT8量化(权重+激活)",
"size": "30 KB",
"accuracy": 99.91,
"latency_ms": 0.03,
"platform": "支持INT8加速的MCU"
}
}

# TFLite转换代码
"""
import tensorflow as tf

# 动态范围量化
converter = tf.lite.TFLiteConverter.from_keras_model(model)
converter.optimizations = [tf.lite.Optimize.DEFAULT]
tflite_model = converter.convert()

# 保存
with open('fastkan_ddd_int8.tflite', 'wb') as f:
f.write(tflite_model)

print(f"模型大小: {len(tflite_model)/1024:.1f} KB")
"""

3. UTA-RLDD数据集

1
2
3
4
5
6
7
8
9
10
11
dataset_info = {
"name": "UTA-RLDD (Real-Life Drowsiness Dataset)",
"classes": 3,
"class_names": ["Alert", "Drowsy", "Very Drowsy"],
"subjects": 60, # 41男, 19女
"video_clips": 480, # 每人8段
"resolution": "640x480 → 64x64(降采样)",
"total_frames": "~300,000",
"split": "70% train / 15% val / 15% test",
"diversity": "多光照/多姿态/多种族"
}

实验结果

不同分辨率性能

输入分辨率 参数量 模型大小 准确率 延迟
224×224 45K 180KB 99.96% 0.12ms
128×128 38K 75KB 99.95% 0.07ms
64×64 32K 35KB 99.94% 0.04ms
32×32 28K 28KB 98.87% 0.02ms

与SOTA对比

模型 准确率 大小 延迟 平台 开源
FastKAN-DDD 99.94% 35KB 0.04ms MCU ✅
CNN-TinyML 97.2% 120KB 0.15ms MCU 部分
MobileNetV2-Tiny 96.8% 350KB 0.8ms 嵌入式 ✅
YOLOv8n 96.1% 6.2MB 8ms GPU ✅
SqueezeNet 95.3% 1.2MB 3ms 嵌入式 ✅
P-YOLOv8 94.7% 2.84MB 5ms 嵌入式 否

IMS开发启示

1. 分级部署架构

2. MCU部署方案

平台 RAM Flash 适用性 功耗
STM32H743 1MB 2MB ✅ 充足 280mW
ESP32-S3 512KB 8MB ✅ 充足 100mW
RP2040 264KB 2MB ✅ 可行 60mW
nRF5340 512KB 1MB ✅ 可行 60mW

3. 与现有IMS集成

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
class IMSTinyMLIntegration:
"""
将FastKAN-DDD集成到IMS系统

架构:
- MCU级:FastKAN-DDD快速判断(0.04ms)
- SoC级:现有DMS精细化分析(30fps)
- 融合级:两级结果加权输出
"""

def __init__(self):
self.mcq_model = FastKANDDD() # 35KB MCU模型
self.soc_model = None # 现有高通平台DMS

def two_stage_detection(self, frame):
"""
两级检测:MCU快速预筛 → SoC精细分析
"""
# Stage 1: MCU快速判断(0.04ms)
mcu_pred = self.mcq_model(frame_64x64)

if mcu_pred == "Alert":
return "Alert", 0.99 # 跳过SoC

# Stage 2: SoC精细分析(仅对非Alert帧)
soc_result = self.soc_model(frame_full_res)

return soc_result

4. 关键优势

  1. 零额外硬件成本:利用现有MCU算力,无需增加BOM
  2. 超低延迟:0.04ms推理,100%实时
  3. 超低功耗:MCU级运行,<100mW
  4. 极小占用:35KB Flash,几乎零RAM占用
  5. 开源可复现:GitHub代码公开

YOLOv12-LAD补充:分心+疲劳联合检测

论文信息

项目 内容
标题 Research on Distracted and Fatigue-Related Driving Behavior Detection Based on YOLOv12-LAD
期刊 Electronics, 15(9), 1838
发表 2026年4月26日
模型大小 2.84 MB (P-YOLOv8参考)
特点 注意力机制增强,分心+疲劳联合检测

对比

维度 FastKAN-DDD YOLOv12-LAD
目标 疲劳3级分类 分心+疲劳多类检测
模型大小 35KB ~5MB
准确率 99.94% ~96%
检测类别 3 (alert/drowsy/very_drowsy) 10+ (手机/抽烟/打哈欠等)
部署 MCU 嵌入式SoC
功耗 <100mW 2-5W

互补使用:FastKAN-DDD做MCU级快速预筛,YOLOv12-LAD做SoC级行为分类。


总结

FastKAN-DDD代表了DMS模型微型化的极致——35KB模型在MCU上实现99.94%准确率。这为IMS系统提供了一个零成本增量的疲劳检测能力:利用现有MCU算力,不需额外硬件,在视觉SoC处理之前就完成快速状态预筛。

核心启示:DMS不一定需要昂贵的SoC和高分辨率摄像头。在资源受限场景(如商用车队、入门级车型、后装设备),FastKAN-DDD的TinyML方案可直接落地。结合YOLOv12-LAD等SoC级行为检测模型,可构建两级高效DMS架构。