Ensuring operational safety is a critical challenge for gantry cranes, particularly given the visual blind spots and complex dynamic conditions typical of industrial sites.Existing object detection methods often struggle to balance inference speed with detection accuracy,leading to missed detections of irregular obstacles or performance degradation in low-light environments.To address these issues,this paper proposes a high-performance real-time obstacle detection model based on an improved YOLOv5s architecture.First, an image preprocessing pipeline incorporating low-light enhancement and denoising is designed to mitigate environmental interference.Second, a parameter-free SimAM is integrated into the feature extraction network.Unlike traditional attention mechanisms,SimAM infers 3D attention weights directly from the feature map without adding extra parameters,thereby enhancing the model’s sensitivity to key obstacle features.Third,the EIoU loss function is introduced to replace the standard CIoU loss,optimizing the bounding box regression by explicitly minimizing the discrepancy in aspect ratios and center points.Experimental results on a self-constructed crane obstacle dataset demonstrate that the proposed method achieves a mean Average Precision of 95.2% with an inference speed of 20.1 ms.This performance significantly outperforms the original YOLOv5s and other state-of-the-art detectors,providing a robust and efficient solution for autonomous crane monitoring systems.