MMAction2 1.x用RawframeDataset训练MViT触发AttributeError求助
MMAction2 1.x迁移中RawframeDataset配置MViT的AttributeError解决方案
错误核心原因
该错误是因为配置文件中某个需要字典类型的字段被误写为字符串。MMAction2 1.x版本对数据集、数据管道的配置格式做了大幅调整,不再兼容v0.24.1中直接用字符串指定组件的写法。关键配置修正点
数据集定义格式
错误示例(v0.24.1风格):
dataset_type = 'RawframeDataset' train_dataset = 'RawframeDataset'1.x正确写法:
dataset_type = 'RawframeDataset' data_root = 'path/to/frames' ann_file_train = 'path/to/train_list.txt' train_dataloader = dict( dataset=dict( type=dataset_type, data_root=data_root, ann_file=ann_file_train, pipeline=train_pipeline ), batch_size=8, num_workers=4 )必须确保
dataset字段是字典结构,而非直接赋值字符串。数据管道(pipeline)配置
检查pipeline内的每个操作是否都用字典定义,不能直接写字符串:错误示例:
train_pipeline = ['LoadImageFromFile', 'Resize']正确格式:
train_pipeline = [ dict(type='LoadImageFromFile'), dict(type='Resize', scale=(224, 224)), dict(type='FormatShape', input_format='NCHW'), dict(type='PackActionInputs') ]模型参数校验
检查MViT模型的配置项,确保所有需要键值对的参数(如backbone、head)都采用字典结构,避免用字符串直接替代。
快速验证方法
可以通过以下代码提前检查配置是否存在类型错误:from mmengine import Config cfg = Config.fromfile('your_config.py') # 检查数据集是否为字典 assert isinstance(cfg.train_dataloader.dataset, dict), "Dataset must be a dict" # 检查pipeline内元素是否为字典 assert all(isinstance(step, dict) for step in cfg.train_pipeline), "Pipeline steps must be dicts"
内容的提问来源于stack exchange,提问作者ThomasEdwin
相关产品推荐
相关产品推荐

