AttributeError: 'str' object has no attribute 'items' when using RawframeDataset with mvit in mmaction2

huangapple go评论111阅读模式
英文:

AttributeError: 'str' object has no attribute 'items' when using RawframeDataset with mvit in mmaction2

问题

I am using mmaction2 branch 1.x. I recently migrated from 0.24 and want to use mvit model. When I train my configuration with RawframeDataset, it stops with message: AttributeError: 'str' object has no attribute 'items' (please see below for detailed log). Any suggestion? Thank you.

英文:

I am using mmaction2 branch 1.x. I recently migrated from 0.24 and want to use mvit model. When I train my configuration with RawframeDataset, it stops with message: AttributeError: 'str' object has no attribute 'items' (please see below for detailed log). Any suggestion? Thank you.

Configuration

  1. #something_mvit.py
  2. _base_ = [
  3. 'mmaction2/configs/_base_/models/mvit_small.py', 'mmaction2/configs/_base_/default_runtime.py'
  4. ]
  5. repeat_times = 1
  6. num_classes = 10
  7. batch_size = 1
  8. # model settings
  9. model = dict(
  10. backbone=dict(
  11. arch='large',
  12. temporal_size=40,
  13. spatial_size=312,
  14. drop_path_rate=0.75,
  15. ),
  16. data_preprocessor=dict(
  17. type='ActionDataPreprocessor',
  18. mean=[114.75, 114.75, 114.75],
  19. std=[57.375, 57.375, 57.375],
  20. blending=dict(
  21. type='RandomBatchAugment',
  22. augments=[
  23. dict(type='MixupBlending', alpha=0.8, num_classes=400),
  24. dict(type='CutmixBlending', alpha=1, num_classes=400)
  25. ]),
  26. format_shape='NCTHW'),
  27. cls_head=dict(in_channels=1152, num_classes=num_classes),
  28. test_cfg=dict(max_testing_views=5))
  29. # dataset settings
  30. dataset_type = 'RawframeDataset'
  31. data_root = 'dataset'
  32. data_root_val = 'dataset'
  33. ann_file_train = 'dataset/train_rawdataset.txt'
  34. ann_file_val = 'dataset/val_rawdataset.txt'
  35. ann_file_test = 'dataset/test_rawdataset.txt'
  36. file_client_args = dict(io_backend='disk')
  37. train_pipeline = [
  38. dict(type='UniformSampleFrames', clip_len=40),
  39. dict(type='RawFrameDecode', **file_client_args),
  40. dict(type='Resize', scale=(-1, 256)),
  41. dict(
  42. type='PytorchVideoWrapper',
  43. op='RandAugment',
  44. magnitude=7,
  45. num_layers=4),
  46. dict(type='RandomErasing', erase_prob=0.25, mode='rand'),
  47. dict(type='FormatShape', input_format='NCTHW'),
  48. dict(type='PackActionInputs')
  49. ]
  50. val_pipeline = [
  51. dict(type='UniformSampleFrames', clip_len=40, test_mode=True),
  52. dict(type='RawFrameDecode', **file_client_args),
  53. dict(type='Resize', scale=(-1, 256)),
  54. dict(type='CenterCrop', crop_size=224),
  55. dict(type='FormatShape', input_format='NCTHW'),
  56. dict(type='PackActionInputs')
  57. ]
  58. test_pipeline = [
  59. dict(type='UniformSampleFrames', clip_len=40, test_mode=True),
  60. dict(type='RawFrameDecode', **file_client_args),
  61. dict(type='Resize', scale=(-1, 224)),
  62. dict(type='ThreeCrop', crop_size=224),
  63. dict(type='FormatShape', input_format='NCTHW'),
  64. dict(type='PackActionInputs')
  65. ]
  66. with_offset = True
  67. filename_tmpl = '{:05}.jpg'
  68. train_dataloader = dict(
  69. batch_size=batch_size,
  70. num_workers=1,
  71. persistent_workers=True,
  72. sampler=dict(type='DefaultSampler', shuffle=True),
  73. dataset=dict(
  74. type='RepeatDataset',
  75. times=repeat_times,
  76. dataset=dict(
  77. type=dataset_type,
  78. ann_file=ann_file_train,
  79. data_prefix=data_root,
  80. num_classes=num_classes,
  81. with_offset=with_offset,
  82. filename_tmpl=filename_tmpl,
  83. pipeline=train_pipeline)))
  84. val_dataloader = dict(
  85. batch_size=batch_size,
  86. num_workers=1,
  87. persistent_workers=True,
  88. sampler=dict(type='DefaultSampler', shuffle=False),
  89. dataset=dict(
  90. type='RepeatDataset',
  91. times=repeat_times,
  92. dataset=dict(
  93. type=dataset_type,
  94. ann_file=ann_file_val,
  95. data_prefix=data_root_val,
  96. num_classes=num_classes,
  97. with_offset=with_offset,
  98. filename_tmpl=filename_tmpl,
  99. pipeline=val_pipeline)))
  100. test_dataloader = dict(
  101. batch_size=1,
  102. num_workers=1,
  103. persistent_workers=True,
  104. sampler=dict(type='DefaultSampler', shuffle=False),
  105. dataset=dict(
  106. type=dataset_type,
  107. ann_file=ann_file_test,
  108. data_prefix=data_root_val,
  109. num_classes=num_classes,
  110. with_offset=with_offset,
  111. filename_tmpl=filename_tmpl,
  112. pipeline=test_pipeline))
  113. val_evaluator = dict(type='AccMetric')
  114. test_evaluator = val_evaluator
  115. train_cfg = dict(
  116. type='EpochBasedTrainLoop', max_epochs=100, val_begin=1, val_interval=3)
  117. val_cfg = dict(type='ValLoop')
  118. test_cfg = dict(type='TestLoop')
  119. base_lr = 1.6e-3
  120. optim_wrapper = dict(
  121. type='AmpOptimWrapper',
  122. optimizer=dict(
  123. type='AdamW', lr=base_lr, betas=(0.9, 0.999), weight_decay=0.05))
  124. param_scheduler = [
  125. dict(
  126. type='LinearLR',
  127. start_factor=0.1,
  128. by_epoch=True,
  129. begin=0,
  130. end=30,
  131. convert_to_iter_based=True),
  132. dict(
  133. type='CosineAnnealingLR',
  134. T_max=70,
  135. eta_min=base_lr / 100,
  136. by_epoch=True,
  137. begin=30,
  138. end=100,
  139. convert_to_iter_based=True)
  140. ]
  141. default_hooks = dict(
  142. checkpoint=dict(interval=3, max_keep_ckpts=5), logger=dict(interval=10))
  143. # Default setting for scaling LR automatically
  144. # - `enable` means enable scaling LR automatically
  145. # or not by default.
  146. # - `base_batch_size` = (8 GPUs) x (8 samples per GPU).
  147. auto_scale_lr = dict(enable=False, base_batch_size=64)
  148. # runtime settings
  149. # checkpoint_config = dict(interval=5)
  150. work_dir = 'runs/'

Log

  1. thomas@RYZEN9:~/proyek$ pyenv exec mmaction2/tools/dist_train.sh something_mvit.py 1
  2. + CONFIG=something_mvit.py
  3. + GPUS=1
  4. + NNODES=1
  5. + NODE_RANK=0
  6. + PORT=29500
  7. + MASTER_ADDR=127.0.0.1
  8. ++ dirname /home/thomas/proyek/mmaction2/tools/dist_train.sh
  9. ++ dirname /home/thomas/proyek/mmaction2/tools/dist_train.sh
  10. + PYTHONPATH=/home/thomas/proyek/mmaction2/tools/..:
  11. + python -m torch.distributed.launch --nnodes=1 --node_rank=0 --master_addr=127.0.0.1 --nproc_per_node=1 --master_port=29500 /home/thomas/proyek/mmaction2/tools/train.py something_mvit.py --launcher pytorch
  12. /home/thomas/.pyenv/versions/miniconda3-3.10-22.11.1-1/lib/python3.10/site-packages/torch/distributed/launch.py:180: FutureWarning: The module torch.distributed.launch is deprecated
  13. and will be removed in future. Use torchrun.
  14. Note that --use_env is set by default in torchrun.
  15. If your script expects `--local_rank` argument to be set, please
  16. change it to read from `os.environ['LOCAL_RANK']` instead. See
  17. https://pytorch.org/docs/stable/distributed.html#launch-utility for
  18. further instructions
  19. warnings.warn(
  20. /home/thomas/.pyenv/versions/miniconda3-3.10-22.11.1-1/lib/python3.10/site-packages/mmengine/utils/dl_utils/setup_env.py:46: UserWarning: Setting OMP_NUM_THREADS environment variable for each process to be 1 in default, to avoid your system being overloaded, please further tune the variable for optimal performance in your application as needed.
  21. warnings.warn(
  22. /home/thomas/.pyenv/versions/miniconda3-3.10-22.11.1-1/lib/python3.10/site-packages/mmengine/utils/dl_utils/setup_env.py:56: UserWarning: Setting MKL_NUM_THREADS environment variable for each process to be 1 in default, to avoid your system being overloaded, please further tune the variable for optimal performance in your application as needed.
  23. warnings.warn(
  24. 02/16 09:14:50 - mmengine - WARNING - The "log_processor" registry in mmaction did not set import location. Fallback to call `mmaction.utils.register_all_modules` instead.
  25. 02/16 09:14:51 - mmengine - INFO -
  26. ------------------------------------------------------------
  27. System environment:
  28. sys.platform: linux
  29. Python: 3.10.8 (main, Nov 24 2022, 14:13:03) [GCC 11.2.0]
  30. CUDA available: True
  31. numpy_random_seed: 209724671
  32. GPU 0: NVIDIA GeForce RTX 3070
  33. CUDA_HOME: None
  34. GCC: gcc (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0
  35. PyTorch: 1.13.1+cu117
  36. PyTorch compiling details: PyTorch built with:
  37. - GCC 9.3
  38. - C++ Version: 201402
  39. - Intel(R) Math Kernel Library Version 2020.0.0 Product Build 20191122 for Intel(R) 64 architecture applications
  40. - Intel(R) MKL-DNN v2.6.0 (Git Hash 52b5f107dd9cf10910aaa19cb47f3abf9b349815)
  41. - OpenMP 201511 (a.k.a. OpenMP 4.5)
  42. - LAPACK is enabled (usually provided by MKL)
  43. - NNPACK is enabled
  44. - CPU capability usage: AVX2
  45. - CUDA Runtime 11.7
  46. - NVCC architecture flags: -gencode;arch=compute_37,code=sm_37;-gencode;arch=compute_50,code=sm_50;-gencode;arch=compute_60,code=sm_60;-gencode;arch=compute_70,code=sm_70;-gencode;arch=compute_75,code=sm_75;-gencode;arch=compute_80,code=sm_80;-gencode;arch=compute_86,code=sm_86
  47. - CuDNN 8.5
  48. - Magma 2.6.1
  49. - Build settings: BLAS_INFO=mkl, BUILD_TYPE=Release, CUDA_VERSION=11.7, CUDNN_VERSION=8.5.0, CXX_COMPILER=/opt/rh/devtoolset-9/root/usr/bin/c++, CXX_FLAGS= -fabi-version=11 -Wno-deprecated -fvisibility-inlines-hidden -DUSE_PTHREADPOOL -fopenmp -DNDEBUG -DUSE_KINETO -DUSE_FBGEMM -DUSE_QNNPACK -DUSE_PYTORCH_QNNPACK -DUSE_XNNPACK -DSYMBOLICATE_MOBILE_DEBUG_HANDLE -DEDGE_PROFILER_USE_KINETO -O2 -fPIC -Wno-narrowing -Wall -Wextra -Werror=return-type -Werror=non-virtual-dtor -Wno-missing-field-initializers -Wno-type-limits -Wno-array-bounds -Wno-unknown-pragmas -Wunused-local-typedefs -Wno-unused-parameter -Wno-unused-function -Wno-unused-result -Wno-strict-overflow -Wno-strict-aliasing -Wno-error=deprecated-declarations -Wno-stringop-overflow -Wno-psabi -Wno-error=pedantic -Wno-error=redundant-decls -Wno-error=old-style-cast -fdiagnostics-color=always -faligned-new -Wno-unused-but-set-variable -Wno-maybe-uninitialized -fno-math-errno -fno-trapping-math -Werror=format -Werror=cast-function-type -Wno-stringop-overflow, LAPACK_INFO=mkl, PERF_WITH_AVX=1, PERF_WITH_AVX2=1, PERF_WITH_AVX512=1, TORCH_VERSION=1.13.1, USE_CUDA=ON, USE_CUDNN=ON, USE_EXCEPTION_PTR=1, USE_GFLAGS=OFF, USE_GLOG=OFF, USE_MKL=ON, USE_MKLDNN=ON, USE_MPI=OFF, USE_NCCL=ON, USE_NNPACK=ON, USE_OPENMP=ON, USE_ROCM=OFF,
  50. TorchVision: 0.14.1+cu117
  51. OpenCV: 4.7.0
  52. MMEngine: 0.5.0
  53. Runtime environment:
  54. cudnn_benchmark: False
  55. mp_cfg: {'mp_start_method': 'fork', 'opencv_num_threads': 0}
  56. dist_cfg: {'backend': 'nccl'}
  57. seed: None
  58. diff_rank_seed: False
  59. deterministic: False
  60. Distributed launcher: pytorch
  61. Distributed training: True
  62. GPU number: 1
  63. ------------------------------------------------------------
  64. 02/16 09:14:51 - mmengine - INFO - Config:
  65. model = dict(
  66. type='Recognizer3D',
  67. backbone=dict(
  68. type='MViT',
  69. arch='large',
  70. drop_path_rate=0.75,
  71. temporal_size=40,
  72. spatial_size=312),
  73. data_preprocessor=dict(
  74. type='ActionDataPreprocessor',
  75. mean=[114.75, 114.75, 114.75],
  76. std=[57.375, 57.375, 57.375],
  77. format_shape='NCTHW',
  78. blending=dict(
  79. type='RandomBatchAugment',
  80. augments=[
  81. dict(type='MixupBlending', alpha=0.8, num_classes=400),
  82. dict(type='CutmixBlending', alpha=1, num_classes=400)
  83. ])),
  84. cls_head=dict(
  85. type='MViTHead',
  86. in_channels=1152,
  87. num_classes=10,
  88. label_smooth_eps=0.1,
  89. average_clips='prob'),
  90. test_cfg=dict(max_testing_views=5))
  91. default_scope = 'mmaction'
  92. default_hooks = dict(
  93. runtime_info=dict(type='RuntimeInfoHook'),
  94. timer=dict(type='IterTimerHook'),
  95. logger=dict(type='LoggerHook', interval=10, ignore_last=False),
  96. param_scheduler=dict(type='ParamSchedulerHook'),
  97. checkpoint=dict(
  98. type='CheckpointHook', interval=3, save_best='auto', max_keep_ckpts=5),
  99. sampler_seed=dict(type='DistSamplerSeedHook'),
  100. sync_buffers=dict(type='SyncBuffersHook'))
  101. env_cfg = dict(
  102. cudnn_benchmark=False,
  103. mp_cfg=dict(mp_start_method='fork', opencv_num_threads=0),
  104. dist_cfg=dict(backend='nccl'))
  105. log_processor = dict(type='LogProcessor', window_size=20, by_epoch=True)
  106. vis_backends = [dict(type='LocalVisBackend')]
  107. visualizer = dict(
  108. type='ActionVisualizer', vis_backends=[dict(type='LocalVisBackend')])
  109. log_level = 'INFO'
  110. load_from = None
  111. resume = False
  112. repeat_times = 1
  113. num_classes = 10
  114. batch_size = 1
  115. dataset_type = 'RawframeDataset'
  116. data_root = 'dataset'
  117. data_root_val = 'dataset'
  118. ann_file_train = 'dataset/train_rawdataset.txt'
  119. ann_file_val = 'dataset/val_rawdataset.txt'
  120. ann_file_test = 'dataset/test_rawdataset.txt'
  121. file_client_args = dict(io_backend='disk')
  122. train_pipeline = [
  123. dict(type='UniformSampleFrames', clip_len=40),
  124. dict(type='RawFrameDecode', io_backend='disk'),
  125. dict(type='Resize', scale=(-1, 256)),
  126. dict(
  127. type='PytorchVideoWrapper',
  128. op='RandAugment',
  129. magnitude=7,
  130. num_layers=4),
  131. dict(type='RandomErasing', erase_prob=0.25, mode='rand'),
  132. dict(type='FormatShape', input_format='NCTHW'),
  133. dict(type='PackActionInputs')
  134. ]
  135. val_pipeline = [
  136. dict(type='UniformSampleFrames', clip_len=40, test_mode=True),
  137. dict(type='RawFrameDecode', io_backend='disk'),
  138. dict(type='Resize', scale=(-1, 256)),
  139. dict(type='CenterCrop', crop_size=224),
  140. dict(type='FormatShape', input_format='NCTHW'),
  141. dict(type='PackActionInputs')
  142. ]
  143. test_pipeline = [
  144. dict(type='UniformSampleFrames', clip_len=40, test_mode=True),
  145. dict(type='RawFrameDecode', io_backend='disk'),
  146. dict(type='Resize', scale=(-1, 224)),
  147. dict(type='ThreeCrop', crop_size=224),
  148. dict(type='FormatShape', input_format='NCTHW'),
  149. dict(type='PackActionInputs')
  150. ]
  151. with_offset = True
  152. filename_tmpl = '{:05}.jpg'
  153. train_dataloader = dict(
  154. batch_size=1,
  155. num_workers=1,
  156. persistent_workers=True,
  157. sampler=dict(type='DefaultSampler', shuffle=True),
  158. dataset=dict(
  159. type='RepeatDataset',
  160. times=1,
  161. dataset=dict(
  162. type='RawframeDataset',
  163. ann_file='dataset/train_rawdataset.txt',
  164. data_prefix='dataset',
  165. num_classes=10,
  166. with_offset=True,
  167. filename_tmpl='{:05}.jpg',
  168. pipeline=[
  169. dict(type='UniformSampleFrames', clip_len=40),
  170. dict(type='RawFrameDecode', io_backend='disk'),
  171. dict(type='Resize', scale=(-1, 256)),
  172. dict(
  173. type='PytorchVideoWrapper',
  174. op='RandAugment',
  175. magnitude=7,
  176. num_layers=4),
  177. dict(type='RandomErasing', erase_prob=0.25, mode='rand'),
  178. dict(type='FormatShape', input_format='NCTHW'),
  179. dict(type='PackActionInputs')
  180. ])))
  181. val_dataloader = dict(
  182. batch_size=1,
  183. num_workers=1,
  184. persistent_workers=True,
  185. sampler=dict(type='DefaultSampler', shuffle=False),
  186. dataset=dict(
  187. type='RepeatDataset',
  188. times=1,
  189. dataset=dict(
  190. type='RawframeDataset',
  191. ann_file='dataset/val_rawdataset.txt',
  192. data_prefix='dataset',
  193. num_classes=10,
  194. with_offset=True,
  195. filename_tmpl='{:05}.jpg',
  196. pipeline=[
  197. dict(type='UniformSampleFrames', clip_len=40, test_mode=True),
  198. dict(type='RawFrameDecode', io_backend='disk'),
  199. dict(type='Resize', scale=(-1, 256)),
  200. dict(type='CenterCrop', crop_size=224),
  201. dict(type='FormatShape', input_format='NCTHW'),
  202. dict(type='PackActionInputs')
  203. ])))
  204. test_dataloader = dict(
  205. batch_size=1,
  206. num_workers=1,
  207. persistent_workers=True,
  208. sampler=dict(type='DefaultSampler', shuffle=False),
  209. dataset=dict(
  210. type='RawframeDataset',
  211. ann_file='dataset/test_rawdataset.txt',
  212. data_prefix='dataset',
  213. num_classes=10,
  214. with_offset=True,
  215. filename_tmpl='{:05}.jpg',
  216. pipeline=[
  217. dict(type='UniformSampleFrames', clip_len=40, test_mode=True),
  218. dict(type='RawFrameDecode', io_backend='disk'),
  219. dict(type='Resize', scale=(-1, 224)),
  220. dict(type='ThreeCrop', crop_size=224),
  221. dict(type='FormatShape', input_format='NCTHW'),
  222. dict(type='PackActionInputs')
  223. ]))
  224. val_evaluator = dict(type='AccMetric')
  225. test_evaluator = dict(type='AccMetric')
  226. train_cfg = dict(
  227. type='EpochBasedTrainLoop', max_epochs=100, val_begin=1, val_interval=3)
  228. val_cfg = dict(type='ValLoop')
  229. test_cfg = dict(type='TestLoop')
  230. base_lr = 0.0016
  231. optim_wrapper = dict(
  232. type='AmpOptimWrapper',
  233. optimizer=dict(
  234. type='AdamW', lr=0.0016, betas=(0.9, 0.999), weight_decay=0.05))
  235. param_scheduler = [
  236. dict(
  237. type='LinearLR',
  238. start_factor=0.1,
  239. by_epoch=True,
  240. begin=0,
  241. end=30,
  242. convert_to_iter_based=True),
  243. dict(
  244. type='CosineAnnealingLR',
  245. T_max=70,
  246. eta_min=1.6e-05,
  247. by_epoch=True,
  248. begin=30,
  249. end=100,
  250. convert_to_iter_based=True)
  251. ]
  252. auto_scale_lr = dict(enable=False, base_batch_size=64)
  253. work_dir = 'runs/'
  254. launcher = 'pytorch'
  255. randomness = dict(seed=None, diff_rank_seed=False, deterministic=False)
  256. 02/16 09:14:51 - mmengine - WARNING - The "visualizer" registry in mmaction did not set import location. Fallback to call `mmaction.utils.register_all_modules` instead.
  257. 02/16 09:14:51 - mmengine - WARNING - The "vis_backend" registry in mmaction did not set import location. Fallback to call `mmaction.utils.register_all_modules` instead.
  258. 02/16 09:14:51 - mmengine - WARNING - The "model" registry in mmaction did not set import location. Fallback to call `mmaction.utils.register_all_modules` instead.
  259. 02/16 09:14:53 - mmengine - WARNING - The "hook" registry in mmaction did not set import location. Fallback to call `mmaction.utils.register_all_modules` instead.
  260. 02/16 09:14:53 - mmengine - INFO - Hooks will be executed in the following order:
  261. before_run:
  262. (VERY_HIGH ) RuntimeInfoHook
  263. (BELOW_NORMAL) LoggerHook
  264. --------------------
  265. before_train:
  266. (VERY_HIGH ) RuntimeInfoHook
  267. (NORMAL ) IterTimerHook
  268. (VERY_LOW ) CheckpointHook
  269. --------------------
  270. before_train_epoch:
  271. (VERY_HIGH ) RuntimeInfoHook
  272. (NORMAL ) IterTimerHook
  273. (NORMAL ) DistSamplerSeedHook
  274. --------------------
  275. before_train_iter:
  276. (VERY_HIGH ) RuntimeInfoHook
  277. (NORMAL ) IterTimerHook
  278. --------------------
  279. after_train_iter:
  280. (VERY_HIGH ) RuntimeInfoHook
  281. (NORMAL ) IterTimerHook
  282. (BELOW_NORMAL) LoggerHook
  283. (LOW ) ParamSchedulerHook
  284. (VERY_LOW ) CheckpointHook
  285. --------------------
  286. after_train_epoch:
  287. (NORMAL ) IterTimerHook
  288. (NORMAL ) SyncBuffersHook
  289. (LOW ) ParamSchedulerHook
  290. (VERY_LOW ) CheckpointHook
  291. --------------------
  292. before_val_epoch:
  293. (NORMAL ) IterTimerHook
  294. --------------------
  295. before_val_iter:
  296. (NORMAL ) IterTimerHook
  297. --------------------
  298. after_val_iter:
  299. (NORMAL ) IterTimerHook
  300. (BELOW_NORMAL) LoggerHook
  301. --------------------
  302. after_val_epoch:
  303. (VERY_HIGH ) RuntimeInfoHook
  304. (NORMAL ) IterTimerHook
  305. (BELOW_NORMAL) LoggerHook
  306. (LOW ) ParamSchedulerHook
  307. (VERY_LOW ) CheckpointHook
  308. --------------------
  309. before_test_epoch:
  310. (NORMAL ) IterTimerHook
  311. --------------------
  312. before_test_iter:
  313. (NORMAL ) IterTimerHook
  314. --------------------
  315. after_test_iter:
  316. (NORMAL ) IterTimerHook
  317. (BELOW_NORMAL) LoggerHook
  318. --------------------
  319. after_test_epoch:
  320. (VERY_HIGH ) RuntimeInfoHook
  321. (NORMAL ) IterTimerHook
  322. (BELOW_NORMAL) LoggerHook
  323. --------------------
  324. after_run:
  325. (BELOW_NORMAL) LoggerHook
  326. --------------------
  327. 02/16 09:14:53 - mmengine - WARNING - The "loop" registry in mmaction did not set import location. Fallback to call `mmaction.utils.register_all_modules` instead.
  328. 02/16 09:14:53 - mmengine - WARNING - The "dataset" registry in mmaction did not set import location. Fallback to call `mmaction.utils.register_all_modules` instead.
  329. Traceback (most recent call last):
  330. File "/home/thomas/.pyenv/versions/miniconda3-3.10-22.11.1-1/lib/python3.10/site-packages/mmengine/registry/build_functions.py", line 121, in build_from_cfg
  331. obj = obj_cls(**args) # type: ignore
  332. File "/home/thomas/proyek/mmaction2/mmaction/datasets/rawframe_dataset.py", line 99, in __init__
  333. super().__init__(
  334. File "/home/thomas/proyek/mmaction2/mmaction/datasets/base.py", line 48, in __init__
  335. super().__init__(
  336. File "/home/thomas/.pyenv/versions/miniconda3-3.10-22.11.1-1/lib/python3.10/site-packages/mmengine/dataset/base_dataset.py", line 241, in __init__
  337. self._join_prefix()
  338. File "/home/thomas/.pyenv/versions/miniconda3-3.10-22.11.1-1/lib/python3.10/site-packages/mmengine/dataset/base_dataset.py", line 538, in _join_prefix
  339. for data_key, prefix in self.data_prefix.items():
  340. AttributeError: 'str' object has no attribute 'items'
  341. During handling of the above exception, another exception occurred:
  342. Traceback (most recent call last):
  343. File "/home/thomas/.pyenv/versions/miniconda3-3.10-22.11.1-1/lib/python3.10/site-packages/mmengine/registry/build_functions.py", line 121, in build_from_cfg
  344. obj = obj_cls(**args) # type: ignore
  345. File "/home/thomas/.pyenv/versions/miniconda3-3.10-22.11.1-1/lib/python3.10/site-packages/mmengine/dataset/dataset_wrapper.py", line 207, in __init__
  346. self.dataset = DATASETS.build(dataset)
  347. File "/home/thomas/.pyenv/versions/miniconda3-3.10-22.11.1-1/lib/python3.10/site-packages/mmengine/registry/registry.py", line 521, in build
  348. return self.build_func(cfg, *args, **kwargs, registry=self)
  349. File "/home/thomas/.pyenv/versions/miniconda3-3.10-22.11.1-1/lib/python3.10/site-packages/mmengine/registry/build_functions.py", line 135, in build_from_cfg
  350. raise type(e)(
  351. AttributeError: class `RawframeDataset` in mmaction/datasets/rawframe_dataset.py: 'str' object has no attribute 'items'
  352. During handling of the above exception, another exception occurred:
  353. Traceback (most recent call last):
  354. File "/home/thomas/.pyenv/versions/miniconda3-3.10-22.11.1-1/lib/python3.10/site-packages/mmengine/registry/build_functions.py", line 121, in build_from_cfg
  355. obj = obj_cls(**args) # type: ignore
  356. File "/home/thomas/.pyenv/versions/miniconda3-3.10-22.11.1-1/lib/python3.10/site-packages/mmengine/runner/loops.py", line 43, in __init__
  357. super().__init__(runner, dataloader)
  358. File "/home/thomas/.pyenv/versions/miniconda3-3.10-22.11.1-1/lib/python3.10/site-packages/mmengine/runner/base_loop.py", line 26, in __init__
  359. self.dataloader = runner.build_dataloader(
  360. File "/home/thomas/.pyenv/versions/miniconda3-3.10-22.11.1-1/lib/python3.10/site-packages/mmengine/runner/runner.py", line 1333, in build_dataloader
  361. dataset = DATASETS.build(dataset_cfg)
  362. File "/home/thomas/.pyenv/versions/miniconda3-3.10-22.11.1-1/lib/python3.10/site-packages/mmengine/registry/registry.py", line 521, in build
  363. return self.build_func(cfg, *args, **kwargs, registry=self)
  364. File "/home/thomas/.pyenv/versions/miniconda3-3.10-22.11.1-1/lib/python3.10/site-packages/mmengine/registry/build_functions.py", line 135, in build_from_cfg
  365. raise type(e)(
  366. AttributeError: class `RepeatDataset` in mmengine/dataset/dataset_wrapper.py: class `RawframeDataset` in mmaction/datasets/rawframe_dataset.py: 'str' object has no attribute 'items'
  367. During handling of the above exception, another exception occurred:
  368. Traceback (most recent call last):
  369. File "/home/thomas/proyek/mmaction2/tools/train.py", line 141, in <module>
  370. main()
  371. File "/home/thomas/proyek/mmaction2/tools/train.py", line 137, in main
  372. runner.train()
  373. File "/home/thomas/.pyenv/versions/miniconda3-3.10-22.11.1-1/lib/python3.10/site-packages/mmengine/runner/runner.py", line 1656, in train
  374. self._train_loop = self.build_train_loop(
  375. File "/home/thomas/.pyenv/versions/miniconda3-3.10-22.11.1-1/lib/python3.10/site-packages/mmengine/runner/runner.py", line 1448, in build_train_loop
  376. loop = LOOPS.build(
  377. File "/home/thomas/.pyenv/versions/miniconda3-3.10-22.11.1-1/lib/python3.10/site-packages/mmengine/registry/registry.py", line 521, in build
  378. return self.build_func(cfg, *args, **kwargs, registry=self)
  379. File "/home/thomas/.pyenv/versions/miniconda3-3.10-22.11.1-1/lib/python3.10/site-packages/mmengine/registry/build_functions.py", line 135, in build_from_cfg
  380. raise type(e)(
  381. AttributeError: class `EpochBasedTrainLoop` in mmengine/runner/loops.py: class `RepeatDataset` in mmengine/dataset/dataset_wrapper.py: class `RawframeDataset` in mmaction/datasets/rawframe_dataset.py: 'str' object has no attribute 'items'
  382. ERROR:torch.distributed.elastic.multiprocessing.api:failed (exitcode: 1) local_rank: 0 (pid: 2909183) of binary: /home/thomas/.pyenv/versions/miniconda3-3.10-22.11.1-1/bin/python
  383. Traceback (most recent call last):
  384. File "/home/thomas/.pyenv/versions/miniconda3-3.10-22.11.1-1/lib/python3.10/runpy.py", line 196, in _run_module_as_main
  385. return _run_code(code, main_globals, None,
  386. File "/home/thomas/.pyenv/versions/miniconda3-3.10-22.11.1-1/lib/python3.10/runpy.py", line 86, in _run_code
  387. exec(code, run_globals)
  388. File "/home/thomas/.pyenv/versions/miniconda3-3.10-22.11.1-1/lib/python3.10/site-packages/torch/distributed/launch.py", line 195, in <module>
  389. main()
  390. File "/home/thomas/.pyenv/versions/miniconda3-3.10-22.11.1-1/lib/python3.10/site-packages/torch/distributed/launch.py", line 191, in main
  391. launch(args)
  392. File "/home/thomas/.pyenv/versions/miniconda3-3.10-22.11.1-1/lib/python3.10/site-packages/torch/distributed/launch.py", line 176, in launch
  393. run(args)
  394. File "/home/thomas/.pyenv/versions/miniconda3-3.10-22.11.1-1/lib/python3.10/site-packages/torch/distributed/run.py", line 753, in run
  395. elastic_launch(
  396. File "/home/thomas/.pyenv/versions/miniconda3-3.10-22.11.1-1/lib/python3.10/site-packages/torch/distributed/launcher/api.py", line 132, in __call__
  397. return launch_agent(self._config, self._entrypoint, list(args))
  398. File "/home/thomas/.pyenv/versions/miniconda3-3.10-22.11.1-1/lib/python3.10/site-packages/torch/distributed/launcher/api.py", line 246, in launch_agent
  399. raise ChildFailedError(
  400. torch.distributed.elastic.multiprocessing.errors.ChildFailedError:
  401. ============================================================
  402. /home/thomas/proyek/mmaction2/tools/train.py FAILED
  403. ------------------------------------------------------------
  404. Failures:
  405. <NO_OTHER_FAILURES>
  406. ------------------------------------------------------------
  407. Root Cause (first observed failure):
  408. [0]:
  409. time : 2023-02-16_09:14:54
  410. host : RYZEN9
  411. rank : 0 (local_rank: 0)
  412. exitcode : 1 (pid: 2909183)
  413. error_file: <N/A>
  414. traceback : To enable traceback see: https://pytorch.org/docs/stable/elastic/errors.html
  415. ============================================================

答案1

得分: 0

我找到了问题的罪魁祸首。将 data_prefix=data_root_xxx 替换为 data_prefix=dict(img=data_root_xxx)

这是工作配置:

  1. # something_mvit.py
  2. _base_ = [
  3. 'mmaction2/configs/_base_/models/mvit_small.py', 'mmaction2/configs/_base_/default_runtime.py'
  4. ]
  5. repeat_times = 1
  6. num_classes = 10
  7. batch_size = 1
  8. # model settings
  9. model = dict(
  10. backbone=dict(
  11. arch='large',
  12. temporal_size=40,
  13. spatial_size=312,
  14. drop_path_rate=0.75,
  15. ),
  16. data_preprocessor=dict(
  17. type='ActionDataPreprocessor',
  18. mean=[114.75, 114.75, 114.75],
  19. std=[57.375, 57.375, 57.375],
  20. blending=dict(
  21. type='RandomBatchAugment',
  22. augments=[
  23. dict(type='MixupBlending', alpha=0.8, num_classes=400),
  24. dict(type='CutmixBlending', alpha=1, num_classes=400)
  25. ]),
  26. format_shape='NCTHW'),
  27. cls_head=dict(in_channels=1152, num_classes=num_classes),
  28. test_cfg=dict(max_testing_views=5))
  29. # dataset settings
  30. dataset_type = 'RawframeDataset'
  31. data_root = 'dataset'
  32. data_root_val = 'dataset'
  33. ann_file_train = 'dataset/train_rawdataset.txt'
  34. ann_file_val = 'dataset/val_rawdataset.txt'
  35. ann_file_test = 'dataset/test_rawdataset.txt'
  36. file_client_args = dict(io_backend='disk')
  37. train_pipeline = [
  38. dict(type='UniformSampleFrames', clip_len=40),
  39. dict(type='RawFrameDecode', **file_client_args),
  40. dict(type='Resize', scale=(-1, 256)),
  41. dict(
  42. type='PytorchVideoWrapper',
  43. op='RandAugment',
  44. magnitude=7,
  45. num_layers=4),
  46. dict(type='RandomErasing', erase_prob=0.25, mode='rand'),
  47. dict(type='FormatShape', input_format='NCTHW'),
  48. dict(type='PackActionInputs')
  49. ]
  50. val_pipeline = [
  51. dict(type='UniformSampleFrames', clip_len=40, test_mode=True),
  52. dict(type='RawFrameDecode', **file_client_args),
  53. dict(type='Resize', scale=(-1, 256)),
  54. dict(type='CenterCrop', crop_size=224),
  55. dict(type='FormatShape', input_format='NCTHW'),
  56. dict(type='PackActionInputs')
  57. ]
  58. test_pipeline = [
  59. dict(type='UniformSampleFrames', clip_len=40, test_mode=True),
  60. dict(type='RawFrameDecode', **file_client_args),
  61. dict(type='Resize', scale=(-1, 224)),
  62. dict(type='ThreeCrop', crop_size=224),
  63. dict(type='FormatShape', input_format='NCTHW'),
  64. dict(type='PackActionInputs')
  65. ]
  66. with_offset = True
  67. filename_tmpl = '{:05}.jpg'
  68. train_dataloader = dict(
  69. batch_size=batch_size,
  70. num_workers=1,
  71. persistent_workers=True,
  72. sampler=dict(type='DefaultSampler', shuffle=True),
  73. dataset=dict(
  74. type='RepeatDataset',
  75. times=repeat_times,
  76. dataset=dict(
  77. type=dataset_type,
  78. ann_file=ann_file_train,
  79. data_prefix=dict(img=data_root),
  80. num_classes=num_classes,
  81. with_offset=with_offset,
  82. filename_tmpl=filename_tmpl,
  83. pipeline=train_pipeline)))
  84. val_dataloader = dict(
  85. batch_size=batch_size,
  86. num_workers=1,
  87. persistent_workers=True,
  88. sampler=dict(type='DefaultSampler', shuffle=False),
  89. dataset=dict(
  90. type='RepeatDataset',
  91. times=repeat_times,
  92. dataset=dict(
  93. type=dataset_type,
  94. ann_file=ann_file_val,
  95. data_prefix=dict(img=data_root_val),
  96. num_classes=num_classes,
  97. with_offset=with_offset,
  98. filename_tmpl=filename_tmpl,
  99. pipeline=val_pipeline,
  100. test_mode=True)))
  101. test_dataloader = dict(
  102. batch_size=1,
  103. num_workers=1,
  104. persistent_workers=True,
  105. sampler=dict(type='DefaultSampler', shuffle=False),
  106. dataset=dict(
  107. type=dataset_type,
  108. ann_file=ann_file_val,
  109. data_prefix=dict(img=data_root_val),
  110. num_classes=num_classes,
  111. with_offset=with_offset,
  112. filename_tmpl=filename_tmpl,
  113. pipeline=test_pipeline,
  114. test_mode=True))
  115. val_evaluator = dict(type='AccMetric')
  116. test_evaluator = val_evaluator
  117. train_cfg = dict(
  118. type='EpochBasedTrainLoop', max_epochs=100, val_begin=1, val_interval=3)
  119. val_cfg = dict(type='ValLoop')
  120. test_cfg = dict(type='TestLoop')
  121. base_lr = 1.6e-3
  122. optim_wrapper = dict(
  123. type='AmpOptimWrapper',
  124. optimizer=dict(
  125. type='AdamW', lr=base_lr, betas=(0.9, 0.999), weight_decay=0.05))
  126. param_scheduler = [
  127. dict(
  128. type='LinearLR',
  129. start_factor=0.1,
  130. by_epoch=True,
  131. begin=0,
  132. end=30,
  133. convert_to_iter_based=True),
  134. dict(
  135. type='CosineAnnealingLR',
  136. T_max=70,
  137. eta_min=base_lr / 100,
  138. by_epoch=True,
  139. begin=30,
  140. end=100,
  141. convert_to_iter_based=True)
  142. ]
  143. default_hooks = dict(
  144. checkpoint=dict(interval=3, max_keep_ckpts=5), logger=dict(interval=10)
  145. # 默认设置以自动缩放学习率
  146. # - `enable` 表示是否默认启用自动缩放学习率。
  147. # - `base_batch_size` = (8 GPU) x (每个GPU 8个样本)。
  148. auto_scale_lr = dict(enable=False, base_batch_size=64)
  149. # 运行时设置
  150. # checkpoint_config = dict(interval=5)
  151. work_dir = 'runs/'
英文:

I have found the culprit. Replace data_prefix=data_root_xxx with data_prefix=dict(img=data_root_xxx)

This is the working config:

  1. #something_mvit.py
  2. _base_ = [
  3. 'mmaction2/configs/_base_/models/mvit_small.py', 'mmaction2/configs/_base_/default_runtime.py'
  4. ]
  5. repeat_times = 1
  6. num_classes = 10
  7. batch_size = 1
  8. # model settings
  9. model = dict(
  10. backbone=dict(
  11. arch='large',
  12. temporal_size=40,
  13. spatial_size=312,
  14. drop_path_rate=0.75,
  15. ),
  16. data_preprocessor=dict(
  17. type='ActionDataPreprocessor',
  18. mean=[114.75, 114.75, 114.75],
  19. std=[57.375, 57.375, 57.375],
  20. blending=dict(
  21. type='RandomBatchAugment',
  22. augments=[
  23. dict(type='MixupBlending', alpha=0.8, num_classes=400),
  24. dict(type='CutmixBlending', alpha=1, num_classes=400)
  25. ]),
  26. format_shape='NCTHW'),
  27. cls_head=dict(in_channels=1152, num_classes=num_classes),
  28. test_cfg=dict(max_testing_views=5))
  29. # dataset settings
  30. dataset_type = 'RawframeDataset'
  31. data_root = 'dataset'
  32. data_root_val = 'dataset'
  33. ann_file_train = 'dataset/train_rawdataset.txt'
  34. ann_file_val = 'dataset/val_rawdataset.txt'
  35. ann_file_test = 'dataset/test_rawdataset.txt'
  36. file_client_args = dict(io_backend='disk')
  37. train_pipeline = [
  38. dict(type='UniformSampleFrames', clip_len=40),
  39. dict(type='RawFrameDecode', **file_client_args),
  40. dict(type='Resize', scale=(-1, 256)),
  41. dict(
  42. type='PytorchVideoWrapper',
  43. op='RandAugment',
  44. magnitude=7,
  45. num_layers=4),
  46. dict(type='RandomErasing', erase_prob=0.25, mode='rand'),
  47. dict(type='FormatShape', input_format='NCTHW'),
  48. dict(type='PackActionInputs')
  49. ]
  50. val_pipeline = [
  51. dict(type='UniformSampleFrames', clip_len=40, test_mode=True),
  52. dict(type='RawFrameDecode', **file_client_args),
  53. dict(type='Resize', scale=(-1, 256)),
  54. dict(type='CenterCrop', crop_size=224),
  55. dict(type='FormatShape', input_format='NCTHW'),
  56. dict(type='PackActionInputs')
  57. ]
  58. test_pipeline = [
  59. dict(type='UniformSampleFrames', clip_len=40, test_mode=True),
  60. dict(type='RawFrameDecode', **file_client_args),
  61. dict(type='Resize', scale=(-1, 224)),
  62. dict(type='ThreeCrop', crop_size=224),
  63. dict(type='FormatShape', input_format='NCTHW'),
  64. dict(type='PackActionInputs')
  65. ]
  66. with_offset = True
  67. filename_tmpl = '{:05}.jpg'
  68. train_dataloader = dict(
  69. batch_size=batch_size,
  70. num_workers=1,
  71. persistent_workers=True,
  72. sampler=dict(type='DefaultSampler', shuffle=True),
  73. dataset=dict(
  74. type='RepeatDataset',
  75. times=repeat_times,
  76. dataset=dict(
  77. type=dataset_type,
  78. ann_file=ann_file_train,
  79. data_prefix=dict(img=data_root),
  80. num_classes=num_classes,
  81. with_offset=with_offset,
  82. filename_tmpl=filename_tmpl,
  83. pipeline=train_pipeline)))
  84. val_dataloader = dict(
  85. batch_size=batch_size,
  86. num_workers=1,
  87. persistent_workers=True,
  88. sampler=dict(type='DefaultSampler', shuffle=False),
  89. dataset=dict(
  90. type='RepeatDataset',
  91. times=repeat_times,
  92. dataset=dict(
  93. type=dataset_type,
  94. ann_file=ann_file_val,
  95. data_prefix=dict(img=data_root_val),
  96. num_classes=num_classes,
  97. with_offset=with_offset,
  98. filename_tmpl=filename_tmpl,
  99. pipeline=val_pipeline,
  100. test_mode=True)))
  101. test_dataloader = dict(
  102. batch_size=1,
  103. num_workers=1,
  104. persistent_workers=True,
  105. sampler=dict(type='DefaultSampler', shuffle=False),
  106. dataset=dict(
  107. type=dataset_type,
  108. ann_file=ann_file_val,
  109. data_prefix=dict(img=data_root_val),
  110. num_classes=num_classes,
  111. with_offset=with_offset,
  112. filename_tmpl=filename_tmpl,
  113. pipeline=test_pipeline,
  114. test_mode=True))
  115. val_evaluator = dict(type='AccMetric')
  116. test_evaluator = val_evaluator
  117. train_cfg = dict(
  118. type='EpochBasedTrainLoop', max_epochs=100, val_begin=1, val_interval=3)
  119. val_cfg = dict(type='ValLoop')
  120. test_cfg = dict(type='TestLoop')
  121. base_lr = 1.6e-3
  122. optim_wrapper = dict(
  123. type='AmpOptimWrapper',
  124. optimizer=dict(
  125. type='AdamW', lr=base_lr, betas=(0.9, 0.999), weight_decay=0.05))
  126. param_scheduler = [
  127. dict(
  128. type='LinearLR',
  129. start_factor=0.1,
  130. by_epoch=True,
  131. begin=0,
  132. end=30,
  133. convert_to_iter_based=True),
  134. dict(
  135. type='CosineAnnealingLR',
  136. T_max=70,
  137. eta_min=base_lr / 100,
  138. by_epoch=True,
  139. begin=30,
  140. end=100,
  141. convert_to_iter_based=True)
  142. ]
  143. default_hooks = dict(
  144. checkpoint=dict(interval=3, max_keep_ckpts=5), logger=dict(interval=10))
  145. # Default setting for scaling LR automatically
  146. # - `enable` means enable scaling LR automatically
  147. # or not by default.
  148. # - `base_batch_size` = (8 GPUs) x (8 samples per GPU).
  149. auto_scale_lr = dict(enable=False, base_batch_size=64)
  150. # runtime settings
  151. # checkpoint_config = dict(interval=5)
  152. work_dir = 'runs/'

huangapple
  • 本文由 发表于 2023年2月16日 12:42:01
  • 转载请务必保留本文链接:https://go.coder-hub.com/75467927.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定