Railway transportation is one of the main modes of long-distance coal transportation, and it is inevitable to cause environmental pollution during the transportation process. In order to improve the environment along the railway and increase the utilization rate of coal resources, this paper proposes a detection algorithm for scattered coal solidification layer during transportation based on the YOLO v8 model, and designs an intelligent recognition model suitable for coal solidification layer detection devices by combining fluorescence detection methods. Through experimental analysis, the model meets the requirements of practical detection and plays a crucial role in environmental protection, with strong practical application value.