Since you are using nn.BCEWithLogitsLoss, I assume you are dealing with a multi-label segmentation (i.e. each pixel might belong to zero, one, or more classes)?
Is this correct or would you like to apply a multi-class segmentation (i.e. each pixel belongs to one class only)?
Your accuracy calculation looks like to multi-class segmentation, as you are calling torch.argmax(outputs, dim=1), so you are currently mixing different use cases.