Detection of Sick Laying Hens by Infrared Thermal Imaging and Deep Learning

The laying hens are prone to get sick during the growing period, and the temperature will fluctuate within a relative range when the disease occurs. This temperature change range can be used as a sign of pathological phenomena in the laying hens. In order to find the floating range of the body surface temperature of the laying hens raised in the poultry house in both healthy and pathological states, and the areas where there is a significant difference in the body surface temperature of the two, a detection method combining infrared thermal imaging technology and neural network is proposed. First, use an infrared thermal imager to obtain an infrared image of the body surface of a layer, and then use a convolutional neural network to establish a recognition model for the characteristic area of the layer, and extract the highest temperature of the region of interest in a healthy and pathological layer. Finally, analyse the temperature difference of each area of interest in the chicken body under these two conditions. The test results show that the accuracy of the convolutional neural network recognition model is 97%; the temperature fluctuation range of the three characteristic areas of healthy and pathological layers are different, and the maximum temperature difference area is 7.8°C.


Introduction
In recent years, with the continuous expansion of the breeding industry, the density of livestock breeding has become higher and higher, and epidemics caused by animal diseases have become more frequent, such as swine fever and chicken disease; this phenomenon not only brings significant economic losses to the breeding industry, but also has a great impact on human health. Therefore, quickly and accurately predicting whether poultry is sick has become the primary task of the industry, and it is also a difficult point in current research. At this stage, the detection of poultry diseases in the breeding industry mainly relies on manual detection, by observing the poultry excrement color, special movements, sounds, and rectal temperature and other characteristics to determine whether the poultry is sick, this method requires a large number of workers, not only is time-consuming and laborintensive, but also mostly depends on the judgment of breeding experience. It is highly subjective and cannot meet the needs of rapid detection and large-scale breeding.
In the research on poultry temperature and health detection, there are currently two temperature measurement methods: contact and non-contact. The contact temperature measurement uses a temperature sensor, which directly contacts the characteristic parts of the chicken body through means such as tying and sticking, and obtains the temperature information of the area [1]. This method is easy to cause the chickens to have a stress response, which does not meet the requirements of welfare breeding, and the device is easily dropped and malfunctions due to environmental influences (layers pecking each other, high humidity, etc.), and is not suitable for long-term observation. Non-contact temperature measurement mainly uses infrared thermal imaging cameras to measure the body surface temperature of poultry [2][3], at present, this method is mostly used for the detection of pathological characteristics of large livestock, such as pigs and cattle [4][5][6][7], and it is less used for chickens with small body size and large feather coverage.
In this experiment, an infrared thermal imager was used to measure the surface temperature of the laying hens, then through the deep convolutional neural network, the infrared temperature of the body surface of the area of interest of the chicken is extracted, by statistical analysis the distribution of different states infrared body temperature of chickens. It provides a basis for the design of the noncontact temperature monitoring system in the poultry house and the study of the pathological temperature range of the laying hens.

Experiment Material
The experiment was conducted at Huixin Breeding Co., Ltd., Lingqiu County, Datong City, Shanxi Province from July 10 to August 30, 2020. From 200 60-day-old laying hens in the hen house, 20 were randomly selected as test samples. The ambient temperature in the poultry house is between 21~23℃, the relative humidity is between 60% and 70%, the feed and drinking water are not restricted, and the ventilation and other conditions meet the poultry breeding standards.
The instruments used in the test are: SAT-G95 infrared thermal imaging camera, temperature measurement range is -20~600℃, temperature measurement accuracy is ±2℃, infrared image resolution is 384 pixels × 288 pixels; G2080B environmental temperature and humidity meter, the temperature measurement range is -20~40℃, the measurement accuracy is ±1℃, the relative humidity measurement range is 10%~90%, and the measurement accuracy is ±5%.

Data Collection
The test time is from 8:00 to 18:00, and the body surface temperature of laying hens is collected every 2 hours. Since the measurement results of the infrared thermal imaging camera will be affected by factors such as ambient temperature, relative humidity, measurement distance and emissivity, the instrument is fixed at a position 1m away from the sample during each measurement, and the emissivity is set to 0.95 [8][9], and then set other parameters according to the measurement results of the environmental temperature and humidity meter. In order to reduce the measurement error, each laying hens takes 5 infrared images as a group, and the shooting is performed in an environmental area with a relatively stable background. Figure 1 shows the distribution of infrared temperature on the body surface of laying hens during the growing period.

Temperature Extraction Method
During the experiment, the samples were all in the growing period and were raised in standard poultry houses. The influence of environmental temperature and humidity on the infrared temperature of the chicken body may not be considered. It can be seen from figure 1 that there is a clear difference between the body color of the laying hen during the growing period and the background area. This is because the feathers of the laying hens in the breeding period are not fully developed and cannot block their own heat radiation. Therefore, the head area, body area and leg area of the chicken body are selected as the characteristic areas.
There are many infrared images of laying hens collected in the experiment, and the amount of data is large. Extracting temperature data in a single image in turn not only increases the processing time, low efficiency, but also has a high probability of human error, which will affect the accuracy. Therefore, the method of convolutional neural network is used to identify the characteristic areas of the chicken body, and the temperature data of each area is extracted according to the coordinates of the prediction frame.

Model Design
Convolutional neural network is used for target detection and classification. The main steps are convolution, batch standardization, activation, pooling and full connection [10], In this model, the first four steps are to extract features from the infrared images of laying hens with the help of filters, etc., and then send the extracted features to the fully connected layer for predictive recognition, and finally output the recognition results.
This article adopts a similar YOLOv3 network model, and its backbone network structure is Darknet-53 [11]. Since the color difference of the infrared image of the laying hen is obvious, the normalization operation is performed on the input infrared image of the laying hen. At the same time, the normalized result is sent to the input layer of the model, and then the network structure samples the input image 3 times, extracts the characteristics of the infrared image of the chicken body, and obtains the prediction results of 3 sizes, and finally outputs the recognition results. The model structure is shown in figure 2. In the process of backpropagation, the disappearance of gradients and over-fitting problems will affect the recognition rate of the model. Therefore, the residual structure is used multiple times between the convolutional layer and the pooling layer of the model to improve the recognition rate of the characteristic regions of the chicken body. The residual structure is shown in figure 3. Each residual block contains 2 convolutional layers, and both use the Relu activation function for non-linear processing.

Data Labeling and Training
Platform. Convert infrared images into 3-channel jpg format with temperature data in batches, and use LabelImg open source annotation tool to manually label the images, each picture is marked with three areas, head (head area), body (body area), and leg (leg area). The marking format is selected to generate the PASCAL VOC format of the xml file. The training platform is: Windows10 Home Chinese 64-bit operating system, the hardware configuration is a Core i7-9750H twelve-thread CPU, the GPU is RTX2060 with 6GB of video memory, and 32GB of memory.

Training Parameters and Results.
In the experiment, a total of 2000 clear infrared images were selected as samples, and they were divided into training set, verification set and test set according to 8:1:1; using Tensorflow2.1 as the basic framework of neural network, the recognition model is established in the Python3.7 environment. During model training, feed small batches of data into the input layer of the network in turn, with each batch set to 64 for random gradient descent; and the exponential decay method is used to optimize the learning rate. The initial learning rate is 0.01, the decay coefficient is 0.99, and the decay speed is 1. Finally, after many iterations, the model has a recognition rate of 97% for the head area and leg area on the 200 images of the test set, and the recognition effect is obvious. The recognition rate of the body area is 76%. The image detection results are shown in figure 4. The tags head, body, and leg represent the recognition areas of the chicken body's head, body, and legs, respectively.

Output Characteristic Area Temperature
The infrared images of laying hens taken by the SAT-G95 thermal imaging camera have temperature data, and the temperature of each pixel on the image is stored in the corresponding CSV file. Therefore, the temperature value of the characteristic part on the image can be extracted by the coordinates of the upper left corner and the lower right corner of the prediction frame. From the data collection in section 2.2, we can see that there are 5 infrared images for each group of laying hen data, therefore, in the CSV file storing infrared image temperature data, the maximum value of the body surface temperature of the characteristic part of the chicken can be extracted

Results and Analysis
Input the infrared images of laying hens in healthy and sick state obtained from the experiment into the recognition model, then in the resulting data, randomly select 50 sets of temperature data of a healthy laying hens and a sick laying hen for comparison, after statistical analysis, the temperature distribution range of the head area, body area and leg area of the laying hen in these two states can be obtained, the results are shown in figure 5. It can be seen from figure 5 that the head temperature of a healthy laying hens is distributed between 37°C and 41°C, and the maximum difference in temperature change is 3.4°C; the head temperature of sick laying hens ranges from 35 to 43°C, and the maximum temperature difference is 7.8°C, and due to the influence of pathological reactions, the temperature will drop sharply. The temperature changes in the body parts of healthy and sick laying hens are chaotic. On the whole, the temperature of the body parts of sick layers is higher than that of healthy layers, but it is not obvious. The temperature of the legs of a healthy laying hen is generally higher than that of a sick laying hen. The temperature of the legs of a healthy laying hen ranges from 34 to 40°C, and the maximum temperature difference is 6.6°C; the head temperature of sick laying hens ranges from 33°C to 47°C, and the maximum temperature difference is 3.7°C. This phenomenon may be affected by pathological reactions. Therefore, changes in head temperature and leg temperature can be used to determine whether a laying hen is sick.

Discussion
In this study, a YOLOv3-like neural network structure was used to identify the characteristic parts of laying hens. In the case of a large amount of data, the purpose of quickly detecting the characteristic parts of the laying hens is achieved, and the temperature of the healthy and sick laying hens is compared to judge whether the laying hens have pathological phenomena. The model has certain shortcomings. The recognition rate of the body parts of the laying hens is low. The reasons for this phenomenon may be: the first, compared with the head area and leg area of the laying hens, the body part has no obvious contour features, and the convolutional neural network cannot accurately extract the characteristics of the body part of the laying hens. Second, there is a lot of noise in the body part of the laying hens, and the value of each pixel on the infrared image is not much different, which leads to the over-fitting phenomenon of the convolutional neural network in this part. Third, laying hens are in the rearing period, their body parts are not fully developed, there are more exposed areas, and the feathers of the body parts cannot completely isolate their own heat radiation. The combination of the two causes the temperature of the body parts to be high and it is difficult to distinguish.

Conclusion
The laying hens feature region recognition model established based on the convolutional neural network structure can accurately identify the head region and leg region of the layer. The recognition rate on the test set is 97%, and the temperature data of the corresponding region can be extracted.
By comparing the temperature in the characteristic area of the laying hens, it is concluded that the temperature of the head area of the healthy laying hens is generally lower than that of the sick laying hens, and there will be no sudden drop in temperature; The temperature in the leg area of a healthy laying hens is higher than that of a sick laying hen, and individual sick laying hens may be higher than healthy laying hens due to pathological reactions.
It can be seen from the temperature change trend of the laying hen when the disease occurs, when the temperature in the head area is higher than 40°C, and the temperature difference is greater than 7.8°C, and the temperature in the leg area is generally lower than 36°C, it can be considered that the layer has a pathological reaction.