Transfer learning in semantic segmentation on Cityscapes dataset

Hello there.
I am totally new to Semantic Segmentation, and my current project is observing effects of domain shifting in Semantic Segmentation. I was thinking of using Cityscapes as my real data set and GTA alongside Synthia as my synthetic data. I have done some basic transfer learning with classification which was fairly straight-forward but I am struggling immensely with it in semantic segmentation. I have tried following several guides that I will link at the end of this post, they are all to some degree different approaches to the same thing. After none of them working for me I don’t know where to look for anymore.
I have a basic understanding of how semantic segmentation works, I can also load my data with no problems. The only problem I have is how to adapt a pretrained semantic segmentation model such as DeepLabV3 to my dataset (in this case Cityscapes). The latest unsuccessful approach I tried was this:

def createDeepLabv3(outputchannels=1):
“”“DeepLabv3 class with custom head
outputchannels (int, optional): The number of output channels
in your dataset masks. Defaults to 1.
model: Returns the DeepLabv3 model with the ResNet101 backbone.
model = torchvision.models.segmentation.deeplabv3_resnet50(pretrained=True,
model.classifier = DeepLabHead(2048, outputchannels)
# Set the model in training mode
return model

But I am not sure what output channels represent. Are they the number of classes in my dataset? If so, Cityscapes has around 35 but only 20 or so are useful, so that also further confuses me as to how should I do this. I am aware that this stems from a lack of understanding of a DeepLabV3 architecture but I am kind of crunching so I am afraid trying to understand that wouldn’t be worth it at his point.
Anyway, the closest I got was using this guide which implemented its own model using LightningModule library which I am not familiar with in the slightest:

Another one that i tried following but was even less successful with was this one:

I’d appreciate a link to some guide that explains how to adjust a pretrained semantic segmentation model to a specific dataset, in this case Cityscapes.