Pedestrian detection is a critical research area in computer vision with practical applications. This paper addresses this key topic by providing a novel lightweight model named Shift Window-YOLOX (SW-YOLOX). The purpose of SW-YOLOX is to significantly enhance the robustness and real-time performance of pedestrian detection under practical application requirements. The proposed method incorporates a novel Shift Window-Mixed Attention Mechanism (SW-MAM), which combines spatial and channel attention for effective feature extraction. In addition, we introduce a novel up-sampling layer, PatchExpandingv2, to enhance spatial feature representation while maintaining computational efficiency. Furthermore, we propose a novel Shift Window-Path Aggregation Feature Pyramid Network (SW-PAFPN) to integrate with the YOLOX detector, further enhancing feature extraction and the robustness of pedestrian detection. Experimental results validated on challenging datasets such as CrowdHuman, MOT17Det, and MOT20Det demonstrate the competitive performance of the proposed SW-YOLOX compared to state-of-the-art methods and its pedestrian detection performance in crowded and complex scenes.