Abstract:Road information is of great significance and value in remote sensing images, and thus the accurate extraction of roads is crucial for many applications. However, there are two main challenges in road recognition. Firstly, the background of satellite images is complex and diverse, while the morphology of roads is also complex and diverse, which poses a challenge to automatic road recognition. Secondly, road pixels only account for a small portion of the entire image, leading to class imbalance. To address these challenges, this study proposes an automatic road recognition algorithm based on an improved SegFormer model. The algorithm employs two main strategies to improve the recognition performance. Firstly, spatial attention modules are added to the output of each stage of the SegFormer encoder. This module helps to weaken the interference from complex backgrounds and enhance the attention to road areas. By introducing spatial attention mechanisms, the model can better capture the features of roads, thereby improving recognition accuracy. Secondly, a hybrid loss function that combines pixel contrast loss and cross-entropy loss is used. Such a loss function can better handle class imbalance problems and make the model place more focus on training road categories. By optimizing the training process, the model can better learn road feature representation, thereby improving recognition accuracy. Comparative experimental analysis shows that the improved model achieves an approximate 3.3% improvement in the mIoU metric on the test set.