I get this error when I run the train.py in MMSeg.
File "/usr/local/envs/open-mmlab/lib/python3.7/site-packages/torch/nn/functional.py", line 3473, in interpolate "size shape must match input shape. " "Input is {}D, size is {}".format(dim, len(size))
ValueError: size shape must match input shape. Input is 2D, size is 3
Extra Info:
Config:
model = dict(
type='EncoderDecoder',
pretrained='open-mmlab://resnet18_v1c',
backbone=dict(
type='ResNetV1c',
depth=18,
num_stages=4,
out_indices=(0, 1, 2, 3),
dilations=(1, 1, 2, 4),
strides=(1, 2, 1, 1),
norm_cfg=dict(type='BN', requires_grad=True),
norm_eval=False,
style='pytorch',
contract_dilation=True),
decode_head=dict(
type='DepthwiseSeparableASPPHead',
in_channels=512,
in_index=3,
channels=128,
dilations=(1, 12, 24, 36),
c1_in_channels=64,
c1_channels=12,
dropout_ratio=0.1,
num_classes=3,
norm_cfg=dict(type='BN', requires_grad=True),
align_corners=False,
loss_decode=dict(
type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0)),
auxiliary_head=dict(
type='FCNHead',
in_channels=256,
in_index=2,
channels=64,
num_convs=1,
concat_input=False,
dropout_ratio=0.1,
num_classes=3,
norm_cfg=dict(type='BN', requires_grad=True),
align_corners=False,
loss_decode=dict(
type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4)),
train_cfg=dict(),
test_cfg=dict(mode='whole'))
dataset_type = 'Lumitec'
data_root = '/content/mmseg-dl-pipeline/data/aug3'
img_norm_cfg = dict(
mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True)
crop_size = (1024, 1024)
train_pipeline = [
dict(type='LoadImageFromFile'),
dict(type='LoadAnnotations'),
dict(type='Resize', img_scale=(2048, 1024), ratio_range=(0.5, 2.0)),
dict(type='RandomCrop', crop_size=(1024, 1024), cat_max_ratio=0.75),
dict(type='RandomFlip', prob=0.5),
dict(type='PhotoMetricDistortion'),
dict(
type='Normalize',
mean=[123.675, 116.28, 103.53],
std=[58.395, 57.12, 57.375],
to_rgb=True),
dict(type='Pad', size=(1024, 1024), pad_val=0, seg_pad_val=255),
dict(type='DefaultFormatBundle'),
dict(type='Collect', keys=['img', 'gt_semantic_seg'])
]
test_pipeline = [
dict(type='LoadImageFromFile'),
dict(
type='MultiScaleFlipAug',
img_scale=(2048, 1024),
flip=False,
transforms=[
dict(type='Resize', keep_ratio=True),
dict(type='RandomFlip'),
dict(
type='Normalize',
mean=[123.675, 116.28, 103.53],
std=[58.395, 57.12, 57.375],
to_rgb=True),
dict(type='ImageToTensor', keys=['img']),
dict(type='Collect', keys=['img'])
])
]
data = dict(
samples_per_gpu=4,
workers_per_gpu=8,
train=dict(
type='Lumitec',
data_root='/content/mmseg-dl-pipeline/data/aug3',
img_dir='/content/mmseg-dl-pipeline/data/aug3/img/img_train',
ann_dir='/content/mmseg-dl-pipeline/data/aug3/ann/ann_train',
pipeline=[
dict(type='LoadImageFromFile'),
dict(type='LoadAnnotations'),
dict(
type='Resize', img_scale=(2048, 1024), ratio_range=(0.5, 2.0)),
dict(
type='RandomCrop', crop_size=(1024, 1024), cat_max_ratio=0.75),
dict(type='RandomFlip', prob=0.5),
dict(type='PhotoMetricDistortion'),
dict(
type='Normalize',
mean=[123.675, 116.28, 103.53],
std=[58.395, 57.12, 57.375],
to_rgb=True),
dict(type='Pad', size=(1024, 1024), pad_val=0, seg_pad_val=255),
dict(type='DefaultFormatBundle'),
dict(type='Collect', keys=['img', 'gt_semantic_seg'])
]),
val=dict(
type='Lumitec',
data_root='/content/mmseg-dl-pipeline/data/aug3',
img_dir='/content/mmseg-dl-pipeline/data/aug3/img/img_test',
ann_dir='/content/mmseg-dl-pipeline/data/aug3/ann/ann_test',
pipeline=[
dict(type='LoadImageFromFile'),
dict(
type='MultiScaleFlipAug',
img_scale=(2048, 1024),
flip=False,
transforms=[
dict(type='Resize', keep_ratio=True),
dict(type='RandomFlip'),
dict(
type='Normalize',
mean=[123.675, 116.28, 103.53],
std=[58.395, 57.12, 57.375],
to_rgb=True),
dict(type='ImageToTensor', keys=['img']),
dict(type='Collect', keys=['img'])
])
]),
test=dict(
type='Lumitec',
data_root='/content/mmseg-dl-pipeline/data/aug3',
img_dir='/content/mmseg-dl-pipeline/data/aug3/img/img_test',
ann_dir='/content/mmseg-dl-pipeline/data/aug3/ann/ann_test',
pipeline=[
dict(type='LoadImageFromFile'),
dict(
type='MultiScaleFlipAug',
img_scale=(2048, 1024),
flip=False,
transforms=[
dict(type='Resize', keep_ratio=True),
dict(type='RandomFlip'),
dict(
type='Normalize',
mean=[123.675, 116.28, 103.53],
std=[58.395, 57.12, 57.375],
to_rgb=True),
dict(type='ImageToTensor', keys=['img']),
dict(type='Collect', keys=['img'])
])
]))
log_config = dict(
interval=200, hooks=[dict(type='TextLoggerHook', by_epoch=False)])
dist_params = dict(backend='nccl')
log_level = 'INFO'
load_from = '/content/mmseg-dl-pipeline/checkpoints/deeplabv3plus_r18-d8_512x1024_80k_cityscapes_20201226_080942-cff257fe.pth'
resume_from = None
workflow = [('train', 1)]
cudnn_benchmark = True
optimizer = dict(type='SGD', lr=0.01, momentum=0.9, weight_decay=0.0005)
optimizer_config = dict()
lr_config = dict(policy='poly', power=0.9, min_lr=0.0001, by_epoch=False)
runner = dict(type='IterBasedRunner', max_iters=10000)
checkpoint_config = dict(by_epoch=False, interval=1000)
evaluation = dict(interval=200, metric='mIoU', pre_eval=True)
work_dir = '/content/mmseg-dl-pipeline/work_dirs'
seed = 0
gpu_ids = range(0, 1)
2022-05-17 14:41:39,721 - mmseg - INFO - Loaded 852 images
******** <mmseg.datasets.lumitec.Lumitec object at 0x7f00e2bbf150>
/content/mmseg-v0/mmseg/models/backbones/resnet.py:431: UserWarning: DeprecationWarning: pretrained is a deprecated, please use "init_cfg" instead
warnings.warn('DeprecationWarning: pretrained is a deprecated, '
/usr/local/envs/open-mmlab/lib/python3.7/site-packages/torch/utils/data/dataloader.py:477: UserWarning: This DataLoader will create 8 worker processes in total. Our suggested max number of worker in current system is 2, which is smaller than what this DataLoader is going to create. Please be aware that excessive worker creation might get DataLoader running slow or even freeze, lower the worker number to avoid potential slowness/freeze if necessary.
cpuset_checked))
2022-05-17 14:41:41,644 - mmseg - INFO - Loaded 214 images
******** <mmseg.datasets.lumitec.Lumitec object at 0x7f00e2b02850>
2022-05-17 14:41:41,646 - mmseg - INFO - load checkpoint from local path: /content/mmseg-dl-pipeline/checkpoints/deeplabv3plus_r18-d8_512x1024_80k_cityscapes_20201226_080942-cff257fe.pth
2022-05-17 14:41:41,696 - mmseg - WARNING - The model and loaded state dict do not match exactly
size mismatch for decode_head.conv_seg.weight: copying a param with shape torch.Size([19, 128, 1, 1]) from checkpoint, the shape in current model is torch.Size([3, 128, 1, 1]).
size mismatch for decode_head.conv_seg.bias: copying a param with shape torch.Size([19]) from checkpoint, the shape in current model is torch.Size([3]).
size mismatch for auxiliary_head.conv_seg.weight: copying a param with shape torch.Size([19, 64, 1, 1]) from checkpoint, the shape in current model is torch.Size([3, 64, 1, 1]).
size mismatch for auxiliary_head.conv_seg.bias: copying a param with shape torch.Size([19]) from checkpoint, the shape in current model is torch.Size([3]).
2022-05-17 14:41:41,698 - mmseg - INFO - Start running, host: root@33fba6192c37, work_dir: /content/mmseg-dl-pipeline/work_dirs
2022-05-17 14:41:41,699 - mmseg - INFO - Hooks will be executed in the following order:
before_run:
(VERY_HIGH ) PolyLrUpdaterHook
(NORMAL ) CheckpointHook
(LOW ) EvalHook
(VERY_LOW ) TextLoggerHook
--------------------
before_train_epoch:
(VERY_HIGH ) PolyLrUpdaterHook
(LOW ) IterTimerHook
(LOW ) EvalHook
(VERY_LOW ) TextLoggerHook
--------------------
before_train_iter:
(VERY_HIGH ) PolyLrUpdaterHook
(LOW ) IterTimerHook
(LOW ) EvalHook
--------------------
after_train_iter:
(ABOVE_NORMAL) OptimizerHook
(NORMAL ) CheckpointHook
(LOW ) IterTimerHook
(LOW ) EvalHook
(VERY_LOW ) TextLoggerHook
--------------------
after_train_epoch:
(NORMAL ) CheckpointHook
(LOW ) EvalHook
(VERY_LOW ) TextLoggerHook
--------------------
before_val_epoch:
(LOW ) IterTimerHook
(VERY_LOW ) TextLoggerHook
--------------------
before_val_iter:
(LOW ) IterTimerHook
--------------------
after_val_iter:
(LOW ) IterTimerHook
--------------------
after_val_epoch:
(VERY_LOW ) TextLoggerHook
--------------------
after_run:
(VERY_LOW ) TextLoggerHook
--------------------
2022-05-17 14:41:41,699 - mmseg - INFO - workflow: [('train', 1)], max: 10000 iters
2022-05-17 14:41:41,699 - mmseg - INFO - Checkpoints will be saved to /content/mmseg-dl-pipeline/work_dirs by HardDiskBackend.
Traceback (most recent call last):
File "/content/mmseg-dl-pipeline/code/train.py", line 19, in <module>
meta=dict())
File "/content/mmseg-v0/mmseg/apis/train.py", line 176, in train_segmentor
runner.run(data_loaders, cfg.workflow)
File "/usr/local/envs/open-mmlab/lib/python3.7/site-packages/mmcv/runner/iter_based_runner.py", line 134, in run
iter_runner(iter_loaders[i], **kwargs)
File "/usr/local/envs/open-mmlab/lib/python3.7/site-packages/mmcv/runner/iter_based_runner.py", line 61, in train
outputs = self.model.train_step(data_batch, self.optimizer, **kwargs)
File "/usr/local/envs/open-mmlab/lib/python3.7/site-packages/mmcv/parallel/data_parallel.py", line 75, in train_step
return self.module.train_step(*inputs[0], **kwargs[0])
File "/content/mmseg-v0/mmseg/models/segmentors/base.py", line 138, in train_step
losses = self(**data_batch)
File "/usr/local/envs/open-mmlab/lib/python3.7/site-packages/torch/nn/modules/module.py", line 889, in _call_impl
result = self.forward(*input, **kwargs)
File "/usr/local/envs/open-mmlab/lib/python3.7/site-packages/mmcv/runner/fp16_utils.py", line 110, in new_func
return old_func(*args, **kwargs)
File "/content/mmseg-v0/mmseg/models/segmentors/base.py", line 108, in forward
return self.forward_train(img, img_metas, **kwargs)
File "/content/mmseg-v0/mmseg/models/segmentors/encoder_decoder.py", line 144, in forward_train
gt_semantic_seg)
File "/content/mmseg-v0/mmseg/models/segmentors/encoder_decoder.py", line 88, in _decode_head_forward_train
self.train_cfg)
File "/content/mmseg-v0/mmseg/models/decode_heads/decode_head.py", line 204, in forward_train
losses = self.losses(seg_logits, gt_semantic_seg)
File "/usr/local/envs/open-mmlab/lib/python3.7/site-packages/mmcv/runner/fp16_utils.py", line 198, in new_func
return old_func(*args, **kwargs)
File "/content/mmseg-v0/mmseg/models/decode_heads/decode_head.py", line 239, in losses
align_corners=self.align_corners)
File "/content/mmseg-v0/mmseg/ops/wrappers.py", line 27, in resize
return F.interpolate(input, size, scale_factor, mode, align_corners)
File "/usr/local/envs/open-mmlab/lib/python3.7/site-packages/torch/nn/functional.py", line 3473, in interpolate
"size shape must match input shape. " "Input is {}D, size is {}".format(dim, len(size))
ValueError: size shape must match input shape. Input is 2D, size is 3