Multi-head cattle identification and tracking algorithm based on improved YOLOv10s

By improving the YOLOv10s model and combining the DeepSort algorithm, the problem of high complexity, difficulty in real-time detection and long-term tracking in the existing technology is solved, and efficient and accurate identification and tracking of many cattle is achieved.

CN119418396APending Publication Date: 2025-02-11ZHENGZHOU UNIVERSITY OF LIGHT INDUSTRY
View PDF 0 Cites 4 Cited by

Patent Information

Application Number
CN202411452414.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-17
Publication Date
2025-02-11

AI Technical Summary

Technical Problem

The existing multi-objective tracking algorithm based on deep learning technology is very complex in practical applications, difficult to detect in real time, and conduct long-term, stable and robust multi-cattle tracking.

Method used

A multi-headed cattle recognition and tracking algorithm based on improved YOLOv10s is proposed. By improving the network structure, the number of model parameters is reduced, the detection and tracking process is accelerated, and performance optimization is achieved in combination with the DeepSort algorithm.

Benefits of technology

Real-time object detection and long-term robust tracking of bulls are realized, reducing model complexity and improving detection efficiency and performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119418396A_ABST
    Figure CN119418396A_ABST
Patent Text Reader

Abstract

The invention provides a multi-head cattle identification and tracking algorithm based on improved YOLOv10s. The multi-head cattle identification and tracking algorithm comprises the steps of collecting and constructing a cattle activity video data set, constructing a multi-target cattle data set according to the cattle activity video data set, and constructing a re-identification data set according to the multi-target cattle data set; an improved YOLOv10s model is constructed, and an improved SPPF module and an improved PSA module are introduced; training the model by using the multi-target cattle data set; selecting a multi-target cattle re-identification model, and training the multi-target cattle re-identification model by using the re-identification data set; and taking the trained model as a target detector, taking the trained multi-target cattle re-identification model as a feature extraction network, and detecting a multi-head cattle to be tracked and identified based on a DeepSort algorithm to obtain a multi-head cattle tracking and identification result. By improving the network structure, the model parameter quantity is reduced, the detection and tracking process is accelerated, and performance optimization is realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of computer vision and artificial intelligence technology, and in particular to a multiple-cattle recognition and tracking algorithm. Background Art

[0002] With the continuous development of smart animal husbandry, animal husbandry is undergoing a profound change. Traditional animal husbandry management methods are gradually unable to meet the efficient, accurate and intelligent management needs of modern animal husbandry. Smart animal husbandry uses modern information technologies such as the Internet of Things, big data, and artificial intelligence to realize intelligent monitoring and management of the entire process of animal husbandry production, greatly improving the production efficiency and management level of animal husbandry. Among them, the management and monitoring of multiple cattle is an important part of smart animal husbandry. Due to the large number of cattle and the wide range of activities, traditional monitoring methods are difficult to meet the needs of real-time tracking of cattle. Therefore, the development of an efficient and accurate multi-cattle tracking technology is of great significance to ensure the health of cattle and improve the production efficiency of animal husbandry.

[0003] In recent years, the research on deep learning technology in the field of vision has developed rapidly. Deep learning technology can simulate the working mode of human brain neural network, automatically learn and extract features in images, and perform tasks such as target detection, recognition, and tracking based on this. Wang Guangming et al. proposed a 3D multi-target tracking framework FlowDet-Track, which innovatively introduced a detection-guided scene flow estimation module and a scene flow truth calculation method based on box transformation, and achieved significant improvement in the tracking accuracy of vehicle categories. Yao Yipeng et al. used the Yolov8-Pose model combined with the ByteTrack algorithm to track pigs in real time, and introduced the region of interest (ROI) to avoid image distortion, improve the measurement accuracy and recognition speed, and reduce the manual burden of pig farm workers in measuring pig body size. Zhang Sheng et al., based on the YOLOv5 target detector and the DeepSort multi-target tracking framework, effectively solved the tracking problems of pedestrians in the background of fast movement, mutual occlusion, and complex weather and lighting changes by introducing an improved CSP module and an extended Kalman filter algorithm.

[0004] However, multi-target tracking algorithms based on deep learning technology still encounter a series of key problems in practical applications. First, the complexity of the current algorithm makes it difficult to embed it directly into edge devices and achieve real-time detection, which poses a significant obstacle to real-time monitoring of cattle health and behavior patterns in pasture environments. Second, given the large number of cattle and their wide range of activities, how to ensure long-term, stable and robust tracking of multiple cattle has become a technical challenge. Summary of the invention

[0005] In order to solve the technical problems that the algorithm is complex and it is difficult to track for a long time, stably and robustly, the present invention proposes a multi-cattle recognition and tracking algorithm based on improved YOLOv10s, which improves the network structure, reduces the number of model parameters, accelerates the detection and tracking process, and achieves performance optimization.

[0006] In order to achieve the above object, the technical solution of the present invention is achieved as follows:

[0007] A multi-cattle recognition and tracking algorithm based on improved YOLOv10s includes the following steps:

[0008] S1: Collect and construct a cattle activity video dataset, construct a multi-target cattle dataset based on the cattle activity video dataset, and construct a re-identification dataset based on the multi-target cattle dataset;

[0009] S2: construct an improved YOLOv10s model, including an input end, a backbone network, a neck network and a detection head connected in sequence, wherein an improved SPPF module and an improved PSA module are introduced into the backbone network;

[0010] S3: Use the multi-target cattle dataset to train the improved YOLOv10s model to obtain a trained improved YOLOv10s model;

[0011] S4: selecting a multi-target cattle re-identification model, and using the re-identification dataset to train the multi-target cattle re-identification model to obtain a trained multi-target cattle re-identification model;

[0012] S5: The trained improved YOLOv10s model is used as the target detector, and the trained multi-target cattle re-identification model is used as the feature extraction network. The multiple cattle to be tracked and identified are detected based on the DeepSort algorithm to obtain the multiple cattle tracking and identification results.

[0013] The method for constructing the multi-target cattle dataset is as follows: through frame-by-frame parsing technology, a continuous video stream is converted into a high-precision static image sequence, and then the graphic image annotation tool LabelImg is used to annotate the images and record their position information. Finally, the annotated images are divided into training set I, verification set I and test set I in a ratio of 8:1:1.

[0014] The method for constructing the re-identification dataset is as follows: using a python script to extract the target information of each cow in each picture in the multi-target cattle dataset, including position and appearance features, constructing a re-identification dataset based on the extracted target information, and dividing it into training set II and test set II in a ratio of 9:1.

[0015] The improved SPPF module reduces the number of channels through a 1x1 convolution layer I, and then performs deep processing through multiple cascaded dilated convolutions to retain more feature information while obtaining the same receptive field, and adds a ReLU activation function after each dilated convolution to enhance the model's ability to learn complex features. The output feature map obtained by the ReLU activation function of multiple cascaded dilated convolutions is fused with the output feature map of the 1x1 convolution layer I through the concat function, and finally the feature map after feature fusion is converted into the number of channels through the 1x1 convolution layer II to restore the number of input channels.

[0016] The backbone network includes 10 layers of modules connected in sequence. The 0th, 1st and 3rd layers are convolutional layers, which are used to reduce the spatial dimension of the feature map and increase the depth. The 5th and 7th layers are SCDown layers, which use point convolution to adjust the channel dimension and then use depth convolution to reduce the spatial dimension of the feature map. The 2nd, 4th and 6th layers are C2F layers, which reduce the computational complexity by reducing the number of input channels by the Bottleneck module. The 8th layer is the C2fCIB layer, which is used to reduce the computational complexity and obtain a stronger feature representation capability than C2f through the CIB structure combining point convolution with depth convolution. The 9th layer is an improved SPPF layer, which is used to improve the model's detection capability for targets of different scales in the feature map; the 10th layer is an improved PSA layer, which is used to enhance the model's attention to key areas in the feature map.

[0017] The improved PSA module reduces the number of channels through a 1x1 convolution layer a, and then performs feature separation through a split operation. The multi-scale head attention module learns the features of multiple scales after feature separation, and the input and output of the multi-scale head attention module are feature fused through the concat function to integrate the diverse information from different heads. The features after feature fusion are enhanced through a feature transformation sequence, and the input and output of the feature transformation sequence are feature fused for the second time through the concat function. Finally, the feature map obtained by the second feature fusion and the feature map obtained by the split operation are feature fused for the third time through the concat function to retain information while further enhancing the feature representation.

[0018] The feature transformation sequence transforms the feature map through a 3x3 convolution layer a while keeping the number of channels unchanged, and halves the number of channels through a 1x1 convolution layer b to achieve feature compression, and then further transforms the compressed feature map through a 3x3 convolution layer b, restores the number of channels to the original value through a 1x1 convolution layer c, and finally transforms the feature map through a 3x3 convolution layer and restores the number of channels.

[0019] The process of training the improved YOLOv10s model is as follows: the multiple cow images in the training set I first enter the backbone network with the improved SPPF module and the improved PSA module for feature extraction, the neck network performs multi-scale feature fusion on the multi-scale feature maps from the backbone network to obtain fused feature maps of different scales, and the detection head outputs prediction results according to the fused feature maps of different scales;

[0020] After each round of training, the loss function value is calculated using the prediction results and the actual annotations, and the model parameters are updated using the gradient descent optimization algorithm. The validation set I data is loaded for prediction, and based on the loss function value and evaluation indicators obtained from the verification, the learning rate decay strategy is used to adjust the model hyperparameters. The training-verification cycle is continued until the preset number of training rounds is reached or the stopping condition that the model performance has not been significantly improved is met. The model weight information that performs best on the validation set is saved, the test set I data is loaded for prediction, and the evaluation indicators on the test set I are calculated to evaluate the generalization ability of the model and obtain a trained improved YOLOv10s model.

[0021] The multi-target cattle re-identification model in step S4 includes ResNet-50 or Inception or VGG or MobileNet; the multi-target cattle re-identification model is trained and tested using training set II and test set II.

[0022] The method for detecting multiple cattle to be tracked and identified based on the DeepSort algorithm is:

[0023] The trained improved YOLOv10s model is used to identify multiple cattle and output the current target detection results; the trained multi-target cattle re-identification model is used to extract high-dimensional feature vectors based on the current target detection results, which represent the appearance information of the target;

[0024] The cascade matching algorithm is used to preliminarily match the high-dimensional feature vector extracted from the current target detection result with the predicted trajectory of the Kalman filter of the previous frame, and then the matching similarity is calculated using the Hungarian algorithm;

[0025] For the target that has been successfully matched in the cascade, the high-dimensional feature vector extracted from the current target detection result is used to update the trajectory information in the Kalman filter, and the predicted trajectory of the current target in the next frame is obtained;

[0026] For targets that fail in cascade matching, find the best matching pair through IOU matching;

[0027] For targets with successful IOU matching, the high-dimensional feature vector extracted from the current target detection result is used to update the trajectory information in the Kalman filter, and the predicted trajectory of the current target in the next frame is obtained;

[0028] For targets that do not match during IOU matching, a new target trajectory in an unconfirmed state is created. After multiple consecutive frames of IOU matching, if the match is successful, it is marked as a confirmed state and the trajectory information in the Kalman filter is updated. At the same time, the predicted trajectory of the current target in the next frame is obtained; if the target does not successfully match the IOU for multiple consecutive frames, it is marked as an unconfirmed state;

[0029] For targets whose trajectories disappear during IOU matching, if they are unconfirmed targets, the trajectories are directly deleted; if they are confirmed targets, the target trajectories are deleted if they do not change within the set time; if they change within the set time, the target status is reconfirmed.

[0030] Beneficial effects of the present invention:

[0031] The present invention adopts an improved YOLOv10s model, improves the network structure of the fast spatial pyramid pooling (SPPF) module and the partial self-attention (PSA) module of the YOLOv10s model, reduces the complexity of the model and significantly improves the model's target detection efficiency and performance for multiple cattle. At the same time, by combining the improved YOLOv10s model with the DeepSORT algorithm based on the re-identification dataset, it realizes long-term robust tracking of the detected multiple cattle and assigns unique IDs, which facilitates subsequent cattle management and behavior analysis. BRIEF DESCRIPTION OF THE DRAWINGS

[0032] 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 or the description of the prior art 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 work.

[0033] Figure 1 The figure is a flow chart of the method of the present invention.

[0034] Figure 2 This is a structural diagram of the improved YOLOv10s model of the present invention.

[0035] Figure 3 This is the structure diagram of the improved fast spatial pyramid pooling (SPPF) module.

[0036] Figure 4 Figure 2 is the structural diagram of the improved partial self-attention (PSA) module.

[0037] Figure 5 This is the algorithm flow of DeepSORT based on improved YOLOv10s.

[0038] Figure 6 This is the tracking effect diagram of the multi-cattle detection algorithm based on the improved YOLOv10s. DETAILED DESCRIPTION

[0039] 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.

[0040] A multi-cattle recognition and tracking algorithm based on improved YOLOv10s, such as Figure 1 As shown, the steps include:

[0041] S1: Collect and construct a cattle activity video dataset, construct a multi-target cattle dataset based on the cattle activity video dataset, and construct a re-identification dataset based on the multi-target cattle dataset.

[0042] Use high-definition cameras to collect video data of cattle activities, select and retain video clips that can clearly show the individual characteristics, behavioral details and surrounding environment of cattle, and then accurately crop and edit the retained video clips to ensure that each clip is closely centered on the characteristics of cattle movement, eating, socializing and other activities, and build a high-quality video dataset of cattle activities. The quality of the dataset is crucial. A high-quality dataset not only directly affects the accuracy of the algorithm, but also significantly improves its effect during the improvement process.

[0043] Constructing a multi-target cattle dataset for training the improved YOLOv10s model: Based on the cattle activity video dataset, the continuous video stream is converted into a high-precision static image sequence through frame-by-frame parsing technology. Then the image is annotated using the graphic image annotation tool LabelImg, the cow images are marked as "Cow", and their location information (bounding box) is recorded. Finally, the annotated images are divided into training set I, validation set I and test set I in a ratio of 8:1:1, and a multi-target cattle dataset for training, validation and testing of the YOLOv10s model is constructed.

[0044] Construct a re-identification dataset for DeepSort algorithm training: Use a python script to extract the target information of each cow in each image in the multi-target cow dataset, including the location (bounding box) and possible appearance features, such as fur color, texture width, and body shape. Construct a re-identification dataset based on the extracted target information and divide it into training set II and test set II in a ratio of 9:1 for the training and evaluation of the DeepSort tracking algorithm.

[0045] S2: construct an improved YOLOv10s model, including an input end, a backbone network, a neck network and a detection head connected in sequence, wherein an improved fast spatial pyramid pooling (SPPF) module and an improved partial self-attention (PSA) module are introduced into the backbone network;

[0046] The SPPF module replaces the original pooling convolution with a dilated convolution and adds a ReLU activation function after each dilated convolution. Figure 3 As shown in the figure, the specific workflow is as follows: first, the number of channels is reduced to 1 / 4 of the original through a 1x1 convolution layer I; then, the feature map is deeply processed through three cascaded 3x3 dilated convolutions (filling is 5, and the dilation rate is also 5); at the same time, the ReLU activation function is added after each dilated convolution to increase the nonlinear ability of the model; the calculation results of the three ReLU activation functions are spliced ​​through the concat function and then feature fused with the output of the 1x1 convolution layer I; finally, the number of channels after feature fusion is converted to restore the input channel number through a 1x1 convolution layer II. Compared with the original pooling operation, the dilated convolution has the characteristics of sparse connection, which retains more feature information while obtaining the same receptive field. The ReLU activation function enhances the learning ability of complex features. These designs help improve the detection accuracy of the model. In addition, a larger reduction ratio of the number of channels reduces the number of parameters and computational complexity of the model, thereby improving the operation efficiency of the model.

[0047] The improved partial self-attention (PSA) module replaces the original feed-forward network (FFN) with a redesigned feature transformation sequence (FTS). This is a sequence of multiple convolutional layers that aims to enhance feature representation through nonlinear transformation and feature compression / expansion, such as Figure 4As shown in the figure, the workflow of the improved partial self-attention (PSA) module is as follows: the input feature map first passes through a 1x1 convolution layer a to reduce the number of channels, and then undergoes a split operation (Split) for feature separation. The multi-scale head attention module (MSHA) learns the features of multiple scales after feature separation. The input and output of the multi-scale head attention module are fused through the concat function to integrate the diverse information from different heads. The features after feature fusion are enhanced through the feature transformation sequence. Then, the input and output of the feature transformation sequence are fused for the second time through the concat function. Finally, the feature map obtained by the second feature fusion and the feature map obtained by the split operation are fused for the third time through the concat function to retain information while further enhancing feature representation. Among them, the split operation (Splite) can split the input feature map into two parts along the channel dimension to introduce feature diversity. The multi-scale head attention module (MSHA) can perform multi-scale attention processing on the input feature map to enhance feature representation capabilities.

[0048] The specific workflow of the feature transformation sequence (FTS) is as follows: Figure 4 As shown in the figure, first, the feature map is transformed through a 3x3 convolution layer (group convolution is used to reduce the amount of calculation), while the number of channels remains unchanged; then, the number of channels is halved through a 1x1 convolution layer to achieve feature compression; then, another 3x3 convolution layer (group convolution is performed using the halved number of channels) is used to further transform the compressed feature map; another 1x1 convolution layer is used to restore the number of channels to the original value to achieve feature expansion; finally, the feature map is finally transformed through a 3x3 convolution layer (group convolution is performed using the original number of channels). This process draws on the design idea of ​​the bottleneck structure, that is, first reducing the amount of calculation by compressing the dimension of the feature map, and then introducing more nonlinearity by expanding the dimension and additional transformations, thereby enhancing the complexity of the model and the feature extraction capability. Compared with the original feedforward network structure, this feature transformation sequence structure can capture richer spatial information and introduce more flexibility in feature transformation.

[0049] S3: Use the multi-target cattle dataset to train the improved YOLOv10s model to obtain a trained improved YOLOv10s model;

[0050] The training process is as follows: Figure 2As shown in the figure, the training set I in the multi-target cattle dataset is input into the improved YOLOv10s model, and the input multi-cattle pictures in the training set I first enter the backbone network: the 0th, 1st, and 3rd layers are convolutional layers, which are used to reduce the spatial dimension of the feature map and increase the depth; the 5th and 7th layers are SCDown layers, which use point convolution to adjust the channel dimension, and then use depth convolution to reduce the spatial dimension of the feature map; the 2nd, 4th, and 6th layers are C2F layers, which are used to reduce the computational complexity by reducing the number of input channels through the Bottleneck module; the 8th layer is the C2fCIB layer, which is used to reduce the computational complexity and obtain a stronger feature representation capability than C2f through the CIB structure combining point convolution and depth convolution; the 9th layer is the improved SPPF layer, which is used to improve the model's detection capability of targets of different scales in the feature map; the 10th layer is the improved PSA layer, which is used to enhance the model's attention to key areas in the feature map.

[0051] Subsequently, the feature map enters the neck network: the 11th and 14th layers are upsampling layers, which are used to enlarge the spatial dimensions of the feature map; the 12th, 15th, 18th, and 21st layers are Concat layers, which concatenate the feature maps of different layers in the channel dimension, where the 12th layer concatenates the feature maps of the previous layer and the 6th layer, the 15th layer concatenates the feature maps of the previous layer and the 4th layer, the 18th layer concatenates the feature maps of the previous layer and the 13th layer, and the 21st layer concatenates the feature maps of the previous layer and the 10th layer; the 13th, 16th, and 19th layers are C2F layers, which combine upsampling and concatenation operations. The feature map formed by upsampling and concatenation operations is converted into a new feature map with specific channels, realizing feature fusion of different scales; the 22nd layer is the C2fCIB layer, which converts the feature map formed by upsampling and concatenation operations into a new feature map with specific channels, realizing feature fusion of different scales and obtaining stronger feature representation capabilities than C2f; the 17th layer is the convolutional layer, which is used to reduce the spatial dimension of the feature map while maintaining the number of channels; the 20th layer is the SCDown layer, which has fewer parameters than the convolutional layer and can more efficiently reduce the spatial dimension of the feature map while keeping the number of channels unchanged.

[0052] Finally, the feature map enters the 23rd detection layer, which converts the feature maps extracted by the 16th, 19th, and 22nd network layers into the final detection results, including the target’s detection box, category, and corresponding confidence information.

[0053] After each round of training, the prediction results and the actual annotations are used to calculate the loss function value, and the model hyperparameters are updated with the help of optimization algorithms such as gradient descent. Subsequently, the validation set data is loaded for prediction, and the learning rate decay strategy is used to adjust the model hyperparameters based on the loss function value and evaluation indicators obtained from the verification. This training-validation cycle will continue until the preset number of training rounds is reached or the stopping condition that the model performance has not been significantly improved within a certain period is met. Finally, the model weights that perform best on the validation set are saved.

[0054] After obtaining the optimal model weights of the improved YOLOv10s model, load the test set data for prediction and calculate the evaluation indicators (such as accuracy, recall, mAP, etc.) on the test set to comprehensively evaluate the generalization ability of the model. In addition, visualize the test results, such as drawing detection boxes, labeling categories, etc., to more intuitively understand the detection effect of the model.

[0055] S4: Select a multi-target cattle re-identification model, use the re-identification dataset to train the multi-target cattle re-identification model, and obtain a trained multi-target cattle re-identification model.

[0056] The multi-target cattle re-identification model includes ResNet-50 or Inception or VGG or MobileNet; the multi-target cattle re-identification model is trained and tested using training set II and test set II.

[0057] S5: The trained improved YOLOv10s model is used as the target detector, and the trained multi-target cattle re-identification model is used as the feature extraction network to detect the multiple cattle to be tracked and identified to obtain the multiple cattle tracking and identification results.

[0058] The algorithm process is as follows: Figure 5 As shown in the figure, first, the current multi-cattle video frame is fed into the improved YOLOv10s model, and the current detection result is output, including the target detection frame, category, and corresponding confidence information. The corresponding image area is cropped from the original image according to the detection frame coordinates, and the trained multi-target cattle re-identification model is used to extract a high-dimensional feature vector based on the cropped corresponding image area, which represents the appearance information of the target, such as color, texture, shape, etc., which can be used to distinguish different targets;

[0059] At each video frame time point, the Kalman filter will obtain the target's predicted trajectory in the next frame based on the current trajectory state for the next round of target detection and trajectory matching;

[0060] The cascade matching algorithm is used to preliminarily match the extracted high-dimensional feature vector with the predicted trajectory of the Kalman filter of the previous frame, and then the Hungarian algorithm is used to calculate the matching similarity and find the optimal matching pair;

[0061] For the target that successfully matches the cascade, the extracted high-dimensional feature vector is used to update the trajectory information in the Kalman filter, including position, velocity, acceleration, etc., and the predicted trajectory of the target in the next frame is obtained;

[0062] For targets that fail in cascade matching, including target mismatch and target track disappearance (target mismatch such as new targets appearing in the camera or targets reappearing after being blocked for a long time, target track disappearance such as missed detection or targets disappearing in the camera), further IOU matching is performed, and the optimal matching pair is found by calculating the intersection and union ratio of the current detection box and the predicted track (prediction box) of the previous frame based on the extracted high-dimensional feature vector;

[0063] For targets with successful IOU matching, the extracted high-dimensional feature vector is used to update the trajectory information in the Kalman filter, including position, velocity, acceleration, etc., and the predicted trajectory of the target in the next frame is obtained;

[0064] For targets that do not match during IOU matching, a new target trajectory in an unconfirmed state is created. After three consecutive frames of successful IOU matching, the new target trajectory can be confirmed as a valid trajectory and the trajectory information in the Kalman filter is updated. At the same time, the predicted trajectory of the target in the next frame is obtained. That is, the new target trajectory is marked as a confirmed state and continues to be used for cascade matching. The new target that has not completed three consecutive frames of successful IOU matching is marked as an unconfirmed state.

[0065] For targets whose tracks disappear during IOU matching, if they are unconfirmed targets, the tracks are directly deleted (the target is considered to have disappeared from the camera). If they are confirmed targets, the track is deleted if it does not change within the set time. If it changes within the set time, the target needs to be successfully matched with IOU for three consecutive frames before it can be confirmed as a valid track, that is, the target continues to be marked as confirmed.

[0066] Among them, the predicted trajectory of the target in the confirmed state is used for cascade matching, and the predicted trajectory of the target in the unconfirmed state is used for IOU matching.

[0067] The trajectory information of the targets that are successfully matched and confirmed will be updated, and the predicted box of the trajectory will be output, including the unique ID of each target.

[0068] Experimental results: By combining the improved YOLOv10s target detection model with DeepSort, the tracking algorithm of the present invention realizes real-time tracking of multiple target cattle. The SPPF module and the PSA module of the backbone network in the YOLOv10s algorithm are improved to reduce the model complexity and improve the detection accuracy.

[0069] Table 1 shows the ablation experiment during the improvement process. The experimental results show that the improved model has an accuracy improvement of 0.9%, a parameter reduction of 4.7%, and a model size reduction of 4.8% compared with the original model. The multi-target cattle detection and tracking effect of the improved YOLOv10s model combined with the DeepSort algorithm is shown in the figure. Figure 6 In summary, the present invention achieves effective detection and tracking effects, while improving the application of the model on edge computing devices.

[0070] Table 1

[0071] Model mAP@0.5(%) mAP@0.5:0.95(%) Parameter quantity (M) Model size (Mb) YOLOv10s 91.3 59.3 8.04 16.6 + Improved SPPFA 91.9 59.9 7.85 16.2 + Improved PSA 91.6 59.7 7.85 16.2 + Improved SPPF + Improved PSA 92.2 60.1 7.66 15.8

[0072] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims

1. A multi-cattle recognition and tracking algorithm based on improved YOLOv10s, characterized in that: The following steps are involved: S1: Collect and construct a cattle activity video dataset, construct a multi-target cattle dataset based on the cattle activity video dataset, and construct a re-identification dataset based on the multi-target cattle dataset; S2: construct an improved YOLOv10s model, including an input end, a backbone network, a neck network and a detection head connected in sequence, wherein an improved SPPF module and an improved PSA module are introduced into the backbone network; S3: Use the multi-target cattle dataset to train the improved YOLOv10s model to obtain a trained improved YOLOv10s model; S4: selecting a multi-target cattle re-identification model, and using the re-identification dataset to train the multi-target cattle re-identification model to obtain a trained multi-target cattle re-identification model; S5: The trained improved YOLOv10s model is used as the target detector, and the trained multi-target cattle re-identification model is used as the feature extraction network. The multiple cattle to be tracked and identified are detected based on the DeepSort algorithm to obtain the multiple cattle tracking and identification results.

2. The multiple cattle recognition and tracking algorithm based on improved YOLOv10s according to claim 1 is characterized in that: The method for constructing the multi-target cattle dataset is as follows: through frame-by-frame parsing technology, a continuous video stream is converted into a high-precision static image sequence, and then the graphic image annotation tool LabelImg is used to annotate the images and record their position information. Finally, the annotated images are divided into training set I, verification set I and test set I in a ratio of 8:1:

1.

3. The multiple cattle recognition and tracking algorithm based on improved YOLOv10s according to claim 2 is characterized in that: The method for constructing the re-identification dataset is as follows: using a python script to extract the target information of each cow in each picture in the multi-target cattle dataset, including position and appearance features, constructing a re-identification dataset based on the extracted target information, and dividing it into training set II and test set II in a ratio of 9:

1.

4. The multiple cattle recognition and tracking algorithm based on improved YOLOv10s according to claim 3 is characterized in that: The improved SPPF module reduces the number of channels through a 1x1 convolution layer I, and then performs deep processing through multiple cascaded dilated convolutions to retain more feature information while obtaining the same receptive field, and adds a ReLU activation function after each dilated convolution to enhance the model's ability to learn complex features. The output feature map obtained by the ReLU activation function of multiple cascaded dilated convolutions is fused with the output feature map of the 1x1 convolution layer I through the concat function, and finally the feature map after feature fusion is converted into the number of channels through the 1x1 convolution layer II to restore the number of input channels.

5. The multiple cattle recognition and tracking algorithm based on improved YOLOv10s according to any one of claims 1 to 4, characterized in that: The backbone network includes 10 layers of modules connected in sequence. The 0th, 1st and 3rd layers are convolutional layers, which are used to reduce the spatial dimension of the feature map and increase the depth. The 5th and 7th layers are SCDown layers, which use point convolution to adjust the channel dimension and then use depth convolution to reduce the spatial dimension of the feature map. The 2nd, 4th and 6th layers are C2F layers, which reduce the computational complexity by reducing the number of input channels by the Bottleneck module. The 8th layer is the C2fCIB layer, which is used to reduce the computational complexity and obtain a stronger feature representation capability than C2f through the CIB structure combining point convolution with depth convolution. The 9th layer is an improved SPPF layer, which is used to improve the model's detection capability for targets of different scales in the feature map; the 10th layer is an improved PSA layer, which is used to enhance the model's attention to key areas in the feature map.

6. The multiple cattle recognition and tracking algorithm based on improved YOLOv10s according to claim 5 is characterized in that: The improved PSA module reduces the number of channels through a 1x1 convolution layer a, and then performs feature separation through a split operation. The multi-scale head attention module learns the features of multiple scales after feature separation, and the input and output of the multi-scale head attention module are feature fused through the concat function to integrate the diverse information from different heads. The features after feature fusion are enhanced through a feature transformation sequence, and the input and output of the feature transformation sequence are feature fused for the second time through the concat function. Finally, the feature map obtained by the second feature fusion and the feature map obtained by the split operation are feature fused for the third time through the concat function to retain information while further enhancing the feature representation.

7. The multiple cattle recognition and tracking algorithm based on improved YOLOv10s according to claim 5, characterized in that: The feature transformation sequence transforms the feature map through a 3x3 convolution layer a while keeping the number of channels unchanged, and halves the number of channels through a 1x1 convolution layer b to achieve feature compression, and then further transforms the compressed feature map through a 3x3 convolution layer b, restores the number of channels to the original value through a 1x1 convolution layer c, and finally transforms the feature map through a 3x3 convolution layer and restores the number of channels.

8. The multiple cattle recognition and tracking algorithm based on improved YOLOv10s according to claim 6, characterized in that: The process of training the improved YOLOv10s model is as follows: the multiple cow images in the training set I first enter the backbone network with the improved SPPF module and the improved PSA module for feature extraction, the neck network performs multi-scale feature fusion on the multi-scale feature maps from the backbone network to obtain fused feature maps of different scales, and the detection head outputs prediction results according to the fused feature maps of different scales; After each round of training, the loss function value is calculated using the prediction results and the actual annotations, and the model parameters are updated using the gradient descent optimization algorithm. The validation set I data is loaded for prediction, and based on the loss function value and evaluation indicators obtained from the verification, the learning rate decay strategy is used to adjust the model hyperparameters. The training-verification cycle is continued until the preset number of training rounds is reached or the stopping condition that the model performance has not been significantly improved is met. The model weight information that performs best on the validation set is saved, the test set I data is loaded for prediction, and the evaluation indicators on the test set I are calculated to evaluate the generalization ability of the model and obtain a trained improved YOLOv10s model.

9. The multiple cattle recognition and tracking algorithm based on improved YOLOv10s according to claim 7, characterized in that: The multi-target cattle re-identification model in step S4 includes ResNet-50 or Inception or VGG or MobileNet; the multi-target cattle re-identification model is trained and tested using training set II and test set II.

10. The multiple cattle recognition and tracking algorithm based on improved YOLOv10s according to claim 8, characterized in that: The method for detecting multiple cattle to be tracked and identified based on the DeepSort algorithm is: The trained improved YOLOv10s model is used to identify multiple cattle and output the current target detection results; the trained multi-target cattle re-identification model is used to extract high-dimensional feature vectors based on the current target detection results, which represent the appearance information of the target; The cascade matching algorithm is used to preliminarily match the high-dimensional feature vector extracted from the current target detection result with the predicted trajectory of the Kalman filter of the previous frame, and then the matching similarity is calculated using the Hungarian algorithm; For the target that has been successfully matched in the cascade, the high-dimensional feature vector extracted from the current target detection result is used to update the trajectory information in the Kalman filter, and the predicted trajectory of the current target in the next frame is obtained; For targets that fail in cascade matching, find the best matching pair through IOU matching; For targets with successful IOU matching, the high-dimensional feature vector extracted from the current target detection result is used to update the trajectory information in the Kalman filter, and the predicted trajectory of the current target in the next frame is obtained; For targets that do not match during IOU matching, a new target trajectory in an unconfirmed state is created. After multiple consecutive frames of IOU matching, if the match is successful, it is marked as a confirmed state and the trajectory information in the Kalman filter is updated. At the same time, the predicted trajectory of the current target in the next frame is obtained; if the target does not successfully match the IOU for multiple consecutive frames, it is marked as an unconfirmed state; For targets whose trajectories disappear during IOU matching, if they are unconfirmed targets, the trajectories are directly deleted; if they are confirmed targets, the target trajectories are deleted if they do not change within the set time; if they change within the set time, the target status is reconfirmed.

Citation Information

Cited By

  • Cow house leaving track identification method

    CN120673447A

  • Method for recognizing cattle leaving their sheds

    CN120673447B

  • Cow ear tag detection method and device based on convolutional neural network

    CN120894801A

  • A method and device for detecting cow ear tags based on convolutional neural networks

    CN120894801B