Open fupogirl opened 2 years ago
It seems like error of wrong dataset config, the batch size (like here) should be defined.
As for customization dataset, you could check out this doc from https://github.com/open-mmlab/mmsegmentation/pull/1522.
I suggest you follow the _base_
dataset config we provided and import it correctly in your config file, you could checkout your full config output in your training log.
If you still meet error, please attach total config parameters in log and we would try to solve it.
base = [ '../base/models/deeplabv3_unet_s5-d16.py', '../base/datasets/drive.py', '../base/default_runtime.py', '../base/schedules/schedule_40k.py' ] model = dict(test_cfg=dict(crop_size=(64, 64), stride=(42, 42))) evaluation = dict(metric='mDice')
No change
It seems like error of wrong dataset config, the batch size (like here) should be defined.
As for customization dataset, you could check out this doc from #1522.
I suggest you follow the
_base_
dataset config we provided and import it correctly in your config file, you could checkout your full config output in your training log.If you still meet error, please attach total config parameters in log and we would try to solve it.
Only my data set drive was downloaded from the official website in a different format, and then converted, divided the images and annotations and training and validation according to the official format, and changed the format in mmsegmentation\mmseg\core\evaluation\class_ names.py added the drive But still this problem, how to solve
It seems like error of wrong dataset config, the batch size (like here) should be defined. As for customization dataset, you could check out this doc from #1522. I suggest you follow the
_base_
dataset config we provided and import it correctly in your config file, you could checkout your full config output in your training log. If you still meet error, please attach total config parameters in log and we would try to solve it.Only my data set drive was downloaded from the official website in a different format, and then converted, divided the images and annotations and training and validation according to the official format, and changed the format in mmsegmentation\mmseg\core\evaluation\class_ names.py added the drive But still this problem, how to solve
Why dont you use drive config file we provided? YOU TOTALLY DO NOT IMPORT YOUR DRIVE CONFIG FILE.
base = [
'../base/models/deeplabv3_unet_s5-d16.py', '../base/datasets/drive.py',
'../base/default_runtime.py', '../base/schedules/schedule_40k.py'
]
It would inherit https://github.com/open-mmlab/mmsegmentation/blob/master/configs/_base_/datasets/drive.py.
Please check out carefully.
Hello everyone, I am trying to fine to the "segmenter_vit-s_linear_8x1_512x512_160k_ade20k" model on another small-sized dataset. But whenever I am trying to train the model, it is showing an error stating that it expects a 4d input but gets a 3d input. I know the 4th dimension is the batch size but I am not getting exactly where to change the batch_size in the configuration file or how to modify my input 2d RGB images. Below is the code for configuration:
from mmcv import Config cfg = Config.fromfile('configs/segmenter/segmenter_vit-s_mask_8x1_512x512_160k_ade20k.py')
from mmseg.apis import set_random_seed
cfg.norm_cfg = dict(type='BN', requires_grad=True) cfg.model.backbone.norm_cfg = cfg.norm_cfg #######cfg.model.backbone.mlp_ratio = 8 #################### cfg.model.decode_head.norm_cfg = cfg.norm_cfg
cfg.model.decode_head.num_classes = 8
cfg.dataset_type = 'StanfordBackgroundDataset_rescaled' cfg.data_root = data_root
cfg.data.samples_per_gpu = 1 cfg.data.workers_per_gpu=1
cfg.img_norm_cfg = dict( mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True) cfg.crop_size = (256, 256) cfg.train_pipeline = [ dict(type='LoadImageFromFile'), dict(type='LoadAnnotations'), dict(type='Resize', img_scale=(2048, 512), ratio_range=(0.5, 2.0)), dict(type='RandomCrop', crop_size=cfg.crop_size, cat_max_ratio=0.75), dict(type='RandomFlip', flip_ratio=0.5), dict(type='PhotoMetricDistortion'), dict(type='Normalize', **cfg.img_norm_cfg), dict(type='Pad', size=cfg.crop_size, pad_val=0, seg_pad_val=255), dict(type='DefaultFormatBundle'), dict(type='Collect', keys=['img', 'gt_semantic_seg']), ]
cfg.test_pipeline = [ dict(type='LoadImageFromFile'), dict( type='MultiScaleFlipAug', img_scale=(2048, 512), flip=False, transforms=[ dict(type='Resize', keep_ratio=True), dict(type='RandomFlip'), dict(type='Normalize', **cfg.img_norm_cfg), dict(type='ImageToTensor', keys=['img']), dict(type='Collect', keys=['img']), ]) ]
cfg.data.train.type = cfg.dataset_type cfg.data.train.data_root = cfg.data_root cfg.data.train.img_dir = img_dir cfg.data.train.ann_dir = ann_dir cfg.data.train.pipeline = cfg.train_pipeline cfg.data.train.split = 'splits/train.txt'
cfg.data.val.type = cfg.dataset_type cfg.data.val.data_root = cfg.data_root cfg.data.val.img_dir = img_dir cfg.data.val.ann_dir = ann_dir cfg.data.val.pipeline = cfg.test_pipeline cfg.data.val.split = 'splits/val.txt'
cfg.data.test.type = cfg.dataset_type cfg.data.test.data_root = cfg.data_root cfg.data.test.img_dir = img_dir cfg.data.test.ann_dir = ann_dir cfg.data.test.pipeline = cfg.test_pipeline cfg.data.test.split = 'splits/val.txt'
cfg.load_from = 'checkpoints/segmenter_vit-s_mask_8x1_512x512_160k_ade20k_20220105_151706-511bb103.pth'
cfg.work_dir = './work_dirs/tutorial'
cfg.runner.max_iters = 200 cfg.log_config.interval = 10 cfg.evaluation.interval = 200 cfg.checkpoint_config.interval = 200
cfg.seed = 0 set_random_seed(0, deterministic=False) cfg.gpu_ids = range(1) cfg.device = 'cuda' ############################
print(f'Config:\n{cfg.pretty_text}')
Below is the code for training the new dataset which is showing the error:
from mmseg.datasets import build_dataset from mmseg.models import build_segmentor from mmseg.apis import train_segmentor
datasets = [build_dataset(cfg.data.train)]
model = build_segmentor(cfg.model)
model.CLASSES = datasets[0].CLASSES
mmcv.mkdir_or_exist(osp.abspath(cfg.work_dir)) train_segmentor(model, datasets, cfg, distributed=False, validate=True, meta=dict())
Below I have atttached the screenshot of the error:
How to solve it