MIRAGE复现总结
📋 环境配置总结
官方建议:
The project is inspired from MiliPoint code repository.
This project was created with Python 3.10, Pytorch 2.4.1 with cuda 11.8, using the Pytorch geometric library (required for the GNN) with packages torch-scatter 2.1.2 and torch-cluster 1.6.3. It can be installed using therequirements.txtfile provided. If the install does not work, you can install the packages manually by following these steps (using conda and pip):
# create a conda environment with python 3.10:
conda create -n myenv -c conda-forge python=3.10
# activate the conda environment:
conda activate myenv
# install pytorch with the appropriate cuda version:
pip install torch==2.4.1+cu118 torchvision --index-url https://download.pytorch.org/whl/cu118
# install other packages
pip install toml matplotlib seaborn scipy opencv-python optuna pytorch_lightning scikit-learn tensorboard pulp ptflops torch_geometric
# install the required packages for pytorch geometric compatible with the appropriate torch and cuda version:
pip install torch-scatter==2.1.2 torch-cluster==1.6.3 --index-url https://data.pyg.org/whl/torch-2.4.1+cu118.html
# Note: if this does not work, try to download and directly install the wheel with theappropriate python version and linux support: torch_scatter-2.1.2+pt24cu118-cp310-cp310-linux_x86_64.whl and torch_cluster-1.6.3+pt24cu118-cp310-cp310-linux_x86_64.whl (downloaded from https://data.pyg.org/whl/torch-2.4.1+cu118.html)
一、最终成功的环境配置参数
二、环境配置遇到的问题及解决方法
三、训练方法(标准流程)每次启动训练的命令:
bash:
cd ~/MIRAGE
conda activate radar_gnn
python mm train mirage pointnet_tiny -config configs/mirage.toml -d_kfold 0 -seed 0 -d_processed_data data/MIRAGE/processed/kfold0.pkl -a cpu
参数说明:
复现完整实验:
bash:
# 给脚本执行权限
chmod +x *.sh
# 复现表5(GNN 特征消融实验)
./mirage_gnn_features_ablation.sh
# 或复现表6(不同模型对比)
./mirage_models_features_ablation.sh
查看结果:
bash:
cat summary_results.csv
训练好的模型保存在 `~/MIRAGE/lightning_logs/` 目录下。
四、环境配置的“一步到位”脚本
如果需要重新配置,可以一次性执行以下命令:
bash:
1. 创建环境
conda create -n radar_gnn python=3.10 -y
conda activate radar_gnn
2. 安装 PyTorch 2.4.1
pip install torch==2.4.1 torchvision==0.19.1 --index-url https://download.pytorch.org/whl/cpu
3. 升级 setuptools
pip install --upgrade setuptools wheel
4. 源码编译 torch-scatter 和 torch-cluster
pip install torch-scatter torch-cluster --no-build-isolation
5. 安装其余依赖
pip install torch_geometric toml matplotlib seaborn scipy opencv-python optuna pytorch_lightning scikit-learn tensorboard pulp ptflops
6. 验证
python -c "import torch; print(torch.__version__); import torch_scatter; import torch_cluster; print('OK')"
五、关键经验总结
1. 版本严格匹配是首要前提:必须使用 Python 3.10 + PyTorch 2.4.1
2. 源码编译比预编译包更可靠:当版本不匹配时,`--no-build-isolation` 是最有效的解决方案
3. Kaggle 不如本地 WSL 可控:如果本地有资源,优先在本地调试
4. 训练时记得加 `-a cpu`:如果安装的是 CPU 版 PyTorch,不加这个参数会报错 `No supported gpu backend found`
六、实验
实验0:GNN + 全部雷达特征训练
雷达特定特征显著提升识别精度
🧪 实验 1:雷达特征的有效性验证(对应论文 Table 5)
脚本名称:
mirage_gnn_features_ablation.sh验证目的:探究雷达点云中不同特征对识别准确率的影响,证明“速度”和“强度”等雷达特有特征能显著提升精度。
具体做法:固定使用 GNN 模型,依次只输入 4 种不同的特征组合:
仅坐标 (x, y, z)
坐标 + 速度 (Doppler)
坐标 + 速度 + 强度 (Intensity)
坐标 + 速度 + 强度 + 时间戳 (Time)
执行代码:
cd ~/MIRAGE
conda activate radar_gnn
./mirage_gnn_features_ablation.sh预期结果:生成
summary_results.csv,包含 4 种特征组合下的准确率,通常能看到准确率逐步上升(比如从 90% → 93% → 95% → 96%)。
⚖️ 实验 2:不同模型架构的对比(对应论文 Table 6)
脚本名称:
mirage_models_features_ablation.sh验证目的:证明作者提出的 GNN 模型比现有的 CNN 和 Transformer 更优秀(不仅准,而且轻量)。
具体做法:在相同的雷达特征输入下,分别训练 3 种模型:
PointNet++(经典点云 CNN)
MiniTransformer(轻量级 Transformer)
作者提出的 GNN(即 PointNet_Tiny)
对比指标:准确率(Accuracy)、参数量(Params)、计算量(FLOPs)、推理速度。
执行代码:
cd ~/MIRAGE
conda activate radar_gnn
./mirage_models_features_ablation.sh预期结果:GNN 的准确率最高(~96%),参数量最小(~0.4 MB),计算量最低。
🌀 实验 3:时空距离的影响(对应论文 Figure 5)
脚本名称:
mirage_gnn_tscale_ablation.sh验证目的:探究图神经网络在构建时空图时,应该连接多长“时间窗口”内的点,找到最佳感受野。
具体做法:调整 GNN 构图时的
model_t_scale参数(即时间窗口大小,比如只看前后 5 帧、10 帧、15 帧、30 帧),分别训练并对比准确率。执行代码:
cd ~/MIRAGE
conda activate radar_gnn
./mirage_gnn_tscale_ablation.sh预期结果:生成一条准确率随时间窗口变化的曲线(论文 Figure 5),通常窗口太小会丢失动态信息,太大则会引入噪声,存在一个最优值。
🚧 实验 4:抗干扰鲁棒性测试(对应论文 Table 7 & 8)
脚本名称:需要分两步运行:
mirage_clean_training.sh+mirage_clean_noisy_validation.sh验证目的:验证模型在真实场景(有 1~4 个路人走动干扰)下的抗干扰能力。
具体做法:
第一步(纯干净训练):只在“无干扰”的数据上训练模型。
第二步(混合训练):在“干净 + 有干扰”的混合数据上训练模型。
测试:分别在“干净测试集”和“有干扰测试集(1人/2人/4人)”上评估两个模型的准确率,观察精度下降幅度和回升情况。
执行代码(必须按顺序):
cd ~/MIRAGE
conda activate radar_gnn# 第一步:先跑纯干净训练
./mirage_clean_training.sh# 第二步:再跑混合训练 + 测试(依赖第一步生成的模型)
./mirage_clean_noisy_validation.sh预期结果:纯干净训练的模型在干扰下准确率会明显下降(比如 96% → 80%),而混合训练的模型在干扰下准确率下降较少(比如 96% → 90%),证明数据增强能提升鲁棒性。
⏱️ 一键全部运行
cd ~/MIRAGE
conda activate radar_gnn
chmod +x *.sh # 给所有脚本添加执行权限(只需执行一次)
./mirage_all.sh
(GPU上预计73h)
七、优化建议
修改模型或调参,可以修改 `configs/mirage.toml` 文件中的参数。