Segmenting cosmological images using the deep learning technique U-Net