I assume your predictions might be a tensor containing logits in the shape [batch_size, nb_classes, height, width].
If that’s the case, you could first create the binary predictions for each class using:
preds = torch.argmax(output, dim=1)
preds_class0 = preds == 0
preds_class1 = preds ==1
...

Once you have these binary maps, you could use findContours from OpenCV as described here 44.