During the process of building stairs by using mobile robot visual simultaneous localization and mapping(SLAM),it is necessary to detect and recognize the features of stairs.Traditional stair detection technologies,such as edge detection and line extrac-tion,often have the characteristic of ideal visual angle and simple background,but they can not extract the stair features under the railing occlusion and complex backgrounds.In order to solve the above problems,a stair target detection method based on improved YOLOv5 used for mobile robots is proposed.The FenceMask data enhancement strategy at the input end is introduced to increase the number of training samples for occluded stairs.The channel attention module(CAM)and spatial attention module(SAM)are con-nected in parallel to form the convolution block attention module(CBAM),enhancing the ability to extract stair features in complex backgrounds.At the prediction end,the non-maximum(NMS)and weighted boxes fusion(WBF)are combined,and the high confi-dence and close position bounding boxes filtered by the NMS are fused into new bounding boxes,improving the detection speed of sin-gle segment and multi-step stairs in the Faster-RCNN and single short multi-box detector(SSD)detection algorithms while meeting accuracy requirements.Simulation results show that the improved YOLOv5 reaches an average accuracy 82.9%with a model size of 18.4 MB,and improves the average accuracy of 86.5%with a model size of 45.5 MB.The improved YOLOv5 can effectively identify the conditions of railing occlusion,complex backgrounds and single segment long stairs.