boostcampaitech2 / semantic-segmentation-level2-cv-09

semantic-segmentation-level2-cv-09 created by GitHub Classroom
2 stars 6 forks source link

DeepLabV3Plus_ResNet101, DeepLabV3Plus_ResNet50 모델 사용시 다음과 같은 에러가 나옵니다. #3

Open Kim-jy0819 opened 3 years ago

Kim-jy0819 commented 3 years ago
Epoch [1/1], Step [20/328],                         Loss: 1.0185, mIoU: 0.145 lr 0.0001
Epoch [1/1], Step [40/328],                         Loss: 0.7599, mIoU: 0.1716 lr 0.0001
Epoch [1/1], Step [60/328],                         Loss: 0.6554, mIoU: 0.1846 lr 0.0001
Epoch [1/1], Step [80/328],                         Loss: 0.7604, mIoU: 0.1932 lr 0.0001
Epoch [1/1], Step [100/328],                         Loss: 1.2363, mIoU: 0.2028 lr 0.0001
Epoch [1/1], Step [120/328],                         Loss: 0.5416, mIoU: 0.2072 lr 0.0001
Epoch [1/1], Step [140/328],                         Loss: 0.4831, mIoU: 0.2127 lr 0.0001
Epoch [1/1], Step [160/328],                         Loss: 0.7067, mIoU: 0.2174 lr 0.0001
Epoch [1/1], Step [180/328],                         Loss: 0.466, mIoU: 0.2208 lr 0.0001
Epoch [1/1], Step [200/328],                         Loss: 0.4629, mIoU: 0.2285 lr 0.0001
Epoch [1/1], Step [220/328],                         Loss: 0.6414, mIoU: 0.233 lr 0.0001
Epoch [1/1], Step [240/328],                         Loss: 0.4219, mIoU: 0.2345 lr 0.0001
Epoch [1/1], Step [260/328],                         Loss: 0.4091, mIoU: 0.2363 lr 0.0001
Epoch [1/1], Step [280/328],                         Loss: 0.5422, mIoU: 0.2384 lr 0.0001
Epoch [1/1], Step [300/328],                         Loss: 0.439, mIoU: 0.2396 lr 0.0001
Epoch [1/1], Step [320/328],                         Loss: 0.5586, mIoU: 0.2408 lr 0.0001
Traceback (most recent call last):
  File "train.py", line 38, in <module>
    trainer.model_test(args)
  File "/opt/ml/segmentation/semantic-segmentation-level2-cv-09/trainer.py", line 127, in train
    outputs = model(images)
  File "/opt/conda/envs/segmentation/lib/python3.7/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/opt/ml/segmentation/semantic-segmentation-level2-cv-09/models/DeepLabV3Plus_ResNet101.py", line 13, in forward
    return self.model(x)['out']
  File "/opt/conda/envs/segmentation/lib/python3.7/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/opt/conda/envs/segmentation/lib/python3.7/site-packages/torchvision/models/segmentation/_utils.py", line 24, in forward
    x = self.classifier(x)
  File "/opt/conda/envs/segmentation/lib/python3.7/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/opt/conda/envs/segmentation/lib/python3.7/site-packages/torch/nn/modules/container.py", line 117, in forward
    input = module(input)
  File "/opt/conda/envs/segmentation/lib/python3.7/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/opt/conda/envs/segmentation/lib/python3.7/site-packages/torchvision/models/segmentation/deeplabv3.py", line 91, in forward
    res.append(conv(x))
  File "/opt/conda/envs/segmentation/lib/python3.7/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/opt/conda/envs/segmentation/lib/python3.7/site-packages/torchvision/models/segmentation/deeplabv3.py", line 61, in forward
    x = mod(x)
  File "/opt/conda/envs/segmentation/lib/python3.7/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/opt/conda/envs/segmentation/lib/python3.7/site-packages/torch/nn/modules/batchnorm.py", line 136, in forward
    self.weight, self.bias, bn_training, exponential_average_factor, self.eps)
  File "/opt/conda/envs/segmentation/lib/python3.7/site-packages/torch/nn/functional.py", line 2054, in batch_norm
    _verify_batch_size(input.size())
  File "/opt/conda/envs/segmentation/lib/python3.7/site-packages/torch/nn/functional.py", line 2037, in _verify_batch_size
    raise ValueError('Expected more than 1 value per channel when training, got input size {}'.format(size))
ValueError: Expected more than 1 value per channel when training, got input size torch.Size([1, 256, 1, 1])

마지막 부분에서 에러가 나는 것 같은데 어떻게 해결해야할까요?

Kim-jy0819 commented 3 years ago

train_loader = torch.utils.data.DataLoader( dataset=train_dataset, batch_size = args.batch_size, shuffle=True, num_workers=args.num_workers, collate_fn=utils.collate_fn, drop_last = True ) drop_last=True하면 해결되네요 ㅎㅎ