For a multi-class segmentation nn.CrossEntropyLoss expects the target as [batch_size, height, width] containing the class indices is [0, nb_classes], while your target has an additional channel dimension.
Remove it via target = target.squeeze(1).