The study focused on the significance of facial expressions in pigs as a mode of communication for assessing their emotions, physical status, and intentions. To address the challenges of recognizing facial expressions due to the simple facial muscle group structure of pigs, a novel pig facial expression recognition model called CReToNeXt-YOLOv5 was proposed. Several improvements were made to enhance the accuracy and detection ability of the model. Firstly, the CIOU loss function was replaced with the EIOU loss function to optimize the training model and achieve more accurate regression. This change improved the overall performance of the model. Secondly, the model was equipped with the Coordinate Attention mechanism, which improved its sensitivity to expression features, making it more effective in recognizing facial expressions. Lastly, the CReToNeXt module was integrated into the model to enhance its detection capability for subtle expressions. The results demonstrated the effectiveness of the CReToNeXt-YOLOv5 model. It achieved a mean average an mAP of 89.4%, showing a significant improvement of 6.7% compared to the original YOLOv5 model. Overall, the experimental results confirmed the effectiveness of the optimized YOLOv5 model, CReToNeXt-YOLOv5, in accurately recognizing facial expressions in pigs.