mmpose icon indicating copy to clipboard operation
mmpose copied to clipboard

[Bug] TypeError: 'NoneType' object is not iterable

Open 52THANOS opened this issue 1 year ago • 21 comments

Prerequisite

  • [X] I have searched Issues and Discussions but cannot get the expected help.
  • [X] The bug has not been fixed in the latest version(https://github.com/open-mmlab/mmpose).

Environment

addict 2.4.0 aenum 3.1.15 aliyun-python-sdk-core 2.13.36 aliyun-python-sdk-kms 2.16.1 asynctest 0.13.0 attrs 23.1.0 certifi 2023.7.22 cffi 1.15.1 charset-normalizer 3.2.0 chumpy 0.70 click 8.1.6 colorama 0.4.6 coloredlogs 15.0.1 contourpy 1.1.0 coverage 7.2.7 crcmod 1.7 cryptography 41.0.3 cycler 0.11.0 Cython 3.0.0 dill 0.3.7 et-xmlfile 1.1.0 exceptiongroup 1.1.2 flake8 6.1.0 flatbuffers 23.5.26 fonttools 4.42.0 grpcio 1.56.2 h5py 3.9.0 humanfriendly 10.0 idna 3.4 importlib-metadata 6.8.0 importlib-resources 6.0.1 iniconfig 2.0.0 interrogate 1.5.0 isort 4.3.21 jmespath 0.10.0 json-tricks 3.17.2 kiwisolver 1.4.4 Markdown 3.4.4 markdown-it-py 3.0.0 matplotlib 3.7.2 mccabe 0.7.0 mdurl 0.1.2 mmcls 1.0.0rc6 mmcv 2.0.1 mmdeploy 1.2.0 d:\downloadproject\mmdeploy mmdeploy-runtime 1.2.0 mmdeploy-runtime-gpu 1.2.0 mmdet 3.1.0 mmengine 0.8.4 mmpose 1.1.0 mmyolo 0.5.0 model-index 0.1.11 modelindex 0.0.2 mpmath 1.3.0 multiprocess 0.70.15 munkres 1.1.4 numpy 1.25.2 onnx 1.14.0 onnxruntime 1.15.1 opencv-python 4.8.0.74 opendatalab 0.0.10 openmim 0.3.9 openpyxl 3.0.9 openxlab 0.0.17 ordered-set 4.1.0 oss2 2.17.0 packaging 23.1 pandas 2.0.3 Pillow 10.0.0 pip 21.3.1 platformdirs 3.10.0 pluggy 1.2.0 prettytable 3.8.0 protobuf 3.20.2 py 1.11.0 pycocotools 2.0.6 pycodestyle 2.11.0 pycparser 2.21 pycryptodome 3.18.0 pyflakes 3.1.0 Pygments 2.16.1 pyparsing 3.0.9 pyreadline3 3.4.1 pytest 7.4.0 python-dateutil 2.8.2 pytz 2023.3 pywin32 306 PyYAML 6.0.1 regex 2023.8.8 requests 2.28.2 rich 13.4.2 scipy 1.11.1 setuptools 60.2.0 shapely 2.0.1 six 1.16.0 sympy 1.12 tabulate 0.9.0 termcolor 2.3.0 terminaltables 3.1.10 toml 0.10.2 tomli 2.0.1 torch 1.13.1+cu117 torchaudio 0.13.1+cu117 torchvision 0.14.1+cu117 tqdm 4.65.2 typing_extensions 4.7.1 tzdata 2023.3 urllib3 1.26.16 wcwidth 0.2.6 wheel 0.37.1 xlrd 1.2.0 xtcocotools 1.13 yapf 0.40.1 zipp 3.16.2 WARNING: You are using pip version 21.3.1; however, version 23.2.1 is available. You should consider upgrading

Reproduces the problem - code sample

            data.update(meta_data)
            data = test_pipeline(data)
            data['inputs'] = data['inputs'].to(self.device)
            batch_data['inputs'].append(data['inputs'])
            batch_data['data_samples'].append(data['data_samples'])

    if data_preprocessor is not None:
        batch_data = data_preprocessor(batch_data, False)
    input_tensor = batch_data['inputs']
    return batch_data, input_tensor

Reproduces the problem - command or script

python tools/deploy.py configs/mmpose/pose_demo_onnxruntime-fp16_static_256.py D:\DownloadProject\mmpose\configs\body_2d_keypoint\topdown_heatmap\coco\xiaozhuanzi.py D:\DownloadProject\mmpose\work_dirs\xiaozhuanzi\epoch_420.pth pose_demo.png --work-dir work_dirs --show

Reproduces the problem - error message

meta_data is none, how can i solve this

Additional information

i think it might be something wrong with config files

52THANOS avatar Aug 10 '23 09:08 52THANOS

base = [ './pose-detection_static.py', '../base/backends/onnxruntime-fp16.py' ] this is my config file

52THANOS avatar Aug 10 '23 09:08 52THANOS

Hi, thanks for using MMPose. Could you provide which script you are running and the whole config file?

LareinaM avatar Aug 22 '23 05:08 LareinaM

Hi, thanks for using MMPose. Could you provide which script you are running and the whole config file? configs/mmpose/pose-detection_onnxruntime-fp16_static.py base = [ './pose-detection_static.py', '../base/backends/onnxruntime-fp16.py' ] actually this file is in mmdeploy , i found that it can not get my custom dataset file in mmpose. here is my config file that use in mmdeloy to convert my model into onnx.

base = ['../../../base/default_runtime.py']

runtime

train_cfg = dict(max_epochs=420, val_interval=10)

optimizer

custom_imports = dict( imports=['mmpose.engine.optim_wrappers.layer_decay_optim_wrapper'], allow_failed_imports=False)

optim_wrapper = dict( optimizer=dict( type='AdamW', lr=5e-4, betas=(0.9, 0.999), weight_decay=0.1), paramwise_cfg=dict( num_layers=12, layer_decay_rate=0.8, custom_keys={ 'bias': dict(decay_multi=0.0), 'pos_embed': dict(decay_mult=0.0), 'relative_position_bias_table': dict(decay_mult=0.0), 'norm': dict(decay_mult=0.0), }, ), constructor='LayerDecayOptimWrapperConstructor', clip_grad=dict(max_norm=1., norm_type=2), )

learning policy

param_scheduler = [ dict( type='LinearLR', begin=0, end=500, start_factor=0.001, by_epoch=False), # warm-up dict( type='MultiStepLR', begin=0, end=210, milestones=[170, 200], gamma=0.1, by_epoch=True) ]

automatically scaling LR based on the actual training batch size

auto_scale_lr = dict(base_batch_size=512)

hooks

default_hooks = dict( checkpoint=dict(save_best='coco/AP', rule='greater', max_keep_ckpts=1))

codec settings

codec = dict( type='UDPHeatmap', input_size=(192, 256), heatmap_size=(48, 64), sigma=2)

model settings

model = dict( type='TopdownPoseEstimator', data_preprocessor=dict( type='PoseDataPreprocessor', mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], bgr_to_rgb=True), backbone=dict( type='mmcls.VisionTransformer', arch={ 'embed_dims': 384, 'num_layers': 12, 'num_heads': 12, 'feedforward_channels': 384 * 4 }, img_size=(256, 192), patch_size=16, qkv_bias=True, drop_path_rate=0.1, with_cls_token=False, output_cls_token=False, patch_cfg=dict(padding=2), init_cfg=dict( type='Pretrained', checkpoint='https://download.openmmlab.com/mmpose/' 'v1/pretrained_models/mae_pretrain_vit_small.pth'), ), head=dict( type='HeatmapHead', in_channels=384, out_channels=2, deconv_out_channels=(256, 256), deconv_kernel_sizes=(4, 4), loss=dict(type='KeypointMSELoss', use_target_weight=True), decoder=codec), test_cfg=dict( flip_test=True, flip_mode='heatmap', shift_heatmap=False, ))

base dataset settings

data_root = 'xiaozhuanzi/' dataset_type = 'xiaozhuanziDataset' data_mode = 'topdown'

pipelines

train_pipeline = [ dict(type='LoadImage'), dict(type='GetBBoxCenterScale'), dict(type='RandomFlip', direction='horizontal'), dict(type='RandomHalfBody'), dict(type='RandomBBoxTransform'), dict(type='TopdownAffine', input_size=codec['input_size'], use_udp=True), dict(type='GenerateTarget', encoder=codec), dict(type='PackPoseInputs') ] val_pipeline = [ dict(type='LoadImage'), dict(type='GetBBoxCenterScale'), dict(type='TopdownAffine', input_size=codec['input_size'], use_udp=True), dict(type='PackPoseInputs') ]

data loaders

train_dataloader = dict( batch_size=32, num_workers=4, persistent_workers=True, sampler=dict(type='DefaultSampler', shuffle=True), dataset=dict( type=dataset_type, data_root=data_root, data_mode=data_mode, ann_file='annotations/train.json', data_prefix=dict(img='train/'), pipeline=train_pipeline, )) val_dataloader = dict( batch_size=32, num_workers=4, persistent_workers=True, drop_last=False, sampler=dict(type='DefaultSampler', shuffle=False, round_up=False), dataset=dict( type=dataset_type, data_root=data_root, data_mode=data_mode, ann_file='annotations/val.json', # bbox_file='data/coco/person_detection_results/' # 'COCO_val2017_detections_AP_H_56_person.json', data_prefix=dict(img='val2017/'), test_mode=True, pipeline=val_pipeline, )) test_dataloader = val_dataloader

evaluators

val_evaluator = dict( type='CocoMetric', ann_file=data_root + 'annotations/val.json') test_evaluator = val_evaluator

52THANOS avatar Aug 22 '23 06:08 52THANOS

Hi @52THANOS , we are not sure about the script and dataset you are trying to use, but the error message may suggest that you did not provide the meta information. Please follow our doc on customizing datasets.

LareinaM avatar Aug 24 '23 07:08 LareinaM

Hi @52THANOS , we are not sure about the script and dataset you are trying to use, but the error message may suggest that you did not provide the meta information. Please follow our doc on customizing datasets.

i add metainfo in my config ,but it did not work out.

auto_scale_lr = dict(base_batch_size=512) backend_args = dict(backend='local') codec = dict( heatmap_size=( 48, 64, ), input_size=( 192, 256, ), sigma=2, type='UDPHeatmap') custom_hooks = [ dict(type='SyncBuffersHook'), ] custom_imports = dict( allow_failed_imports=False, imports=[ 'mmpose.engine.optim_wrappers.layer_decay_optim_wrapper', ]) data_mode = 'topdown' data_root = 'spine/' dataset_type = 'spineDataset' default_hooks = dict( checkpoint=dict( interval=10, max_keep_ckpts=1, rule='greater', save_best='coco/AP', type='CheckpointHook'), logger=dict(interval=50, type='LoggerHook'), param_scheduler=dict(type='ParamSchedulerHook'), sampler_seed=dict(type='DistSamplerSeedHook'), timer=dict(type='IterTimerHook'), visualization=dict(enable=False, type='PoseVisualizationHook')) default_scope = 'mmpose' env_cfg = dict( cudnn_benchmark=False, dist_cfg=dict(backend='nccl'), mp_cfg=dict(mp_start_method='fork', opencv_num_threads=0)) launcher = 'none' load_from = None log_level = 'INFO' log_processor = dict( by_epoch=True, num_digits=6, type='LogProcessor', window_size=50) model = dict( backbone=dict( arch=dict( embed_dims=384, feedforward_channels=1536, num_heads=12, num_layers=12), drop_path_rate=0.1, img_size=( 256, 192, ), init_cfg=dict( checkpoint= 'https://download.openmmlab.com/mmpose/v1/pretrained_models/mae_pretrain_vit_small.pth', type='Pretrained'), output_cls_token=False, patch_cfg=dict(padding=2), patch_size=16, qkv_bias=True, type='mmcls.VisionTransformer', with_cls_token=False), data_preprocessor=dict( bgr_to_rgb=True, mean=[ 123.675, 116.28, 103.53, ], std=[ 58.395, 57.12, 57.375, ], type='PoseDataPreprocessor'), head=dict( decoder=dict( heatmap_size=( 48, 64, ), input_size=( 192, 256, ), sigma=2, type='UDPHeatmap'), deconv_kernel_sizes=( 4, 4, ), deconv_out_channels=( 256, 256, ), in_channels=384, loss=dict(type='KeypointMSELoss', use_target_weight=True), out_channels=17, type='HeatmapHead'), test_cfg=dict(flip_mode='heatmap', flip_test=True, shift_heatmap=False), type='TopdownPoseEstimator') optim_wrapper = dict( clip_grad=dict(max_norm=1.0, norm_type=2), constructor='LayerDecayOptimWrapperConstructor', optimizer=dict( betas=( 0.9, 0.999, ), lr=0.0005, type='AdamW', weight_decay=0.1), paramwise_cfg=dict( custom_keys=dict( bias=dict(decay_multi=0.0), norm=dict(decay_mult=0.0), pos_embed=dict(decay_mult=0.0), relative_position_bias_table=dict(decay_mult=0.0)), layer_decay_rate=0.8, num_layers=12)) param_scheduler = [ dict( begin=0, by_epoch=False, end=500, start_factor=0.001, type='LinearLR'), dict( begin=0, by_epoch=True, end=210, gamma=0.1, milestones=[ 170, 200, ], type='MultiStepLR'), ] resume = False test_cfg = dict() test_dataloader = dict( batch_size=32, dataset=dict( ann_file='annotations/val2017.json', data_mode='topdown', data_prefix=dict(img='val_verse/'), data_root='spine/', pipeline=[ dict(type='LoadImage'), dict(type='GetBBoxCenterScale'), dict(input_size=( 192, 256, ), type='TopdownAffine', use_udp=True), dict(type='PackPoseInputs'), ], test_mode=True, type='spineDataset'), drop_last=False, num_workers=4, persistent_workers=True, sampler=dict(round_up=False, shuffle=False, type='DefaultSampler')) test_evaluator = dict( ann_file='spine/annotations/val2017.json', type='CocoMetric') train_cfg = dict(by_epoch=True, max_epochs=420, val_interval=10) train_dataloader = dict( batch_size=32, dataset=dict( ann_file='annotations/train2017.json', data_mode='topdown', data_prefix=dict(img='train_verse/'), data_root='spine/', metainfo=dict(from_file='configs/base/datasets/spine.py'), pipeline=[ dict(type='LoadImage'), dict(type='GetBBoxCenterScale'), dict(direction='horizontal', type='RandomFlip'), dict(type='RandomHalfBody'), dict(type='RandomBBoxTransform'), dict(input_size=( 192, 256, ), type='TopdownAffine', use_udp=True), dict( encoder=dict( heatmap_size=( 48, 64, ), input_size=( 192, 256, ), sigma=2, type='UDPHeatmap'), type='GenerateTarget'), dict(type='PackPoseInputs'), ], type='spineDataset'), num_workers=4, persistent_workers=True, sampler=dict(shuffle=True, type='DefaultSampler')) train_pipeline = [ dict(type='LoadImage'), dict(type='GetBBoxCenterScale'), dict(direction='horizontal', type='RandomFlip'), dict(type='RandomHalfBody'), dict(type='RandomBBoxTransform'), dict(input_size=( 192, 256, ), type='TopdownAffine', use_udp=True), dict( encoder=dict( heatmap_size=( 48, 64, ), input_size=( 192, 256, ), sigma=2, type='UDPHeatmap'), type='GenerateTarget'), dict(type='PackPoseInputs'), ] val_cfg = dict() val_dataloader = dict( batch_size=32, dataset=dict( ann_file='annotations/val2017.json', data_mode='topdown', data_prefix=dict(img='val_verse/'), data_root='spine/', pipeline=[ dict(type='LoadImage'), dict(type='GetBBoxCenterScale'), dict(input_size=( 192, 256, ), type='TopdownAffine', use_udp=True), dict(type='PackPoseInputs'), ], test_mode=True, type='spineDataset'), drop_last=False, num_workers=4, persistent_workers=True, sampler=dict(round_up=False, shuffle=False, type='DefaultSampler')) val_evaluator = dict( ann_file='spine/annotations/val2017.json', type='CocoMetric') val_pipeline = [ dict(type='LoadImage'), dict(type='GetBBoxCenterScale'), dict(input_size=( 192, 256, ), type='TopdownAffine', use_udp=True), dict(type='PackPoseInputs'), ] vis_backends = [ dict(type='LocalVisBackend'), ] visualizer = dict( name='visualizer', type='PoseLocalVisualizer', vis_backends=[ dict(type='LocalVisBackend'), ]) work_dir = './work_dirs\spine'

52THANOS avatar Aug 25 '23 05:08 52THANOS

i added metainfo in train and val dataloader, it seems useless. my script python tools/deploy.py configs/mmpose/pose-detection_onnxruntime-fp16_static.py D:\DownloadProject\mmpose\configs\body_2d_keypoint\topdown_heatmap\coco\spine.py D:\DownloadProject\mmpose\work_dirs\spine\epoch_420.pth D:\DownloadProject\mmpose\spine\test_verse\3_2_600.png

52THANOS avatar Aug 25 '23 05:08 52THANOS

Hi @52THANOS , we are not sure about the script and dataset you are trying to use, but the error message may suggest that you did not provide the meta information. Please follow our doc on customizing datasets.

i debugged the code finding that the dataset type is based on module_dict. the content of module_dict are all baseDataset such as cocostyle or mpii etc. even though my custom dataset is based on cocodataset , the code seems can not get that. metainfo did not help with that.

module_dict = DATASETS.module_dict for dataloader_name in [ 'test_dataloader', 'val_dataloader', 'train_dataloader' ]: if dataloader_name not in model_cfg: continue dataloader_cfg = model_cfg[dataloader_name] dataset_cfg = dataloader_cfg.dataset dataset_mmpose = module_dict.get(dataset_cfg.type, None)

52THANOS avatar Aug 25 '23 07:08 52THANOS

What was the solution to this in the end?

bc-arl avatar Oct 01 '23 22:10 bc-arl

What was the solution to this in the end?

problems are not solved

52THANOS avatar Oct 12 '23 03:10 52THANOS

@Tau-J This is in-place and not solved. Please open it and resolve

Priyanshu88 avatar Mar 13 '24 05:03 Priyanshu88

Sorry for closing it by mistakes, and it is reopened now. However, we cannot reproduce this error with the provided information. It seems occur when exporting onnx model, maybe you guys can raise an issue to mmdeploy.

Tau-J avatar Mar 13 '24 05:03 Tau-J

My traceback is coming from below: File "/opt/conda/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1190, in _call_impl return forward_call(*input, **kwargs) File "/opt/conda/lib/python3.9/site-packages/mmpose/models/data_preprocessors/data_preprocessor.py", line 94, in forward for data_sample, pad_shape in zip(data_samples, batch_pad_shape): TypeError: 'NoneType' object is not iterable

Priyanshu88 avatar Mar 13 '24 05:03 Priyanshu88

Sorry for closing it by mistakes, and it is reopened now. However, we cannot reproduce this error with the provided information. It seems occur when exporting onnx model, maybe you guys can raise an issue to mmdeploy.

I raised this issue last year in mmdeploy. But no one solve it.

52THANOS avatar Mar 13 '24 05:03 52THANOS

Sorry for closing it by mistakes, and it is reopened now. However, we cannot reproduce this error with the provided information. It seems occur when exporting onnx model, maybe you guys can raise an issue to mmdeploy.

I raised this issue last year in mmdeploy. But no one solve it.

I'm sorry but it's hard for us to reproduce the error with the information you provide, because you are training with your own customized dataset. And you did not privide necessary information like the traceback, the minimum code snippet that can reproduce the error, etc.

Tau-J avatar Mar 13 '24 06:03 Tau-J

My traceback is coming from below: File "/opt/conda/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1190, in _call_impl return forward_call(*input, **kwargs) File "/opt/conda/lib/python3.9/site-packages/mmpose/models/data_preprocessors/data_preprocessor.py", line 94, in forward for data_sample, pad_shape in zip(data_samples, batch_pad_shape): TypeError: 'NoneType' object is not iterable

According to the traceback, I suggest checking the path of you training data(json & imgs). This error usually occurs when the training imgs are not found, especially when you set a wrong path in your config.

For example, your dataset path should be '{data_root}/{img}/' when your img is stored at aaa/bbb/c.jpg:

train_dataloader = dict(
    ...
    dataset=dict(
        type=dataset_type,
        data_root='aaa',
        ann_file='path/to/your/train/json',
        data_prefix=dict(img='bbb'),
        # specify dataset meta information
        metainfo=dict(from_file='configs/_base_/datasets/custom.py'),
        ...),
)

Tau-J avatar Mar 13 '24 06:03 Tau-J

Feel free to look into my detailed rtmo config everything is configured properly even the same data paths works for rtmpose config.

auto_scale_lr = dict(base_batch_size=256)
backend_args = dict(backend='local')
codec = dict(
    input_size=(
        640,
        640,
    ), type='YOLOXPoseAnnotationProcessor')
custom_hooks = [
    dict(
        new_train_pipeline=[
            dict(type='LoadImage'),
            dict(
                bbox_keep_corner=False,
                clip_border=True,
                input_size=(
                    640,
                    640,
                ),
                pad_val=(
                    114,
                    114,
                    114,
                ),
                rotate_prob=0,
                scale_prob=0,
                scale_type='long',
                shift_prob=0,
                type='BottomupRandomAffine'),
            dict(type='YOLOXHSVRandomAug'),
            dict(type='RandomFlip'),
            dict(get_invalid=True, type='BottomupGetHeatmapMask'),
            dict(
                by_box=True,
                by_kpt=True,
                keep_empty=False,
                type='FilterAnnotations'),
            dict(
                encoder=dict(
                    input_size=(
                        640,
                        640,
                    ),
                    type='YOLOXPoseAnnotationProcessor'),
                type='GenerateTarget'),
            dict(type='PackPoseInputs'),
        ],
        num_last_epochs=20,
        priority=48,
        type='YOLOXPoseModeSwitchHook'),
    dict(
        epoch_attributes=dict({
            280:
            dict({
                'loss_mle.loss_weight': 5.0,
                'loss_oks.loss_weight': 10.0,
                'proxy_target_cc': True
            })
        }),
        priority=48,
        type='RTMOModeSwitchHook'),
    dict(priority=48, type='SyncNormHook'),
    dict(
        ema_type='ExpMomentumEMA',
        momentum=0.0002,
        priority=49,
        strict_load=False,
        type='EMAHook',
        update_buffers=True),
]
data_mode = 'bottomup'
data_root = 'ABC/data/'
dataset_coco = dict(
    ann_file='root/annotations/person_keypoints_train2017.json',
    data_mode='bottomup',
    data_prefix=dict(img='root/train2017/'),
    data_root='ABC/data/',
    pipeline=[
        dict(backend_args=None, type='LoadImage'),
        dict(
            img_scale=(
                640,
                640,
            ),
            pad_val=114.0,
            pre_transform=[
                dict(backend_args=None, type='LoadImage'),
            ],
            type='Mosaic'),
        dict(
            bbox_keep_corner=False,
            clip_border=True,
            distribution='uniform',
            input_size=(
                640,
                640,
            ),
            pad_val=114,
            rotate_factor=10,
            scale_factor=(
                0.75,
                1.0,
            ),
            shift_factor=0.1,
            transform_mode='perspective',
            type='BottomupRandomAffine'),
        dict(
            img_scale=(
                640,
                640,
            ),
            pad_val=114.0,
            pre_transform=[
                dict(backend_args=None, type='LoadImage'),
            ],
            ratio_range=(
                0.8,
                1.6,
            ),
            type='YOLOXMixUp'),
        dict(type='YOLOXHSVRandomAug'),
        dict(type='RandomFlip'),
        dict(
            by_box=True,
            by_kpt=True,
            keep_empty=False,
            type='FilterAnnotations'),
        dict(
            encoder=dict(
                input_size=(
                    640,
                    640,
                ), type='YOLOXPoseAnnotationProcessor'),
            type='GenerateTarget'),
        dict(type='PackPoseInputs'),
    ],
    type='CocoDataset')
deepen_factor = 0.33
default_hooks = dict(
    badcase=dict(
        badcase_thr=5,
        enable=False,
        metric_type='loss',
        out_dir='badcase',
        type='BadCaseAnalysisHook'),
    checkpoint=dict(interval=40, max_keep_ckpts=3, type='CheckpointHook'),
    logger=dict(interval=50, type='LoggerHook'),
    param_scheduler=dict(type='ParamSchedulerHook'),
    sampler_seed=dict(type='DistSamplerSeedHook'),
    timer=dict(type='IterTimerHook'),
    visualization=dict(enable=False, type='PoseVisualizationHook'))
default_scope = 'mmpose'
env_cfg = dict(
    cudnn_benchmark=False,
    dist_cfg=dict(backend='nccl'),
    mp_cfg=dict(mp_start_method='fork', opencv_num_threads=0))
input_size = (
    640,
    640,
)
load_from = None
log_level = 'INFO'
log_processor = dict(
    by_epoch=True, num_digits=6, type='LogProcessor', window_size=50)
metafile = 'dataset_coco.py'
model = dict(
    backbone=dict(
        act_cfg=dict(type='Swish'),
        deepen_factor=0.33,
        init_cfg=dict(
            checkpoint=
            'https://download.openmmlab.com/mmdetection/v2.0/yolox/yolox_s_8x8_300e_coco/yolox_s_8x8_300e_coco_20211121_095711-4592a793.pth',
            prefix='backbone.',
            type='Pretrained'),
        norm_cfg=dict(eps=0.001, momentum=0.03, type='BN'),
        out_indices=(
            2,
            3,
            4,
        ),
        spp_kernal_sizes=(
            5,
            9,
            13,
        ),
        type='CSPDarknet',
        widen_factor=0.5),
    data_preprocessor=dict(
        batch_augments=[
            dict(
                interval=1,
                random_size_range=(
                    480,
                    800,
                ),
                size_divisor=32,
                type='BatchSyncRandomResize'),
        ],
        mean=[
            0,
            0,
            0,
        ],
        pad_size_divisor=32,
        std=[
            1,
            1,
            1,
        ],
        type='PoseDataPreprocessor'),
    head=dict(
        assigner=dict(
            dynamic_k_indicator='oks',
            oks_calculator=dict(
                metainfo='dataset_coco.py', type='PoseOKS'),
            type='SimOTAAssigner',
            use_keypoints_for_center=True),
        dcc_cfg=dict(
            feat_channels=128,
            gau_cfg=dict(
                act_fn='SiLU',
                drop_path=0.0,
                dropout_rate=0.0,
                expansion_factor=2,
                pos_enc='add',
                s=128),
            in_channels=256,
            num_bins=(
                192,
                256,
            ),
            spe_channels=128),
        featmap_strides=(
            16,
            32,
        ),
        head_module_cfg=dict(
            act_cfg=dict(type='Swish'),
            channels_per_group=36,
            cls_feat_channels=256,
            in_channels=256,
            norm_cfg=dict(eps=0.001, momentum=0.03, type='BN'),
            num_classes=1,
            pose_vec_channels=256,
            stacked_convs=2,
            widen_factor=0.5),
        loss_bbox=dict(
            eps=1e-16,
            loss_weight=5.0,
            mode='square',
            reduction='sum',
            type='IoULoss'),
        loss_bbox_aux=dict(loss_weight=1.0, reduction='sum', type='L1Loss'),
        loss_cls=dict(
            loss_weight=1.0,
            reduction='sum',
            type='VariFocalLoss',
            use_target_weight=True),
        loss_mle=dict(
            loss_weight=1.0, type='MLECCLoss', use_target_weight=True),
        loss_oks=dict(
            loss_weight=30.0,
            metainfo='dataset_coco.py',
            reduction='none',
            type='OKSLoss'),
        loss_vis=dict(
            loss_weight=1.0,
            reduction='mean',
            type='BCELoss',
            use_target_weight=True),
        num_keypoints=17,
        overlaps_power=0.5,
        prior_generator=dict(
            centralize_points=True,
            strides=[
                16,
                32,
            ],
            type='MlvlPointGenerator'),
        type='RTMOHead'),
    init_cfg=dict(
        a=2.23606797749979,
        distribution='uniform',
        layer='Conv2d',
        mode='fan_in',
        nonlinearity='leaky_relu',
        type='Kaiming'),
    neck=dict(
        deepen_factor=0.33,
        encoder_cfg=dict(
            ffn_cfg=dict(
                act_cfg=dict(type='GELU'),
                embed_dims=256,
                feedforward_channels=1024,
                ffn_drop=0.0),
            self_attn_cfg=dict(dropout=0.0, embed_dims=256, num_heads=8)),
        hidden_dim=256,
        in_channels=[
            128,
            256,
            512,
        ],
        output_indices=[
            1,
            2,
        ],
        projector=dict(
            act_cfg=None,
            in_channels=[
                256,
                256,
            ],
            kernel_size=1,
            norm_cfg=dict(type='BN'),
            num_outs=2,
            out_channels=256,
            type='ChannelMapper'),
        type='HybridEncoder',
        widen_factor=0.5),
    test_cfg=dict(input_size=(
        640,
        640,
    ), nms_thr=0.65, score_thr=0.1),
    type='BottomupPoseEstimator')
optim_wrapper = dict(
    clip_grad=dict(max_norm=0.1, norm_type=2),
    constructor='ForceDefaultOptimWrapperConstructor',
    optimizer=dict(lr=0.004, type='AdamW', weight_decay=0.05),
    paramwise_cfg=dict(
        bias_decay_mult=0,
        bypass_duplicate=True,
        custom_keys=dict({'neck.encoder': dict(lr_mult=0.05)}),
        force_default_settings=True,
        norm_decay_mult=0),
    type='OptimWrapper')
param_scheduler = [
    dict(
        begin=0,
        by_epoch=True,
        convert_to_iter_based=True,
        end=5,
        type='QuadraticWarmupLR'),
    dict(
        T_max=280,
        begin=5,
        by_epoch=True,
        convert_to_iter_based=True,
        end=280,
        eta_min=0.0002,
        type='CosineAnnealingLR'),
    dict(begin=280, by_epoch=True, end=281, factor=2.5, type='ConstantLR'),
    dict(
        T_max=300,
        begin=281,
        by_epoch=True,
        convert_to_iter_based=True,
        end=580,
        eta_min=0.0002,
        type='CosineAnnealingLR'),
    dict(begin=580, by_epoch=True, end=600, factor=1, type='ConstantLR'),
]
resume = False
test_cfg = dict()
test_dataloader = dict(
    batch_size=1,
    dataset=dict(
        ann_file='root/annotations/person_keypoints_val2017.json',
        data_mode='bottomup',
        data_prefix=dict(img='root/val2017/'),
        data_root='ABC/data/',
        pipeline=[
            dict(type='LoadImage'),
            dict(
                input_size=(
                    640,
                    640,
                ),
                pad_val=(
                    114,
                    114,
                    114,
                ),
                type='BottomupResize'),
            dict(
                meta_keys=(
                    'id',
                    'img_id',
                    'img_path',
                    'ori_shape',
                    'img_shape',
                    'input_size',
                    'input_center',
                    'input_scale',
                ),
                type='PackPoseInputs'),
        ],
        test_mode=True,
        type='CocoDataset'),
    drop_last=False,
    num_workers=2,
    persistent_workers=True,
    pin_memory=True,
    sampler=dict(round_up=False, shuffle=False, type='DefaultSampler'))
test_evaluator = dict(
    ann_file='ABC/data/root/annotations/person_keypoints_val2017.json',
    nms_mode='none',
    score_mode='bbox',
    type='CocoMetric')
train_cfg = dict(
    by_epoch=True,
    dynamic_intervals=[
        (
            580,
            1,
        ),
    ],
    max_epochs=600,
    val_interval=20)
train_dataloader = dict(
    batch_size=32,
    dataset=dict(
        ann_file='root/annotations/person_keypoints_train2017.json',
        data_mode='bottomup',
        data_prefix=dict(img='root/train2017/'),
        data_root='ABC/data/',
        pipeline=[
            dict(backend_args=None, type='LoadImage'),
            dict(
                img_scale=(
                    640,
                    640,
                ),
                pad_val=114.0,
                pre_transform=[
                    dict(backend_args=None, type='LoadImage'),
                ],
                type='Mosaic'),
            dict(
                bbox_keep_corner=False,
                clip_border=True,
                distribution='uniform',
                input_size=(
                    640,
                    640,
                ),
                pad_val=114,
                rotate_factor=10,
                scale_factor=(
                    0.75,
                    1.0,
                ),
                shift_factor=0.1,
                transform_mode='perspective',
                type='BottomupRandomAffine'),
            dict(
                img_scale=(
                    640,
                    640,
                ),
                pad_val=114.0,
                pre_transform=[
                    dict(backend_args=None, type='LoadImage'),
                ],
                ratio_range=(
                    0.8,
                    1.6,
                ),
                type='YOLOXMixUp'),
            dict(type='YOLOXHSVRandomAug'),
            dict(type='RandomFlip'),
            dict(
                by_box=True,
                by_kpt=True,
                keep_empty=False,
                type='FilterAnnotations'),
            dict(
                encoder=dict(
                    input_size=(
                        640,
                        640,
                    ),
                    type='YOLOXPoseAnnotationProcessor'),
                type='GenerateTarget'),
            dict(type='PackPoseInputs'),
        ],
        type='CocoDataset'),
    num_workers=8,
    persistent_workers=True,
    pin_memory=True,
    sampler=dict(shuffle=True, type='DefaultSampler'))
train_pipeline_stage1 = [
    dict(backend_args=None, type='LoadImage'),
    dict(
        img_scale=(
            640,
            640,
        ),
        pad_val=114.0,
        pre_transform=[
            dict(backend_args=None, type='LoadImage'),
        ],
        type='Mosaic'),
    dict(
        bbox_keep_corner=False,
        clip_border=True,
        distribution='uniform',
        input_size=(
            640,
            640,
        ),
        pad_val=114,
        rotate_factor=10,
        scale_factor=(
            0.75,
            1.0,
        ),
        shift_factor=0.1,
        transform_mode='perspective',
        type='BottomupRandomAffine'),
    dict(
        img_scale=(
            640,
            640,
        ),
        pad_val=114.0,
        pre_transform=[
            dict(backend_args=None, type='LoadImage'),
        ],
        ratio_range=(
            0.8,
            1.6,
        ),
        type='YOLOXMixUp'),
    dict(type='YOLOXHSVRandomAug'),
    dict(type='RandomFlip'),
    dict(by_box=True, by_kpt=True, keep_empty=False, type='FilterAnnotations'),
    dict(
        encoder=dict(
            input_size=(
                640,
                640,
            ), type='YOLOXPoseAnnotationProcessor'),
        type='GenerateTarget'),
    dict(type='PackPoseInputs'),
]
train_pipeline_stage2 = [
    dict(type='LoadImage'),
    dict(
        bbox_keep_corner=False,
        clip_border=True,
        input_size=(
            640,
            640,
        ),
        pad_val=(
            114,
            114,
            114,
        ),
        rotate_prob=0,
        scale_prob=0,
        scale_type='long',
        shift_prob=0,
        type='BottomupRandomAffine'),
    dict(type='YOLOXHSVRandomAug'),
    dict(type='RandomFlip'),
    dict(get_invalid=True, type='BottomupGetHeatmapMask'),
    dict(by_box=True, by_kpt=True, keep_empty=False, type='FilterAnnotations'),
    dict(
        encoder=dict(
            input_size=(
                640,
                640,
            ), type='YOLOXPoseAnnotationProcessor'),
        type='GenerateTarget'),
    dict(type='PackPoseInputs'),
]
val_cfg = dict()
val_dataloader = dict(
    batch_size=1,
    dataset=dict(
        ann_file='root/annotations/person_keypoints_val2017.json',
        data_mode='bottomup',
        data_prefix=dict(img='root/val2017/'),
        data_root='ABC/data/',
        pipeline=[
            dict(type='LoadImage'),
            dict(
                input_size=(
                    640,
                    640,
                ),
                pad_val=(
                    114,
                    114,
                    114,
                ),
                type='BottomupResize'),
            dict(
                meta_keys=(
                    'id',
                    'img_id',
                    'img_path',
                    'ori_shape',
                    'img_shape',
                    'input_size',
                    'input_center',
                    'input_scale',
                ),
                type='PackPoseInputs'),
        ],
        test_mode=True,
        type='CocoDataset'),
    drop_last=False,
    num_workers=2,
    persistent_workers=True,
    pin_memory=True,
    sampler=dict(round_up=False, shuffle=False, type='DefaultSampler'))
val_evaluator = dict(
    ann_file='ABC/data/root/annotations/person_keypoints_val2017.json',
    nms_mode='none',
    score_mode='bbox',
    type='CocoMetric')
val_pipeline = [
    dict(type='LoadImage'),
    dict(
        input_size=(
            640,
            640,
        ),
        pad_val=(
            114,
            114,
            114,
        ),
        type='BottomupResize'),
    dict(
        meta_keys=(
            'id',
            'img_id',
            'img_path',
            'ori_shape',
            'img_shape',
            'input_size',
            'input_center',
            'input_scale',
        ),
        type='PackPoseInputs'),
]
vis_backends = [
    dict(type='LocalVisBackend'),
]
visualizer = dict(
    name='visualizer',
    type='PoseLocalVisualizer',
    vis_backends=[
        dict(type='LocalVisBackend'),
    ])
widen_factor = 0.5

Priyanshu88 avatar Mar 13 '24 06:03 Priyanshu88

Hi @Priyanshu88 ,MMPose will load the img from ${MMPOSE}/ABC/data/root/train2017/, e.g. ${MMPOSE}/ABC/data/root/train2017/000001.jpg. ${MMPOSE} means the installation directory of mmpose. Is this the correct path?

data_root = 'ABC/data/'
dataset_coco = dict(
    ann_file='root/annotations/person_keypoints_train2017.json',
    data_mode='bottomup',
    data_prefix=dict(img='root/train2017/'),
    data_root='ABC/data/',

Tau-J avatar Mar 13 '24 06:03 Tau-J

File "/opt/conda/lib/python3.9/site-packages/mmpose/models/data_preprocessors/data_preprocessor.py"

It seems that you install mmpose via pip install mmpose. We recommend install mmpose as follows:

git clone https://github.com/open-mmlab/mmpose.git
cd mmpose
pip install -r requirements.txt
pip install -v -e .

Tau-J avatar Mar 13 '24 07:03 Tau-J

I reinstalled using the suggested method but the error still persists. Also regarding the data path the same paths are working for rtmpose. Note that this problem only exists when trying pruning with rtmo not while training rtmo generally. I have modified using this pruning config to run the job.

Priyanshu88 avatar Mar 13 '24 07:03 Priyanshu88

Hi @Priyanshu88 , RTMO is not supported to conduct pruning.

Tau-J avatar Mar 13 '24 07:03 Tau-J

Can you please look into this since it is interconnected and related to dataset part. I tried debugging it and figured out that it is even before going into pruning fisher config.

Here is the detailed traceback you might want to refer:

 runner = Runner.from_cfg(cfg)
  File "/opt/conda/lib/python3.9/site-packages/mmengine/runner/runner.py", line 462, in from_cfg
    runner = cls(
  File "/opt/conda/lib/python3.9/site-packages/mmengine/runner/runner.py", line 429, in __init__
    self.model = self.build_model(model)
  File "/opt/conda/lib/python3.9/site-packages/mmengine/runner/runner.py", line 836, in build_model
    model = MODELS.build(model)
  File "/opt/conda/lib/python3.9/site-packages/mmengine/registry/registry.py", line 570, in build
    return self.build_func(cfg, *args, **kwargs, registry=self)
  File "/opt/conda/lib/python3.9/site-packages/mmengine/registry/build_functions.py", line 232, in build_model_from_cfg
    return build_from_cfg(cfg, registry, default_args)
  File "/opt/conda/lib/python3.9/site-packages/mmengine/registry/build_functions.py", line 121, in build_from_cfg
    obj = obj_cls(**args)  # type: ignore
  File "/mmrazor/mmrazor/implementations/pruning/group_fisher/algorithm.py", line 57, in __init__
    self.mutator.prepare_from_supernet(self.architecture)
  File "/mmrazor/mmrazor/models/mutators/channel_mutator/channel_mutator.py", line 113, in prepare_from_supernet
    units = self._prepare_from_tracer(supernet, self.parse_cfg)
  File "/mmrazor/mmrazor/models/mutators/channel_mutator/channel_mutator.py", line 311, in _prepare_from_tracer
    unit_configs = tracer.analyze(model)
  File "/mmrazor/mmrazor/models/task_modules/tracer/channel_analyzer.py", line 107, in analyze
    fx_graph = self._fx_trace(model)
  File "/mmrazor/mmrazor/models/task_modules/tracer/channel_analyzer.py", line 132, in _fx_trace
    args = self.demo_input.get_data(model)
  File "/mmrazor/mmrazor/models/task_modules/demo_inputs/demo_inputs.py", line 34, in get_data
    data = self._get_data(model, input_shape, training)
  File "/mmrazor/mmrazor/models/task_modules/demo_inputs/default_demo_inputs.py", line 108, in _get_data
    return defaul_demo_inputs(model, input_shape, training, self.scope)
  File "/mmrazor/mmrazor/models/task_modules/demo_inputs/default_demo_inputs.py", line 79, in defaul_demo_inputs
    return demo_input().get_data(model, input_shape, training)
  File "/mmrazor/mmrazor/models/task_modules/demo_inputs/demo_inputs.py", line 34, in get_data
    data = self._get_data(model, input_shape, training)
  File "/mmrazor/mmrazor/models/task_modules/demo_inputs/demo_inputs.py", line 57, in _get_data
    data = self._get_mm_data(model, input_shape, training)
  File "/mmrazor/mmrazor/models/task_modules/demo_inputs/demo_inputs.py", line 63, in _get_mm_data
    data = model.data_preprocessor(data, training)
  File "/opt/conda/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1190, in _call_impl
    return forward_call(*input, **kwargs)
  File "/mmpose/mmpose/mmpose/models/data_preprocessors/data_preprocessor.py", line 94, in forward
    for data_sample, pad_shape in zip(data_samples, batch_pad_shape):
TypeError: 'NoneType' object is not iterable

Priyanshu88 avatar Mar 13 '24 07:03 Priyanshu88