Format of segmentation labels?

If I have a binary mask of an image, what it the best way to encode this label for a segmentation network like Segnet or U-Net? Should the label be by pixel if there are only two classes?


I am also interested in your question.
Did you find a way?