You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

MMAction2 1.x用RawframeDataset训练MViT触发AttributeError求助

MMAction2 1.x迁移中RawframeDataset配置MViT的AttributeError解决方案
  • 错误核心原因
    该错误是因为配置文件中某个需要字典类型的字段被误写为字符串。MMAction2 1.x版本对数据集、数据管道的配置格式做了大幅调整,不再兼容v0.24.1中直接用字符串指定组件的写法。

  • 关键配置修正点

    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字段是字典结构,而非直接赋值字符串。

    2. 数据管道(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')
      ]
      
    3. 模型参数校验
      检查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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.01 00:05:20