Abstract: The national rural revitalization strategy has advanced, and new requirements for modern internet-of-things (IoT)-based farm supervision tools have been proposed. This study proposes a “you-only-look-once” (YOLO) v5 convolutional neural network to optimize the candidate frame’s center point algorithm. Five YOLOv5 models are used to identify and classify captive pigs. According to the experimental results, the K-median algorithm has a better effect than using the K-means algorithm, and its average intersection over union is approximately 1?2% higher. In our scenario, the commercial application value of the YOLOv5s model is higher, and the corresponding performance results of F1-score, mAP0.5, mAP0.5:0.95, FPS, and R2 are 92.21%, 95.18%, 64.85%, 75 FPS, and 85.54%, respectively. Keywords: Deep learning, convolutional neural network; YOLOv5; object detection; internet-of-things, computer vision.