open-mmlab / mmpretrain

OpenMMLab Pre-training Toolbox and Benchmark
https://mmpretrain.readthedocs.io/en/latest/
Apache License 2.0
3.45k stars 1.07k forks source link

[Bug] I encountered a problem while fine-tuning the model on a custom dataset. #1748

Open Leezp99 opened 1 year ago

Leezp99 commented 1 year ago

Branch

main branch (mmpretrain version)

Describe the bug

I followed the instructions at https://mmpretrain.readthedocs.io/zh_CN/latest/notes/finetune_custom_dataset.html to fine-tune the model, but I encountered an issue in the custom dataset: "init() got an unexpected keyword argument 'split'". How can I resolve this problem? I noticed that someone else has also faced the same issue. Can you tell me how to fix it? The link is here: "https://github.com/open-mmlab/mmpretrain/discussions/1696".

Environment

base = [ '../base/models/resnet50.py', '../base/datasets/imagenet_bs32.py', '../base/schedules/imagenet_bs256.py', '../base/default_runtime.py' ]

模型设置

model = dict( backbone=dict( frozen_stages=2, init_cfg=dict( type='Pretrained', checkpoint='https://download.openmmlab.com/mmclassification/v0/resnet/resnet50_8xb32_in1k_20210831-ea4938fc.pth', prefix='backbone', )), head=dict(num_classes=12), )

数据设置

data_root = 'data/custom_dataset' train_dataloader = dict( batch_size=256, dataset=dict( type='CustomDataset', data_root=data_root, ann_file='', data_prefix='train', with_label=True, )) val_dataloader = dict( dataset=dict( type='CustomDataset', data_root=data_root, ann_file='', data_prefix='val', with_label=True, )) test_dataloader = dict( dataset=dict( type='CustomDataset', data_root=data_root, ann_file='', data_prefix='test', with_label=True, ))

test_dataloader = val_dataloader

训练策略设置

optim_wrapper = dict( optimizer=dict(type='SGD', lr=0.01, momentum=0.9, weight_decay=0.0001)) param_scheduler = dict( type='MultiStepLR', by_epoch=True, milestones=[15], gamma=0.1)

Other information

No response

Ezra-Yu commented 1 year ago

what's your mmegine, mmpretrain, mmcv version?

Kailthen commented 1 year ago

same error

fenghuoxiguozu commented 1 year ago

add split='' to class CustomDataset,i solved this issue image

csaroff commented 11 months ago

Is a fix for this gonna land? I'm just following the basic custom dataset docs that the OP mentioned. This is my first time using the library and it doesn't give me warm-fuzzy's that the tutorial has been broken since at least August