113 lines
3.9 KiB
Python
113 lines
3.9 KiB
Python
|
|
#!/usr/bin/env python3
|
||
|
|
"""
|
||
|
|
最简配置测试 - 只测试基本的数据加载和模型构建
|
||
|
|
"""
|
||
|
|
|
||
|
|
import os
|
||
|
|
import sys
|
||
|
|
sys.path.insert(0, '/workspace/bevfusion')
|
||
|
|
|
||
|
|
def test_minimal():
|
||
|
|
"""测试最简配置"""
|
||
|
|
try:
|
||
|
|
print("🔧 创建最简配置...")
|
||
|
|
|
||
|
|
# 简单的配置
|
||
|
|
config = {
|
||
|
|
'model': {
|
||
|
|
'type': 'BEVFusion',
|
||
|
|
'encoders': {
|
||
|
|
'lidar': {
|
||
|
|
'voxelize': {
|
||
|
|
'max_num_points': 10,
|
||
|
|
'point_cloud_range': [-54.0, -54.0, -5.0, 54.0, 54.0, 3.0],
|
||
|
|
'voxel_size': [0.075, 0.075, 0.2],
|
||
|
|
'max_voxels': [120000, 160000]
|
||
|
|
},
|
||
|
|
'backbone': {
|
||
|
|
'type': 'SparseEncoder',
|
||
|
|
'in_channels': 5,
|
||
|
|
'sparse_shape': [1440, 1440, 41],
|
||
|
|
'output_channels': 128,
|
||
|
|
'order': ['conv', 'norm', 'act'],
|
||
|
|
'encoder_channels': [[16, 16, 32], [32, 32, 64], [64, 64, 128], [128, 128]],
|
||
|
|
'encoder_paddings': [[0, 0, 1], [0, 0, 1], [0, 0, [1, 1, 0]], [0, 0]]
|
||
|
|
}
|
||
|
|
}
|
||
|
|
},
|
||
|
|
'fuser': {
|
||
|
|
'type': 'ConvFuser',
|
||
|
|
'in_channels': [256], # 只用lidar特征
|
||
|
|
'out_channels': 256
|
||
|
|
},
|
||
|
|
'heads': {
|
||
|
|
'map': {
|
||
|
|
'type': 'EnhancedBEVSegmentationHead', # 用简单的分割头
|
||
|
|
'in_channels': 256,
|
||
|
|
'classes': ['drivable_area', 'ped_crossing', 'walkway', 'stop_line', 'carpark_area', 'divider'],
|
||
|
|
'loss': 'focal',
|
||
|
|
'deep_supervision': True,
|
||
|
|
'use_dice_loss': True,
|
||
|
|
'dice_weight': 0.5,
|
||
|
|
'focal_alpha': 0.25,
|
||
|
|
'focal_gamma': 2.0,
|
||
|
|
'grid_transform': {
|
||
|
|
'input_scope': [[-54.0, 54.0, 0.75], [-54.0, 54.0, 0.75]],
|
||
|
|
'output_scope': [[-50, 50, 0.167], [-50, 50, 0.167]]
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
},
|
||
|
|
'data': {
|
||
|
|
'samples_per_gpu': 1,
|
||
|
|
'workers_per_gpu': 0
|
||
|
|
},
|
||
|
|
'optimizer': {
|
||
|
|
'type': 'AdamW',
|
||
|
|
'lr': 1e-4
|
||
|
|
},
|
||
|
|
'lr_config': {
|
||
|
|
'policy': 'CosineAnnealing',
|
||
|
|
'warmup': 'linear',
|
||
|
|
'warmup_iters': 500,
|
||
|
|
'warmup_ratio': 0.33333333,
|
||
|
|
'min_lr_ratio': 1e-3
|
||
|
|
},
|
||
|
|
'runner': {
|
||
|
|
'type': 'EpochBasedRunner',
|
||
|
|
'max_epochs': 1 # 只训练1个epoch用于测试
|
||
|
|
},
|
||
|
|
'checkpoint_config': {
|
||
|
|
'interval': 1
|
||
|
|
},
|
||
|
|
'log_config': {
|
||
|
|
'interval': 50,
|
||
|
|
'hooks': [{'type': 'TextLoggerHook'}]
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
print("✅ 最简配置创建成功")
|
||
|
|
|
||
|
|
# 保存配置文件
|
||
|
|
import yaml
|
||
|
|
with open('configs/test_minimal.yaml', 'w') as f:
|
||
|
|
yaml.dump(config, f, default_flow_style=False)
|
||
|
|
|
||
|
|
print("✅ 配置文件保存到 configs/test_minimal.yaml")
|
||
|
|
|
||
|
|
return True
|
||
|
|
|
||
|
|
except Exception as e:
|
||
|
|
print(f"❌ 最简配置测试失败: {e}")
|
||
|
|
import traceback
|
||
|
|
traceback.print_exc()
|
||
|
|
return False
|
||
|
|
|
||
|
|
if __name__ == "__main__":
|
||
|
|
success = test_minimal()
|
||
|
|
if success:
|
||
|
|
print("\n🎉 最简配置创建成功!")
|
||
|
|
print("现在可以运行: python tools/train.py configs/test_minimal.yaml")
|
||
|
|
else:
|
||
|
|
print("\n❌ 配置创建失败")
|