-
Hi, how to use MMSelfSup to train a model on my own dataset? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 8 replies
-
There is an example for COCO dataset. #511 |
Beta Was this translation helpful? Give feedback.
-
We provide an example of MAE on my own dataset, which have no labels. Please use the 1.x branch of MMSelfSup. The documentation website is: https://mmselfsup.readthedocs.io/en/1.x/ _base_ = [
'../_base_/models/mae_vit-base-p16.py',
# '../_base_/datasets/imagenet_mae.py', # removed
'../_base_/schedules/adamw_coslr-200e_in1k.py',
'../_base_/default_runtime.py',
]
#<<<<<<< modified <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
# custom dataset
dataset_type = 'mmcls.CustomDataset'
data_root = 'data/sbu/'
file_client_args = dict(backend='disk')
train_pipeline = [
dict(type='LoadImageFromFile', file_client_args=file_client_args),
dict(
type='RandomResizedCrop',
size=224,
scale=(0.2, 1.0),
backend='pillow',
interpolation='bicubic'),
dict(type='RandomFlip', prob=0.5),
dict(type='PackSelfSupInputs', meta_keys=['img_path'])
]
# dataset 8 x 512
train_dataloader = dict(
batch_size=512,
num_workers=8,
persistent_workers=True,
sampler=dict(type='DefaultSampler', shuffle=True),
collate_fn=dict(type='default_collate'),
dataset=dict(
type=dataset_type,
data_root=data_root,
# ann_file='meta/train.txt', # removed if you don't have the annotation file
data_prefix=dict(img_path='./'),
pipeline=train_pipeline))
#>>>>>>>>>> modified >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
# optimizer wrapper
optimizer = dict(
type='AdamW', lr=1.5e-4 * 4096 / 256, betas=(0.9, 0.95), weight_decay=0.05)
optim_wrapper = dict(
type='OptimWrapper',
optimizer=optimizer,
paramwise_cfg=dict(
custom_keys={
'ln': dict(decay_mult=0.0),
'bias': dict(decay_mult=0.0),
'pos_embed': dict(decay_mult=0.),
'mask_token': dict(decay_mult=0.),
'cls_token': dict(decay_mult=0.)
}))
# learning rate scheduler
param_scheduler = [
dict(
type='LinearLR',
start_factor=1e-4,
by_epoch=True,
begin=0,
end=40,
convert_to_iter_based=True),
dict(
type='CosineAnnealingLR',
T_max=360,
by_epoch=True,
begin=40,
end=400,
convert_to_iter_based=True)
]
# runtime settings
# pre-train for 400 epochs
train_cfg = dict(max_epochs=400)
default_hooks = dict(
logger=dict(type='LoggerHook', interval=100),
# only keeps the latest 3 checkpoints
checkpoint=dict(type='CheckpointHook', interval=1, max_keep_ckpts=3))
# randomness
randomness = dict(seed=0, diff_rank_seed=True)
resume = True Feel free to ask question for using custom dataset. |
Beta Was this translation helpful? Give feedback.
-
I am using the above config, but I would like to initialize from weights in model zoo. So I added following line in config However, I am getting following warnings and it seems that state dicts are different due to additional prefix
|
Beta Was this translation helpful? Give feedback.
We provide an example of MAE on my own dataset, which have no labels.
Please use the 1.x branch of MMSelfSup.
The documentation website is: https://mmselfsup.readthedocs.io/en/1.x/
Please follow this documentaion to install the latest version of MMSelfsup