How many classes do you have?
In that you say it outputs two channels, I’d assume that you’re making a binary segmentation.
According to https://pytorch.org/docs/stable/nn.html#torch.nn.CrossEntropyLoss 3, your target should be just a 2D map where the pixels has the value of the appropriate class, i.e. a binary mask with 0’s and 1’s. Hope this makes sense.