Deep learning-based sheep vital sign recognition method

By constructing lightweight sheep's life characteristics recognition models based on deep learning methods, the problems of low efficiency and accuracy of low efficiency in existing technology have been solved, and high -efficiency, lightweight and high -precision sheep life characteristics recognition is realized.

CN119380371AActive Publication Date: 2025-01-28CHINA AGRI UNIV
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202411407070.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-10
Publication Date
2025-01-28
Estimated Expiration
2044-10-10

AI Technical Summary

Technical Problem

The prior art has low efficiency and low accuracy in identifying life characteristics of sheep, especially in real-time monitoring of large-scale farms.

Method used

Based on deep learning methods, through image feature extraction, multi -scale characteristics fusion, and life characteristics output modules, we can build lightweight sheep life characteristics recognition models to achieve non -contact recognition.

Benefits of technology

Achieved efficient, lightweight, and high -precision sheep's life characteristics recognition, which can accurately identify the livelihood characteristics of sheep in complex background and improve the benefits of breeding.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119380371A_ABST
    Figure CN119380371A_ABST
Patent Text Reader

Abstract

The invention provides a sheep vital sign recognition method based on deep learning, and the method comprises the steps: determining researched sheep vital signs, making a sheep vital sign data set, constructing a sheep vital sign recognition model, and training the sheep vital sign recognition model based on the sheep vital sign data set. And performing performance evaluation on the trained sheep vital sign recognition model based on the sheep vital sign data set, and outputting a sheep vital sign recognition result. According to the method, sheep vital sign recognition can be realized, the parameter quantity and the calculated quantity are smaller than those of other widely used target detection network models, the comprehensive precision is higher than that of other target detection network models, and the method can be widely applied to the crossing field of artificial intelligence and animal husbandry.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of artificial intelligence cross technology, and in particular to a method for identifying life characteristics of sheep based on deep learning. Background Art

[0002] Life characteristics are common characteristics exhibited by organisms and can be replicated or inherited to offspring. The life characteristics of sheep, such as rumination, stress, lethargy, normal, lying down, sleeping, etc., are important indicators that directly reflect their health status. Timely identification of the life characteristics of sheep is of great significance for farmers to effectively monitor the health status of the flock and improve the breeding efficiency. At present, the identification of the life characteristics of sheep mainly relies on manual observation, which is inefficient. In addition, it is also extremely challenging to continuously monitor the life characteristics of large-scale sheep herds. Therefore, it is urgent to develop an efficient, high-precision and lightweight method for identifying the life characteristics of sheep.

[0003] Existing research mainly uses sensors, deep learning and computer vision technology to realize intelligent recognition of livestock life characteristics. However, it is difficult for sensors to avoid interfering with the natural behavior of livestock. In particular, sheep are timid and more prone to stress reactions; deep learning and computer vision technology face many challenges when dealing with complex scenes, such as occlusion between livestock and complex backgrounds. In addition, for farms that require real-time monitoring, the complexity of the model is also an important factor affecting actual deployment. Therefore, it is very necessary to design a method for identifying sheep life characteristics based on deep learning. Summary of the invention

[0004] In order to overcome the shortcomings of the prior art, the purpose of the present invention is to provide a method for identifying sheep life characteristics based on deep learning.

[0005] To achieve the above object, the present invention provides the following solutions:

[0006] The present invention provides a method for identifying life characteristics of sheep based on deep learning, comprising:

[0007] Determine the vital characteristics of the sheep to be studied: Based on expert inquiries, literature review and on-site observation, determine the vital characteristics of the sheep to be studied, including rumination, stress, lethargy, normal, lying down and sleeping;

[0008] Create a dataset of sheep vital signs: Build a visual system to collect images of sheep vital signs, annotate and divide the dataset, and then perform data enhancement on vital signs with less data in the training set, and finally obtain a dataset of sheep vital signs;

[0009] Constructing a sheep life feature recognition model based on deep learning, including an image feature extraction module, a multi-scale feature fusion module and a life feature output module, wherein the image feature extraction module is used to extract multi-scale feature representations from the sheep life feature image, the multi-scale feature fusion module is used to fuse and enhance the extracted multi-scale feature representations, and the life feature output module recognizes the fused feature information and outputs the recognition result;

[0010] The sheep life characteristics recognition model is trained based on the sheep life characteristics data set to obtain weights;

[0011] The performance of the trained sheep vital signs recognition model is evaluated based on the test set of the sheep vital signs data set, and the sheep vital signs recognition results are output.

[0012] Preferably, the image feature extraction module of the sheep life feature recognition model follows a lightweight strategy, and the core module is a lightweight feature extraction module, which is composed of a local processing function, two point-by-point processing functions, a normalization and activation function, specifically:

[0013] The local processing function uses a 3*3 weight matrix to slide on the input feature map to calculate the weighted sum of the local area. The feature map after local processing is expressed as:

[0014] O lc =I*W lc +b lc

[0015] Where I is the input feature map, * represents the convolution operation, and W lc is the local processing function kernel weight, b lc For compensation items;

[0016] The weight matrix size of the point-by-point processing function is 1*1, which is used to change in the channel dimension without changing the spatial dimension of the feature map. The output feature map after the point-by-point processing function is expressed as:

[0017] Output = O lc ×W l +b i

[0018] Where W i Represents the point-by-point processing function kernel weight, b i is the compensation term, and i represents the i-th point-by-point processing.

[0019] The normalization function and the activation function are placed between the two point-by-point processing functions, and the normalization function expression is:

[0020]

[0021] Where Output is the output feature map after point-by-point processing, μ and σ 2 are the mean and variance of the current batch of data, γ and β are learnable parameters, and ∈ is a constant that enhances numerical stability;

[0022] Preferably, the image feature extraction module of the sheep life feature recognition model includes, in addition to the lightweight feature extraction module, an embedded feature simplification module, a merged feature simplification module and a multi-level feature extraction module, specifically:

[0023] The embedded feature reduction module is a matrix with a sliding distance of 4, which is used for initial feature extraction. The weight matrix size is 4. Through the convolution operation, the size of the original sheep life feature image can be reduced by 4 times to 160*160. The formula for the change of feature map size is:

[0024]

[0025] In the formula, H in and W in are the length and width of the input feature map, p_size and p_stride are the size of the weight matrix and the sliding distance, respectively. out and W out are the length and width of the output feature map, respectively, expanding the original channel dimension from 3 to 40;

[0026] The merged feature reduction module is a conventional convolution with a sliding distance of 2 and a weight matrix size of 2, which reduces the size of the feature map by 2 times. The formula for the change in feature map size is:

[0027]

[0028] In the formula, H out and W out are the length and width of the output feature map, H in and W in are the length and width of the input feature map, S is the sliding distance, k is the weight matrix size, and the three merged feature reduction modules output feature maps of 80*80, 40*40, and 20*20 respectively. At the same time, the number of output channels of the three merged feature reduction modules are 80, 160, and 320 respectively;

[0029] The multi-level feature extraction module captures the global and local features of the image and fuses these features together to obtain four feature maps with scales of 160*160, 80*80, 40*40, and 20*20.

[0030] Preferably, the multi-scale feature fusion module of the sheep life feature recognition model includes a lightweight feature enhancement module, a feature splicing module, a feature enhancement module and a feature integration module, specifically:

[0031] The lightweight feature enhancement module consists of a prediction module and a reorganization module. The prediction module reduces the dimension of the input feature map through a convolution layer, and then predicts the weight parameters required for each position of the feature map through another convolution layer. The reorganization module uses the predicted weights and the original feature map to generate an upsampled feature map. The key formula of the lightweight feature enhancement module is:

[0032]

[0033] Where i and j are the coordinates of the output feature map y, K up is the weight size, S is the magnification factor, p, q are the traversed areas, and m is each traversed element. is the weight of the mth element at position (i, j), which is predicted by the prediction module, x i+p·S,j+q·S For the element at the corresponding position in the input feature map x, the magnification factor of the lightweight feature enhancement module is set to 2, and the output feature map size is twice the size of the input feature map;

[0034] The feature splicing module is used to combine feature maps of different scales to ensure that the sheep life feature recognition model can fully utilize information of different scales;

[0035] The feature enhancement module first performs an input feature map Perform local enhancement operation, the local enhancement formula is:

[0036]

[0037] Where, L b,c,i,j is the value of the local enhanced feature map in the bth batch, the cth channel, and the spatial position (i, j), X b,c,i,j is the value of the input feature map in batch b, channel c and spatial position (i, j), k is the local enhancement window size, which defines the size of each local region, m and n are the indices of the pixel positions within the local window,

[0038] Secondly, a global enhancement operation is used to convert the entire feature map into a single value, which is conducive to capturing global features. The global enhancement formula is:

[0039]

[0040] In the formula, G b,c Represents the value of the enhanced feature map in batch b and channel c, where H and W are the height and width of the input feature map respectively;

[0041] Then, the local features and global features are transformed and reconstructed through one-dimensional convolution respectively. For the local enhanced features, the local features are combined with the input feature map through element-by-element multiplication to highlight the local features; for the globally enhanced features, the global enhanced features are combined with the local enhanced features through addition to fuse the global context information;

[0042] Finally, the feature maps that have been processed with local and global enhancement are de-enhanced to restore the original spatial dimensions;

[0043] The weight matrix size of the feature integration module is 3, and the sliding distance is 2, which can reduce the spatial dimension of the feature map, while increasing the number of channels of the feature map and extracting more advanced abstract features; the feature integration module can further integrate feature maps from different layers after the feature splicing module to fuse feature information.

[0044] Preferably, the life sign output module is composed of three detection heads, each of which includes two branches, and the bounding box loss and the classification loss are calculated by two 3*3 convolutions and one 1*1 two-dimensional convolution respectively. The life sign output module uses an optimization function to improve the model training process, wherein the optimization function is:

[0045]

[0046] In the formula,

[0047]

[0048] Where λ and μ are weight coefficients, is the ratio of the intersection and union of the model prediction area and the true label area, and They are the coordinates of the center point of the real frame, and They are the coordinates of the center point of the prediction box, d w and d h are the width difference and height difference between the center point of the real box and the predicted box, w p is the width of the prediction box, h t is the height of the real frame, max(x t ,x p ) is the maximum value of the x coordinates of the real box and the predicted box, max(y t ,y p ) is the maximum value of the y coordinates of the real box and the predicted box. The value of θ is determined during the model training process. t is the probability that the model predicts the life feature category as the positive category, and γ is the balance coefficient for adjusting the positive and negative categories.

[0049] Preferably, the performance of the trained sheep life feature recognition model is evaluated based on the test set of the sheep life feature data set. The indicators for evaluating the lightweight degree of the model are the number of parameters and the amount of computation. Among them, the formula for calculating the number of parameters is:

[0050] Number of parameters = ∑(K × K × C in × C out )

[0051] In the formula, K is the size of the filter, C in is the number of input channels, and C out is the number of output channels;

[0052] The formula for calculating the amount of computation is:

[0053] Amount of computation = ∑(K × K × C in × C out × H × W) * 10 9

[0054] In the formula, K is the size of the filter, C in is the number of input channels, C out is the number of output channels, and H and W respectively represent the height and width of the output feature map;

[0055] The indicator for evaluating the accuracy of the model is the comprehensive accuracy of all life feature categories, and the calculation formula is:

[0056] Comprehensive accuracy = a * σ + b * δ

[0057] Among them, a + b = 1 and a, b ∈ [0, 1], σ is the rough positioning accuracy, δ is the fine positioning accuracy, and the calculation formulas for σ and δ are:

[0058]

[0059] In the formula, n is the number of life feature categories. When only rough positioning is required in the task scenario, a > b, otherwise a < b. P and R are the recognition accuracy and recall rate of each life feature category. The intersection-over-union threshold of P and R under rough positioning is set to 0.5, and the intersection-over-union threshold of P and R under fine positioning is set to 0.5 - 0.95.

[0060] According to the specific embodiments provided by the present invention, the following technical effects are disclosed by the present invention:

[0061] The present invention provides a method for identifying sheep life characteristics based on deep learning, the method comprising: determining the sheep life characteristics to be studied, preparing a sheep life characteristic data set, constructing a sheep life characteristic identification model, training the sheep life characteristic identification model based on the sheep life characteristic data set, performing performance evaluation on the trained sheep life characteristic identification model based on the sheep life characteristic data set, and outputting a sheep life characteristic identification result. The present invention has the following beneficial effects:

[0062] (1) The present invention proposes a contactless method for identifying the vital characteristics of sheep. Through deep learning and computer vision technology, the vital characteristics of sheep, such as lethargy, normality, wandering, etc., are detected, which is helpful for farmers to monitor the health status of the flock in time and improve the breeding efficiency.

[0063] (2) The present invention has produced a dataset of vital characteristics of sheep, collecting image data of six vital characteristics of sheep in a shed environment, namely, rumination, stress, lethargy, normal, lying down, and sleeping, which is beneficial to promoting research and development in the field of sheep breeding.

[0064] (3) The present invention proposes a lightweight and high-precision sheep life feature recognition model. By adopting a lightweight network as the backbone network for sheep life feature recognition, the consumption of computing resources is reduced and lightweight life feature recognition is achieved. Through a lightweight feature enhancement method, a feature enhancement module and a loss function, the model can achieve high-precision recognition of sheep life features in complex and occluded backgrounds while being lightweight. BRIEF DESCRIPTION OF THE DRAWINGS

[0065] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.

[0066] Figure 1 A flow chart of a method provided by an embodiment of the present invention;

[0067] Figure 2 This is a schematic diagram of the structure of the sheep life characteristics recognition model. DETAILED DESCRIPTION

[0068] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0069] The purpose of the present invention is to provide a method for identifying the vital characteristics of sheep based on deep learning. The method has fewer parameters and calculation amount than other widely used target detection network models, and has higher comprehensive accuracy than other target detection network models. The method can be widely used in the intersection of artificial intelligence and animal husbandry.

[0070] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.

[0071] Figure 1 A flow chart of a method provided by an embodiment of the present invention, such as Figure 1 As shown, the present invention provides a method for identifying life characteristics of sheep based on deep learning, comprising:

[0072] Step 100: Determine the vital characteristics of the sheep under study;

[0073] Step 200: Create a sheep vital characteristics data set;

[0074] Step 300: constructing a sheep life feature recognition model;

[0075] Step 400: training a sheep life feature recognition model based on a sheep life feature data set to obtain weights;

[0076] Step 500: Perform performance evaluation on the trained sheep vital characteristics recognition model based on the test set of the sheep vital characteristics data set, and output the sheep vital characteristics recognition result.

[0077] The steps of the present invention are introduced in conjunction with the embodiments:

[0078] Step 100, determining the vital characteristics of the sheep to be studied, specifically:

[0079] The vital characteristics of the sheep directly reflect the health status of the sheep, which can be determined by combining expert consultation, literature review and on-site observation;

[0080] In the embodiment of the present invention, the life characteristics of the sheep studied include rumination, stress, listlessness, normal, lying down, and sleeping.

[0081] In step 200, a sheep vital characteristics dataset is constructed, specifically:

[0082] Data collection: The sheep vital characteristics data set is collected by building a visual system. The visual system consists of a camera, a sheepfold equipped with a feeding trough and a water trough, and a number of sheep. The camera positions are reasonably deployed according to the layout of the sheepfold to ensure that the vital characteristics information of the sheep can be fully covered and completely recorded;

[0083] The collected videos are framed and screened: different sampling intervals are set according to the characteristics of life characteristics. When the life characteristics do not change significantly over time, a larger sampling interval is set, so as to extract high-quality sheep life characteristic images containing as many characteristics as possible. In the embodiment of the present invention, there are 4702 sheep characteristic images after screening, of which 1901 images contain a single sheep and 2801 images contain multiple sheep;

[0084] Create a dataset of images of the vital characteristics of sheep throughout the day: select the sheep with a rectangular box and mark the category of the vital characteristics of the sheep. When marking, the entire body range of the sheep should be selected to capture more vital characteristics; divide the original dataset into training set, validation set and test set in a ratio of 8:1:1, and the test set should be randomly extracted from various types of vital characteristics images in a balanced manner; perform data enhancement on vital characteristics with less data in the training set, and the data enhancement methods include randomly cropping an area, randomly rotating a certain angle, randomly translating a certain distance, randomly flipping horizontally or vertically, adding noise to the image, etc. The probability of each operation being executed is set to 50%, and each operation may be performed at the same time. Among them, the rotation angle is randomly selected between 0 and 5°, and flipping and translation include changes in the horizontal and vertical directions.

[0085] In step 300, a sheep life feature recognition model is constructed, specifically:

[0086] like Figure 2 As shown, the sheep life feature recognition model includes an image feature extraction module, a multi-scale feature fusion module and a life feature output module. The image feature extraction module is used to extract multi-scale feature representations from the sheep life feature image, the multi-scale feature fusion module is used to fuse and enhance the extracted multi-scale feature representations, and the life feature output module recognizes the fused feature information to obtain the recognition result.

[0087] The network structure hierarchy of the sheep life feature recognition model is shown in Table 1, where the number of channels refers to the depth of the feature map, which represents the number of features that can be extracted. The size of the feature map includes width and height, reflecting the spatial dimension information. The feature maps at the lower level are larger in size and contain more spatial information, which is suitable for detecting larger objects in the image. The feature maps at the higher level are smaller in size and contain more semantic information, which is suitable for detecting smaller objects.

[0088] Table 1 Structural hierarchy of feature extraction module and multi-scale feature fusion module of sheep life feature recognition model

[0089]

[0090]

[0091] The 0th to 8th layers of the sheep life feature recognition model are image feature extraction modules, the input is a 640*640 image, the number of image channels is 3, wherein the 0th layer is an embedded feature reduction module layer, the 1st, 3rd, 5th and 7th layers are lightweight feature extraction module layers, the 2nd, 4th and 6th layers are merged feature reduction module layers, and the 8th layer is a multi-level feature extraction module layer;

[0092] The embedded feature reduction module layer at layer 0 is a matrix with a sliding distance of 4, which is used for initial feature extraction. The weight matrix size is 4. Through the convolution operation, the size of the original sheep life feature image can be reduced by 4 times to 160*160. The formula for the change of feature map size is:

[0093]

[0094] In the formula, H in and W in are the length and width of the input feature map, p_size and p_stride are the size of the weight matrix and the sliding distance, respectively. out and W out are the length and width of the output feature map, respectively. This expands the model's receptive field, helps capture more advanced features, and expands the original channel dimension from 3 to 40, which can improve the feature's expressiveness.

[0095] The merged feature reduction module layer is a conventional convolution with a sliding distance of 2 and a weight matrix size of 2, which reduces the size of the feature map by 2 times. The formula for the change in feature map size is:

[0096]

[0097] In the formula, H out and W out are the length and width of the output feature map, H in and W in are the length and width of the input feature map, S is the sliding distance, k is the size of the weight matrix, and the 2nd, 4th, and 6th layers of the three merged feature reduction module layers output feature maps of 80*80, 40*40, and 20*20, respectively. At the same time, the output channel numbers of the three merged feature reduction module layers are 80, 160, and 320, respectively, to further extract features;

[0098] The lightweight feature extraction module layer consists of a 3*3 local processing function and two 1*1 point-by-point processing functions. The output feature map after the point-by-point processing function is expressed as:

[0099] Output = O lc ×W i +b i

[0100] Where W i Represents the point-by-point processing function kernel weight, b i is a compensation term, i represents the i-th point-by-point processing, and the normalization function and activation function are placed between the point-by-point processing functions. The normalization function expression is:

[0101]

[0102] Where Output is the output feature map after point-by-point processing, μ and σ 2 are the mean and variance of the current batch of data, γ and β are learnable parameters, ∈ is a constant that enhances numerical stability. The amount of calculation under the combination of local processing function and point-by-point processing function is less than the conventional method. In addition, the normalization function and activation function are only used between two point-by-point processing functions, which can achieve lightweight network structure design while ensuring effective feature extraction;

[0103] The multi-level feature extraction module layer captures the global and local features of the image and fuses these features together to obtain four feature maps with scales of 160*160, 80*80, 40*40, and 20*20, which provides rich feature information for subsequent life feature recognition tasks and helps the model detect objects at different scales.

[0104] The 9th to 20th layers of the sheep life feature recognition model are the multi-scale feature fusion module, which includes a lightweight feature enhancement module, a feature splicing module, a feature enhancement module and a feature integration module;

[0105] The lightweight feature enhancement module is the 9th and 12th layers of the model, which consists of a prediction module and a reorganization module. The prediction module reduces the dimension of the input feature map through a convolution layer, and then predicts the weight parameters required for each position of the feature map through another convolution layer. The reorganization module uses the predicted weights and the original feature map to generate the upsampled feature map. The key formula of the lightweight feature enhancement module is:

[0106]

[0107] Where i and j are the coordinates of the output feature map y, K up is the weight size, S is the magnification factor, p, q are the traversed areas, and m is each traversed element. is the weight of the mth element at position (i, j), which is predicted by the prediction module, x i+p·S,j+q·Sis the element at the corresponding position in the input feature map x. The magnification factor of the lightweight feature enhancement module is set to 2, and the output feature map size is twice the size of the input feature map, which helps to improve the performance of the model in dense prediction tasks and capture subtle features in the presence of occlusion and complex background;

[0108] The feature splicing module is the 10th, 13th, 16th and 19th layers of the model. The 10th and 13th layers are used to splice multiple feature maps along a specific dimension. Low-level feature maps usually have high spatial resolution but less semantic information, while high-level feature maps have rich semantic information but low spatial resolution. The feature splicing module combines feature maps of different levels to ensure that the sheep life feature recognition model can make full use of information of different scales. The 16th layer is used to splice the feature map after the convolution operation with the output feature map of the 11th layer, further integrating features of different levels, increasing the number of channels of the feature map, and providing more abundant information for subsequent detection tasks. The 19th layer is the feature fusion before the final detection, which is used to combine feature maps of different scales so that the model can more accurately identify the category of sheep life features.

[0109] The feature enhancement module is the 11th, 14th, 17th and 20th layers of the model. First, the input feature map Perform local enhancement operation, the local enhancement formula is:

[0110]

[0111] Where, L b,c,i,j is the value of the local enhanced feature map in the bth batch, the cth channel, and the spatial position (i, j), X b,c,i,j is the value of the input feature map in batch b, channel c and spatial position (i, j), k is the local enhancement window size, which defines the size of each local region, m and n are the indices of the pixel positions within the local window,

[0112] Secondly, a global enhancement operation is used to convert the entire feature map into a single value, which is conducive to capturing global features. The global enhancement formula is:

[0113]

[0114] In the formula, G b,c Represents the value of the enhanced feature map in batch b and channel c, where H and W are the height and width of the input feature map respectively;

[0115] Then, the local features and global features are transformed and reconstructed through one-dimensional convolution respectively. For the local enhanced features, the local features are combined with the input feature map through element-by-element multiplication to highlight the local features; for the globally enhanced features, the global enhanced features are combined with the local enhanced features through addition to fuse the global context information;

[0116] Finally, the feature maps that have been processed with local and global enhancement are de-enhanced to restore the original spatial dimensions;

[0117] The feature enhancement module can fuse feature information of different scales, thereby improving the recognition accuracy of the sheep life feature recognition model for sheep of different scales due to different distances in the image;

[0118] The feature integration module is the 15th and 18th layers of the model. The weight matrix size of the feature integration module is 3 and the sliding distance is 2. It can reduce the spatial dimension of the feature map and increase the number of channels of the feature map to extract more advanced abstract features. The feature integration module can further integrate feature maps from different layers after the feature splicing module to fuse feature information.

[0119] The life sign output module is composed of three detection heads, each of which contains two branches. The bounding box loss and classification loss are calculated by two 3*3 convolutions and one 1*1 two-dimensional convolution respectively. The life sign output module uses an optimization function to improve the model training process and further improve the accuracy of the model. The optimization function is:

[0120]

[0121] In the formula,

[0122]

[0123] Where λ and μ are weight coefficients, is the ratio of the intersection and union of the model prediction area and the true label area, and They are the coordinates of the center point of the real frame, and They are the coordinates of the center point of the prediction box, d w and d h are the width difference and height difference between the center point of the real box and the predicted box, w p is the width of the prediction box, h t is the height of the real frame, max(x t ,x p ) is the maximum value of the x coordinates of the real box and the predicted box, max(y t ,y p) is the maximum value of the y coordinates of the real box and the predicted box. The value of θ is determined during the model training process. t is the probability that the model predicts the life feature category as the positive category, and γ is the balance coefficient for adjusting the positive and negative categories. Compared with the traditional optimization function, the optimization function of the present invention not only focuses on the overlapping area between the model prediction area and the true label area, but also considers the center point position of the bounding box, aspect ratio, angle and other geometric characteristics, so that the model can converge faster to the optimal solution during the training process, further improving the model accuracy.

[0124] In step 400, the sheep life feature recognition model is trained based on the sheep life feature data set to obtain weights, specifically:

[0125] Input the prepared data set into the constructed sheep vital characteristics recognition model;

[0126] The models in the embodiments of the present invention are all run on the same computer, which is equipped with an Intel (R) Xeon (R) E5-2686 v4 (2.3GHz) CPU with 64GB RAM and an NVIDIA GeForce RTX 4090 56GB GPU; the operating system is Windows 10 Professional 64-bit; the deep learning development and image processing environment in the embodiments of the present invention is composed of PyCharm 2023.2, Python 3.10.9, PyTorch 2.0.1, Torchvision 0.15.2, CUDA11.8, cuDNN 8.7.0 and OpenCV Python4.9.0;

[0127] The image size of the model input in the embodiment of the present invention is 640×640 pixels; to ensure the effectiveness of the results, the epoch is uniformly set to 200, the batchsize is set to 32, and the remaining hyperparameters keep the default values.

[0128] In step 500, the performance of the trained sheep life feature recognition model is evaluated based on the test set of the sheep life feature data set, and the sheep life feature recognition result is output, specifically:

[0129] In the embodiment of the present invention, two indicators, namely, the parameter quantity and the calculation quantity, are selected to measure the lightweight degree of the model, and the comprehensive accuracy of all life feature categories is selected to evaluate the recognition accuracy of the model;

[0130] The parameter quantity refers to the number of operations that the network model needs to calculate, which reflects the time complexity of the model. The calculation formula is shown below:

[0131] Parameter quantity = ∑(K×K×C in ×C out)

[0132] The computing volume refers to floating-point operations per second in billions, and the calculation formula is as shown below:

[0133] Computing volume = ∑(K×K×C in ×C out ×H×W)*10 9

[0134] In the formula, K is the size of the filter, C in is the number of input channels, C out is the number of output channels, and H and W respectively represent the height and width of the output feature map;

[0135] The calculation formula for the comprehensive accuracy of all life feature categories is as shown below. Among them, a + b = 1 and a, b ∈ [0, 1], σ is the rough positioning accuracy, δ is the fine positioning accuracy, and the calculation formulas for σ and δ are: In the formula, n is the number of life feature categories. When only rough positioning is required in the task scenario, a > b, otherwise a < b. P and R are the recognition accuracy and recall rate of each life feature category. The intersection-over-union threshold of P and R under rough positioning is set to 0.5, and the intersection-over-union threshold of P and R under fine positioning is set to 0.5 - 0.95. In the present invention, a and b are respectively set to 0.7 and 0.3;

[0136] Comprehensive accuracy = a*σ + b*δ

[0137] As shown in Table 2, the number of parameters and the computing volume of the sheep life feature recognition model proposed in the present invention are both smaller than those of other widely used object detection network models, and the recognition accuracy is higher than that of other object detection network models. The experimental comparison results show that the lightweight and high-precision strategy proposed in the present invention is successful, and the sheep life feature recognition model proposed in the present invention has significant advantages of lightweight and high precision;

[0138] Table 2 Performance comparison table of the life feature recognition model of the present invention and widely used object detection network models

[0139]

[0140] In this specification, each embodiment is described in a progressive manner. The key point of each embodiment is to illustrate the differences from other embodiments. The same or similar parts among the embodiments can be referred to each other.

[0141] The principles and implementation methods of the present invention are described in this article using specific examples. The description of the above embodiments is only used to help understand the method and core idea of ​​the present invention. At the same time, for those skilled in the art, according to the idea of ​​the present invention, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as limiting the present invention.

Claims

1. A method for identifying sheep life characteristics based on deep learning, characterized in that: include: Determine the vital characteristics of the sheep to be studied: Based on expert inquiries, literature review and on-site observation, determine the vital characteristics of the sheep to be studied, including rumination, stress, lethargy, normal, lying down and sleeping; Create a dataset of sheep vital signs: Build a visual system to collect images of sheep vital signs, annotate and divide the dataset, and then perform data enhancement on vital signs with less data in the training set, and finally obtain a dataset of sheep vital signs; Constructing a sheep life feature recognition model based on deep learning, including an image feature extraction module, a multi-scale feature fusion module and a life feature output module, wherein the image feature extraction module is used to extract multi-scale feature representations from the sheep life feature image, the multi-scale feature fusion module is used to fuse and enhance the extracted multi-scale feature representations, and the life feature output module recognizes the fused feature information and outputs the recognition result; The sheep life characteristics recognition model is trained based on the sheep life characteristics data set to obtain weights; The performance of the trained sheep vital signs recognition model is evaluated based on the test set of the sheep vital signs data set, and the sheep vital signs recognition results are output.

2. The method according to claim 1, characterized in that The image feature extraction module of the sheep life feature recognition model follows a lightweight strategy, and the core module is a lightweight feature extraction module. The lightweight feature extraction module is composed of a local processing function, two point-by-point processing functions, and a normalization and activation function, specifically: The local processing function uses a 3*3 weight matrix to slide on the input feature map to calculate the weighted sum of the local area. The feature map after local processing is expressed as: O lc =I*W lc +b lc Where I is the input feature map, * represents the convolution operation, and W lc is the local processing function kernel weight, b lc For compensation items; The weight matrix size of the point-by-point processing function is 1*1, which is used to change in the channel dimension without changing the spatial dimension of the feature map. The output feature map after the point-by-point processing function is expressed as: Output=Q lc ×W i +b i Where W i Represents the point-by-point processing function kernel weight, b i is the compensation term, and i represents the i-th point-by-point processing. The normalization function and the activation function are placed between the two point-by-point processing functions, and the normalization function expression is: Where Output is the output feature map after point-by-point processing, μ and σ 2 are the mean and variance of the current batch of data, γ and β are learnable parameters, and ∈ is a constant that enhances numerical stability.

3. The method according to claim 1, characterized in that The image feature extraction module of the sheep life feature recognition model includes, in addition to the lightweight feature extraction module, an embedded feature simplification module, a merged feature simplification module and a multi-level feature extraction module, specifically: The embedded feature reduction module is a matrix with a sliding distance of 4, which is used for initial feature extraction. The weight matrix size is 4. Through the convolution operation, the size of the original sheep life feature image can be reduced by 4 times to 160*160. The formula for the change of feature map size is: In the formula, H in and W in are the length and width of the input feature map, p_size and p_stride are the size of the weight matrix and the sliding distance, respectively. out and W out are the length and width of the output feature map, respectively, expanding the original channel dimension from 3 to 40; The merged feature reduction module is a conventional convolution with a sliding distance of 2 and a weight matrix size of 2, which reduces the size of the feature map by 2 times. The formula for the change in feature map size is: In the formula, H out and W out are the length and width of the output feature map, H in and W in are the length and width of the input feature map, S is the sliding distance, k is the weight matrix size, and the three merged feature reduction modules output feature maps of 80*80, 40*40, and 20*20 respectively. At the same time, the number of output channels of the three merged feature reduction modules are 80, 160, and 320 respectively; The multi-level feature extraction module captures the global and local features of the image and fuses these features together to obtain four feature maps with scales of 160*160, 80*80, 40*40, and 20*20.

4. The method according to claim 1, characterized in that: The multi-scale feature fusion module of the sheep life feature recognition model includes a lightweight feature enhancement module, a feature splicing module, a feature enhancement module and a feature integration module, specifically: The lightweight feature enhancement module consists of a prediction module and a recombination module. The prediction module reduces the dimension of the input feature map through a convolutional layer, and then predicts the weight parameters required for each position of the feature map through another convolutional layer. The recombination module uses the predicted weights and the original feature map to generate an upsampled feature map. The key formula of the lightweight feature enhancement module is: Where i and j are the coordinates of the output feature map y, K up is the weight size, S is the magnification factor, p, q are the traversed areas, and m is each traversed element. is the weight of the mth element at position (i, j), which is predicted by the prediction module, x i+p·S,j+q·S For the element at the corresponding position in the input feature map x, the magnification factor of the lightweight feature enhancement module is set to 2, and the output feature map size is twice the size of the input feature map; The feature splicing module is used to combine feature maps of different scales to ensure that the sheep life feature recognition model can make full use of information of different scales; The feature enhancement module first performs an input feature map Perform local enhancement operation, the local enhancement formula is: Where, L b,c,i,j is the value of the local enhanced feature map in the bth batch, the cth channel, and the spatial position (i, j), X b,c,i,j is the value of the input feature map in batch b, channel c and spatial position (i, j), k is the local enhancement window size, which defines the size of each local region, m and n are the indices of the pixel positions within the local window, Secondly, a global enhancement operation is adopted to convert the entire feature map into a single value, which is beneficial to capturing global features. The global enhancement formula is: In the formula, G b,c Represents the value of the enhanced feature map in batch b and channel c, where H and W are the height and width of the input feature map respectively; Then, the local features and global features are respectively subjected to feature transformation and reconstruction through one-dimensional convolution. For the locally enhanced features, the local features are combined with the input feature map through element-wise multiplication to highlight the local features; For the globally enhanced features, the globally enhanced features are combined with the locally enhanced features through addition to fuse the global context information; Finally, the feature map processed by local and global enhancement is subjected to an anti-enhancement operation to restore the original spatial dimension; The weight matrix of the feature integration module has a size of 3 and a sliding distance of 2, which can reduce the spatial dimension of the feature map while increasing the number of channels of the feature map, and extract more advanced abstract features; The feature integration module can further integrate the feature maps from different layers and fuse the feature information after the feature splicing module.

5. The method according to claim 1, characterized in that The life feature output module consists of three detection heads. Each detection head contains two branches, which calculate the bounding box loss and classification loss through 2 3*3 convolutions and 1 1*1 two-dimensional convolution respectively. The life feature output module uses an optimization function to improve the model training process. Among them, the optimization function is: In the formula, Where λ and μ are weight coefficients, is the ratio of the intersection and union of the model prediction area and the true label area, and They are the coordinates of the center point of the real frame, and They are the coordinates of the center point of the prediction box, d w and d h are the width difference and height difference between the center point of the real box and the predicted box, respectively, w p is the width of the prediction box, h t is the height of the real frame, max(x t ,x p ) is the maximum value of the x coordinates of the real box and the predicted box, max(y t ,y p ) is the maximum value of the y coordinates of the real box and the predicted box. The value of θ is determined during the model training process. t is the probability that the model predicts the life feature category as the positive category, and γ is the balance coefficient for adjusting the positive and negative categories.

6. The method according to claim 1, characterized in that The performance of the trained sheep life feature recognition model is evaluated based on the test set of the sheep life feature dataset. The indicators for evaluating the lightweight degree of the model are the number of parameters and the amount of computation. Among them, the formula for calculating the number of parameters is: Parameter quantity = ∑(K×K×C in ×C out ) Where K is the size of the filter, C in is the number of input channels, C out is the number of output channels; The formula for calculating the amount of computation is: Calculation amount = ∑(K×K×C in ×C out ×H×W)*10 9 Where K is the size of the filter, C in is the number of input channels, C out is the number of output channels, H and W represent the height and width of the output feature map respectively; The indicator for evaluating the model accuracy is the comprehensive accuracy of all life feature categories. The calculation formula is: Comprehensive accuracy = a*σ + b*δ Among them, a + b = 1 and a, b ∈ [0, 1]. σ is the rough positioning accuracy, and δ is the fine positioning accuracy. The calculation formulas for σ and δ are: In the formula, n is the number of life feature categories. When only rough positioning is required in the task scenario, a > b, otherwise a < b. P and R are the recognition accuracy and recall rate of each life feature category. The intersection-over-union threshold of P and R under rough positioning is set to 0.5, and the intersection-over-union threshold of P and R under fine positioning is set to 0.5 - 0.95.

Citation Information

Patent Citations

  • Knowledge distillation-based YOLOv5s lightweight sheep variety identification method and system

    CN116052211A

  • Pasture sheep target automatic segmentation method and system based on deep learning

    CN116993977A

  • Sheep behavior characteristic identification method and system

    CN118296552A

  • Sheep apparent state identification method and system based on improved supervised learning network

    CN120429681A

  • Systems and methods utilizing artificial intelligence for placental assessment and examination

    US20210056691A1