Obstacles that intrude into the rail area can lead to serious rail accidents, so obstacle detection technology is an essential guarantee for the safe operation of fully automatic trains. To meet the high-performance requirements of onboard obstacle detection, an efficient feature-aware convolutional neural network (EFA-Net) is proposed in this paper. The MA-FPN is designed as feature fusion network to extract multi-scale context information. In the detection head, the dynamic awareness block is used to refine the features. A joint representation branch and the generalized focal loss function are introduced to optimize the training effect. The experiments are based on the dataset of real-world rail transit environment. The results show that EFA-Net can achieve a detection accuracy of 90.4% mAP at a detection speed of 20.4 FPS, and the lightweight design significantly reduces the computational complexity of the proposed model. Compared with other classical detectors, EFA-Net has the best comprehensive performance.