Finetune semantic segmentation model on our dataset

ehsanzb: <p>Hi there,</p>
<p>do you have a tutorial/guidance on how to finetune provided trained semantic segmentation model of torchvision 0.3 (FCN or DeepLabV3 with Resnet 50 or 101 backbone) on our dataset (transfer learning for semantic segmentation)?</p>

ptrblck: <p>The general logic should be the same for classification and segmentation use cases, so I would just stick to the <a href="https://pytorch.org/tutorials/beginner/finetuning_torchvision_models_tutorial.html" rel="nofollow noopener">Finetuning tutorial</a>.<br>
The main difference would be the output shape (pixel-wise classification in the segmentation use case) and the transformations (make sure to apply the same transformations on the input image and mask, e.g. crop).</p>

ehsanzb: <p>What about this tutorial:</p>
<p><a href="https://colab.research.google.com/github/pytorch/vision/blob/temp-tutorial/tutorials/torchvision_finetuning_instance_segmentation.ipynbhttps:/colab.research.google.com/github/pytorch/vision/blob/temp-tutorial/tutorials/torchvision_finetuning_instance_segmentation.ipynb" class="onebox" target="_blank" rel="nofollow noopener">https://colab.research.google.com/github/pytorch/vision/blob/temp-tutorial/tutorials/torchvision_finetuning_instance_segmentation.ipynbhttps:/colab.research.google.com/github/pytorch/vision/blob/temp-tutorial/tutorials/torchvision_finetuning_instance_segmentation.ipynb</a></p>

ptrblck: <p>This one looks even better for your use case! <img src="https://discuss.pytorch.org/images/emoji/apple/slight_smile.png?v=9" title=":slight_smile:" class="emoji" alt=":slight_smile:"></p>

msminhas93: <p>I’ve written a tutorial on how to fine-tune DeepLabv3 for semantic segmentation in PyTorch. The tutorial link is: <a href="https://expoundai.wordpress.com/2019/08/30/transfer-learning-for-segmentation-using-deeplabv3-in-pytorch/" rel="nofollow noopener">https://expoundai.wordpress.com/2019/08/30/transfer-learning-for-segmentation-using-deeplabv3-in-pytorch/</a></p>
<p>The github repo link is: <a href="https://github.com/msminhas93/DeepLabv3FineTuning" rel="nofollow noopener">https://github.com/msminhas93/DeepLabv3FineTuning</a></p>

Ankan_Sharma: <p>hey your notebook is not loading. giving error. pls share the updated link</p>

Pratibha: <p>Hello,<br>
I am following your link. I have few queries onto this:</p>
<ol>
<li>
<p>I have 3 classes, even though I tried to change the number of out_channels to 3, still model.eval() shows final layer with 21 classes. Please clarify this.</p>
</li>
<li>
<p>It has batch size 4. I am trying to train it on single image. So when I change batch size to 1, it is throwing an error.</p>
</li>
<li>
<p>Can you help to decode the result into a mask? I dont know how to do that.</p>
</li>
</ol>
<p>Please help in this regard. Thank you.</p>

rui_zhou: <p><div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/5/1/519adac19b6693ea5db89b4382d903b6fc7a6c91.png" data-download-href="https://discuss.pytorch.org/uploads/default/519adac19b6693ea5db89b4382d903b6fc7a6c91" title="bug2"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/5/1/519adac19b6693ea5db89b4382d903b6fc7a6c91_2_690x244.png" alt="bug2" data-base62-sha1="bDUrRpqGygFUrzON5NMcLqYSUJX" width="690" height="244" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/5/1/519adac19b6693ea5db89b4382d903b6fc7a6c91_2_690x244.png, https://discuss.pytorch.org/uploads/default/optimized/3X/5/1/519adac19b6693ea5db89b4382d903b6fc7a6c91_2_1035x366.png 1.5x, https://discuss.pytorch.org/uploads/default/original/3X/5/1/519adac19b6693ea5db89b4382d903b6fc7a6c91.png 2x" data-dominant-color="F4F4F4"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">bug2</span><span class="informations">1072×380 55.2 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div> I am following your tutorials, I have following error when I run the code … Do you tell me where is the problem?.</p>