A Deep Learning-Based Method for Sheep Vital Sign Recognition

By using a deep learning-based method for sheep vital sign recognition, the problem of low efficiency in sheep vital sign recognition has been solved, achieving efficient and lightweight sheep vital sign recognition, thereby improving breeding efficiency and recognition accuracy.

CN119380371BActive Publication Date: 2025-10-31CHINA AGRI UNIV
View PDF 1 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

In existing technologies, the identification of vital signs in sheep mainly relies on manual observation, which is inefficient and difficult to achieve efficient and accurate monitoring in large-scale farms. Sensors and deep learning methods face challenges in identifying interference and complex scenes.

Method used

A deep learning-based method for identifying sheep vital signs is adopted, which includes feature identification, construction of a lightweight feature extraction module, a multi-scale feature fusion module, and a vital sign output module. Through image feature extraction, multi-scale feature fusion, and recognition, combined with a lightweight network and feature enhancement module, high-precision recognition is achieved.

Benefits of technology

It achieves contactless, efficient, and lightweight sheep vital sign recognition, improving breeding efficiency, accurately identifying sheep vital signs in complex backgrounds, and reducing computational resource consumption.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119380371B_ABST
    Figure CN119380371B_ABST
Patent Text Reader

Abstract

This invention provides a deep learning-based method for identifying sheep vital signs. The method includes: determining the vital signs of the sheep under study; creating a sheep vital sign dataset; constructing a sheep vital sign identification model; training the sheep vital sign identification model based on the sheep vital sign dataset; evaluating the performance of the trained sheep vital sign identification model based on the sheep vital sign dataset; and outputting the sheep vital sign identification result. This invention can achieve sheep vital sign identification with fewer parameters and lower computational cost compared to other widely used object detection network models, while achieving higher overall accuracy. It can be widely applied in the interdisciplinary field of artificial intelligence and animal husbandry.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of artificial intelligence interdisciplinary technology, and in particular to a method for identifying the vital signs of sheep based on deep learning. Background Technology

[0002] Vital characteristics are shared traits exhibited by organisms that can be replicated or inherited by offspring. In sheep, vital characteristics such as rumination, stress, lethargy, normalcy, resting, and sleep are important indicators that directly reflect their health status. Timely identification of sheep's vital characteristics is crucial for farmers to effectively monitor the health of their flocks and improve farming efficiency. Currently, the identification of sheep's vital characteristics mainly relies on manual observation, which is inefficient. Furthermore, continuously monitoring the vital characteristics of large-scale sheep farms is extremely challenging. Therefore, there is an urgent need to develop an efficient, high-precision, and lightweight method for identifying sheep's vital characteristics.

[0003] Current research primarily employs sensors, deep learning, and computer vision technologies to achieve intelligent identification of livestock vital signs. However, sensors inevitably interfere with the natural behavior of livestock. Sheep, in particular, are timid and more prone to stress responses. Deep learning and computer vision technologies face numerous challenges when handling complex scenes, such as occlusion between livestock and complex backgrounds. Furthermore, for farms requiring real-time monitoring, model complexity is a significant factor affecting practical deployment. Therefore, designing a deep learning-based method for sheep vital sign identification is essential. Summary of the Invention

[0004] In order to overcome the shortcomings of the existing technology, the purpose of this invention is to provide a method for identifying the vital signs of sheep based on deep learning.

[0005] To achieve the above objectives, the present invention provides the following solution:

[0006] This invention provides a deep learning-based method for identifying the vital signs of sheep, comprising:

[0007] Determine the vital characteristics of the sheep in the study: Based on expert consultation, literature review and on-site observation, determine the vital characteristics of the sheep in the study, including rumination, stress, lethargy, normal, resting and sleeping;

[0008] Creating a sheep vital signs dataset: A vision system was built to collect images of sheep vital signs, and the dataset was labeled and segmented. Then, data augmentation was performed on vital signs with less data in the training set, and finally, a sheep vital signs dataset was obtained.

[0009] A deep learning-based sheep vital sign recognition model is constructed, including an image feature extraction module, a multi-scale feature fusion module, and a vital sign output module. The image feature extraction module is used to extract multi-scale feature representations from sheep vital sign images. The multi-scale feature fusion module is used to fuse and enhance the extracted multi-scale feature representations. The vital sign output module identifies the fused feature information and outputs the recognition result.

[0010] The weights are obtained by training a sheep vital sign recognition model based on a sheep vital sign dataset;

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

[0012] Preferably, the image feature extraction module of the sheep vital sign recognition model follows a lightweight strategy, with the core module being a lightweight feature extraction module. This lightweight feature extraction module consists of a local processing function, two pointwise processing functions, and a normalization and activation function, specifically:

[0013] The local processing function uses a 3x3 weight matrix to slide across the input feature map, calculating a weighted sum for local regions. The locally processed feature map is represented as follows:

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

[0015] In the formula, I is the input feature map, * represents the convolution operation, and W lc b represents the kernel weights of the local processing function. lc As compensation;

[0016] The weight matrix of the pointwise processing function is 1*1 in size, used to vary along the channel dimension without changing the spatial dimension of the feature map. The output feature map after the pointwise processing function is represented as follows:

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

[0018] In the formula, W i The representative is the kernel weight of the pointwise processing function, b i For compensation terms, i represents the i-th point-by-point processing.

[0019] The normalization function and activation function are placed between the two pointwise processing functions. The expression for the normalization function is:

[0020]

[0021] In the formula, Output is the output feature map after pointwise processing, and μ and σ 2 γ and β are the mean and variance of the current batch of data, respectively; γ and β are learnable parameters; and ∈ is a constant that enhances numerical stability.

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

[0023] The embedded feature simplification module is a matrix with a sliding distance of 4, used for initial feature extraction. The weight matrix size is 4. Through convolution operations, it can reduce the size of the original sheep vital feature image by a factor of 4, shrinking it to 160*160. The formula for the feature map size change is:

[0024]

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

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

[0027]

[0028] In the formula, H out and W out H represents the length and width of the output feature map, respectively. in and W in The length and width of the input feature map are respectively, S is the sliding distance, and k is the size of the weight matrix. The three merged feature simplification 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 simplification modules are 80, 160, and 320 respectively.

[0029] The multi-level feature extraction module captures 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 vital sign 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 reconstruction module. The prediction module reduces the dimensionality of the input feature map through a convolutional layer, and then predicts the weight parameters needed at each position of the feature map through another convolutional layer. The reconstruction 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] In the formula, i and j are the coordinates of the output feature map y, and K up Here, S represents the weight, p and q represent the regions being traversed, and m represents each element being traversed. Let x be the weight of the m-th element at position (i, j), which is predicted by the prediction module. i+p·S,j+q·S For the element at the corresponding position in the input feature map x, the amplification factor of the lightweight feature enhancement module is set to 2, and the size of the output feature map is twice the size of the input feature map;

[0034] The feature stitching module is used to combine feature maps of different scales to ensure that the sheep vital signs recognition model can make full use of information at different scales.

[0035] The feature enhancement module first processes the input feature map. Perform local enhancement operation; the local enhancement formula is:

[0036]

[0037] In the formula, L b,c,i,j X is the value of the locally enhanced feature map at spatial location (i,j) in the b-th batch and c-th channel. b,c,i,j is the value of the input feature map at batch b, channel c, and spatial location (i,j), k is the local enhancement window size, defining the size of each local region, and m and n are the indices of the pixel positions within the local window.

[0038] Secondly, a global enhancement operation is used to transform the entire feature map into a single value, which is beneficial for capturing global features. The global enhancement formula is as follows:

[0039]

[0040] In the formula, G b,c This 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 and global features are transformed and reconstructed 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 global enhanced features are combined with the local enhanced features through addition to fuse global contextual information.

[0042] Finally, the feature maps that have undergone local and global enhancement are subjected to inverse enhancement operations to restore the original spatial dimensions;

[0043] The feature integration module has a weight matrix of size 3 and a sliding distance of 2, which can reduce the spatial dimension of the feature map while increasing the number of channels in the feature map and extracting higher-level abstract features. After the feature splicing module, the feature integration module can further integrate feature maps from different layers and fuse feature information.

[0044] Preferably, the vital sign output module consists of three detection heads, each containing two branches. These branches calculate the bounding box loss and classification loss using two 3x3 convolutions and one 1x1 two-dimensional convolution, respectively. The vital 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] In the formula, λ and μ are weighting coefficients. It is the ratio of the intersection to the union of the model's predicted region and the true labeled region. and These are the coordinates of the center point of the ground truth bounding box. and These are the coordinates of the center point of the prediction box, d w and d h These are the width and height differences between the center points of the ground truth bounding box and the predicted bounding box, respectively. p It is the width of the prediction box, h t It is the height of the actual bounding box, max(x) t ,x p The maximum x-coordinate of the ground truth bounding box and the predicted bounding box is max(y). t ,y p That is, the maximum y-coordinate of the ground truth bounding box and the predicted bounding box. The value of θ is determined during model training. t γ is the probability that the model predicts the life characteristic category as positive, 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 dataset. The metrics 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 metric for evaluating the accuracy of the model is the comprehensive accuracy of all life feature categories, and the 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 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] This invention provides a deep learning-based method for identifying sheep vital signs. The method includes: determining the vital signs of the sheep under study; creating a sheep vital sign dataset; constructing a sheep vital sign identification model; training the sheep vital sign identification model based on the sheep vital sign dataset; evaluating the performance of the trained sheep vital sign identification model based on the sheep vital sign dataset; and outputting the sheep vital sign identification result. The beneficial effects of this invention are as follows:

[0062] (1) This invention proposes a non-contact sheep vital sign identification method, which uses deep learning and computer vision technology to detect the vital signs of sheep, such as lethargy, normality, and wandering, which helps farmers monitor the health status of sheep flocks in a timely manner and improve breeding efficiency.

[0063] (2) This invention has created a sheep vital characteristics dataset, which collects image data of six vital characteristics of sheep in a stall environment, namely rumination, stress, lethargy, normal, resting and sleeping, which is beneficial to promoting research and development in the field of sheep breeding.

[0064] (3) This invention proposes a lightweight and high-precision sheep vital sign recognition model. By using a lightweight network as the backbone network for sheep vital sign recognition, the consumption of computing resources is reduced, and lightweight vital sign recognition is achieved. Through a lightweight feature enhancement method, feature enhancement module and loss function, the model can achieve high-precision recognition of sheep vital signs in complex and occluded backgrounds while being lightweight. Attached Figure Description

[0065] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0066] Figure 1 A flowchart of the method provided in an embodiment of the present invention;

[0067] Figure 2 A schematic diagram of the structure of a sheep vital sign recognition model. Detailed Implementation

[0068] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0069] The purpose of this invention is to provide a deep learning-based method for identifying the vital signs of sheep. This method has fewer parameters and less computation than other widely used target detection network models, while achieving higher overall accuracy. It can be widely applied in the intersection of artificial intelligence and animal husbandry.

[0070] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.

[0071] Figure 1 A flowchart of the method provided in the embodiments of the present invention, such as Figure 1 As shown, this invention provides a deep learning-based method for identifying the vital signs of sheep, comprising:

[0072] Step 100: Determine the vital characteristics of the sheep being studied;

[0073] Step 200: Create a dataset of sheep vital signs;

[0074] Step 300: Construct a sheep vital sign recognition model;

[0075] Step 400: Train the sheep vital sign recognition model based on the sheep vital sign dataset to obtain weights;

[0076] Step 500: Evaluate the performance of the trained sheep vital sign recognition model based on the test set of the sheep vital sign dataset, and output the sheep vital sign recognition results.

[0077] The steps of the present invention will be described in conjunction with the embodiments:

[0078] Step 100: Determine the vital characteristics of the sheep being studied, specifically:

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

[0080] In this embodiment of the invention, the vital characteristics of sheep studied include rumination, stress, lethargy, normal state, resting, and sleep.

[0081] In step 200, a sheep vital signs dataset is constructed, specifically as follows:

[0082] Data collection: The sheep vital signs dataset is collected by building a vision system. The vision system consists of a camera, a sheep pen equipped with a feeding trough and a water trough, and a number of sheep. The camera positions are reasonably deployed according to the sheep pen layout to ensure comprehensive coverage and complete recording of the sheep's vital signs information.

[0083] The collected videos are frame-sampling and filtering: different sampling intervals are set according to the characteristics of vital signs. When the vital signs do not change significantly over time, a larger sampling interval is set so as to extract high-quality sheep vital sign images containing as many features as possible. In this embodiment of the invention, there are a total of 4,702 sheep feature images after filtering, including 1,901 images of a single sheep and 2,801 images of multiple sheep.

[0084] Create a full-day dataset of sheep vital sign images: Select sheep using bounding boxes and label their vital sign categories. The entire body area of ​​the sheep should be included in the labeling to capture more vital signs. Divide the original dataset into training, validation, and test sets in an 8:1:1 ratio. The test set should be randomly selected from each category of vital sign images. Perform data augmentation on vital sign images with limited data in the training set. Data augmentation methods include randomly cropping a region, randomly rotating by a certain angle, randomly translating by a certain distance, randomly flipping horizontally or vertically, and adding noise to the image. Each operation has a 50% probability of execution, and operations may be performed simultaneously. The rotation angle is randomly selected between 0 and 5°, and the flipping and translation include changes in both the horizontal and vertical directions.

[0085] In step 300, a sheep vital sign recognition model is constructed, specifically as follows:

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

[0087] The network structure hierarchy of the sheep vital sign recognition model is shown in Table 1. 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 spatial dimensional information. Lower-level feature maps are larger in size and contain more spatial information, making them suitable for detecting larger objects in the image. Higher-level feature maps are smaller in size and contain more semantic information, making them suitable for detecting smaller objects.

[0088] Table 1. Structural hierarchy of the feature extraction module and multi-scale feature fusion module in the sheep vital sign recognition model.

[0089]

[0090]

[0091] The sheep vital sign recognition model consists of image feature extraction modules in layers 0 through 8. The input is a 640*640 image with 3 channels. Layer 0 is an embedded feature simplification module layer, layers 1, 3, 5, and 7 are lightweight feature extraction module layers, layers 2, 4, and 6 are merged feature simplification module layers, and layer 8 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, used for initial feature extraction. The weight matrix size is 4. Through convolution operations, the size of the original sheep vital feature image can be reduced by a factor of 4, shrinking it to 160*160. The formula for the feature map size change is:

[0093]

[0094] In the formula, H in and W in p_size and p_stride are the length and width of the input feature map, respectively, and the weight matrix size and sliding distance are the size and sliding distance, respectively. H out and W out These represent the length and width of the output feature map, respectively, thereby expanding the model's receptive field, which is beneficial for capturing higher-level features. This expands the original channel dimension from 3 to 40, enhancing the expressive power of the features.

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

[0096]

[0097] In the formula, H out and W out H represents the length and width of the output feature map, respectively. in and W in The length and width of the input feature map are respectively, S is the sliding distance, and k is the size of the weight matrix. The three merged feature simplification module layers (layers 2, 4, and 6) 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 simplification module layers are 80, 160, and 320 respectively, for further feature extraction.

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

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

[0100] In the formula, W i The representative is the kernel weight of the pointwise processing function, b i The compensation term is represented by 'i', which indicates the i-th pointwise processing step. A normalization function and an activation function are placed between the pointwise processing functions. The expression for the normalization function is:

[0101]

[0102] In the formula, Output is the output feature map after pointwise processing, and μ and σ 2 , respectively, are the mean and variance of the current batch of data, γ and β are learnable parameters, ∈ is a constant to enhance numerical stability, the computational cost of combining local processing function and pointwise processing function is less than that of conventional method, in addition, the normalization function and activation function are only used between two pointwise processing functions, which can achieve lightweight network structure design while ensuring effective feature extraction;

[0103] The multi-level feature extraction module layer captures 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. This 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 vital sign 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 located at layers 9 and 12 of the model, consisting of a prediction module and a reconstruction module. The prediction module reduces the dimensionality 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 reconstruction 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:

[0106]

[0107] In the formula, i and j are the coordinates of the output feature map y, and K up Here, S represents the weight, p and q represent the regions being traversed, and m represents each element being traversed. Let x be the weight of the m-th element at position (i, j), which is predicted by the prediction module. i+p·S,j+q·SFor the element at the corresponding position in the input feature map x, the amplification factor of the lightweight feature enhancement module is set to 2, and the size of the output feature map is twice the size of the input feature map. This helps to improve the performance of the model in dense prediction tasks and capture subtle features in the presence of occlusion and complex backgrounds.

[0108] The feature stitching module comprises layers 10, 13, 16, and 19 of the model. Layers 10 and 13 stitch multiple feature maps along a specific dimension. Low-level feature maps typically have high spatial resolution but less semantic information, while high-level feature maps have rich semantic information but lower spatial resolution. By merging feature maps from different levels, the feature stitching module ensures that the sheep vital sign recognition model can fully utilize information at different scales. Layer 16 stitches the feature map after convolution with the output feature map of layer 11, further integrating features from different levels, increasing the number of channels in the feature map, and providing richer information for subsequent detection tasks. Layer 19 performs feature fusion before final detection, combining feature maps at different scales to enable the model to more accurately identify sheep vital sign categories.

[0109] The feature enhancement module comprises layers 11, 14, 17, and 20 of the model. It first enhances the input feature map... Perform local enhancement operation; the local enhancement formula is:

[0110]

[0111] In the formula, L b,c,i,j X is the value of the locally enhanced feature map at spatial location (i,j) in the b-th batch and c-th channel. b,c,i,j is the value of the input feature map at batch b, channel c, and spatial location (i,j), k is the local enhancement window size, defining the size of each local region, and m and n are the indices of the pixel positions within the local window.

[0112] Secondly, a global enhancement operation is used to transform the entire feature map into a single value, which is beneficial for capturing global features. The global enhancement formula is as follows:

[0113]

[0114] In the formula, G b,c This 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 and global features are transformed and reconstructed 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 global enhanced features are combined with the local enhanced features through addition to fuse global contextual information.

[0116] Finally, the feature maps that have undergone local and global enhancement are subjected to inverse enhancement operations to restore the original spatial dimensions;

[0117] The feature enhancement module can fuse feature information at different scales to improve the recognition accuracy of sheep vital signs recognition model for sheep at different scales in images due to different distances.

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

[0119] The vital sign output module consists of three detection heads, each containing two branches. These branches calculate the bounding box loss and classification loss using two 3x3 convolutions and one 1x1 two-dimensional convolution, respectively. The vital sign output module uses an optimization function to improve the model training process and further enhance the model's accuracy. The optimization function is as follows:

[0120]

[0121] In the formula,

[0122]

[0123] In the formula, λ and μ are weighting coefficients. It is the ratio of the intersection to the union of the model's predicted region and the true labeled region. and These are the coordinates of the center point of the ground truth bounding box. and These are the coordinates of the center point of the prediction box, d w and d h These are the width and height differences between the center points of the ground truth bounding box and the predicted bounding box, respectively. p It is the width of the prediction box, h t It is the height of the actual bounding box, max(x) t ,x p The maximum x-coordinate of the ground truth bounding box and the predicted bounding box is max(y). t ,y pThat is, the maximum y-coordinate of the ground truth bounding box and the predicted bounding box. The value of θ is determined during model training. t γ is the probability that the model predicts the life feature category as positive, and γ is the balance coefficient for adjusting positive and negative categories. Compared with traditional optimization functions, the optimization function of this invention not only focuses on the overlapping area between the model's predicted region and the true label region, but also considers the geometric characteristics such as the center point position of the bounding box, aspect ratio, and angle, so that the model can converge to the optimal solution faster during training and further improve the model accuracy.

[0124] In step 400, the sheep vital sign recognition model is trained based on the sheep vital sign dataset to obtain weights, specifically as follows:

[0125] Input the prepared dataset into the constructed sheep vital sign recognition model;

[0126] The models in this embodiment of the invention 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 this embodiment of the invention consists of PyCharm 2023.2, Python 3.10.9, PyTorch 2.0.1, Torchvision 0.15.2, CUDA 11.8, cuDNN 8.7.0 and OpenCV Python 4.9.0;

[0127] In this embodiment of the invention, the image size of the model input is 640×640 pixels; to ensure the validity of the results, the epoch is uniformly set to 200, the batch size is set to 32, and the other hyperparameters are kept at their default values.

[0128] In step 500, the performance of the trained sheep vital sign recognition model is evaluated based on the test set of the sheep vital sign dataset, and the sheep vital sign recognition results are output, specifically:

[0129] In this embodiment of the invention, two indicators, parameter quantity and computational quantity, are selected to measure the lightweight nature of the model, and the comprehensive accuracy of all life characteristic categories is selected to evaluate the recognition accuracy of the model.

[0130] The number of parameters refers to the number of operations required for the network model, reflecting the model's time complexity. The calculation formula is shown below:

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

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

[0133] Computing power = ∑(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 follows. 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 for P and R under rough positioning is set to 0.5, and the intersection-over-union threshold for P and R under fine positioning is set to 0.5 - 0.95. In this 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 computing power of the sheep life feature recognition model proposed in this 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 this invention is successful, and the sheep life feature recognition model proposed in this invention has significant advantages of lightweight and high precision;

[0138] Table 2 Performance comparison table of the life feature recognition model of this 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 explain the differences from other embodiments. For the same or similar parts between each embodiment, reference can be made to each other.

[0141] This document uses specific examples to illustrate the principles and implementation methods of the present invention. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of the present invention. Furthermore, those skilled in the art will recognize that, based on the ideas of the present invention, there will be changes in the specific implementation methods and application scope. Therefore, the content of this specification should not be construed as a limitation of the present invention.

Claims

1. A method for identifying vital signs of sheep based on deep learning, characterized in that, include: Determine the vital characteristics of the sheep in the study: Based on expert consultation, literature review and on-site observation, determine the vital characteristics of the sheep in the study, including rumination, stress, lethargy, normal, resting and sleeping; Creating a sheep vital signs dataset: A vision system was built to collect images of sheep vital signs, and the dataset was labeled and segmented. Then, data augmentation was performed on vital signs with less data in the training set, and finally, a sheep vital signs dataset was obtained. A deep learning-based sheep vital sign recognition model is constructed, including an image feature extraction module, a multi-scale feature fusion module, and a vital sign output module. The image feature extraction module is used to extract multi-scale feature representations from sheep vital sign images. The multi-scale feature fusion module is used to fuse and enhance the extracted multi-scale feature representations. The vital sign output module identifies the fused feature information and outputs the recognition result. The weights are obtained by training a sheep vital sign recognition model based on a sheep vital sign dataset; The performance of the trained sheep vital sign recognition model is evaluated using a test set based on a sheep vital sign dataset, and the sheep vital sign recognition results are output. The multi-scale feature fusion module of the sheep vital sign 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 reconstruction module. The prediction module reduces the dimensionality of the input feature map through a convolutional layer, and then predicts the weight parameters needed at each position of the feature map through another convolutional layer. The reconstruction 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: In the formula, i and j are the coordinates of the output feature map y, and K up Here, S represents the weight, p and q represent the regions being traversed, and m represents each element being traversed. Let x be the weight of the m-th element at position (i, j), which is predicted by the prediction module. i+p·S,j+q·S For the element at the corresponding position in the input feature map x, the amplification factor of the lightweight feature enhancement module is set to 2, and the size of the output feature map is twice the size of the input feature map; The feature stitching module is used to combine feature maps of different scales to ensure that the sheep vital signs recognition model can make full use of information at different scales. The feature enhancement module first processes the input feature map. Perform local enhancement operation; the local enhancement formula is: In the formula, L b,c,i,j X is the value of the locally enhanced feature map at spatial location (i,j) in the b-th batch and c-th channel. b,c,i,j is the value of the input feature map at batch b, channel c, and spatial location (i,j), k is the local enhancement window size, defining the size of each local region, and m and n are the indices of the pixel positions within the local window. Secondly, a global enhancement operation is used to transform the entire feature map into a single value, which is beneficial for capturing global features. The global enhancement formula is as follows: In the formula, G b,c This 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 and global features are transformed and reconstructed by one-dimensional convolution. For the enhanced local features, the local features are combined with the input feature map by element-wise multiplication to highlight the local features. For the globally enhanced features, the global enhanced features are combined with the local enhanced features by addition, thus fusing global contextual information. Finally, the feature maps that have undergone local and global enhancement are subjected to anti-enhancement operations to restore the original spatial dimensions; The feature integration module has a weight matrix 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 in the feature map and extracting higher-level abstract features. Following the feature stitching module, the feature integration module can further integrate feature maps from different layers and fuse feature information. The vital sign output module consists of three detection heads, each containing two branches. These branches calculate the bounding box loss and classification loss using two 3x3 convolutions and one 1x1 two-dimensional convolution, respectively. The vital sign output module uses an optimization function to improve the model training process. The optimization function is: In the formula, In the formula, λ and μ are weighting coefficients. It is the ratio of the intersection to the union of the model's predicted region and the true labeled region. and These are the coordinates of the center point of the ground truth bounding box. and These are the coordinates of the center point of the prediction box, d w and d h These are the width and height differences between the center points of the ground truth bounding box and the predicted bounding box, respectively. p It is the width of the prediction box, h t It is the height of the actual bounding box, max(x) t ,x p The maximum x-coordinate of the ground truth bounding box and the predicted bounding box is max(y). t ,y p That is, the maximum y-coordinate of the ground truth bounding box and the predicted bounding box. The value of θ is determined during model training. t γ is the probability that the model predicts the life characteristic category as positive, and γ is the balance coefficient for adjusting the positive and negative categories.

2. The method according to claim 1, characterized in that, The image feature extraction module of the sheep vital sign recognition model follows a lightweight strategy. Its core module is a lightweight feature extraction module, which consists of a local processing function, two pointwise processing functions, and a normalization and activation function. Specifically: The local processing function slides a 3*3 weight matrix over the input feature map to calculate the weighted sum of the local region. The feature map after local processing is expressed as: O lc =I*W lc +b lc In the formula, I is the input feature map, * represents the convolution operation, and W lc b is the kernel weight of the local processing function. lc As compensation; The weight matrix of the pointwise processing function has a size of 1*1 and is used to vary in the channel dimension without changing the spatial dimension of the feature map. The output feature map after the pointwise processing function is expressed as: Output=O lc ×W i +b i In the formula, W i The representative is the kernel weight of the pointwise processing function, b i For compensation terms, i represents the i-th point-by-point processing; The normalization function and the activation function are placed between two pointwise processing functions. The expression of the normalization function is: In the formula, Output is the output feature map after pointwise processing, and μ and σ 2 γ and β are the mean and variance of the current batch of data, respectively; γ 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, in addition to the lightweight feature extraction module, also includes an embedded feature reduction module, a merged feature reduction module, and a multi-level feature extraction module, specifically: The embedded feature reduction module is a matrix with a sliding distance of 4 and is used for initial feature extraction. The weight matrix has a size of 4. Through convolution operations, the size of the original sheep life feature image can be reduced by 4 times, shrinking to 160*160. The formula for the change in the feature map size is: In the formula, H in and W in p_size and p_stride are the length and width of the input feature map, respectively, and the weight matrix size and sliding distance are the size and sliding distance, respectively. H out and W out These represent 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. The weight matrix has a size of 2, which reduces the size of the feature map by 2 times. The formula for the change in the feature map size is: In the formula, H out and W out H represents the length and width of the output feature map, respectively. in and W in The length and width of the input feature map are respectively, S is the sliding distance, and k is the size of the weight matrix. The three merged feature simplification 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 simplification 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, Based on the test set of the sheep life feature dataset, the performance of the trained sheep life feature recognition model is evaluated. The indicators for evaluating the lightweight degree of the model are the number of parameters and the computational complexity. Among them, the formula for calculating the number of parameters is: Parameter quantity = ∑(K×K×C) in ×C out ) In the formula, K is the size of the filter, and C in It is the number of input channels, C out This refers to the number of output channels; The formula for calculating the computational complexity is: Computational complexity = ∑(K×K×C) in ×C out ×H×W)*10 9 In the formula, K is the size of the filter, and C in It is the number of input channels, C out This refers to the number of output channels, where 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*δ Where a + b = 1 and a, b ∈ [0,1], σ is the rough localization accuracy, δ is the fine localization accuracy, and the calculation formulas for σ and δ are: In the formula, n is the number of life feature categories. When the task scenario only requires rough localization, 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 for P and R under rough localization is set to 0.5, and the intersection-over-union threshold for P and R under fine localization is set to 0.5 - 0.95.

Citation Information

Patent Citations

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

    CN120429681A