Target detection method under similar background based on improved YOLOv11 model
By improving the IES-Bottleneck module and Slim-Neck network of the YOLOv11 model and combining them with the MPDIoU loss function, the problems of missed detection and false detection in similar backgrounds of dairy cow pens were solved, achieving high-precision and real-time dairy cow target detection and improving the stability and reliability of the detection system.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-18
- Publication Date
- 2026-03-31
AI Technical Summary
In similar settings in dairy pens, existing target detection models are prone to missed detections and false detections, affecting the stability and reliability of detection performance.
An improved YOLOv11 model is adopted, and the C3k2 module is replaced by the IES-Bottleneck module. Combined with the Slim-Neck network and MPDIoU loss function, the feature discrimination and target extraction capabilities are enhanced, and the detection problem in complex backgrounds is alleviated.
It significantly improves the accuracy and recall rate of dairy cow target detection, especially maintaining high accuracy and real-time detection capabilities under varying lighting and complex background conditions, thereby enhancing the robustness of the detection system.
Smart Images

Figure CN121768039A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of target detection, and in particular to a target detection method based on an improved YOLOv11 model in similar backgrounds. Background Technology
[0002] Accurate identification and monitoring of dairy cows is a crucial aspect of the intelligent development of livestock farming. However, in actual farming environments, the coat color of dairy cows often resembles the background color of the barn, easily leading to false negatives and missed detections in target detection models, thus affecting the stability and reliability of detection performance. Therefore, developing a target detection method based on an improved YOLOv11 model for similar backgrounds is of great significance for achieving continuous, effective, and accurate monitoring and management of dairy cows.
[0003] Currently, non-contact technologies based on sensor technology and computer vision are the two main approaches for dairy cow detection. While sensor-based contact methods offer advantages such as high real-time performance and accuracy, the wearing of sensors may cause additional stress to dairy cows already in their physiologically sensitive period, interfering with their natural behavior. In contrast, computer vision-based technologies require no physical contact, enabling comprehensive and continuous observation of dairy cows without interfering with their normal activities. In the field of visual detection, target detection algorithms can be mainly divided into single-stage and two-stage algorithms. Among them, single-stage algorithms have been widely used in agricultural and livestock environments due to their good balance between speed and accuracy. However, actual farms face problems such as uneven lighting, complex backgrounds, and target occlusion, all of which affect the accuracy and robustness of the detection system. Therefore, how to achieve high-precision, real-time dairy cow target detection under varying lighting and complex background conditions remains a key problem that urgently needs to be solved. Summary of the Invention
[0004] The technical problem to be solved by this invention is to provide a target detection method based on an improved YOLOv11 model in similar backgrounds. This method can effectively solve the problems of missed detection and false detection in the current target detection model in similar environments of dairy cow pens, thereby improving the accuracy of target detection in dairy cows. It can provide a more efficient and accurate solution for target detection in similar pen backgrounds, thus providing reliable technical support for dairy cow monitoring in large-scale farms.
[0005] A method for object detection in similar backgrounds based on an improved YOLOv11 model, specifically including the following steps: S1. Collect images of peripartum dairy cows to construct an initial dataset. After augmenting the dataset using data augmentation methods, divide it proportionally into training, validation, and test sets. S2. Construct an improved YOLOv11-ISD model, specifically including: S2.1 In the backbone network, a three-branch bottleneck structure IES-Bottleneck is designed. The Bottleneck module in the C3k2 module of the backbone network is replaced with the IES-Bottleneck module to construct the C3k2-IES module. In S2.2, the PAN path aggregation network is replaced with Slim-Neck in the neck network; the original CIoU loss function of the YOLOv11 model is replaced with the MPDIoU loss function. S3. Train and validate the training set and validation set using the YOLOv11-ISD model, and evaluate the detection performance using the test set.
[0006] Further, S1 specifically includes the following: S101, using FFmpeg software to extract keyframes from the video to obtain X images, and retaining Y images after removing highly similar images; S102. Using the CycleGAN data augmentation method, style transfer is performed on periparturient dairy cow images across lighting conditions to augment them into Z enhanced images, forming a dataset of a total of Y+Z images. S103. Use the Labelme image annotation tool to annotate the bounding boxes of the cow targets, and divide the training set, validation set and test set in a ratio of 8:1:1.
[0007] Furthermore, the structure of the IES-Bottleneck is as follows: the original Bottleneck is used as the main path, and the input features are transformed by two layers of 3×3 convolutions in sequence; the first parallel branch adopts the iEMA attention mechanism, and the input features are processed by 1×1 convolution, 3×3 depthwise separable convolution and 1×1 convolution, and coupled with the EMA module to dynamically calibrate the channel weights; the second parallel branch adopts SCConv spatial and channel reconstruction convolution, and reduces similar background textures and filters discriminative channel features through SRU spatial reconstruction unit and CRU channel reconstruction unit; after the three output features are concatenated and aggregated, multi-source information is fused through a 1×1 convolution layer to generate discriminative features.
[0008] Furthermore, the iEMA attention mechanism includes an iRMB inverted residual structure and an EMA attention mechanism to enhance feature extraction capabilities.
[0009] Furthermore, the SCConv spatial and channel reconstruction convolution is composed of SRU spatial reconstruction units and CRU channel reconstruction units connected sequentially. Furthermore, in the neck network, the Slim-Neck process works as follows: the input features are first compressed by a 1×1 standard convolution of the GSConv module, and then processed by a depthwise separable convolution of DWConv. The outputs of the two steps are concatenated along the channel dimension and then a channel recombination operation is performed to enhance feature interaction. In the VoV-GSCSP module, the input features are processed by a dual-branch heterogeneous architecture after the initial convolution transformation: one branch retains the original features to maintain low-level semantic information, and the other branch performs nonlinear feature transformation through the GSBottleneck structure. The dual-path outputs are concatenated by channels and fused with a 1×1 convolution to achieve cross-stage feature aggregation.
[0010] Furthermore, the calculation formula for the MPDIoU loss function is as follows: (1) (2) (3) (4) Where A and B represent the predicted bounding box and the ground truth bounding box, respectively. , )and( , ) represents the coordinates of the top left and bottom right corners of bounding box A. , )and( , The coordinates of the top-left and bottom-right corners of bounding box B are represented by ω and h, respectively, where ω and h represent the width and height of the bounding box. x and γ Represents the coordinates of the diagonal vertices of the two bounding boxes. d 1 represents the center point of the two bounding boxes at... x Distance in direction d 2 represents the center points of the two bounding boxes. γ Distance in directions, ∩ represents the intersection, ∪ represents the union.
[0011] Furthermore, in S3, precision (P), recall (R), number of parameters, and model size are used as evaluation criteria, and the evaluation formula is as follows: (5) (6) Among them, TP is the number of true positives, FN is the number of false negatives, and FP is the number of false positives.
[0012] Compared with the prior art, the advantages and positive effects of the present invention are: 1. In complex scenarios where the background of the barn and the coat color of the cows are highly similar, the detection model of this invention significantly outperforms the baseline model in key indicators; 2. This invention designs an IES-Bottleneck module, which, by embedding it into the C3k2 module, enhances the model's feature discrimination ability in complex and highly homogeneous backgrounds; 3. In the baseline model YOLOv11, this invention replaces the neck network with Slim-Neck to improve the model's ability to extract targets; 4. This invention replaces the CIoU loss function in the baseline model YOLOv11 with the MPDIoU loss function, thereby effectively enhancing the model's recognition accuracy for partially occluded targets. Attached Figure Description
[0013] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. Obviously, the drawings described below are merely some embodiments of the present invention, and those skilled in the art can obtain other drawings based on these drawings without creative effort. In the drawings: Figure 1 The images are of a dairy cow dataset after data augmentation technology according to an embodiment of the present invention.
[0014] Figure 2 This is a schematic diagram of the framework of the improved YOLOv11 network structure according to an embodiment of the present invention.
[0015] Figure 3 This is a schematic diagram of the IES-Bottleneck network according to an embodiment of the present invention.
[0016] Figure 4 This is a schematic diagram of the improved C3k2 module network according to an embodiment of the present invention.
[0017] Figure 5 This is a schematic diagram of the Slim-Neck network according to an embodiment of the present invention.
[0018] Figure 6 The graph shows the performance results of the YOLOv11-ISD model in this embodiment of the invention.
[0019] Figure 7 This is a visual comparison chart showing the difference between YOLOv11 before and after the improvement in this embodiment of the invention. Detailed Implementation
[0020] The present invention will be further described below with reference to the accompanying drawings and embodiments: A target detection method based on an improved YOLOv11 model in similar backgrounds, characterized by the following steps: S1. Collect images of dairy cows during the periparturient period, construct an initial dataset, expand the dataset using data augmentation methods, and then divide it into training, validation, and test sets according to the proportions. S1 specifically includes the following: S101. Keyframes were extracted from the video using FFmpeg software, resulting in 5123 images. Due to the cows' slow movements and prolonged static postures, highly similar images were removed from the dataset, leaving 1174 images. S102. Using the CycleGAN data augmentation method, style transfer was performed on periparturient dairy cow images across lighting conditions to expand the dataset, constructing an image dataset of a total of 1687 images, including 513 augmented images. S103. Use the Labelme image annotation tool to annotate the bounding boxes of the cow targets, and divide the training set, validation set and test set in a ratio of 8:1:1.
[0021] S2. Construct an improved YOLOv11-ISD model, specifically including: S2.1 In the backbone network, a three-branch bottleneck structure IES-Bottleneck is designed. The Bottleneck module in the C3k2 module of the backbone network is replaced with the IES-Bottleneck module to construct the C3k2-IES module. The structure of the IES-Bottleneck is as follows: The original Bottleneck serves as the main path, with input features sequentially transformed through two 3×3 convolutional layers. The first parallel branch employs the iEMA attention mechanism, processing input features through 1×1 convolution, 3×3 depthwise separable convolution, and another 1×1 convolution, coupled with an EMA module to dynamically calibrate channel weights. The second parallel branch uses SCConv spatial and channel reconstruction convolutions, reducing similar background textures and filtering discriminative channel features through SRU spatial reconstruction units and CRU channel reconstruction units. The three output features are then concatenated and aggregated, and multi-source information is fused through a 1×1 convolutional layer to generate discriminative features. The iEMA attention mechanism includes an iRMB inverted residual structure and an EMA attention mechanism to enhance feature extraction capabilities. The specific process is as follows: Input features are first processed by the iRMB module, where channel expansion is used to increase feature dimensionality. DWConv depthwise separable convolutions are used to extract spatial features and long-range dependencies. After dimensionality reduction to compress the number of channels, residual connections are used to achieve identity mapping and feature fusion. Output features are fed back to the EMA module, which divides the features into g groups along the channel dimension and processes them through two branches: a 1× branch introduces global average pooling to aggregate spatial context information, and the other branch extracts features through 3×3 convolutions. The outputs of the two branches are processed by a Sigmoid function and normalization, then merged through a cross-dimensional interaction module to capture pixel-level pairwise relationships. Finally, the input features are enhanced by Sigmoid mapping to obtain the output features.
[0022] The SCConv spatial and channel reconstruction convolution is composed of SRU spatial reconstruction units and CRU channel reconstruction units connected sequentially. The specific working process is as follows: Input features are weighted and filtered in the spatial dimension by SRU to enhance the feature response of important regions and suppress redundant spatial information; CRU filters and reconstructs the spatially refined features at the channel level, retaining information-rich feature channels and eliminating redundant channels; The SCConv module can effectively suppress feature redundancy caused by color similarity, thereby extracting more discriminative spatial structure information and channel features, and improving the detection robustness of the model in complex environments.
[0023] In S2.2, the PAN path aggregation network is replaced with Slim-Neck in the neck network; the original CIoU loss function of the YOLOv11 model is replaced with the MPDIoU loss function to alleviate the problem of decreased detection performance caused by target deformation and occlusion. The Slim-Neck process works as follows: Input features are first compressed through a 1×1 standard convolution in the GSConv module, and then processed using a depthwise separable convolution in the DWConv module. The outputs of the two steps are concatenated along the channel dimension and then channel recombination is performed to enhance feature interaction. In the VoV-GSCSP module, the input features are processed using a dual-branch heterogeneous architecture after the initial convolution transformation: one branch retains the original features to maintain low-level semantic information, while the other branch performs non-linear feature transformation through the GSBottleneck structure. The dual-path outputs are concatenated through channels and fused with a 1×1 convolution to achieve cross-stage feature aggregation. The MPDIoU loss function, based on the distance between the overlapping region of the bounding box and the center point, further introduces the maximum vertical distance as a penalty term, thereby effectively enhancing the model's recognition accuracy for partially occluded targets. The calculation formula of the MPDIoU loss function is as follows: (1) (2) (3) (4) Where A and B represent the predicted bounding box and the ground truth bounding box, respectively. , )and( , ) represents the coordinates of the top left and bottom right corners of bounding box A. , )and( , The coordinates of the top-left and bottom-right corners of bounding box B are represented by ω and h, respectively, where ω and h represent the width and height of the bounding box. x and γ Represents the coordinates of the diagonal vertices of the two bounding boxes. d 1 represents the center point of the two bounding boxes at... x Distance in direction d 2 represents the center points of the two bounding boxes. γ Distance in directions, ∩ represents the intersection, ∪ represents the union.
[0024] S3. Train and validate the training and validation sets using the YOLOv11-ISD model, and evaluate the detection performance using the test set; wherein, precision (P), recall (R), number of parameters, and model size are used as evaluation criteria, and the evaluation formula is as follows: (5) (6) Among them, TP is the number of true positives, FN is the number of false negatives, and FP is the number of false positives.
[0025] A target detection system based on an improved YOLOv11 model includes: a data processing module for performing the dataset construction, expansion, and partitioning operations as described in claim 1 or 2; a model construction module for constructing the YOLOv11-ISD model as described in any one of claims 1, 3-7; and a training and validation module for training, validating, and evaluating the performance of the dataset using the YOLOv11-ISD model.
[0026] Specifically, to verify the effectiveness of the model's introduction of the three-branch bottleneck structure IES-Bottleneck, the Slim-Neck module, and the MPDIoU loss function, experiments were conducted on an enhanced dairy cow image dataset. Figure 6As shown, during training, loss metrics such as box loss, classification loss (cls loss), and deep feature loss (dfl loss) all decrease rapidly in the early stages of training, while precision (P) and recall (R) increase significantly in tandem. Subsequently, these metrics gradually converge and stabilize, indicating that the model has good optimization characteristics and training stability. Furthermore, the improved model performs excellently on multiple performance metrics, achieving a precision of 97.6% and a recall of 96.8%. These results demonstrate that the proposed model has high detection accuracy.
[0027] To evaluate the performance of the IES-Bottleneck, SlimNeck network, and DIoU loss function on the improved YOLOv11, experimental validation was conducted on the YOLOv11-ISD model. Using the same model parameters, a set of ablation experiments was designed based on a cow behavior dataset, and the results are shown in Table 1.
[0028] Table 1: Ablation Test Results
[0029] As shown in Table 1, replacing the standard Bottleneck in the C3k2 structure with the IES-Bottleneck module improved precision (P) by 0.8% in the experiment. However, this module also increased the number of model parameters and computational complexity due to the introduction of additional branches. To address the decrease in recall (R), a Slim-Neck structure was introduced. By optimizing the feature fusion path and compressing redundant parameters, the recall was significantly improved by 1.3%, but this resulted in a slight decrease in precision. To achieve a better balance between precision and recall, the MPDIoU loss function was introduced to replace the original bounding box regression loss. Ultimately, with the synergistic effect of MPDIoU, the model improved precision and recall by 1.6% and 1%, respectively, achieving a balanced optimization of both metrics.
[0030] Such as visualization Figure 7 As shown, a series of comparative experiments were conducted under normal lighting conditions and during the midday high-intensity lighting period (12:00-15:00) in the dairy pens. Under strong light conditions, the improved model showed a significant advantage over the original model, effectively detecting small-scale dairy cow targets with colors similar to the background, and maintaining stable detection capabilities even under direct strong light. Under normal lighting conditions, the improved model also performed robustly, accurately identifying small targets with colors similar to the background, and maintaining good detection capabilities even when some typical features of dairy cows were obscured, allowing it to detect adhered individual dairy cows.
[0031] In summary, the YOLOv11-ISD model demonstrates superior detection performance compared to the baseline model under various lighting conditions, and is particularly valuable in complex scenes with strong lighting interference and low distinction between the target and the background.
[0032] The above-disclosed embodiments are merely specific examples of the present invention. However, the present invention is not limited thereto, and any variations that can be conceived by those skilled in the art should fall within the protection scope of the present invention.
Claims
1. A target detection method based on an improved YOLOv11 model in similar backgrounds, characterized in that, Specifically, the following steps are included: S1. Collect images of dairy cows during the periparturient period, construct an initial dataset, expand the dataset using data augmentation methods, and then divide it into training, validation, and test sets according to the proportions. S2. Construct an improved YOLOv11-ISD model, specifically including: S2.1 In the backbone network, a three-branch bottleneck structure IES-Bottleneck is designed. The Bottleneck module in the C3k2 module of the backbone network is replaced with the IES-Bottleneck module to construct the C3k2-IES module. In S2.2, the PAN path aggregation network is replaced with Slim-Neck in the neck network; the original CIoU loss function of the YOLOv11 model is replaced with the MPDIoU loss function. S3. Train and validate the training set and validation set using the YOLOv11-ISD model, and evaluate the detection performance using the test set.
2. The target detection method based on the improved YOLOv11 model under similar backgrounds according to claim 1, characterized in that, S1 specifically includes the following: S101. Use FFmpeg software to extract keyframes from the video to obtain X images. After removing highly similar images, retain Y images. S102. Using the CycleGAN data augmentation method, style transfer is performed on periparturient dairy cow images across lighting conditions to augment them into Z enhanced images, forming a dataset of a total of Y+Z images. S103. Use the Labelme image annotation tool to annotate the bounding boxes of the cow targets, and divide the training set, validation set and test set in a ratio of 8:1:
1.
3. The target detection method based on the improved YOLOv11 model under similar backgrounds according to claim 1, characterized in that, The structure of the IES-Bottleneck is as follows: the original Bottleneck is used as the main path, and the input features are transformed by two layers of 3×3 convolutions. The first parallel branch adopts the iEMA attention mechanism, and the input features are processed by 1×1 convolution, 3×3 depthwise separable convolution and 1×1 convolution, and coupled with the EMA module to dynamically calibrate the channel weights. The second parallel branch adopts SCConv spatial and channel reconstruction convolution, and reduces similar background textures and selects discriminative channel features through SRU spatial reconstruction unit and CRU channel reconstruction unit. After the three output features are concatenated and aggregated, they are fused with multi-source information through a 1×1 convolution layer to generate discriminative features.
4. The target detection method based on the improved YOLOv11 model under similar backgrounds according to claim 3, characterized in that, The iEMA attention mechanism includes the iRMB inverted residual structure and the EMA attention mechanism, which are used to enhance feature extraction capabilities.
5. The target detection method based on the improved YOLOv11 model according to claim 3, characterized in that, The SCConv spatial and channel reconstruction convolution is composed of SRU spatial reconstruction units and CRU channel reconstruction units connected sequentially.
6. The target detection method based on the improved YOLOv11 model under similar backgrounds according to claim 1, characterized in that, In the neck network, the working process of the Slim-Neck is as follows: the input features are first compressed by the 1×1 standard convolution of the GSConv module, and then the feature is processed by the DWConv depthwise separable convolution. The outputs of the two steps are concatenated along the channel dimension and then the channel recombination operation is performed to enhance feature interaction. In the VoV-GSCSP module, the input features are processed using a dual-branch heterogeneous architecture after initial convolutional transformation: one branch retains the original features to maintain low-level semantic information, while the other branch performs non-linear feature transformation through the GSBottleneck structure. The dual-path outputs are then fused with 1×1 convolutions via channel concatenation to achieve cross-stage feature aggregation.
7. The target detection method based on the improved YOLOv11 model under similar backgrounds according to claim 1, characterized in that, The formula for calculating the MPDIoU loss function is as follows: (1) (2) (3) (4) Where A and B represent the predicted bounding box and the ground truth bounding box, respectively. , )and( , ) represents the coordinates of the top left and bottom right corners of bounding box A. , )and( , The coordinates of the top-left and bottom-right corners of bounding box B are represented by ω and h, respectively, where ω and h represent the width and height of the bounding box. x and γ Represents the coordinates of the diagonal vertices of the two bounding boxes. d 1 represents the center point of the two bounding boxes at... x Distance in direction d 2 represents the center points of the two bounding boxes. γ Distance in directions, ∩ represents the intersection, ∪ represents the union.
8. The target detection method based on the improved YOLOv11 model under similar backgrounds according to claim 1, characterized in that, In S3, precision (P), recall (R), number of parameters, and model size are used as evaluation criteria, and the evaluation formula is as follows: (5) (6) Among them, TP is the number of true positives, FN is the number of false negatives, and FP is the number of false positives.