Retinal OCT image segmentation plays a crucial role in the diagnosis of eye diseases. Traditional layer segmentation methods are time-consuming and heavily reliant on the subjective judgment of annotators. To address these challenges, this paper proposes an automatic retinal OCT image layer segmentation approach based on attention mechanisms. The model replaces regular convolutions of U-Net with dilated convolutions to increase the model’s receptive field while preserving the feature map size. Additionally, a hybrid attention mechanism module, called spatial and channel attention module (scSE), is introduced in encoder part scSE module combines spatial and channel attention, enhancing the model’s focus on important features and improving its robustness and generalization. The proposed model is validated on a publicly available dataset, and the results demonstrate its superiority over other methods in retinal layer segmentation, achieving a Dice coefficient of 0.845. The proposed model performs well in retinal layer segmentation tasks, providing more accurate guidance for assisting doctors in diagnosing retinal diseases.