#!/usr/bin/env python3 """ 测试Phase 4B完整配置是否能正确构建模型 """ import os import sys sys.path.insert(0, '/workspace/bevfusion') def test_phase4b_config(): """测试Phase 4B配置""" try: print("🔧 测试Phase 4B完整配置...") # 加载配置 from mmcv import Config config_file = 'configs/nuscenes/det/transfusion/secfpn/camera+lidar/swint_v0p075/multitask_BEV2X_phase4b_rmtppad_segmentation.yaml' cfg = Config.fromfile(config_file) print("✅ 配置文件加载成功") # 简化配置用于测试 cfg.data.samples_per_gpu = 1 cfg.data.workers_per_gpu = 0 # 设置训练模式 cfg.model.train_cfg = { 'object': { 'grid_size': [1440, 1440, 41] }, 'map': {} } print("🔧 检查模型组件...") # 检查所有必要的组件 model_config = cfg.model required_components = [ 'encoders.camera.backbone', 'encoders.camera.neck', 'encoders.camera.vtransform', 'encoders.lidar.backbone', 'fuser', 'decoder.backbone', 'decoder.neck', 'heads.object', 'heads.map' ] for component in required_components: keys = component.split('.') value = model_config try: for key in keys: value = value[key] print(f"✅ {component}: {value.get('type', 'configured')}") except (KeyError, TypeError): print(f"❌ 缺少组件: {component}") return False print("🎉 Phase 4B配置验证通过!") print("\n配置摘要:") print(f"- Camera: SwinTransformer + GeneralizedLSSFPN + DepthLSSTransform") print(f"- LiDAR: SparseEncoder") print(f"- Fusion: ConvFuser") print(f"- Decoder: SECOND + SECONDFPN") print(f"- Heads: TransFusionHead + EnhancedTransformerSegmentationHead") print(f"- 分割类别数: {len(cfg.map_classes)}") print(f"- 检测类别数: {len(cfg.object_classes)}") return True except Exception as e: print(f"❌ 配置测试失败: {e}") import traceback traceback.print_exc() return False if __name__ == "__main__": success = test_phase4b_config() if success: print("\n🚀 Phase 4B配置准备就绪,可以开始训练!") else: print("\n❌ 配置存在问题,需要修复")