[Objective] Beef cattle breeding stands as a pivotal element in contemporary animal husbandry, with precise individual identification serving as the cornerstone for the advancement of automated technologies, including intelligent weight measurement, body condition scoring, body conformation assessment, and behavior monitoring. However, the actual breeding environment is fraught with challenges such as soiled conditions, intricate backgrounds, and the constant movement of animals, which contribute to the high variability of cattle face data features. Additionally, the effects of inconsistent lighting and diverse shooting angles can lead to blurred key features, increasing the risk of misjudgment during the detection process. In light of these challenges, an improved model named YOLO-PCW, built upon the YOLOv11 algorithm, was introduced to enhance the detection performance while preserving a lightweight structure to address the complexities of precise cattle face recognition in challenging breeding environments. [Methods] The research leveraged the cow fusion dataset (CFD), a comprehensive collection of real-world cattle face images captured under variable lighting conditions, from multiple angles, and against complex backgrounds, for the purpose of model training and validation. Concurrently, a custom cow monitor dataset (CMD) was created from video footage obtained through the Zhaoyuan Qingyangbao Breeding Farm's monitoring system, providing a robust basis for evaluating the model's generalization capabilities. The YOLOv11 architecture served as the foundational framework for implementing the following performance improvements. The partial convolution (PConv) was seamlessly integrated into the C3K2 module within the YOLOv11 head network. Utilizing the sparse convolutional properties of PConv on the feature maps, the convolutional structure was meticulously optimized, reduceing computational redundancy and memory access while preserving the model's accuracy—rendering it highly suitbale for real-time applications. Additionally, the convolutional block attention module (CBAM) was incorporated to enhance feature map processing through adaptive channel-wise and spatial attentions. This refinement enabled precise extraction of target regions by mitigating background interference, allowing the model to focus on critical anatomical features such as the eyes, mouth, and nose. Furthermore, the weighted intersection over union (WIoU) loss function was adopted to replace the CIoU, optimizing the weighted strategy for bounding box regression errors. This innovation reduced the adverse effects of large or outlier gradients in extreme samples, enabling the model to prioritize average-quality samples for refinement. The resulting improvment in key region localization accuracy bolstered the model's generalization capability and overall performance, establishing a state-of-the-art cattle face recognition framework. [Results and Discussion] The YOLO-PCW model achieved a remarkable accuracy rate (P) of 96.4%, a recall rate (R) of 96.7%, and a mean average precision (mAP) of 98.7%. With a parameter count of 2.3 M and a computational load of 5.6 GFLOPs, the YOLO-PCW not only improved accuracy, recall, and mean average precision by 3.6, 5, and 4.4 percentage point respectively, but also achieved a significant reduction in floating-point computational load and parameter size, down to 88.9% and 88.5% of the original model, respectively. Ablation studies revealed that the CBAM module enhanced precision from 92.8% to 95.2%. The WIoU loss function optimized target positioning accuracy, achieving a precision of 93.8%. The PConv module contributed to a substantial reduction in computational load from 6.3 GFLOPs to 5.5 GFLOPs, thereby significantly lightening the model's computational burden. The synergistic collaboration of these multiple components provided robust support for enhancing the performance of the cattle face recognition model. Comparative experiments demonstrated that the YOLO-PCW model, when benchmarked against algorithms such as Faster-RCNN, SSD, YOLOv5, YOLOv7-tiny, and YOLOv8 under identical conditions, exhibited the most outstanding performance, effectively balancing recognition accuracy with computational efficiency and achieving optimal utilization of computational resources. [Conclusions] The improved YOLO-PCW model, with its lightweight architecture and optimized attention mechanism, could successfully improve detection accuracy while simplify deployment. It is capable of delivering precise cattle face recognition in real-world breeding environments, offering an efficient and practical solution for individual identification in applications such as animal welfare breeding, intelligent ranch management, smart ranch construction, and animal health monitoring.