Abstract
Complex farming environments, breed variation, and the high cost of manual annotation remain major obstacles to robust pig detection, while cross-breed detection under few-shot conditions has been insufficiently explored in previous studies. To address this gap, we propose a few-shot pig detection framework that combines an improved YOLOv7 detector with CycleGAN-based pseudo-sample generation. The detector was enhanced through anchor optimization, Efficient Channel Attention (ECA), and Log-Sum-Exp (LSE) pooling to improve localization and feature discrimination in dense pigsty scenes. In addition, an optimized CycleGAN with perceptual loss was used to generate synthetic Duroc-like pig images to enrich the limited target-domain training set. The framework was evaluated using a two-dataset design: a White Pig Base Dataset was used to establish the source-domain detector and validate the architectural improvements, whereas a Duroc Pig Few-Shot Dataset was used to assess cross-breed adaptation under a 10-shot setting. The experimental results show that the proposed method achieved 98.16% mAP on the White pig dataset and 85.52% mAP on the Duroc Few-Shot Dataset. On the Duroc Few-Shot Dataset, the final framework outperformed Faster R-CNN, CenterNet, and YOLOv8, and also surpassed DCGAN- and SRGAN-based augmentation strategies. These results indicate that the proposed method provides an effective and practical solution for cross-breed few-shot pig detection, with potential value for intelligent livestock monitoring under annotation-limited conditions.