Currently, research on on-board real-time quantitative detection of rail fasteners is few. Therefore, this paper proposes and validates an improved YOLOv8 based method for quantitative detection of rail fasteners, leveraging the capabilities of edge miniaturized artificial intelligence (AI) computing devices. First, the lightweight MobileNetV3 is employed as the backbone network for our model to increase detection speed, and the SA attention mechanism is integrated at the end of the backbone network to enhance the feature of the fasteners. Then the deformable convolution is introduced to reconstruct the bottleneck structure of the neck network, which can segment fasteners without compromising accuracy. Subsequently, the optimized network model is utilized on a Jetson AGX Xavier edge AI computing device by the TensorRT acceleration method. Segmentation results are then extracted at the pixel level for quantitative analysis of fastener breakage degree and deflection angle, so as to correct the detection results. Experimental results show that the size of the improved lightweight network volume is reduced by 28% compared to the original YOLOv8 model, and the frame rate on the edge AI computing device is lifted by 71.87%, i.e., 55 f/s. Furthermore, the model is refined based on quantitative analysis results, resulting in an mAP0.5 of 97.0%, and real-time quantitative detection of rail fasteners is realized.