Vehicle V2 Density Map - Optimization Options

Model size / speed / accuracy trade-offs | Current: ResNet50 + FPN | Target: faster inference

Current (V2)
25M
params | 408 img/s | MAE 1.52
Smallest option
2.5M
MobileNetV3-Small (10x smaller)
Fastest path
2-4x
TensorRT (no retrain)
Best balance
5M
MobileNetV3-Large (5x smaller)

Option Comparison

OptionBackboneParamsEst. img/sEst. MAEModel SizeRecommend
Current V2ResNet5025M4081.52102 MB
AResNet1811M~700~1.60~45 MB★★★
BEfficientNet-B05M~800~1.65~22 MB★★★
C (推薦)MobileNetV3-Large5M~1000~1.70~20 MB★★★ 最佳
DMobileNetV3-Small2.5M~1500~1.90~10 MB★★
EGhostNet v24.9M~1200~1.75~20 MB★★
FTinyViT-5M5M~900~1.65~20 MB★★

Speed vs Accuracy Scatter

Recommendation: MobileNetV3-Large

為什麼推薦

架構改動

# Before: ResNet50 + FPN
backbone = ResNet50(pretrained)
# layer1-4 outputs: 256, 512, 1024, 2048 channels
# 4-level FPN

# After: MobileNetV3-Large + simplified FPN
import timm
backbone = timm.create_model(
    "mobilenetv3_large_100.ra_in1k",
    pretrained=True, features_only=True
)
# Block outputs: 16, 24, 40, 112, 960 channels
# Use blocks 2/4/6 for 3-level FPN
# Or just blocks.4 for single-level decoder (even faster)

簡化 decoder 再加速

當前 FPN:4 lateral + 3 smooth + 3 head = 10 conv layers
極簡版:1 lateral + 1 conv + upsample + 1 head = 4 conv layers,再省 30% 時間

替代路徑:不重訓直接優化

優化方式加速難度準度影響說明
TensorRT fp16 engine2-3xtorch.onnx.exporttrtexec --fp16
TensorRT INT8再 1.5-2x-1~3% MAE需要 calibration 資料(100-500 張圖)
輸入降到 256x2562.3x極低+5-10% MAE只改 preprocess resize size
torch.compile1.2-1.5x極低加一行 model = torch.compile(model)
ONNX Runtime1.3-1.7xCPU/邊緣部署
最直接的組合
目標是 DeepStream 部署 → 現有 V2 直接轉 TensorRT INT8 engine,不用重訓:408 img/s → 約 2000 img/s(5x 加速)。半小時可完成。

按使用場景選方案

場景推薦方案目標
最高 fps(多相機同時處理)MobileNetV3-Large + TensorRT INT83000+ img/s
最低延遲(即時單幀)MobileNetV3-Small + TensorRT< 1 ms/frame
邊緣部署(Jetson Nano/NX)MobileNetV3-Small + INT8低功耗,100-300 img/s
伺服器部署(省 GPU)當前 V2 + TensorRT~2000 img/s,無需重訓
保準度第一ResNet18 + TensorRT900+ img/s,MAE 僅 +0.08

實作路徑

路徑時間結果
路徑 1:TensorRT 優化(零重訓)30 分鐘V2 → ~2000 img/s,MAE 不變
路徑 2:訓 MobileNetV3-Large1-2 小時V3 → ~1000 img/s,MAE ~1.7
路徑 3:兩者結合 ⭐2-3 小時V3+TRT → ~3000 img/s,MAE ~1.7

Next Action

建議:

  1. 先做路徑 1(TensorRT) — 半小時驗證現有模型的實際部署速度
  2. 如果 2000 img/s 已夠用 → 停止,直接部署
  3. 如果還不夠快或邊緣部署 → 做路徑 2,訓 MobileNetV3 版本
  4. 最後再轉 TRT INT8 → 路徑 3 終極版

Generated 2026-04-14 | Benchmark estimates based on GB10/RTX 5090 profiles | Related: Models Guide | Current V2 Report