Diabetic macular edema (DME) is a typical fundus disease that can cause blindness in severe cases. The morphology of the inner limiting membrane (ILM) to the retinal pigment epithelium (RPE) layer in the retina and the macular edema (ME) area are important features for the diagnosis of DME. Doctors usually use non-invasive and high-resolution optical coherence tomography (OCT) to examine the fundus of the patient. However, manual diagnosis has low efficiency and strong subjectivity. Realizing the automatic segmentation of the ILM-RPE layer and ME is extremely important for the early diagnosis of DME. In this paper, the attention mechanism based on residual convolution module U-Net (RCU-Net) is proposed for the automatic segmentation of the retinal layer and cystoid edema lesions. Through the fusion of the residual structure and CBAM for feature extraction, the useful features in the channel and space are effectively strengthened, and the network can better learn different levels of information. The proposed network is combined with the Lov asz-softmax loss, which can better target the correlation between targets to obtain the optimal segmentation model during training. Finally, this paper compares the proposed method with several other segmentation methods. The experimental results show that the MIoU of the method in this model reaches 88.595%, and the Accuracy reaches 99.171%. The RCU-Net proposed in this paper is used to segment the ILM-RPE layer and ME region in the retina OCT B-scan images, and its overall performance is better than other networks.