open-mmlab / mmdetection

OpenMMLab Detection Toolbox and Benchmark
https://mmdetection.readthedocs.io
Apache License 2.0
29.02k stars 9.36k forks source link

'Recognizer3D is not in the mmengine::model registry. #11028

Open superme3322 opened 11 months ago

superme3322 commented 11 months ago

When I trained C3d with my own data set(RawframeDataset), I used the file ‘\mmaction2\configs\recognition\c3d\c3d_sports1m-pretrained_8xb30-16x1x1-45e_fight-rgb.py’ It calls the 'base/models/c3d_sports1m_pretrained.py' file, And report an error [KeyError: 'Recognizer3D is not in the mmengine::model registry. Please check whether the value of Recognizer3D is correct or it was registered as expected. More details can be found at https://mmengine.readthedocs.io/en/latest/advanced_tutorials/config.html#import-the-custom-module']

c3d_sports1m-pretrained_8xb30-16x1x1-45e_fight-rgb.py `

base = [ '../../base/models/c3d_sports1m_pretrained.py',

'../../base/default_runtime.py'

]

dataset_type = 'RawframeDataset' data_root = 'data/fight/rawframes' data_root_val = 'data/fight/rawframes' split = 3 # official train/test splits. valid numbers: 1, 2, 3 ann_file_train = f'data/fight/fight_trainsplit{split}_rawframes.txt' ann_file_val = f'data/fight/fight_valsplit{split}_rawframes.txt' ann_file_test = f'data/fight/fight_valsplit{split}_rawframes.txt' img_norm_cfg = dict(mean=[104, 117, 128], std=[1, 1, 1], to_bgr=False)#

file_client_args = dict(io_backend='disk')

train_pipeline = [

dict(type='DecordInit', **file_client_args),

dict(type='SampleFrames', clip_len=16, frame_interval=1, num_clips=1),
dict(type='RawFrameDecode'),#
dict(type='Normalize', **img_norm_cfg),#
dict(type='Collect', keys=['imgs', 'label'], meta_keys=[]),#
dict(type='ToTensor', keys=['imgs', 'label']),#

#dict(type='DecordDecode'),
dict(type='Resize', scale=(128, 171)),
dict(type='RandomCrop', size=112),
dict(type='Flip', flip_ratio=0.5),
dict(type='FormatShape', input_format='NCTHW'),
#dict(type='PackActionInputs')

] val_pipeline = [

dict(type='DecordInit', **file_client_args),

dict(
    type='SampleFrames',
    clip_len=16,
    frame_interval=1,
    num_clips=1,
    test_mode=True),
dict(type='RawFrameDecode'),#

dict(type='DecordDecode'),
dict(type='Resize', scale=(128, 171)),
dict(type='CenterCrop', crop_size=112),
dict(type='FormatShape', input_format='NCTHW'),
dict(type='PackActionInputs')

] test_pipeline = [

dict(type='DecordInit', **file_client_args),

dict(
    type='SampleFrames',
    clip_len=16,
    frame_interval=1,
    num_clips=10,
    test_mode=True),
#dict(type='DecordDecode'),    
dict(type='RawFrameDecode'),#
dict(type='Normalize', **img_norm_cfg),#
dict(type='Collect', keys=['imgs', 'label'], meta_keys=[]),#
dict(type='ToTensor', keys=['imgs', 'label']),#
dict(type='Resize', scale=(128, 171)),
dict(type='CenterCrop', crop_size=112),
dict(type='FormatShape', input_format='NCTHW'),
#dict(type='PackActionInputs')

]

train_dataloader = dict( batch_size=20, num_workers=8, persistent_workers=True, sampler=dict(type='DefaultSampler', shuffle=True), dataset=dict( type=dataset_type, ann_file=ann_file_train, data_prefix=dict(video=data_root), pipeline=train_pipeline)) val_dataloader = dict( batch_size=5, num_workers=8, persistent_workers=True, sampler=dict(type='DefaultSampler', shuffle=False), dataset=dict( type=dataset_type, ann_file=ann_file_val, data_prefix=dict(video=data_root_val), pipeline=val_pipeline, test_mode=True)) test_dataloader = dict( batch_size=1, num_workers=8, persistent_workers=True, sampler=dict(type='DefaultSampler', shuffle=False), dataset=dict( type=dataset_type, ann_file=ann_file_test, data_prefix=dict(video=data_root_val), pipeline=test_pipeline, test_mode=True))

val_evaluator = dict(type='AccMetric') test_evaluator = val_evaluator

train_cfg = dict( type='EpochBasedTrainLoop', max_epochs=20, val_begin=1, val_interval=5) val_cfg = dict(type='ValLoop') test_cfg = dict(type='TestLoop')

param_scheduler = [ dict( type='MultiStepLR', begin=0, end=20, by_epoch=True, milestones=[10, 40], gamma=0.1) ]

optim_wrapper = dict( optimizer=dict(type='SGD', lr=0.001, momentum=0.9, weight_decay=0.0005), clip_grad=dict(max_norm=40, norm_type=2))

default_hooks = dict(checkpoint=dict(interval=5))

auto_scale_lr = dict(enable=False, base_batch_size=240)

`

c3d_sports1m_pretrained.py `

model settings

model = dict( type='Recognizer3D', backbone=dict( type='C3D', pretrained= # noqa: E251 'https://download.openmmlab.com/mmaction/recognition/c3d/c3d_sports1m_pretrain_20201016-dcc47ddc.pth', # noqa: E501 style='pytorch', conv_cfg=dict(type='Conv3d'), norm_cfg=None, act_cfg=dict(type='ReLU'), dropout_ratio=0.5, init_std=0.005), cls_head=dict( type='I3DHead', num_classes=2, in_channels=4096, spatial_type=None, dropout_ratio=0.5, init_std=0.01,

average_clips='prob'),

#data_preprocessor=dict(
    #type='ActionDataPreprocessor',
    #mean=[104, 117, 128],
    #std=[1, 1, 1],
    #format_shape='NCTHW'),
train_cfg=None,
#test_cfg=None    
test_cfg=dict(average_clips='score')))

`

dvskabangira commented 10 months ago

hi, iam experiencing the same error, did you manage to resolve it

Ktour123 commented 1 month ago

hi, iam experiencing the same error, did you manage to resolve it