[Objective] Beef cattle breeding constitutes a pivotal component of modern animal husbandry, where accurate individual identification serves as the cornerstone for advancing automated technologies, including intelligent weight measurement, body condition scoring, body conformation assessment, and behavior monitoring. However, practical breeding environments are riddled with challenges: soiled conditions, cluttered backgrounds, and constant animal movement collectively result in high variability in cattle facial data features. Furthermore, inconsistent lighting and diverse shooting angles often obscure key features, increasing the risk of misjudgment during detection. To tackle these issues, this study introduces an improved model, YOLO-PCW, which enhances detection performance while maintaining a lightweight structure, effectively addressing the complexities of precise cattle face recognition in challenging breeding settings. [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 model training and validation. Concurrently, a Custom Cow Monitor Dataset (CMD) was created from video footage obtained through the a 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, reducing computational redundancy and memory access while preserving the model's accuracy, rendering it highly suitable 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 improvement 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%, recall rate (R) of 96.7%, and mean average precision (mAP) of 98.7%. With 2.3 million parameters and a computational load of 5.6 GFLOPs, it not only improved accuracy, recall, and mAP 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's, 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 substantially reduced computational load from 6.3 GFLOPs to 5.5 GFLOPs, thereby lightening the model's computational burden significantly. The synergistic collaboration of these components provided robust support for enhancing the performance of the cattle face recognition model. Comparative experiments demonstrated that under identical conditions, the YOLO-PCW model outperformed algorithms such as Faster-RCNN, SSD, YOLOv5, YOLOv7-tiny, and YOLOv8 under identical conditions, exhibiting the most outstanding performance. It effectively balanced recognition accuracy with computational efficiency, achieving optimal utilization of computational resources. [Conclusions] The improved YOLO-PCW model, featuring a lightweight architecture and optimized attention mechanism, could successfully improve detection accuracy while simplifies deployment. It can achieve precise cattle face recognition in real-world breeding environments, providing 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.