bev-project/EVAL_EPOCH23_COMPLETE.sh

124 lines
4.0 KiB
Bash
Executable File

#!/bin/bash
# Epoch 23完整评估 - 检测+分割
set -e
export PATH=/opt/conda/bin:$PATH
export LD_LIBRARY_PATH=/opt/conda/lib/python3.8/site-packages/torch/lib:/opt/conda/lib:/usr/local/cuda/lib64:$LD_LIBRARY_PATH
export PYTHONPATH=/workspace/bevfusion:$PYTHONPATH
cd /workspace/bevfusion
echo "========================================================================"
echo "Epoch 23 完整评估 (GPU 4-7, 不影响训练)"
echo "========================================================================"
echo ""
TIMESTAMP=$(date +%Y%m%d_%H%M%S)
EVAL_DIR="eval_results/epoch23_complete_${TIMESTAMP}"
mkdir -p "$EVAL_DIR"
CONFIG="configs/nuscenes/det/transfusion/secfpn/camera+lidar/swint_v0p075/multitask_enhanced_phase1_HIGHRES.yaml"
CHECKPOINT="runs/enhanced_from_epoch19/epoch_23.pth"
echo "配置文件: $CONFIG"
echo "Checkpoint: $CHECKPOINT (516MB)"
echo "输出目录: $EVAL_DIR"
echo "使用GPU: 4-7 (避开训练GPU 0-3)"
echo ""
# 阶段1: 3D检测评估
echo "========== 阶段1: 3D目标检测评估 =========="
CUDA_VISIBLE_DEVICES=4,5,6,7 \
LD_LIBRARY_PATH=/opt/conda/lib/python3.8/site-packages/torch/lib:/opt/conda/lib:/usr/local/cuda/lib64:$LD_LIBRARY_PATH \
PATH=/opt/conda/bin:$PATH \
/opt/conda/bin/torchpack dist-run -np 4 /opt/conda/bin/python tools/test.py \
"$CONFIG" \
"$CHECKPOINT" \
--eval bbox \
--out "$EVAL_DIR/detection_results.pkl" \
--cfg-options data.workers_per_gpu=0 \
2>&1 | tee "$EVAL_DIR/detection_eval.log"
echo ""
echo "========== 阶段2: BEV分割评估 =========="
CUDA_VISIBLE_DEVICES=4,5,6,7 \
LD_LIBRARY_PATH=/opt/conda/lib/python3.8/site-packages/torch/lib:/opt/conda/lib:/usr/local/cuda/lib64:$LD_LIBRARY_PATH \
PATH=/opt/conda/bin:$PATH \
/opt/conda/bin/torchpack dist-run -np 4 /opt/conda/bin/python tools/test.py \
"$CONFIG" \
"$CHECKPOINT" \
--eval map \
--out "$EVAL_DIR/segmentation_results.pkl" \
--cfg-options data.workers_per_gpu=0 \
2>&1 | tee "$EVAL_DIR/segmentation_eval.log"
echo ""
echo "========== 阶段3: 综合评估 =========="
CUDA_VISIBLE_DEVICES=4,5,6,7 \
LD_LIBRARY_PATH=/opt/conda/lib/python3.8/site-packages/torch/lib:/opt/conda/lib:/usr/local/cuda/lib64:$LD_LIBRARY_PATH \
PATH=/opt/conda/bin:$PATH \
/opt/conda/bin/torchpack dist-run -np 4 /opt/conda/bin/python tools/test.py \
"$CONFIG" \
"$CHECKPOINT" \
--eval bbox map \
--out "$EVAL_DIR/complete_results.pkl" \
--cfg-options data.workers_per_gpu=0 \
2>&1 | tee "$EVAL_DIR/complete_eval.log"
echo ""
echo "========================================================================"
echo "评估完成!生成报告..."
echo "========================================================================"
# 提取关键指标
python3 << 'PYTHON_SCRIPT'
import re
import os
eval_dir = os.environ.get('EVAL_DIR', 'eval_results/epoch23_complete_*')
log_files = ['detection_eval.log', 'segmentation_eval.log', 'complete_eval.log']
report = []
report.append("=" * 80)
report.append("Epoch 23 评估报告摘要")
report.append("=" * 80)
report.append("")
for log_file in log_files:
log_path = f"{eval_dir}/{log_file}"
if os.path.exists(log_path):
with open(log_path, 'r') as f:
content = f.read()
# 提取NDS和mAP
nds_match = re.search(r'NDS:\s+([\d\.]+)', content)
map_match = re.search(r'mAP:\s+([\d\.]+)', content)
miou_match = re.search(r'mIoU.*?:\s+([\d\.]+)', content)
report.append(f"--- {log_file} ---")
if nds_match:
report.append(f" NDS: {nds_match.group(1)}")
if map_match:
report.append(f" mAP: {map_match.group(1)}")
if miou_match:
report.append(f" mIoU: {miou_match.group(1)}")
report.append("")
report.append("=" * 80)
report.append(f"完整日志: {eval_dir}/")
report.append("=" * 80)
print('\n'.join(report))
# 保存报告
with open(f"{eval_dir}/SUMMARY.txt", 'w') as f:
f.write('\n'.join(report))
PYTHON_SCRIPT
echo ""
echo "评估报告: $EVAL_DIR/SUMMARY.txt"
echo "完整日志: $EVAL_DIR/"
echo ""