| # OV-COCO 鲁棒性评估 (Robustness Evaluation) |
|
|
| 评估目标检测模型在图像退化条件下的性能,**专为 OV-COCO 数据集设计**,支持 `base_ap50`、`novel_ap50`、`all_ap50` 指标。 |
|
|
| ## 目录结构 |
|
|
| ``` |
| robustness_eval/ |
| ├── test_robustness_ovcoco.py # OV-COCO 鲁棒性测试脚本 |
| ├── merge_robustness_results.py # 结果合并与报告生成 |
| ├── run_clearclip_robustness.sh # ClearCLIP 8-GPU 并行测试 |
| ├── run_clipself_robustness.sh # CLIPSelf 8-GPU 并行测试 |
| ├── logs/ # 运行日志 |
| └── results/ # 测试结果 |
| ├── clearclip/ |
| └── clipself/ |
| ``` |
|
|
| ## 退化类型 (15 种 benchmark) |
|
|
| | 类别 | 退化类型 | |
| |------|----------| |
| | Noise | gaussian_noise, shot_noise, impulse_noise | |
| | Blur | defocus_blur, glass_blur, motion_blur, zoom_blur | |
| | Weather | snow, frost, fog, brightness | |
| | Digital | contrast, elastic_transform, pixelate, jpeg_compression | |
| |
| ## 严重程度 |
| |
| 1-5 级,数字越大退化越严重。共 75 个场景 (15 类型 × 5 级别)。 |
| |
| ## 评估指标 |
| |
| ### OV-COCO 特有指标 |
| - **base_ap50**: 已知类别 (48 类) 的 AP@IoU=0.50 |
| - **novel_ap50**: 新类别 (17 类) 的 AP@IoU=0.50 |
| - **all_ap50**: 所有类别 (65 类) 的 AP@IoU=0.50 |
| |
| ### 鲁棒性指标 |
| - **P (Performance)**: 原始图像上的性能 |
| - **mPC (mean Performance under Corruption)**: 所有退化条件下的平均性能 |
| - **rPC (relative Performance under Corruption)**: mPC / P,衡量鲁棒性 |
| |
| ## 使用方法 |
| |
| ### 1. 运行鲁棒性测试 |
| |
| ```bash |
| cd /mnt/bn/strategy-mllm-train/user/wangjunjie/code/xiaomoguhzz/DeCLIP_private/robustness_eval |
| |
| # ClearCLIP (8 GPU 并行,后台运行) |
| bash run_clearclip_robustness.sh --nohup |
| |
| # CLIPSelf (8 GPU 并行,后台运行) |
| bash run_clipself_robustness.sh --nohup |
| |
| # 两个可以同时运行(GPU 显存足够时) |
| bash run_clearclip_robustness.sh --nohup && bash run_clipself_robustness.sh --nohup |
| ``` |
| |
| ### 2. 监控进度 |
| |
| ```bash |
| # 查看日志 |
| tail -f logs/gpu0_clearclip.log |
|
|
| # 检查完成数量 (预期 75 个) |
| ls results/clearclip/*_results.pkl 2>/dev/null | wc -l |
| ls results/clipself/*_results.pkl 2>/dev/null | wc -l |
| ``` |
| |
| ### 3. 合并结果并生成报告 |
| |
| ```bash |
| # ClearCLIP |
| python3 merge_robustness_results.py \ |
| --results-dir results/clearclip \ |
| --model-name ClearCLIP |
| |
| # CLIPSelf |
| python3 merge_robustness_results.py \ |
| --results-dir results/clipself \ |
| --model-name CLIPSelf |
| ``` |
| |
| ### 4. 输出文件 |
| |
| - **日志报告**: 控制台输出 base_ap50、novel_ap50、all_ap50 等汇总 |
| - **Excel 报告**: `results/<model>/robustness_report.xlsx` |
| - Summary: P、mPC、rPC 汇总 |
| - Category mPC: 按退化类别 (noise/blur/weather/digital) 统计 |
| - Corruption Avg: 每种退化类型的平均值 |
| - Base Ap50 / Novel Ap50 / All Ap50: 详细 15×5 矩阵 |
| - Full Matrix: 完整结果(便于复制到论文) |
|
|
| ## 单场景测试 |
|
|
| 如需测试单个场景: |
|
|
| ```bash |
| cd /mnt/bn/strategy-mllm-train/user/wangjunjie/code/xiaomoguhzz/DeCLIP_private/CLIPSelf/F-ViT |
| export PYTHONPATH=$PWD:/opt/tiger/xiaomoguhzz/mmdetection:$PYTHONPATH |
| |
| python3 /mnt/bn/strategy-mllm-train/user/wangjunjie/code/xiaomoguhzz/DeCLIP_private/robustness_eval/test_robustness_ovcoco.py \ |
| configs/declip/fvit_vitb16_upsample_fpn_bs64_3e_ovcoco_clearclip.py \ |
| work_dirs/clearclip_ovcoco/epoch_3.pth \ |
| --out /tmp/test.pkl \ |
| --corruptions gaussian_noise \ |
| --severities 1 \ |
| --eval bbox |
| ``` |
|
|
| ## 注意事项 |
|
|
| 1. **依赖安装**: |
| ```bash |
| pip install imagecorruptions openpyxl pandas |
| ``` |
|
|
| 2. **运行时间**: 75 个场景 × 4836 图像,8 GPU 并行约需 2-3 小时 |
|
|
| 3. **与旧脚本的区别**: |
| - 旧脚本使用 `mmdet/test_robustness.py`,只输出标准 COCO 指标 |
| - 新脚本 `test_robustness_ovcoco.py` 调用 `CocoDatasetOV.evaluate()`,输出 OV-COCO 特有的 base/novel AP50 |
|
|
| ## 模型路径 |
|
|
| | 模型 | Config | Checkpoint | |
| |------|--------|------------| |
| | ClearCLIP | `configs/declip/fvit_vitb16_upsample_fpn_bs64_3e_ovcoco_clearclip.py` | `work_dirs/clearclip_ovcoco/epoch_3.pth` | |
| | CLIPSelf | `configs/ov_coco/fvit_vitb16_upsample_fpn_bs64_3e_ovcoco_eva_clipself_proposals.py` | `/opt/tiger/xiaomoguhzz/fvit_eva_vitb16_ovcoco_clipself_proposals.pth` | |
|
|