A method and device for detecting cow ear tags based on convolutional neural networks
By optimizing the convolutional neural network of the YOLOv11 algorithm, a cattle ear tag detection model was constructed, which solved the efficiency, accuracy and cost problems of existing cattle identification technologies. It achieved efficient and low-cost non-contact detection, adaptable to lighting and soiling scenarios, and helped intelligent management of animal husbandry.
Patent Information
- Application Number
- CN202510939228.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-08
- Publication Date
- 2026-03-06
- Estimated Expiration
- 2045-07-08
AI Technical Summary
Existing cattle identification technologies have shortcomings in terms of efficiency, accuracy, cost, ease of use, and automation integration. Traditional physical ear tags are inefficient and prone to misreading, while electronic ear tags are costly, easily damaged, and difficult to integrate with digital systems.
A convolutional neural network was used to optimize the YOLOv11 algorithm. A bull's ear mark detection model was constructed by using adaptive downsampling, dynamic sample attention scale sequence fusion, and a dual-kernel convolutional cross-stage partial dark image recovery module. Non-contact detection was then performed using a general-purpose camera.
It improves the performance of cattle ear tag detection, reduces costs, adapts to complex scenarios, and achieves efficient batch identification, which helps to refine feeding and disease prevention and control, and promotes intelligent management of animal husbandry.
Smart Images

Figure CN120894801B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer vision technology, and in particular to a method and device for detecting cow ear tags based on convolutional neural networks. Background Technology
[0002] In modern, large-scale livestock management, accurate and efficient identification of individual livestock such as cattle is the core foundation for achieving refined feeding, disease prevention and control, pedigree tracking, production performance testing, and product quality and safety traceability. Currently, mainstream cattle identification technologies have significant limitations: Traditional physical ear tag identification, which involves attaching unique alphanumeric tags to cattle and relying on close-range manual observation and recording, is inexpensive and easy to implement, but extremely inefficient in large herds. It is also susceptible to misreading and missed readings due to lighting, angle, dirt, and personnel conditions. Data entry is manual, making integration with digital systems difficult, and there are safety risks associated with personnel handling large livestock. Electronic ear tag (RFID) identification uses radio frequency chips for non-contact reading, offering high automation and speed, but requires expensive dedicated readers, resulting in high deployment and maintenance costs. Effective reading distance is short and location requirements are stringent. The cost of ear tags and equipment is far higher than traditional ear tags. The internal ID needs to be associated with an additional visual number, lacking intuitiveness, and the ear tags are easily damaged and detached, leading to identification failures. In summary, existing technologies have shortcomings in terms of efficiency, accuracy, cost, ease of use, and automation integration. There is an urgent need to explore new cattle identification methods that are non-contact, highly efficient, low-cost, highly accurate, and easily integrated with existing management processes. Summary of the Invention
[0003] To address the aforementioned problems in the existing technology, embodiments of the present invention provide a method and device for detecting cow ear tags based on convolutional neural networks.
[0004] In a first aspect, embodiments of the present invention provide a method for detecting cow ear tags based on a convolutional neural network, comprising: acquiring multiple cow ear tag images to form a model construction dataset; replacing the ordinary convolutional layers 3, 5, and 7 in the YOLOv11 backbone network with adaptive downsampling (Adown); introducing dynamic sample attention scale sequence fusion in layers 25 and 26 of the YOLOv11 neck network; replacing all dual-kernel convolutional cross-stage modules (C3k2 modules) in the model with dual-kernel convolutional cross-stage dark image recovery modules (C3k2-Dblock) to optimize the YOLOv11 target detection algorithm and construct an optimized cow ear tag detection model; training the optimized cow ear tag detection model using a training set; and using the trained cow ear tag detection model to detect cow ear tag images.
[0005] Based on the above method embodiments, the cow ear tag detection method based on convolutional neural networks provided in this embodiment of the invention, wherein acquiring multiple cow ear tag images to form a model construction dataset includes: acquiring multiple original cow ear tag images, sharpening and denoising each cow ear tag image to obtain multiple preprocessed images, wherein the multiple preprocessed images constitute the model construction dataset.
[0006] Based on the above method embodiments, the cow tassel detection method based on convolutional neural networks provided in this embodiment of the invention, wherein the ordinary convolutional layers 3, 5 and 7 in the YOLOv11 backbone network are replaced with adaptive downsampling (Adown), includes: the adaptive downsampling (Adown) uses a generalized efficient layer aggregation network GELAN, including the cross-stage partial network CSPNet and the efficient layer aggregation network ELAN.
[0007] Based on the above method embodiments, the bovine ear tag detection method based on convolutional neural networks provided in this embodiment of the invention introduces dynamic sample attention scale sequence fusion in the 25th and 26th layers of the YOLOv11 neck network, which includes: the dynamic sample attention scale sequence fusion is obtained by combining the adaptive multi-scale feature fusion mechanism ASFF with the content-aware upsampling method DySample.
[0008] Based on the above method embodiments, the bull sign detection method based on convolutional neural networks provided in this embodiment of the invention replaces all the dual-kernel convolutional cross-stage modules C3k2 modules in the model with dual-kernel convolutional cross-stage dark image recovery modules C3k2-Dblock. The dual-kernel convolutional cross-stage dark image recovery module C3k2-Dblock is obtained by improving the dual-kernel convolutional cross-stage modules C3k2 modules through dense blocks DBlock in Dark Image Recovery DarkIR. The dense blocks DBlock fuse dense connections DenseNet, local feature fusion LFF, and residual learning ResNet.
[0009] Based on the above method embodiments, the cow ear tag detection method based on convolutional neural networks provided in this embodiment of the invention includes training the optimized cow ear tag detection model using a training set, which involves using the model to construct a dataset to train the optimized cow ear tag detection model, thereby obtaining a trained cow ear tag detection model.
[0010] Based on the above method embodiments, the cow ear tag detection method based on convolutional neural networks provided in this embodiment of the invention includes the following steps: after obtaining the trained cow ear tag detection model, saving the model weight parameters with the extension ".pt"; reloading the model weight parameters to obtain a loaded cow ear tag detection model; and using the loaded cow ear tag detection model to detect the cow ear tag image.
[0011] Secondly, embodiments of the present invention provide a cow ear tag detection device based on a convolutional neural network, comprising: a first main module for acquiring multiple cow ear tag images to form a model construction dataset; a second main module for replacing the ordinary convolutions in layers 3, 5, and 7 of the YOLOv11 backbone network with adaptive downsampling (Adown); a third main module for introducing dynamic sample attention scale sequence fusion in layers 25 and 26 of the YOLOv11 neck network; a fourth main module for replacing all C3k2 modules in the dual-kernel convolutional cross-stage of the model with C3k2-Dblock, a dual-kernel convolutional cross-stage dark image recovery module, thereby optimizing the YOLOv11 target detection algorithm and constructing an optimized cow ear tag detection model; a fifth main module for training the optimized cow ear tag detection model using a training set; and a sixth main module for detecting cow ear tag images using the trained cow ear tag detection model.
[0012] Thirdly, embodiments of the present invention provide an electronic device, comprising:
[0013] At least one processor, at least one memory, and a communication interface; wherein,
[0014] The processor, memory, and communication interface communicate with each other;
[0015] The memory stores program instructions that can be executed by the processor. The processor calls the program instructions to execute the cow talus detection method based on a convolutional neural network provided by any of the various implementations of the first aspect.
[0016] Fourthly, embodiments of the present invention provide a non-transitory computer-readable storage medium storing computer instructions that cause a computer to execute the bull talon detection method based on a convolutional neural network provided in any of the various implementations of the first aspect.
[0017] The bovine ear tag detection method and device based on convolutional neural networks provided in this invention improves bovine ear tag detection performance by optimizing YOLOv11, with mAP50 increasing by 2.3% compared to YOLOv11 and by 2.7% compared to mAP50-95. It uses a universal camera, resulting in lower costs than electronic ear tag solutions. Non-contact detection reduces safety risks and adapts to complex scenarios such as lighting and soiling. It can be integrated with digital systems to achieve efficient batch recognition, assisting in refined feeding and disease prevention and control, and promoting intelligent management of animal husbandry. Attached Figure Description
[0018] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0019] Figure 1 This is a schematic diagram of the cow ear tag detection method based on convolutional neural networks provided in an embodiment of the present invention;
[0020] Figure 2 This is a schematic diagram of the structure of the cow ear tag detection device based on a convolutional neural network provided in an embodiment of the present invention;
[0021] Figure 3 A schematic diagram of the physical structure of an electronic device provided in an embodiment of the present invention;
[0022] Figure 4 A schematic diagram of the improved YOLOv11 bovine ear tag detection network structure provided in an embodiment of the present invention;
[0023] Figure 5 A schematic diagram of the improved YOLOv11 bovine ear tag detection results provided in an embodiment of the present invention. Detailed Implementation
[0024] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, 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, 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. In addition, the technical features of the various embodiments or individual embodiments provided by the present invention can be arbitrarily combined to form feasible technical solutions. Such combinations are not constrained by the order of steps and / or structural composition patterns, but must be based on the ability of those skilled in the art to implement them. When the combination of technical solutions is contradictory or cannot be implemented, it should be considered that such combination of technical solutions does not exist and is not within the scope of protection claimed by the present invention. If there are step numbers in the following embodiments, they are only set for ease of explanation and the order between steps is not limited. The execution order of each step in the embodiments can be adaptively adjusted according to the understanding of those skilled in the art.
[0025] This invention provides a method for detecting cow ear tags based on convolutional neural networks. (See also...) Figure 1 The method includes: acquiring multiple bull ear tag images to form a model construction dataset; replacing the ordinary convolutions in layers 3, 5, and 7 of the YOLOv11 backbone network with adaptive downsampling (Adown); introducing dynamic sample attention scale sequence fusion in layers 25 and 26 of the YOLOv11 neck network; replacing all dual-kernel convolutional cross-stage modules (C3k2 modules) in the model with dual-kernel convolutional cross-stage dark image recovery modules (C3k2-Dblock) to optimize the YOLOv11 target detection algorithm and construct an optimized bull ear tag detection model; training the optimized bull ear tag detection model using a training set; and using the trained bull ear tag detection model to detect bull ear tag images.
[0026] Based on the above method embodiments, as an optional embodiment, the cow ear tag detection method based on convolutional neural networks provided in this embodiment of the invention, wherein acquiring multiple cow ear tag images to form a model construction dataset includes: acquiring multiple original cow ear tag images, sharpening and denoising each cow ear tag image to obtain multiple preprocessed images, wherein the multiple preprocessed images constitute the model construction dataset.
[0027] See Figure 4Multiple bull ear tag images were acquired and sharpened and denoised. The ordinary convolutions in the YOLOv11 backbone network (layers 3, 5, and 7) were replaced with Adown downsampling. Dynamic sample attention scale sequence fusion (ASF-DySample) was introduced in layers 25 and 26 of the neck network. All C3k2 modules in the model were replaced with C3k2-Dblock. Finally, the YOLOv11 target detection algorithm was optimized, and a bull ear tag detection model was constructed. The optimized bull ear tag target detection model was trained based on the training set. The trained bull ear tag target detection model and the images to be detected were used to detect bull ear tags.
[0028] Based on the above method embodiments, as an optional embodiment, the cow tassel detection method based on convolutional neural networks provided in this embodiment of the invention, wherein the ordinary convolutional layers 3, 5 and 7 in the YOLOv11 backbone network are replaced with adaptive downsampling (Adown), includes: the adaptive downsampling (Adown) uses a generalized efficient layer aggregation network GELAN, including the cross-stage partial network CSPNet and the efficient layer aggregation network ELAN.
[0029] The YOLOv11 backbone network replaces the ordinary convolutions (layers 3, 5, and 7) with ADown downsampling. ADown downsampling uses a Generalized Efficient Layer Aggregation Network (GELAN), which balances lightweight design, inference speed, and accuracy. GELAN integrates the design principles of CSPNet and ELAN, creating a flexible network architecture that can be tuned to different application requirements and computational resources. CSPNet reduces redundant computation by segmenting and merging feature maps, while ELAN uses layer aggregation to enhance feature representation. Unlike traditional deep network architectures that rely on specific types of computational units, GELAN allows the use of various types of computational blocks within its framework, such as traditional convolutional layers, depthwise separable convolutions, or other novel computational units.
[0030] GELAN improves convolutional operations, enabling the network to better preserve and utilize gradient information during training. Gradient information is crucial for optimization in deep learning because it indicates how the loss function changes with model parameters. In this way, GELAN achieves higher parameter efficiency than traditional convolutional neural networks, maintaining high detection accuracy even with a smaller network size. It addresses the information loss problem inherent in traditional convolutional neural networks when handling object detection tasks and improves the efficiency of model parameter utilization. GELAN optimizes the network structure through a gradient path planning technique, allowing the network to more effectively optimize weights while preserving the integrity of input information, thereby improving detection accuracy.
[0031] Based on the above method embodiments, as an optional embodiment, the bovine ear tag detection method based on convolutional neural networks provided in this embodiment of the invention, wherein dynamic sample attention scale sequence fusion is introduced in the 25th and 26th layers of the YOLOv11 neck network, including: the dynamic sample attention scale sequence fusion is obtained by combining the adaptive multi-scale feature fusion mechanism ASFF and the content-aware upsampling method DySample.
[0032] Dynamic sample attention scale sequence fusion (ASF-DySample) is introduced in layers 25 and 26 of the neck network. The ASFF and DySample modules work together to significantly improve the performance of YOLO series models (especially for small targets) in multi-scale feature fusion and upsampling.
[0033] ASFF addresses the information conflict and inconsistency issues inherent in traditional feature pyramid networks (such as FPN and PANet) during multi-scale feature fusion. In object detection, feature maps at different scales (typically from different depths of the backbone network) contain information with varying semantic levels and spatial details. Simply concatenating or adding them together may allow noise from shallow layers (high resolution, rich in detail but weak semantics) to interfere with reliable information from deeper layers (low resolution, strong semantics but blurred details), and vice versa, resulting in poor fusion performance, especially detrimental to small object detection.
[0034] ASFF Core Idea: Serialized Fusion Path: ASFF does not fuse all scale features at once, but rather employs an ordered, adaptive fusion process. Typically, it fuses sequentially along the scale of the feature pyramid (from largest to smallest or smallest to largest). Spatial and Channel Attention: This is the soul of ASFF. When fusing feature maps of two adjacent scales (e.g., fusing a higher-resolution P_i with a lower-resolution but semantically stronger P_i+1 to generate a new P_i): Channel Attention: Channel attention (such as the SE module or its variants) is applied to P_i+1 (providing semantic guidance) to generate channel weight vectors. This aims to emphasize feature channels in P_i+1 that are more relevant to the current task.
[0035] Spatial attention: Apply spatial attention (such as convolution to generate a spatial weight map) to P_i (which provides spatial details). This aims to focus on more important spatial regions in P_i (such as regions that may contain the target).
[0036] Adaptive weighted fusion: The channel-weighted P_i+1 is upsampled (usually by interpolation) to the same resolution as P_i. Then, the spatially weighted P_i is summed with the upsampled channel-weighted P_i+1. The weights here are not fixed but learned through a small network (such as a 1x1 convolution) that considers the contextual information of both feature maps and dynamically determines which scale of information should be trusted more at each location.
[0037] ASFF adaptively selects and fuses information through an attention mechanism, effectively reducing conflicts and inconsistencies between features at different scales. Channel attention focuses on important semantic features, while spatial attention focuses on key spatial locations, making the fused features more discriminative. The fusion of shallow detail information and deep semantic information is more accurate, significantly improving the feature representation of small targets (such as cow ears, which may occupy a small area in an image). The entire fusion process (including the attention module and fusion weight generation) is differentiable and can be optimized using training data.
[0038] DySample provides an efficient, lightweight, and high-performance upsampling method for upscaling low-resolution feature maps to high resolution within a feature pyramid for fusion with shallow features. Traditional upsampling methods (such as nearest neighbor interpolation and bilinear interpolation) are fixed and parameterless, unable to adapt to image content; while learnable upsampling (such as transposed convolution) is computationally expensive and prone to introducing checkerboard artifacts.
[0039] The core idea of DySample: DySample's core lies in dynamically generating upsampling kernels using local information from the input feature map itself. Dynamic kernel generation: For each location (i, j) to be filled in the target high-resolution map, DySample does not use a predefined fixed kernel (such as a bilinear kernel). Instead, it computes a small, content-relevant upsampling kernel K(i, j) in real time based on the corresponding location and its neighborhood information in the input low-resolution feature map. This kernel is typically small (e.g., 4x4). Lightweight generator: The network structure that generates this dynamic kernel K(i, j) is very simple and efficient. It typically consists of several lightweight operations: On the low-resolution input feature map, features are extracted from the region (e.g., 4x4 or 5x5) mapped back to the low-resolution coordinates (i / s, j / s) (where s is a scaling factor) from the target location (i, j). A very small network (e.g., one or more 1x1 convolutional layers) is applied to this local region feature to directly predict the upsampling kernel weights K(i, j) (a 4x4 weight matrix) for that location. Weighted summation: The generated dynamic kernel K(i,j) is used to perform a weighted summation on the corresponding local neighborhood (4x4 region) of the input feature map to obtain the output value at the target position (i,j).
[0040] DySample's upsampling kernels are dynamically generated based on the local content of the input image, better adapting to edges, textures, and other structures to produce clearer, more natural high-resolution features while reducing blur and artifacts. Compared to transposed convolutions, DySample's kernel generation network is extremely lightweight (primarily 1x1 convolutions), significantly reducing computational complexity and parameter count to negligible levels. Due to its working principle (independent kernel generation at each location, small kernel size, and overlapping computation), it effectively avoids the checkerboard artifact problem common in transposed convolutions. DySample can easily replace upsampling operations (interpolation or transposed convolutions) in existing models (such as the FPN / PANet part of YOLO). Its performance improvement over fixed interpolation and transposed convolutions has been validated on multiple tasks (such as object detection and semantic segmentation).
[0041] When ASFF sequentially fuses feature maps of different scales, it inevitably involves upsampling operations (enlarging deep, low-resolution features to fuse with shallow, high-resolution features). In this case, DySample serves as the ideal upsampler in the ASFF fusion step. ASFF adaptively selects and fuses semantic and spatial information at different scales, resolving fusion conflicts. DySample is responsible for reconstructing spatial details (enlarging feature maps) with high quality and efficiency during the fusion process, providing ASFF with a more accurate high-resolution feature representation. ASFF ensures that shallow information (containing details of small objects) is effectively utilized during fusion and is not overwhelmed by deep information. DySample guarantees that deep semantic information retains a clearer structure after upsampling, providing more accurate semantic guidance for shallow details, jointly improving the feature representation capability and detection accuracy for small objects. DySample's lightweight nature allows the ASFF fusion process to introduce powerful adaptive capabilities while increasing computational overhead very only slightly, maintaining the overall efficiency of the model.
[0042] ASFF is an adaptive multi-scale feature fusion mechanism that effectively solves the information conflict problem in feature pyramid fusion by combining sequential fusion paths with channel and spatial attention and dynamic fusion weights, significantly improving the model's feature representation ability (especially for small targets). DySample is an efficient, content-aware upsampling method that dynamically generates tiny upsampling kernels. Compared to fixed interpolation and transposed convolution, it can provide clearer and more natural high-resolution feature reconstructions with extremely low computational cost. The two are closely integrated: DySample provides high-quality upsampling for ASFF, and ASFF uses the results of DySample for adaptive fusion. This collaborative work greatly enhances the model's ability to handle multi-scale targets (especially small targets such as cow ears) while maintaining the model's efficiency.
[0043] Based on the above method embodiments, as an optional embodiment, the bull sign detection method based on convolutional neural networks provided in this embodiment of the invention, wherein all dual-kernel convolutional cross-stage modules C3k2 modules in the model are replaced with dual-kernel convolutional cross-stage dark image recovery modules C3k2-Dblock, includes: the dual-kernel convolutional cross-stage dark image recovery module C3k2-Dblock is obtained by improving the dual-kernel convolutional cross-stage modules C3k2 modules through dense blocks DBlock in Dark Image Recovery DarkIR, wherein the dense blocks DBlock fuse dense connections DenseNet, local feature fusion LFF and residual learning ResNet.
[0044] Replace all C3k2 modules in the model with C3k2-Dblock. The core idea of DBlock originates from DenseNet, but it is usually optimized by combining the idea of residual learning (ResNet) to form Residual DenseBlock (RDB) or similar variants.
[0045] Dense connectivity is the core feature of DBlock. The input of each layer (convolutional layer) within a block comes not only from the output of the previous layer, but also from the outputs of all preceding layers within that block. Formally: the input of the l-th layer x_l = Concat([x_0, x_1, ..., x_{l-1}]), where x_0 is the initial input of the DBlock.
[0046] This characteristic forces the network to retain and reuse low-level features (such as edges and textures) from shallow layers and abstract features from deep layers. Each layer can directly obtain gradients from the input and all preceding layers, greatly improving gradient backpropagation. Each layer receives a concatenation of features containing information at different levels of abstraction, enhancing the richness and expressiveness of the features. Because features are highly reused, each layer can be designed to be narrower (i.e., the out_channels of the convolution can be smaller), potentially making it more efficient overall than simply stacking convolutional layers.
[0047] Another feature of DBlock is Local Feature Fusion (LFF): directly concatenating features from all previous layers would lead to a sharp increase in the number of channels, increasing the computational burden on subsequent layers. To address this, DBlock adds a 1x1 convolutional layer (or a small bottleneck structure) after dense connections (usually at the end of the block). This compresses the excessively high channel dimension after concatenation, reducing computation. Information from different layers is selectively fused to learn a compact and information-rich feature representation as the output of the DBlock. This 1x1 convolutional layer is often called the Local Feature Fusion Layer (LFF Layer).
[0048] Building upon a standard Dense Block, a global residual connection is typically added. That is, the final output of the entire Dense Block, F_out = LFF(DenseBlock(x_in)) + x_in. This has the advantage of allowing the network to more easily learn identity transformations, meaning that if complex feature transformations are not required, the network can simply pass the input (this is important in image enhancement because the input image itself already contains a lot of useful information). It can also further alleviate the vanishing gradient problem and accelerate convergence. Furthermore, it ensures that low-level information from the original input (such as the overall structure) can be losslessly passed to subsequent layers.
[0049] Block internal structural details (typical):
[0050] Input: x_in
[0051] Layer 1: Conv(3x3, Growth Rate G)->ReLU. Input: x_in
[0052] Layer 2: Conv(3x3, G)->ReLU. Input: Concat(x_in, layer1_out)
[0053] Layer 3: Conv(3x3, G)->ReLU. Input: Concat(x_in, layer1_out, layer2_out)
[0054] ...(There can be more layers, such as 4 or 5 layers)
[0055] Local feature fusion: Conv(1x1, Output Channels). Input: Concat(x_in, layer1_out, layer2_out, layer3_out, ...)
[0056] Output: LFF_out + x_in (residual join)
[0057] DBlock's dense connections and local fusion mechanism enable it to effectively extract and integrate multi-level features (from details to semantics) from noisy and information-sparse inputs, providing a rich information foundation for subsequent image reconstruction (such as denoising, brightening, and contrast adjustment). Shallow details are preserved and passed to deeper layers through dense connections, aiding in the identification of fine textures in images. Simultaneously, the abstract features learned by deep networks help distinguish between real image structure and noise. The vanishing gradient problem is particularly severe in deep networks; DBlock's dense and residual connection design ensures smooth information flow and gradient propagation. Despite its structural complexity, by controlling the Growth Rate (G) and utilizing 1x1 convolutional dimensionality reduction, DBlock delivers powerful performance while maintaining a relatively reasonable model size and computational complexity.
[0058] DBlock is a powerful feature extraction module that integrates the best features of DenseNet, Local Feature Fusion (LFF), and Residual Learning (ResNet). It is specifically optimized for the core challenges of low-light image enhancement, such as information scarcity, severe noise interference, and difficult gradient propagation, by forcing feature reuse, promoting information flow, efficiently fusing multi-scale features, and stabilizing the training process. DBlock is one of the key architectural innovations of the DarkIR model that enables it to effectively improve the quality of low-light images, restore lost details, and suppress noise.
[0059] Based on the above method embodiments, as an optional embodiment, the cow ear tag detection method based on convolutional neural networks provided in this embodiment of the invention includes training the optimized cow ear tag detection model using a training set, which includes: using the model to construct a dataset to train the optimized cow ear tag detection model, thereby obtaining a trained cow ear tag detection model.
[0060] The model was used to construct a dataset to train the cow ear tag detection model, resulting in the trained model. The input image size was set to 640×640, the batch size was 16, the number of training iterations was 100, the initial learning rate was 0.01, and the optimizer used was SGD.
[0061] Table 1 shows a comparison of the detection results of this invention and YOLOv11s:
[0062] Table 1
[0063]
[0064] As can be seen from the table above, the present invention has significantly improved the performance of YOLOv11 after making improvements. It is 2.3% higher than YOLOv11 in mAP50 and 2.7% higher than YOLOv11 in mAP50-95.
[0065] To verify the effectiveness of the three improvements, the present invention conducted the following six sets of ablation experiments on the three innovative points. The results of the ablation experiments are shown in Table 2:
[0066] Table 2
[0067]
[0068] The data in the three tables of the comparative and ablation experiments above clearly demonstrate the effective improvement of the algorithm.
[0069] Based on the above method embodiments, as an optional embodiment, the cow ear tag detection method based on convolutional neural networks provided in this embodiment of the invention, wherein the cow ear tag detection model is used to detect cow ear tags in images, includes: after obtaining the trained cow ear tag detection model, saving the model weight parameters with the extension ".pt"; reloading the model weight parameters to obtain a loaded cow ear tag detection model, and using the loaded cow ear tag detection model to detect cow ear tags in images. The detection results can be found in [reference needed]. Figure 5 .
[0070] The bovine ear tag detection method based on convolutional neural networks provided in this invention improves bovine ear tag detection performance by optimizing YOLOv11, with mAP50 increasing by 2.3% compared to YOLOv11 and by 2.7% compared to mAP50-95. It uses a universal camera, resulting in lower costs than electronic ear tag solutions. Non-contact detection reduces safety risks and adapts to complex scenarios such as lighting and soiling. It can be integrated with digital systems to achieve efficient batch recognition, assisting in refined feeding and disease prevention and control, and promoting intelligent management of animal husbandry.
[0071] The implementation of the various embodiments of this invention is based on programmed processing (i.e., software) using a device with processor functionality. Therefore, in practical engineering, the technical solutions and functions of the various embodiments of this invention can be encapsulated into various modules. Based on this reality, and building upon the above embodiments, this invention provides a cow talon detection device based on a convolutional neural network, which is used to execute the cow talon detection method based on a convolutional neural network in the above method embodiments. See also... Figure 2The device includes: a first main module for acquiring multiple cow ear tag images to form a model construction dataset; a second main module for replacing the ordinary convolutions in layers 3, 5, and 7 of the YOLOv11 backbone network with adaptive downsampling (Adown); a third main module for introducing dynamic sample attention scale sequence fusion in layers 25 and 26 of the YOLOv11 neck network; a fourth main module for replacing all C3k2 modules in the dual-kernel convolutional cross-stage with C3k2-Dblock modules in the dual-kernel convolutional cross-stage dark image recovery, thus optimizing the YOLOv11 object detection algorithm and constructing an optimized cow ear tag detection model; a fifth main module for training the optimized cow ear tag detection model using a training set; and a sixth main module for detecting cow ear tag images using the trained cow ear tag detection model.
[0072] The bovine ear tag detection device based on a convolutional neural network provided in this embodiment of the invention employs... Figure 2 Several modules within the system have been optimized using YOLOv11 to improve the detection performance of cattle ear tags, with mAP50 increasing by 2.3% compared to YOLOv11 and by 2.7% compared to mAP50-95. The system utilizes a universal camera, resulting in lower costs than electronic ear tag solutions. Non-contact detection reduces safety risks and adapts to complex scenarios such as lighting and soiling. It can be integrated with digital systems to achieve efficient batch identification, supporting refined feeding and disease prevention, and promoting intelligent management of animal husbandry.
[0073] It should be noted that the apparatus in the device embodiments provided by the present invention can be used not only to implement the methods in the above method embodiments, but also to implement the methods in other method embodiments provided by the present invention. The difference lies only in setting corresponding functional modules (i.e., software). Its principle is basically the same as that of the above device embodiments provided by the present invention. As long as those skilled in the art, based on the above device embodiments and referring to the specific technical solutions in other method embodiments, obtain corresponding technical means and technical solutions composed of these technical means by combining technical features, and under the premise of ensuring the practicality of the technical solution, they can improve the apparatus in the above device embodiments to obtain corresponding device-type embodiments (i.e., software) for implementing the methods in other method-type embodiments. For example:
[0074] Based on the above device embodiments, as an optional embodiment, the cow ear tag detection device based on convolutional neural networks provided in this embodiment of the invention further includes: a first sub-module, used to acquire multiple cow ear tag images and form a model construction dataset, including: acquiring multiple original cow ear tag images, sharpening and denoising each cow ear tag image to obtain multiple pre-processed images, wherein the multiple pre-processed images form the model construction dataset.
[0075] Based on the above device embodiments, as an optional embodiment, the cow tassel detection device based on convolutional neural networks provided in this embodiment of the invention further includes: a second submodule, used to replace the ordinary convolutions in layers 3, 5, and 7 of the YOLOv11 backbone network with adaptive downsampling (Adown), including: the adaptive downsampling (Adown) uses a generalized efficient layer aggregation network (GELAN), including a cross-stage partial network (CSPNet) and an efficient layer aggregation network (ELAN).
[0076] Based on the above device embodiments, as an optional embodiment, the cow ear tag detection device based on convolutional neural networks provided in this embodiment of the invention further includes: a third sub-module, used to implement the introduction of dynamic sample attention scale sequence fusion in the 25th and 26th layers of the YOLOv11 neck network, including: the dynamic sample attention scale sequence fusion is obtained by combining the adaptive multi-scale feature fusion mechanism ASFF and the content-aware upsampling method DySample.
[0077] Based on the above device embodiments, as an optional embodiment, the bull sign detection device based on convolutional neural networks provided in this embodiment of the invention further includes: a fourth sub-module, used to replace all the dual-kernel convolutional cross-stage partial modules C3k2 modules in the model with dual-kernel convolutional cross-stage partial dark image recovery modules C3k2-Dblock, including: the dual-kernel convolutional cross-stage partial dark image recovery module C3k2-Dblock is obtained by improving the dual-kernel convolutional cross-stage partial modules C3k2 modules through dense blocks DBlock in Dark Image Recovery DarkIR, wherein the dense blocks DBlock fuse dense connections DenseNet, local feature fusion LFF and residual learning ResNet.
[0078] Based on the above device embodiments, as an optional embodiment, the cow ear tag detection device based on convolutional neural networks provided in this embodiment of the invention further includes: a fifth sub-module, used to implement the training of the optimized cow ear tag detection model using a training set, including: using the dataset constructed by the model to train the optimized cow ear tag detection model, thereby obtaining a trained cow ear tag detection model.
[0079] Based on the above device embodiments, as an optional embodiment, the cow ear tag detection device based on convolutional neural networks provided in this embodiment of the invention further includes: a sixth sub-module, used to implement the detection of cow ear tag images using a trained cow ear tag detection model, including: after obtaining the trained cow ear tag detection model, saving model weight parameters with the extension ".pt"; reloading the model weight parameters to obtain a loaded cow ear tag detection model, and using the loaded cow ear tag detection model to detect cow ear tag images.
[0080] The method in this embodiment of the invention is implemented using an electronic device; therefore, it is necessary to introduce the relevant electronic device. For this purpose, this embodiment of the invention provides an electronic device, such as... Figure 3 As shown, the electronic device includes at least one processor, a communications interface, at least one memory, and a communications bus, wherein the at least one processor, the communications interface, and the at least one memory communicate with each other via the communications bus. The at least one processor can invoke logical instructions stored in the at least one memory to execute all or part of the steps of the methods provided in the foregoing method embodiments.
[0081] Furthermore, when the logical instructions in at least one of the aforementioned memories can be implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various method embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0082] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0083] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0084] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of the present invention. Based on this understanding, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order than those shown in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, or sometimes in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or action, or using a combination of dedicated hardware and computer instructions.
[0085] It should be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element. Any expressions such as "predetermined threshold," "preset threshold," etc., without specifying a particular value, can be determined by those skilled in the art through simple experimentation or appropriate adjustments.
[0086] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for detecting ear tags based on a convolutional neural network, characterized in that, The application relates to a method for detecting ear tags of cattle. The method comprises the following steps: acquiring multiple ear tag images of cattle to form a model construction dataset; replacing ordinary convolution in the third layer, the fifth layer and the seventh layer of a YOLOv11 backbone network with adaptive downsampling Adown; introducing dynamic sample attention scale sequence fusion into the 25th layer and the 26th layer of a YOLOv11 neck network; replacing all double-core convolution cross-stage partial module C3k2 modules in the model with double-core convolution cross-stage partial dark image restoration modules C3k2-Dblock, optimizing a YOLOv11 target detection algorithm, and constructing an optimized ear tag detection model of cattle; training the optimized ear tag detection model of cattle by using a training set; and detecting ear tag images of cattle by using the trained ear tag detection model of cattle. The replacement of ordinary convolution in the third layer, the fifth layer and the seventh layer of the YOLOv11 backbone network with adaptive downsampling Adown comprises the following steps: the adaptive downsampling Adown uses a generalized efficient layer aggregation network GELAN, which comprises a cross-stage partial network CSPNet and an efficient layer aggregation network ELAN. The introduction of dynamic sample attention scale sequence fusion into the 25th layer and the 26th layer of the YOLOv11 neck network comprises the following steps: the dynamic sample attention scale sequence fusion is obtained by combining an adaptive multi-scale feature fusion mechanism ASFF and a content-aware upsampling method DySample. The replacement of all double-core convolution cross-stage partial module C3k2 modules in the model with double-core convolution cross-stage partial dark image restoration modules C3k2-Dblock comprises the following steps: the double-core convolution cross-stage partial dark image restoration modules C3k2-Dblock are obtained by improving the double-core convolution cross-stage partial module C3k2 modules through a dense block DBlock in dark image restoration DarkIR, and the dense block DBlock fuses a dense network DenseNet, local feature fusion LFF and residual learning ResNet. 2.The ear tag detection method based on a convolutional neural network according to claim 1, characterized in that, The acquisition of multiple ear tag images of cattle to form a model construction dataset comprises the following steps: multiple original ear tag images of cattle are collected, each ear tag image of cattle is subjected to data enhancement processing such as sharpening, brightness increase, noise increase and inversion, multiple preprocessed images are obtained, and the multiple preprocessed images form the model construction dataset. 3.The ear tag detection method based on convolutional neural network according to claim 1, wherein, The training of the optimized ear tag detection model of cattle by using a training set comprises the following steps: the optimized ear tag detection model of cattle is trained by using the model construction dataset, and a trained ear tag detection model of cattle is obtained. 4.The ear tag detection method based on a convolutional neural network according to claim 1, wherein, The detection of ear tag images of cattle by using the trained ear tag detection model of cattle comprises the following steps: after the trained ear tag detection model of cattle is obtained, model weight parameters with an extension name of ".pt" are saved; the model weight parameters are reloaded, an ear tag detection model of cattle is obtained, and ear tag images of cattle are detected by using the ear tag detection model of cattle.
5. A convolutional neural network-based ear tag detection device, characterized by, The application relates to a method for detecting ear tags of cattle. The first main module is used for realizing acquisition of multiple ear tag images of cattle to form a model construction dataset; the second main module is used for realizing replacement of normal convolution in the 3rd layer, the 5th layer and the 7th layer of a YOLOv11 backbone network with adaptive downsampling Adown; the third main module is used for realizing introduction of a dynamic sample attention scale sequence fusion at the 25th layer and the 26th layer of a YOLOv11 neck network; the fourth main module is used for realizing replacement of all double-core convolution cross-stage partial modules C3k2 modules in the model with double-core convolution cross-stage partial dark image restoration modules C3k2-Dblock, optimizing the YOLOv11 target detection algorithm, and constructing an optimized ear tag detection model of cattle; the fifth main module is used for realizing training of the optimized ear tag detection model of cattle by using a training set; and the sixth main module is used for realizing detection of ear tag images of cattle by using the trained ear tag detection model of cattle. The replacement of the normal convolution in the 3rd layer, the 5th layer and the 7th layer of the YOLOv11 backbone network with the adaptive downsampling Adown comprises that the adaptive downsampling Adown uses a generalized efficient layer aggregation network GELAN, which comprises a cross-stage partial network CSPNet and an efficient layer aggregation network ELAN. The introduction of the dynamic sample attention scale sequence fusion at the 25th layer and the 26th layer of the YOLOv11 neck network comprises that the dynamic sample attention scale sequence fusion is obtained by combination of an adaptive multi-scale feature fusion mechanism ASFF and a content-aware upsampling method DySample. The replacement of all double-core convolution cross-stage partial modules C3k2 modules in the model with double-core convolution cross-stage partial dark image restoration modules C3k2-Dblock comprises that the double-core convolution cross-stage partial dark image restoration modules C3k2-Dblock are obtained by improvement of the double-core convolution cross-stage partial modules C3k2 modules through a dense block DBlock in dark image restoration DarkIR, and the dense block DBlock fuses a dense connection DenseNet, a local feature fusion LFF and a residual learning ResNet.
6. An electronic device, comprising: The device comprises: at least one processor, at least one memory and a communication interface; wherein the processor, the memory and the communication interface communicate with each other; the memory stores program instructions executable by the processor, and the processor invokes the program instructions to execute the method in any one of claims 1 to 4.
7. A non-transitory computer-readable storage medium, comprising: The non-transitory computer readable storage medium stores computer instructions, and the computer instructions enable a computer to execute the method in any one of claims 1 to 4.
Citation Information
Patent Citations
Remote sensing target detection method based on convolutional neural network
CN119152367A
Multi-head cattle identification and tracking algorithm based on improved YOLOv10s
CN119418396A