You can add debug print statements to these functions and check what is calculated and if there might be a bug in the code.
You can use nn.CrossEntropyLoss with a model output shape of [batch_size, nb_classes, height, width] and a target in the shape [batch_size, height, width] containing class indices in the range [0, nb_classes-1].
The accuracy and IOU looks a bit strange, so I would probably check them first.
You can call model.eval() and wrap the testing loop into with torch.no_grad() to calculate the validation/testing results.