Coal-rock interface identification technology was pivotal in automatically adjusting the shearer’s cutting drum during coal mining. However, it also served as a technical bottleneck hindering the advancement of intelligent coal mining. This study aimed to address the poor accuracy of current coal-rock identification technology on comprehensive working faces, coupled with the limited availability of coal-rock datasets. The loss function of the SegFormer model was enhanced, the model’s hyperparameters and learning rate were adjusted, and an automatic recognition method was proposed for coal-rock interfaces based on FL-SegFormer. Additionally, an experimental platform was constructed to simulate the dusty environment during coal-rock cutting by the shearer, enabling the collection of coal-rock test image datasets. The morphology-based algorithms were employed to expand the coal-rock image datasets through image rotation, color dithering, and Gaussian noise injection so as to augment the diversity and applicability of the datasets. As a result, a coal-rock image dataset comprising 8424 samples was generated. The findings demonstrated that the FL-SegFormer model achieved a Mean Intersection over Union (MIoU) and mean pixel accuracy (MPA) of 97.72% and 98.83%, respectively. The FL-SegFormer model outperformed other models in terms of recognition accuracy, as evidenced by an MIoU exceeding 95.70% of the original image. Furthermore, the FL-SegFormer model using original coal-rock images was validated from No. 15205 working face of the Yulin test mine in northern Shaanxi. The calculated average error was only 1.77%, and the model operated at a rate of 46.96 frames per second, meeting the practical application and deployment requirements in underground settings. These results provided a theoretical foundation for achieving automatic and efficient mining with coal mining machines and the intelligent development of coal mines.