TypeError: train_step() got an unexpected keyword argument 'optim_wrapper' #1984
Unanswered
TSLNIHAOGIT
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
把旧版本的mmocr文件复制到最新的版本,然后训练时报错:TypeError: train_step() got an unexpected keyword argument 'optim_wrapper',该如何解决呢?
以下是一些配置信息:
09/14 16:33:26 - mmengine - INFO - Config:
PAD = 42
TRAIN_STATE = True
alphabet_file = './tools/data/alphabet/structure_alphabet.txt'
alphabet_len = 39
checkpoint_config = dict(interval=1)
dataset_type = 'OCRDataset'
default_hooks = dict(
checkpoint=dict(interval=1, type='CheckpointHook'),
logger=dict(interval=100, type='LoggerHook'),
param_scheduler=dict(type='ParamSchedulerHook'),
sampler_seed=dict(type='DistSamplerSeedHook'),
sync_buffer=dict(type='SyncBuffersHook'),
timer=dict(type='IterTimerHook'),
visualization=dict(
draw_gt=False,
draw_pred=False,
enable=False,
interval=1,
show=False,
type='VisualizationHook'))
default_scope = 'mmocr'
env_cfg = dict(
cudnn_benchmark=False,
dist_cfg=dict(backend='nccl'),
mp_cfg=dict(mp_start_method='fork', opencv_num_threads=0))
evaluation = dict(interval=1, metric='acc')
fp16 = dict(loss_scale='dynamic')
img_norm_cfg = dict(
mean=[
0.5,
0.5,
0.5,
], std=[
0.5,
0.5,
0.5,
])
label_convertor = dict(
dict_file='./tools/data/alphabet/structure_alphabet.txt',
max_seq_len=500,
start_end_same=False,
type='TableMasterConvertor',
with_unknown=True)
launcher = 'none'
load_from = None
log_config = dict(
hooks=[
dict(type='TextLoggerHook'),
], interval=100)
log_level = 'INFO'
log_processor = dict(by_epoch=True, type='LogProcessor', window_size=10)
lr_config = dict(
policy='step',
step=[
12,
15,
],
warmup='linear',
warmup_iters=50,
warmup_ratio=0.3333333333333333)
max_seq_len = 500
model = dict(
backbone=dict(
gcb_config=dict(
att_scale=False,
fusion_type='channel_add',
headers=1,
layers=[
False,
True,
True,
True,
],
ratio=0.0625),
input_dim=3,
layers=[
1,
2,
5,
3,
],
type='TableResNetExtra'),
bbox_loss=dict(reduction='sum', type='TableL1Loss'),
decoder=dict(
N=3,
d_model=512,
decoder=dict(
dropout=0.0,
feed_forward=dict(d_ff=2024, d_model=512, dropout=0.0),
self_attn=dict(d_model=512, dropout=0.0, headers=8),
size=512,
src_attn=dict(d_model=512, dropout=0.0, headers=8)),
type='TableMasterDecoder'),
encoder=dict(
d_model=512, dropout=0.2, max_len=5000, type='PositionalEncoding'),
label_convertor=dict(
dict_file='./tools/data/alphabet/structure_alphabet.txt',
max_seq_len=500,
start_end_same=False,
type='TableMasterConvertor',
with_unknown=True),
loss=dict(ignore_index=42, reduction='mean', type='MASTERTFLoss'),
max_seq_len=500,
type='TABLEMASTER')
optim_wrapper = dict(
optimizer=dict(lr=0.0003, type='Adam'), type='OptimWrapper')
param_scheduler = [
dict(factor=1.0, type='ConstantLR'),
]
randomness = dict(seed=None)
resume = False
resume_from = None
start_end_same = False
test = dict(
ann_file='/data_0/dataset/processed_data/lmdb/StructureLabel_val/',
dataset_info='table_master_dataset',
img_prefix='/data_0/dataset/pubtabnet/val/',
loader=dict(
max_seq_len=500,
parser=dict(
keys=[
'filename',
'text',
],
keys_idx=[
0,
1,
],
separator=' ',
type='TableMASTERLmdbParser'),
repeat=1,
type='TableMASTERLmdbLoader'),
pipeline=[
dict(type='LoadImageFromNdarrayV2'),
dict(keep_ratio=True, long_size=480, type='TableResize'),
dict(
mask_ratio=(
8,
8,
),
pad_val=0,
return_mask=True,
size=(
480,
480,
),
train_state=True,
type='TablePad'),
dict(type='ToTensorOCR'),
dict(
mean=[
0.5,
0.5,
0.5,
], std=[
0.5,
0.5,
0.5,
], type='NormalizeOCR'),
dict(
keys=[
'img',
],
meta_keys=[
'filename',
'ori_shape',
'img_shape',
'scale_factor',
'img_norm_cfg',
'ori_filename',
'pad_shape',
],
type='Collect'),
],
test_mode=True,
type='OCRDataset')
test_anno_file1 = '/data_0/dataset/processed_data/lmdb/StructureLabel_val/'
test_img_prefix = '/data_0/dataset/pubtabnet/val/'
test_pipeline = [
dict(type='LoadImageFromNdarrayV2'),
dict(keep_ratio=True, long_size=480, type='TableResize'),
dict(
mask_ratio=(
8,
8,
),
pad_val=0,
return_mask=True,
size=(
480,
480,
),
train_state=True,
type='TablePad'),
dict(type='ToTensorOCR'),
dict(mean=[
0.5,
0.5,
0.5,
], std=[
0.5,
0.5,
0.5,
], type='NormalizeOCR'),
dict(
keys=[
'img',
],
meta_keys=[
'filename',
'ori_shape',
'img_shape',
'scale_factor',
'img_norm_cfg',
'ori_filename',
'pad_shape',
],
type='Collect'),
]
total_epochs = 17
train1 = dict(
ann_file='/data_0/dataset/processed_data/lmdb/StructureLabel_train/',
img_prefix='/data_0/dataset/pubtabnet/train/',
loader=dict(
max_seq_len=500,
parser=dict(
keys=[
'filename',
'text',
],
keys_idx=[
0,
1,
],
separator=' ',
type='TableMASTERLmdbParser'),
repeat=1,
type='TableMASTERLmdbLoader'),
pipeline=[
dict(type='LoadImageFromNdarrayV2'),
dict(keep_ratio=True, long_size=480, type='TableResize'),
dict(
mask_ratio=(
8,
8,
),
pad_val=0,
return_mask=True,
size=(
480,
480,
),
train_state=True,
type='TablePad'),
dict(type='TableBboxEncode'),
dict(type='ToTensorOCR'),
dict(
mean=[
0.5,
0.5,
0.5,
], std=[
0.5,
0.5,
0.5,
], type='NormalizeOCR'),
dict(
keys=[
'img',
],
meta_keys=[
'filename',
'ori_shape',
'img_shape',
'text',
'scale_factor',
'bbox',
'bbox_masks',
'pad_shape',
],
type='Collect'),
],
test_mode=False,
type='OCRDataset')
train_anno_file1 = '/data_0/dataset/processed_data/lmdb/StructureLabel_train/'
train_cfg = dict(max_epochs=100, type='EpochBasedTrainLoop', val_interval=10)
train_dataloader = dict(
batch_size=2,
dataset=[
dict(
ann_file=
'/data_0/dataset/processed_data/lmdb/StructureLabel_train/',
img_prefix='/data_0/dataset/pubtabnet/train/',
loader=dict(
max_seq_len=500,
parser=dict(
keys=[
'filename',
'text',
],
keys_idx=[
0,
1,
],
separator=' ',
type='TableMASTERLmdbParser'),
repeat=1,
type='TableMASTERLmdbLoader'),
pipeline=[
dict(type='LoadImageFromNdarrayV2'),
dict(keep_ratio=True, long_size=480, type='TableResize'),
dict(
mask_ratio=(
8,
8,
),
pad_val=0,
return_mask=True,
size=(
480,
480,
),
train_state=True,
type='TablePad'),
dict(type='TableBboxEncode'),
dict(type='ToTensorOCR'),
dict(
mean=[
0.5,
0.5,
0.5,
],
std=[
0.5,
0.5,
0.5,
],
type='NormalizeOCR'),
dict(
keys=[
'img',
],
meta_keys=[
'filename',
'ori_shape',
'img_shape',
'text',
'scale_factor',
'bbox',
'bbox_masks',
'pad_shape',
],
type='Collect'),
],
test_mode=False,
type='OCRDataset'),
],
num_workers=2,
persistent_workers=True,
sampler=dict(shuffle=True, type='DefaultSampler'))
train_img_prefix = '/data_0/dataset/pubtabnet/train/'
train_pipeline = [
dict(type='LoadImageFromNdarrayV2'),
dict(keep_ratio=True, long_size=480, type='TableResize'),
dict(
mask_ratio=(
8,
8,
),
pad_val=0,
return_mask=True,
size=(
480,
480,
),
train_state=True,
type='TablePad'),
dict(type='TableBboxEncode'),
dict(type='ToTensorOCR'),
dict(mean=[
0.5,
0.5,
0.5,
], std=[
0.5,
0.5,
0.5,
], type='NormalizeOCR'),
dict(
keys=[
'img',
],
meta_keys=[
'filename',
'ori_shape',
'img_shape',
'text',
'scale_factor',
'bbox',
'bbox_masks',
'pad_shape',
],
type='Collect'),
]
tta_model = dict(type='EncoderDecoderRecognizerTTAModel')
valid = dict(
ann_file='/data_0/dataset/processed_data/lmdb/StructureLabel_val/',
dataset_info='table_master_dataset',
img_prefix='/data_0/dataset/pubtabnet/val/',
loader=dict(
max_seq_len=500,
parser=dict(
keys=[
'filename',
'text',
],
keys_idx=[
0,
1,
],
separator=' ',
type='TableMASTERLmdbParser'),
repeat=1,
type='TableMASTERLmdbLoader'),
pipeline=[
dict(type='LoadImageFromNdarrayV2'),
dict(keep_ratio=True, long_size=480, type='TableResize'),
dict(
mask_ratio=(
8,
8,
),
pad_val=0,
return_mask=True,
size=(
480,
480,
),
train_state=True,
type='TablePad'),
dict(type='TableBboxEncode'),
dict(type='ToTensorOCR'),
dict(
mean=[
0.5,
0.5,
0.5,
], std=[
0.5,
0.5,
0.5,
], type='NormalizeOCR'),
dict(
keys=[
'img',
],
meta_keys=[
'filename',
'ori_shape',
'img_shape',
'scale_factor',
'img_norm_cfg',
'ori_filename',
'bbox',
'bbox_masks',
'pad_shape',
],
type='Collect'),
],
test_mode=True,
type='OCRDataset')
valid_anno_file1 = '/data_0/dataset/processed_data/lmdb/StructureLabel_val/'
valid_img_prefix = '/data_0/dataset/pubtabnet/val/'
valid_pipeline = [
dict(type='LoadImageFromNdarrayV2'),
dict(keep_ratio=True, long_size=480, type='TableResize'),
dict(
mask_ratio=(
8,
8,
),
pad_val=0,
return_mask=True,
size=(
480,
480,
),
train_state=True,
type='TablePad'),
dict(type='TableBboxEncode'),
dict(type='ToTensorOCR'),
dict(mean=[
0.5,
0.5,
0.5,
], std=[
0.5,
0.5,
0.5,
], type='NormalizeOCR'),
dict(
keys=[
'img',
],
meta_keys=[
'filename',
'ori_shape',
'img_shape',
'scale_factor',
'img_norm_cfg',
'ori_filename',
'bbox',
'bbox_masks',
'pad_shape',
],
type='Collect'),
]
vis_backends = [
dict(type='LocalVisBackend'),
]
visualizer = dict(
name='visualizer',
type='TextRecogLocalVisualizer',
vis_backends=[
dict(type='LocalVisBackend'),
])
work_dir = './work_dirs/table_master_lmdb_ResnetExtract_Ranger_0930'
workflow = [
(
'train',
1,
),
]
09/14 16:33:32 - mmengine - INFO - Distributed training is not used, all SyncBatchNorm (SyncBN) layers in the model will be automatically reverted to BatchNormXd layers if they are used.
09/14 16:33:32 - mmengine - INFO - Hooks will be executed in the following order:
before_run:
(VERY_HIGH ) RuntimeInfoHook
(BELOW_NORMAL) LoggerHook
before_train:
(VERY_HIGH ) RuntimeInfoHook
(NORMAL ) IterTimerHook
(VERY_LOW ) CheckpointHook
before_train_epoch:
(VERY_HIGH ) RuntimeInfoHook
(NORMAL ) IterTimerHook
(NORMAL ) DistSamplerSeedHook
before_train_iter:
(VERY_HIGH ) RuntimeInfoHook
(NORMAL ) IterTimerHook
after_train_iter:
(VERY_HIGH ) RuntimeInfoHook
(NORMAL ) IterTimerHook
(BELOW_NORMAL) LoggerHook
(LOW ) ParamSchedulerHook
(VERY_LOW ) CheckpointHook
after_train_epoch:
(NORMAL ) IterTimerHook
(NORMAL ) SyncBuffersHook
(LOW ) ParamSchedulerHook
(VERY_LOW ) CheckpointHook
before_val:
(VERY_HIGH ) RuntimeInfoHook
before_val_epoch:
(NORMAL ) IterTimerHook
(NORMAL ) SyncBuffersHook
before_val_iter:
(NORMAL ) IterTimerHook
after_val_iter:
(NORMAL ) IterTimerHook
(NORMAL ) VisualizationHook
(BELOW_NORMAL) LoggerHook
after_val_epoch:
(VERY_HIGH ) RuntimeInfoHook
(NORMAL ) IterTimerHook
(BELOW_NORMAL) LoggerHook
(LOW ) ParamSchedulerHook
(VERY_LOW ) CheckpointHook
after_val:
(VERY_HIGH ) RuntimeInfoHook
after_train:
(VERY_HIGH ) RuntimeInfoHook
(VERY_LOW ) CheckpointHook
before_test:
(VERY_HIGH ) RuntimeInfoHook
before_test_epoch:
(NORMAL ) IterTimerHook
before_test_iter:
(NORMAL ) IterTimerHook
after_test_iter:
(NORMAL ) IterTimerHook
(NORMAL ) VisualizationHook
(BELOW_NORMAL) LoggerHook
after_test_epoch:
(VERY_HIGH ) RuntimeInfoHook
(NORMAL ) IterTimerHook
(BELOW_NORMAL) LoggerHook
after_test:
(VERY_HIGH ) RuntimeInfoHook
after_run:
(BELOW_NORMAL) LoggerHook
09/14 16:33:32 - mmengine - WARNING - Dataset list has no metainfo.
dataset_meta
in visualizer will be None.09/14 16:33:33 - mmengine - WARNING - "FileClient" will be deprecated in future. Please use io functions in https://mmengine.readthedocs.io/en/latest/api/fileio.html#file-io
09/14 16:33:33 - mmengine - WARNING - "HardDiskBackend" is the alias of "LocalBackend" and the former will be deprecated in future.
09/14 16:33:33 - mmengine - INFO - Checkpoints will be saved to /mnt/e/python_project_new/mmocr/work_dirs/table_master_lmdb_ResnetExtract_Ranger_0930.
Traceback (most recent call last):
File "/mnt/e/python_project_new/mmocr/tools/train.py", line 116, in
main()
File "/mnt/e/python_project_new/mmocr/tools/train.py", line 112, in main
runner.train()
File "/home/future/miniconda3/lib/python3.8/site-packages/mmengine/runner/runner.py", line 1745, in train
model = self.train_loop.run() # type: ignore
File "/home/future/miniconda3/lib/python3.8/site-packages/mmengine/runner/loops.py", line 96, in run
self.run_epoch()
File "/home/future/miniconda3/lib/python3.8/site-packages/mmengine/runner/loops.py", line 112, in run_epoch
self.run_iter(idx, data_batch)
File "/home/future/miniconda3/lib/python3.8/site-packages/mmengine/runner/loops.py", line 128, in run_iter
outputs = self.runner.model.train_step(
TypeError: train_step() got an unexpected keyword argument 'optim_wrapper'
Beta Was this translation helpful? Give feedback.
All reactions