Optical coherence tomography (OCT) is being investigated in diabetic retinopathy (DR) diagnostics as a real-time evaluation tool. Currently, OCT images are the main methods for the diagnosis of patients with DR. Hyperreflective foci (HRF) are potential biomarkers for the diagnosis and prediction of the progression and prognosis of patients with DR. The development of artificial intelligence (AI) models for segmenting HRF is of great significance for the clinical diagnosis and treatment of patients with DR. The purpose of this study is to construct a deep-learning algorithm that automatically segments the HRF in OCT images, helping ophthalmologists make early diagnosis and evaluate the prognosis of patients with DR. In this paper, to investigate the algorithms that are appropriate for the segmentation of HRF, we propose an HRF segmentation algorithm on the basis of Attention U-Net. We fuse the features of each layer and use the fused multi-scale information to guide the generation of the attention map. Then, we embed a hybrid attention module of space and channel at the decoder end of the network to capture the spatial and channel correlations of the feature map, making the network focus on the location and channels related to the target region. We propose a novel algorithm, to our knowledge, based on Attention U-Net and the experimental results on 172 OCT images from 50 patients with DR demonstrated that our method is effective for the HRF segmentation. In five-fold cross-validation, the dice similarity coefficient (DSC), sensitivity (SE), and precision (P) reach 63.79±0.94, 66.66±2.54, and 67.10±1.96, respectively. The overall segmentation effect of this model surpasses that of the other four networks, and the HRF can be segmented more accurately and identified more easily. In a segment model, balancing SE and P is difficult. We developed an improved Attention U-Net that effectively segments HRF with high SE and P, outperforming other algorithms in HRF segmentation. This model holds significant potential for the early detection, treatment evaluation, and prognosis assessment of patients with diabetic retinopathy (DR).