How to automatically detect pigs has important application significance in large-scale pig breeding.On the one hand,it can liberate the labor force of breeding workers and improve production efficiency.On the other hand,it can improve the quality of pork.Just like people,when pigs have some physical illnesses,their faces will also have feedback information,such as facial deformation,ulceration,red eyes,tear marks and other features.In this paper,based on the neural network target detection model YOLOv5,a lightweight pig face detection model and a pig face anomaly detection model optimized for small target detection are designed respectively,and they can work on embedded devices and PC terminals respectively.Based on this,a pig facial anomaly detection system composed of detection terminals,servers,and clients was built.The paper first designed the architecture of the pig face anomaly detection system,and determined that the pig face detection and image collection tasks performed by the detection terminal.Considering the limited computing power of the equipment carried by the detection terminal,the paper set out to design an extremely lightweight target detection network that can run on the detection terminal.Based on YOLOv5 s network,this paper uses ShuffleNet and Depth Wise convolution to carry out convolution kernel lightweight design,structure pruning and model channel compression,and designs a lightweight target detection model THE-YOLO5.After quantifying the parameters of THE-YOLO5 model into an int8 model,the size of the model is only 172 KBytes.In terms of model performance,the model’s m AP is slightly lower than 95% before compression to 78.8%,the amount of parameters has been reduced from about 7 million to 60224,and the amount of calculation has dropped from 18.4GFLOPs to 0.1 GFLOPs,which has reached the requirements for deployment in embedded terminals.For the detection of facial abnormalities in pigs,the paper selects red-eye lesions for research.Due to the small proportion of the eye target of the pig in the picture,the recall rate and detection accuracy of the YOLOv5 model have a large room for improvement.The paper selected some adjustments to improve this phenomenon,including including adding a CBAM attention mechanism to the YOLOv5 backbone network and adding a small target detection head.These improvements have increased the algorithm’s recall rate from 88.6% to 92.9%,and m AP from 93.3% to 94.9%.Aiming at the problem that the model is likely to misdetect normal pig eyes,the paper added a control data set in the data enhancement stage to optimize the false detection situation.In the end,the number of misdetections in the false detection test set of 100 pictures in this paper was reduced from 62 to 7.The thesis also designed the hardware of the detection terminal for collecting the face of pigs.Using the AI expansion package of STM32 Cube MX,the pig face detection model was transplanted to the STM32H743VIT6 single-chip microcomputer to develop the software and hardware program of the detection terminal.The thesis uses Java language and C# language to develop the server-side program and client-side program of the system respectively.After the simulation test,the detection terminal can maintain the detection of live pigs at more than3 frames per second,which basically achieved the research purpose of the paper. |