zijundeng / pytorch-semantic-segmentation

PyTorch for Semantic Segmentation
MIT License
1.72k stars 393 forks source link

Train SegNet #46

Open muralabmahmuds opened 6 years ago

muralabmahmuds commented 6 years ago

Hi @zijundeng and everybody,

First of all, thank you for your codes. I am a very beginner in semantic segmentation area.

I want to run your codes using SegNet model, but I didn't find the "train.py" for SegNet. Then, I simply try to modify "train.py" from folder "train/cityscapes-psp_net" and change the net in line 42. from : net = PSPNet(num_classes=cityscapes.num_classes) to be : net = SegNet(num_classes=cityscapes.num_classes)

But, I found this error and still cannot solve the problem. _RuntimeError: invalid argument 0: Sizes of tensors must match except in dimension 1. Got 31 and 32 in dimension 2 at /opt/conda/conda-bld/pytorch1525909934016/work/aten/src/THC/generic/THCTensorMath.cu:111

Please, kindly your suggestion. Thank you.

zijundeng commented 6 years ago

It seems that two feature maps mismatch in the "height" dimension. You can use " torch.nn.functional.upsample" to make sure that the two feature maps are in the same spatial size. Best regards, Zijun

muralabmahmuds notifications@github.com 于2018年8月21日周二 下午4:44写道:

Hi @zijundeng https://github.com/zijundeng and everybody,

First of all, thank you for your codes. I am a very beginner in semantic segmentation area.

I want to run your codes using SegNet model, but I didn't find the "train.py" for SegNet. Then, I simply try to modify "train.py" from folder "train/cityscapes-psp_net" and change the net in line 42. from : net = PSPNet(num_classes=cityscapes.num_classes) to be : net = SegNet(num_classes=cityscapes.num_classes)

But, I found this error and still cannot solve the problem. RuntimeError: invalid argument 0: Sizes of tensors must match except in dimension 1. Got 31 and 32 in dimension 2 at /opt/conda/conda-bld/pytorch_1525909934016/work/aten/src/THC/generic/THCTensorMath.cu:111

Please, kindly your suggestion. Thank you.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/zijundeng/pytorch-semantic-segmentation/issues/46, or mute the thread https://github.com/notifications/unsubscribe-auth/AWj5K8Fi4nacqTK9Wj750LIOYzKgfFOKks5uS8hegaJpZM4WFWSV .

muralabmahmuds commented 6 years ago

Dear @zijundeng Thank you for your kind reply. I am searching about "torch.nn.functional.upsample" but I still could not understand how to use it and where should I put it to solve my above problem. Would you give an example of how to follow your suggestion regarding "torch.nn.functional.upsample", please? Thank you very much!