295 lines
8.7 KiB
Bash
Executable File
295 lines
8.7 KiB
Bash
Executable File
#!/bin/bash
|
||
|
||
# 验证共享BEV层GCA实现的完整性
|
||
# 不需要Python环境,纯bash检查
|
||
|
||
echo "=============================================="
|
||
echo "共享BEV层GCA实现验证"
|
||
echo "=============================================="
|
||
|
||
cd /workspace/bevfusion
|
||
|
||
SUCCESS_COUNT=0
|
||
TOTAL_COUNT=0
|
||
|
||
# 辅助函数
|
||
check_pass() {
|
||
SUCCESS_COUNT=$((SUCCESS_COUNT + 1))
|
||
TOTAL_COUNT=$((TOTAL_COUNT + 1))
|
||
echo " ✅ PASS: $1"
|
||
}
|
||
|
||
check_fail() {
|
||
TOTAL_COUNT=$((TOTAL_COUNT + 1))
|
||
echo " ❌ FAIL: $1"
|
||
}
|
||
|
||
# 测试1: 配置文件存在性
|
||
echo ""
|
||
echo "=== 测试1: 配置文件检查 ==="
|
||
|
||
if [ -f "configs/nuscenes/det/transfusion/secfpn/camera+lidar/swint_v0p075/multitask_BEV2X_phase4a_stage1.yaml" ]; then
|
||
check_pass "Baseline配置存在"
|
||
else
|
||
check_fail "Baseline配置缺失"
|
||
fi
|
||
|
||
if [ -f "configs/nuscenes/det/transfusion/secfpn/camera+lidar/swint_v0p075/multitask_BEV2X_phase4a_stage1_gca.yaml" ]; then
|
||
check_pass "GCA配置存在"
|
||
else
|
||
check_fail "GCA配置缺失"
|
||
fi
|
||
|
||
# 测试2: GCA配置内容检查
|
||
echo ""
|
||
echo "=== 测试2: GCA配置内容验证 ==="
|
||
|
||
CONFIG_FILE="configs/nuscenes/det/transfusion/secfpn/camera+lidar/swint_v0p075/multitask_BEV2X_phase4a_stage1_gca.yaml"
|
||
|
||
if grep -q "shared_bev_gca:" "$CONFIG_FILE"; then
|
||
check_pass "shared_bev_gca配置存在"
|
||
|
||
# 检查enabled
|
||
if grep -A 5 "shared_bev_gca:" "$CONFIG_FILE" | grep -q "enabled: true"; then
|
||
check_pass "shared_bev_gca.enabled = true"
|
||
else
|
||
check_fail "shared_bev_gca.enabled未设置为true"
|
||
fi
|
||
|
||
# 检查in_channels
|
||
if grep -A 5 "shared_bev_gca:" "$CONFIG_FILE" | grep -q "in_channels: 512"; then
|
||
check_pass "shared_bev_gca.in_channels = 512"
|
||
else
|
||
check_fail "shared_bev_gca.in_channels配置异常"
|
||
fi
|
||
|
||
# 检查reduction
|
||
if grep -A 5 "shared_bev_gca:" "$CONFIG_FILE" | grep -q "reduction: 4"; then
|
||
check_pass "shared_bev_gca.reduction = 4"
|
||
else
|
||
check_fail "shared_bev_gca.reduction配置异常"
|
||
fi
|
||
else
|
||
check_fail "shared_bev_gca配置缺失"
|
||
fi
|
||
|
||
# 检查work_dir
|
||
if grep -q "work_dir: /data/runs/phase4a_stage1_gca" "$CONFIG_FILE"; then
|
||
check_pass "work_dir配置正确 (区分GCA版本)"
|
||
else
|
||
check_fail "work_dir配置异常"
|
||
fi
|
||
|
||
# 检查use_internal_gca
|
||
if grep -A 10 "map:" "$CONFIG_FILE" | grep -q "use_internal_gca: false"; then
|
||
check_pass "分割头use_internal_gca = false"
|
||
else
|
||
check_fail "分割头use_internal_gca配置缺失"
|
||
fi
|
||
|
||
# 检查load_interval
|
||
if grep -A 3 "data:" "$CONFIG_FILE" | grep -q "load_interval: 2"; then
|
||
check_pass "data.val.load_interval = 2"
|
||
else
|
||
check_fail "data.val.load_interval配置缺失"
|
||
fi
|
||
|
||
# 检查evaluation interval
|
||
if grep -A 5 "evaluation:" "$CONFIG_FILE" | grep -q "interval: 10"; then
|
||
check_pass "evaluation.interval = 10"
|
||
else
|
||
check_fail "evaluation.interval配置缺失"
|
||
fi
|
||
|
||
# 测试3: 代码文件检查
|
||
echo ""
|
||
echo "=== 测试3: 代码文件验证 ==="
|
||
|
||
# GCA模块
|
||
if [ -f "mmdet3d/models/modules/gca.py" ]; then
|
||
check_pass "GCA模块文件存在"
|
||
|
||
if grep -q "class GCA" "mmdet3d/models/modules/gca.py"; then
|
||
check_pass "GCA类定义存在"
|
||
else
|
||
check_fail "GCA类定义缺失"
|
||
fi
|
||
else
|
||
check_fail "GCA模块文件缺失"
|
||
fi
|
||
|
||
# modules __init__.py
|
||
if [ -f "mmdet3d/models/modules/__init__.py" ]; then
|
||
check_pass "modules/__init__.py存在"
|
||
else
|
||
check_fail "modules/__init__.py缺失"
|
||
fi
|
||
|
||
# 测试4: BEVFusion主模型修改
|
||
echo ""
|
||
echo "=== 测试4: BEVFusion主模型验证 ==="
|
||
|
||
BEVFUSION_FILE="mmdet3d/models/fusion_models/bevfusion.py"
|
||
|
||
# 检查shared_bev_gca参数
|
||
if grep -q "shared_bev_gca: Dict\[str, Any\] = None" "$BEVFUSION_FILE"; then
|
||
check_pass "BEVFusion.__init__接受shared_bev_gca参数"
|
||
else
|
||
check_fail "BEVFusion.__init__未添加shared_bev_gca参数"
|
||
fi
|
||
|
||
# 检查GCA初始化
|
||
if grep -q "self.shared_bev_gca = GCA(" "$BEVFUSION_FILE"; then
|
||
check_pass "BEVFusion初始化shared_bev_gca"
|
||
else
|
||
check_fail "BEVFusion未初始化shared_bev_gca"
|
||
fi
|
||
|
||
# 检查GCA调用
|
||
if grep -q "if self.shared_bev_gca is not None:" "$BEVFUSION_FILE"; then
|
||
check_pass "BEVFusion.forward中有GCA调用逻辑"
|
||
|
||
if grep -A 1 "if self.shared_bev_gca is not None:" "$BEVFUSION_FILE" | grep -q "x = self.shared_bev_gca(x)"; then
|
||
check_pass "BEVFusion.forward正确调用GCA"
|
||
else
|
||
check_fail "BEVFusion.forward GCA调用位置错误"
|
||
fi
|
||
else
|
||
check_fail "BEVFusion.forward未调用GCA"
|
||
fi
|
||
|
||
# 测试5: 分割头修改
|
||
echo ""
|
||
echo "=== 测试5: EnhancedBEVSegmentationHead验证 ==="
|
||
|
||
ENHANCED_FILE="mmdet3d/models/heads/segm/enhanced.py"
|
||
|
||
# 检查use_internal_gca参数
|
||
if grep -q "use_internal_gca: bool = False" "$ENHANCED_FILE"; then
|
||
check_pass "分割头接受use_internal_gca参数"
|
||
else
|
||
check_fail "分割头未添加use_internal_gca参数"
|
||
fi
|
||
|
||
# 检查GCA条件初始化
|
||
if grep -q "if self.use_internal_gca:" "$ENHANCED_FILE"; then
|
||
check_pass "分割头有GCA条件初始化逻辑"
|
||
else
|
||
check_fail "分割头缺少GCA条件初始化"
|
||
fi
|
||
|
||
# 检查GCA条件调用
|
||
if grep -q "if self.gca is not None:" "$ENHANCED_FILE"; then
|
||
check_pass "分割头forward有GCA条件调用"
|
||
else
|
||
check_fail "分割头forward缺少GCA条件调用"
|
||
fi
|
||
|
||
# 测试6: 启动脚本
|
||
echo ""
|
||
echo "=== 测试6: 启动脚本检查 ==="
|
||
|
||
if [ -f "START_PHASE4A_SHARED_GCA.sh" ]; then
|
||
check_pass "启动脚本存在"
|
||
|
||
if grep -q "multitask_BEV2X_phase4a_stage1_gca.yaml" "START_PHASE4A_SHARED_GCA.sh"; then
|
||
check_pass "启动脚本使用正确的配置文件"
|
||
else
|
||
check_fail "启动脚本配置文件路径错误"
|
||
fi
|
||
|
||
if [ -x "START_PHASE4A_SHARED_GCA.sh" ]; then
|
||
check_pass "启动脚本有执行权限"
|
||
else
|
||
chmod +x START_PHASE4A_SHARED_GCA.sh
|
||
check_pass "启动脚本权限已修复"
|
||
fi
|
||
else
|
||
check_fail "启动脚本缺失"
|
||
fi
|
||
|
||
# 测试7: Checkpoint检查
|
||
echo ""
|
||
echo "=== 测试7: Checkpoint验证 ==="
|
||
|
||
if [ -f "/workspace/bevfusion/runs/run-326653dc-2334d461/epoch_5.pth" ]; then
|
||
check_pass "epoch_5.pth存在"
|
||
SIZE=$(ls -lh /workspace/bevfusion/runs/run-326653dc-2334d461/epoch_5.pth | awk '{print $5}')
|
||
echo " Checkpoint大小: $SIZE"
|
||
else
|
||
check_fail "epoch_5.pth缺失"
|
||
fi
|
||
|
||
# 测试8: 磁盘空间检查
|
||
echo ""
|
||
echo "=== 测试8: 磁盘空间验证 ==="
|
||
|
||
AVAIL_GB=$(df /workspace | tail -1 | awk '{print int($4/1024/1024)}')
|
||
echo " 可用空间: ${AVAIL_GB}GB"
|
||
|
||
if [ "$AVAIL_GB" -gt 30 ]; then
|
||
check_pass "磁盘空间充足 (${AVAIL_GB}GB > 30GB)"
|
||
else
|
||
check_fail "磁盘空间不足 (${AVAIL_GB}GB < 30GB)"
|
||
fi
|
||
|
||
# 检查.eval_hook
|
||
EVAL_HOOK_COUNT=$(find /workspace/bevfusion/runs -name ".eval_hook" -type d 2>/dev/null | wc -l)
|
||
if [ "$EVAL_HOOK_COUNT" -eq 0 ]; then
|
||
check_pass "无.eval_hook缓存残留"
|
||
else
|
||
check_fail "发现${EVAL_HOOK_COUNT}个.eval_hook目录,需要清理"
|
||
fi
|
||
|
||
# 测试9: 配置对比
|
||
echo ""
|
||
echo "=== 测试9: Baseline vs GCA配置对比 ==="
|
||
|
||
echo " Baseline配置:"
|
||
echo " - shared_bev_gca: $(grep -c 'shared_bev_gca:' configs/nuscenes/det/transfusion/secfpn/camera+lidar/swint_v0p075/multitask_BEV2X_phase4a_stage1.yaml || echo 0) 处"
|
||
echo " - work_dir: $(grep 'work_dir:' configs/nuscenes/det/transfusion/secfpn/camera+lidar/swint_v0p075/multitask_BEV2X_phase4a_stage1.yaml)"
|
||
|
||
echo ""
|
||
echo " GCA配置:"
|
||
echo " - shared_bev_gca: $(grep -c 'shared_bev_gca:' configs/nuscenes/det/transfusion/secfpn/camera+lidar/swint_v0p075/multitask_BEV2X_phase4a_stage1_gca.yaml) 处"
|
||
echo " - work_dir: $(grep 'work_dir:' configs/nuscenes/det/transfusion/secfpn/camera+lidar/swint_v0p075/multitask_BEV2X_phase4a_stage1_gca.yaml)"
|
||
|
||
if grep -q "shared_bev_gca:" configs/nuscenes/det/transfusion/secfpn/camera+lidar/swint_v0p075/multitask_BEV2X_phase4a_stage1_gca.yaml; then
|
||
check_pass "GCA配置包含shared_bev_gca"
|
||
else
|
||
check_fail "GCA配置缺少shared_bev_gca"
|
||
fi
|
||
|
||
# 总结
|
||
echo ""
|
||
echo "=============================================="
|
||
echo "验证结果总结"
|
||
echo "=============================================="
|
||
echo "通过: ${SUCCESS_COUNT}/${TOTAL_COUNT} 测试"
|
||
echo ""
|
||
|
||
if [ "$SUCCESS_COUNT" -eq "$TOTAL_COUNT" ]; then
|
||
echo "🎉 所有验证通过!"
|
||
echo ""
|
||
echo "架构摘要:"
|
||
echo " ✅ Baseline配置已恢复 (无GCA)"
|
||
echo " ✅ GCA配置已创建 (共享BEV层GCA)"
|
||
echo " ✅ BEVFusion主模型已修改"
|
||
echo " ✅ 分割头已支持可选GCA"
|
||
echo " ✅ Checkpoint已就绪"
|
||
echo " ✅ 磁盘空间充足"
|
||
echo ""
|
||
echo "下一步: 在Docker容器内启动训练"
|
||
echo " docker exec -it bevfusion bash"
|
||
echo " cd /workspace/bevfusion"
|
||
echo " bash START_PHASE4A_SHARED_GCA.sh"
|
||
echo ""
|
||
exit 0
|
||
else
|
||
echo "⚠️ ${TOTAL_COUNT} - ${SUCCESS_COUNT} = $((TOTAL_COUNT - SUCCESS_COUNT)) 个测试失败"
|
||
echo "请检查上述错误信息"
|
||
echo ""
|
||
exit 1
|
||
fi
|
||
|