Chicken farm detection method and system based on YOLO-CV model
By introducing the Stem architecture, residual communication block and multi-scale feature fusion technology into the YOLO-CV model, the real-time and accuracy problems of detecting the number of laying hens in chicken farms are solved, and rapid and accurate detection of chickens and eggs is achieved. , reducing labor intensity and safety risks.
Patent Information
- Application Number
- CN202410652919.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-24
- Publication Date
- 2024-08-23
AI Technical Summary
In the field of poultry breeding, it is difficult for existing technology to effectively realize real-time intelligent detection of the number of laying hens in chicken farms, resulting in high labor intensity, high safety risks, and the problem of ‘excessive waiting to fill the number’.
Using the chicken farm detection method based on the YOLO-CV model, through the construction of Stem architecture module, residual communication block Rs-Block, multi-head self-attention and MR module, multi-scale feature fusion PANet and other technologies, a system that can quickly detect chickens and Egg model to improve detection accuracy and efficiency.
It achieves rapid and accurate detection of chickens and eggs in chicken farms, reduces the risk of worker injury, improves the safety and efficiency of breeding management, and meets real-time requirements.
Smart Images

Figure CN118537852A
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of computer vision and image recognition, and in particular to a chicken farm detection method and system based on a YOLO-CV model. Background Art
[0002] In agricultural production, especially in the field of poultry farming, how to use machine learning algorithms to achieve intelligent management of chicken farms has become a topic of great concern. Once achieved, it can greatly reduce the recognized labor intensity of farming, improve the safety factor, and at the same time find out the "abnormal" laying hens by comparing the number. In chicken farms, the yolo-cv model is used to detect the number of eggs and laying hens in the chicken farm, so as to find out the "abnormal" laying hens, achieve the purpose of reducing costs and increasing efficiency, and effectively reduce the risk of worker injuries. Summary of the invention
[0003] Purpose of the invention: In view of the problems pointed out in the background technology, the present invention proposes a chicken farm detection method based on the YOLO-CV model. The detection speed meets the real-time requirements, and the improved detection model can be better applied to chicken farm detection.
[0004] Technical solution: The present invention provides a chicken farm detection method based on the YOLO-CV model, and the specific steps are as follows:
[0005] Step 1: Collect chicken farm data to create an image dataset, annotate it using a labeling tool, and create a label dataset; integrate the image and label datasets to create a model training dataset;
[0006] Step 2: First build the Stem architecture module in the backbone feature extraction network to achieve the fusion of image features during the initial feature extraction.
[0007] Step 3: Construct the residual communication block Rs-block in the backbone feature extraction network;
[0008] Step 4: Construct multi-head self-attention and MR modules in the residual communication block;
[0009] Step 5: Multi-scale feature fusion PANet is used in the neck network;
[0010] Step 6: Train the YOLO-CV network model to obtain the best model weights and perform chicken farm detection on the image data to be detected.
[0011] Furthermore, the specific steps of step 1 are as follows:
[0012] Step 1.1: Create an image dataset by fusing image data of different types of chicken farms;
[0013] Step 1.2: Use the data annotation tool Labelimg to annotate the chicken farm images. The annotated image labels are divided into chickens and eggs. Rectangular boxes are used to mark the positions of chickens and eggs in the image. The images are annotated in YOLO format to obtain the chicken farm image dataset.
[0014] Step 1.3: Integrate the image dataset and the label dataset to create a training dataset; the dataset is divided into a training set, a validation set, and a test set in a ratio of 8:1:1.
[0015] Furthermore, the Stem module in step 2 includes a combination of Conv, BN and RELU, so as to achieve the effect of preliminary feature extraction. The whole process is shown as follows:
[0016] F Stem =RELU(BN( 7×7 Conv(X)))
[0017] Among them: 7 represents the size of the convolution kernel, X represents the input feature map, F Stem It is obtained through convolution.
[0018] Furthermore, the step 3 includes the following sub-steps:
[0019] Step 3.1: The residual communication block Rs-block is composed of multi-head self-attention, MR module, and skip connection. First, the feature vector output by the Stem module in step 2 is used as the input of the next layer of Rs-block module features. When the feature input is divided into two parallel branches, the main branch is multi-head self-attention and MR module, and the branch branch is skip connection. This is more comprehensive when extracting the chicken and egg data features.
[0020] Step 3.2: Add the features of the main branch and the trunk branch extracted in step 3.1, and then use the output features as the input of the next layer of Rs-block, so as to extract image features from two different directions. The formula is as follows:
[0021] F Rs-Block =RELU(MR(TA(RELU(BN(MR(x)))))+BN(Conv(x)))
[0022] Among them: F Rs-Block represents the Rs-Block module, MR represents the multi-scale module, TA represents multi-head self-attention, and x represents the output feature vector of the previous layer.
[0023] Furthermore, the step 4 includes the following sub-steps:
[0024] Step 4.1 The MR module consists of four parallel sub-modules. First, the feature vector output from the Rs-block module in step 3 is used as the input of the next layer of MR module features. In the MR module, the input features are sent to each sub-module according to four different expansion rates. The sub-module of each expansion rate is responsible for capturing the feature details of a specific scale from the image. After all sub-modules are processed, the feature maps they obtain will be merged by element-by-element addition. This merging process integrates multi-scale feature information, thereby enhancing the model's detection performance for targets of different sizes. The formula is as follows:
[0025] F MR =Conv 1 (x)+Conv 2 (x)+Conv 3 (x)+Conv 4 (x)
[0026] Among them: F MR represents the MR multi-scale module, 1, 2, 3, 4 represent the expansion rate, and x represents the output feature vector of the previous layer.
[0027] Furthermore, the step 5 includes the following sub-steps:
[0028] Step 5.1: The first step of feature fusion: PANet first gradually increases the resolution of the low-resolution feature map output by the backbone network by upsampling it to match the size of the feature map of the higher level. Then, these upsampled feature maps are fused with the feature maps output by the backbone network at the corresponding level, so that the low-level detail information can be combined with the high-level semantic information.
[0029] Step 5.2: The second step of feature fusion: After completing the first fusion, PANet continues to process these fused feature maps. It upsamples these fused feature maps again to match and fuse with higher-level feature maps. This process is another feature fusion from low to high resolution, with the aim of further integrating feature information at different scales.
[0030] Step 5.3: Output of the final feature map: After two feature fusions by PANet, three feature maps with different resolutions are finally obtained. These feature maps carry rich details and semantic information, providing a more comprehensive feature representation for the subsequent detection head.
[0031] Step 5.4: Detection by head network: Finally, the three feature maps of different resolutions are fed into the head network, which is responsible for detecting the target based on these fused features, including bounding box prediction, confidence score, and category probability calculation.
[0032] Furthermore, in the network model training of step 6, iterations were performed 200 times, the initial learning rate was set to 0.01, the minimum learning rate was set to 0.001, the bitch_size was set to 16, the AUTO optimizer was used, and the weight decay was set to 0.0005.
[0033] Compared with the prior art, the present invention has the following beneficial effects:
[0034] 1. The MR module used in the present invention is composed of multi-scale modules. This design enables the model to capture features of different scales at the same time, thereby effectively enhancing the detection ability of multi-scale targets. It can also integrate more abundant features, enhance model robustness, use parallel computing to improve efficiency, simplify model complexity, improve detection accuracy, and improve the performance of deep learning models in target detection tasks.
[0035] 2. The present invention adopts an innovative residual communication block, called Rs-Block, which is constructed by combining a multi-scale module (MR module) and a multi-head self-attention mechanism and utilizing jump connections. This design aims to enhance the depth and richness of feature representation while reducing the number of parameters and computational complexity of the model. Rs-Block effectively expands the receptive field of the model and enhances the ability to capture contextual information by improving the flow of information in the network and the efficiency of gradient propagation. In addition, this module also promotes the development of more efficient and high-performance deep learning models. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] Figure 1 is a method flow chart of an embodiment of the present invention;
[0037] Figure 2 is an overall network structure diagram of an embodiment of the present invention;
[0038] Figure 3 is a schematic diagram of a Stem module in an embodiment of the present invention;
[0039] Figure 4 is a structural diagram of Rs-Block in an embodiment of the present invention;
[0040] Figure 5 is a structural diagram of MR in an embodiment of the present invention;
[0041] Figure 6 is a schematic diagram of a multi-head self-attention module in an embodiment of the present invention;
[0042] Figure 7 is a schematic diagram of a C3 module in an embodiment of the present invention;
[0043] Figure 8 is a schematic diagram of a CBS module in an embodiment of the present invention;
[0044] Fig. 9 It is a detection effect diagram of the algorithm of the present invention. DETAILED DESCRIPTION
[0045] The following examples will be used to further illustrate the present invention. It should be clear that these examples are only intended to provide a deeper understanding of the present invention and do not constitute a limitation on the scope of protection thereof. Personnel with certain professional skills in this technical field may make some non-fundamental improvements and adjustments based on the contents disclosed in the present invention, and these changes or adjustments shall also be regarded as part of the protection of the present invention.
[0046] The present invention proposes a chicken farm detection method based on the YOLO-CV model, and the specific steps are as follows:
[0047] Step 1: Collect chicken farm data to create an image dataset, annotate it using a labeling tool, and create a label dataset; integrate the image and label datasets to create a model training dataset;
[0048] Step 1.1: Create an image dataset by fusing image data of different types of chicken farms;
[0049] Step 1.2: Use the data annotation tool Labelimg to annotate the chicken farm images. The annotated image labels are divided into chickens and eggs. Rectangular boxes are used to mark the positions of chickens and eggs in the image. The images are annotated in YOLO format to obtain the chicken farm image dataset.
[0050] Step 1.3: Integrate the image dataset and the label dataset to create a training dataset; the dataset is divided into a training set, a validation set, and a test set in a ratio of 8:1:1.
[0051] Step 2: First build the Stem architecture module in the backbone feature extraction network to integrate image features during preliminary feature extraction.
[0052] Step 2.1 First, 7×7Conv, normalized BN and activation function RELU are combined in series. The whole process is as follows:
[0053] F Stem =RELU(BN( 7×7 Conv(X)))
[0054] Among them: 7 represents the size of the convolution kernel, X represents the input feature map, F Stem It is obtained through convolution.
[0055] Step 3: Construct the residual communication block Rs-Block in the backbone feature extraction network;
[0056] Step 3.1: The residual communication block Rs-Block is composed of multi-head self-attention, MR module, and skip connection. First, the feature vector output by the Stem module in step 2 is used as the input of the next layer of Rs-block module features. When the feature input is divided into two parallel branches, the main branch is multi-head self-attention and MR module, and the branch branch is skip connection. This is more comprehensive when extracting the chicken and egg data features.
[0057] Step 3.2: Add the features of the main branch and trunk branch extracted in step 3.1, and then use the output features as the input of the next layer of Rs-block. This is to extract image features from two different directions.
[0058] The formula is as follows:
[0059] F Rs-Block =RELU(MR(TA(RELU(BN(MR(x)))))+BN(Conv(x)))
[0060] Among them: F Rs-Block represents the Rs-Block module, MR represents the multi-scale module, TA represents multi-head self-attention, and x represents the output feature vector of the previous layer.
[0061] Step 4: Establish a MR multi-scale module in the residual communication block;
[0062] Step 4.1 The MR multi-scale module consists of four parallel sub-modules. First, the feature vector output from the Rs-block module in step 3 is used as the input of the next layer of MR module features. In the MR module, the input features are sent to each sub-module according to four different expansion rates. The sub-module of each expansion rate is responsible for capturing the feature details of a specific scale from the image. After all sub-modules are processed, the feature maps they obtain will be merged by element-by-element addition. This merging process integrates multi-scale feature information, thereby enhancing the model's detection performance for targets of different sizes. The formula is as follows:
[0063] F MR =Conv 1 (x)+Conv 2 (x)+Conv 3 (x)+Conv 4 (x)
[0064] Among them: F MR represents the MR multi-scale module, 1, 2, 3, 4 represent the expansion rate, and x represents the output feature vector of the previous layer.
[0065] Step 5: Multi-scale feature fusion PANet is used in the neck network;
[0066] Step 5.1: The first step of feature fusion: PANet first gradually increases the resolution of the low-resolution feature map output by the backbone network by upsampling it to match the size of the feature map of the higher level. Then, these upsampled feature maps are fused with the feature maps output by the backbone network at the corresponding level, so that the low-level detail information can be combined with the high-level semantic information.
[0067] Step 5.2: The second step of feature fusion: After completing the first fusion, PANet continues to process these fused feature maps. It upsamples these fused feature maps again to match and fuse with higher-level feature maps. This process is another feature fusion from low to high resolution, with the aim of further integrating feature information at different scales.
[0068] Step 5.3: Output of the final feature map: After two feature fusions by PANet, three feature maps with different resolutions are finally obtained. These feature maps carry rich details and semantic information, providing a more comprehensive feature representation for the subsequent detection head.
[0069] Step 5.4: Detection by head network: Finally, the three feature maps of different resolutions are fed into the head network, which is responsible for detecting the target based on these fused features, including bounding box prediction, confidence score, and category probability calculation.
[0070] Step 6: Train the YOLO-CV network model to obtain the best model weights and perform chicken farm detection on the image data to be detected.
[0071] Step 6.1 is specifically set to 200 iterations, the initial learning rate is set to 0.01, the minimum learning rate is set to 0.001, the bitch_size is set to 16, the AUTO optimizer is used, and the weight decay is set to 0.0005.
[0072] Step 6.2: After training, the optimal weights are obtained, and the test set is tested using the optimal weights to obtain the test results.
[0073] The evaluation indicators used in the implementation of the present invention are accuracy, comprehensive evaluation index (F-Measure), mean average precision (MAP), parameter quantity (Params), and calculation quantity (GFLOPs). The formulas of each evaluation index are as follows:
[0074]
[0075] This indicator reflects the proportion of the number of samples predicted to be positive to the total number of positive samples; among them, TP represents the number of positive samples predicted to be positive; TN represents the number of negative samples predicted to be negative; FP represents the number of negative samples predicted to be positive; and FN represents the number of positive samples predicted to be negative.
[0076] The F1-Measure formula is as follows:
[0077]
[0078] The data for experimental training in this paper comes from Zhanggongdu Egg Industry Co., Ltd. The total amount of image data set is 3305, the training set is 2645, the validation set is 330, and the test set is 330. The experimental environment parameters are shown in Table 1 below.
[0079] Table 1
[0080]
[0081] against Fig. 9 , it shows good accuracy in the test set. The experimental results are shown in Table 2. From the table, we can see the model parameter quantity and calculation amount of the YOLO-CV detection algorithm. The improved chicken farm detection model can meet the real-time requirements.
[0082] Table 2
[0083]
[0084] The above embodiments are only for illustrating the technical concept and features of the present invention, and their purpose is to enable people familiar with the technology to understand the content of the present invention and implement it accordingly, and they cannot be used to limit the protection scope of the present invention. Any equivalent transformation or modification made according to the spirit of the present invention should be included in the protection scope of the present invention.
Claims
1. A chicken farm detection method based on the YOLO-CV model, characterized in that: The specific steps are as follows: Step 1: Collect chicken farm data to create an image dataset, annotate it using a labeling tool, and create a label dataset; integrate the image and label datasets to create a model training dataset; Step 2: Build the YOLO-CV network model. First, build the Stem module in the backbone feature extraction network to obtain the image features fused during the preliminary feature extraction. Step 3: Construct the residual communication block Rs-block in the backbone feature extraction network; Step 4: Construct multi-head self-attention and MR modules in the residual communication block; Step 5: Multi-scale feature fusion PANet is used in the neck network; Step 6: Train the YOLO-CV network model to obtain the best model weights and perform chicken farm detection on the image data to be detected.
2. A chicken farm detection method based on the YOLO-CV model according to claim 1, characterized in that: The specific steps of step 1 are as follows: Step 1.1: Create an image dataset by fusing image data of different types of chicken farms; Step 1.2: Use the data annotation tool Labelimg to annotate the chicken farm images. The annotated image labels are divided into chickens and eggs. Rectangular boxes are used to mark the positions of chickens and eggs in the image. The images are annotated in YOLO format to obtain the chicken farm image dataset. Step 1.3: Integrate the image dataset and the label dataset to create a training dataset; the dataset is divided into a training set, a validation set, and a test set.
3. A chicken farm detection method based on the YOLO-CV model according to claim 1, characterized in that: In step 2, the Stem module is composed of Conv, BN and RELU, and the process is as follows: F Stem =RELU(BN( 7×7 Conv(X))) Among them: 7 represents the size of the convolution kernel, X represents the input feature map, F Stem It is obtained through convolution.
4. A chicken farm detection method based on the YOLO-CV model according to claim 1, characterized in that: The step 3 comprises the following steps: Step 3.1: The residual communication block Rs-block is composed of multi-head self-attention, MR module, and skip connection. The feature vector output by the Stem module in step 2 is used as the input of the feature of the next layer Rs-block module. When the feature is input, it is divided into two parallel branches, where the main branch is multi-head self-attention and MR module, and the branch branch is skip connection. Step 3.2: Add the features of the main branch and the trunk branch extracted in step 3.1, and then use the output features as the input of the next layer of Rs-block. The formula is as follows: F Rs-Block =RELU(MR(TA(RELU(BN(MR(x)))))+BN(Conv(x))) Among them: F Rs-Block represents the Rs-Block module, MR represents the multi-scale module, TA represents multi-head self-attention, and x represents the output feature vector of the previous layer.
5. The chicken farm detection method based on the YOLO-CV model according to claim 1, characterized in that: The step 4 comprises the following steps: Step 4.1 The MR module consists of four parallel submodules; the feature vector output by the Rs-block module in step 3 is used as the input of the next layer of MR module features. In the MR module, the input features are sent to each submodule according to four different expansion rates. The submodule of each expansion rate is responsible for capturing the feature details of a specific scale from the image; after all submodules are processed, the feature maps they obtain are merged by element-by-element addition, and the formula is as follows: F MR =Conv 1 (x)+Conv 2 (x)+Conv 3 (x)+Conv 4 (x) Among them: F MR represents the MR multi-scale module, and 1, 2, 3, and 4 represent the dilation rates.
6. The chicken farm detection method based on the YOLO-CV model according to claim 1, characterized in that: The step 5 comprises the following steps: Step 5.1: PANet first gradually increases the resolution of the low-resolution feature map output by the backbone network by upsampling it to match the size of the feature map of the higher level. Then, these upsampled feature maps are fused with the feature maps output by the backbone network at the corresponding level. Step 5.2: After completing the first fusion, PANet continues to process these fused feature maps, upsamples them again, and further integrates feature information of different scales; Step 5.3: After two feature fusions by PANet, three feature maps with different resolutions are finally obtained; Step 5.4: The three feature maps of different resolutions are fed into the head network, which is responsible for detecting the target based on these fused features, including bounding box prediction, confidence score, and category probability calculation.
7. A chicken farm detection system based on the YOLO-CV model, characterized in that: Including data acquisition module, YOLO-CV network model, training and detection module; The data acquisition module collects chicken farm data to produce an image data set, annotates it through a labeling tool, and produces a label data set; integrates the image and label data sets to produce a model training data set; The YOLO-CV network model first constructs a Stem module in the backbone feature extraction network to obtain image features fused during preliminary feature extraction; constructs a residual communication block Rs-block in the backbone feature extraction network; constructs a multi-head self-attention and MR module in the residual communication block; and adopts a multi-scale feature fusion PANet in the neck network; The training detection module performs network model training on the YOLO-CV network model, trains the best model weights, and performs chicken farm detection on the image data to be detected.
8. A chicken farm detection system based on the YOLO-CV model according to claim 7, characterized in that: The construction of the residual communication block Rs-block in the backbone feature extraction network includes: The residual communication block Rs-block is composed of multi-head self-attention, MR module, and skip connection. The feature vector output by the Stem module in step 2 is used as the input of the feature of the next layer Rs-block module. When the feature is input, it is divided into two parallel branches, where the main branch is multi-head self-attention and MR module, and the branch branch is skip connection. After extracting features from the main branch and the trunk branch, the features are added together, and the output features are used as the input of the next layer of Rs-block. The formula is as follows: F Rs-Block =RELU(MR(TA(RELU(BN(MR(x)))))+BN(Conv(x))) Among them: F Rs-Block represents the Rs-Block module, MR represents the multi-scale module, TA represents multi-head self-attention, and x represents the output feature vector of the previous layer.
9. A chicken farm detection system based on the YOLO-CV model according to claim 7, characterized in that: The construction of the multi-head self-attention and MR modules in the residual communication block includes: The MR module consists of four parallel submodules. The feature vector output by the Rs-block module in step 3 is used as the input of the next layer of MR module features. In the MR module, the input features are sent to each submodule according to four different expansion rates. Each submodule with each expansion rate is responsible for capturing feature details of a specific scale from the image. After all submodules are processed, the feature maps they obtain are merged by element-by-element addition. The formula is as follows: F MR =Conv 1 (x)+Conv 2 (x)+Conv 3 (x)+Conv 4 (x) Among them: F MR represents the MR multi-scale module, and 1, 2, 3, and 4 represent the dilation rates.
10. A chicken farm detection system based on the YOLO-CV model according to claim 7, characterized in that: The multi-scale feature fusion PANet used in the neck network includes: PANet first gradually increases the resolution of the low-resolution feature maps output by the backbone network by upsampling them to match the size of the feature maps of a higher level. Then, these upsampled feature maps are fused with the feature maps output by the backbone network at the corresponding level. After completing the first fusion, PANet continues to process these fused feature maps and upsamples them again to further integrate feature information of different scales. After two feature fusions of PANet, three feature maps with different resolutions are finally obtained; The three feature maps of different resolutions are fed into the head network, which is responsible for detecting the target based on these fused features, including bounding box prediction, confidence score, and category probability calculation.
Citation Information
Patent Citations
Sugarcane aphid target detection method based on lightweight YOLO v5
CN114708231A
Method and system for detecting vehicle on enhanced thermal infrared image based on improved SSD (Solid State Disk)
CN115171001A
Lightweight military target detection method based on SMCA-YOLOv5
CN115424091A
Agricultural pest detection method and device based on YOLO v5
CN115546187A
Intelligent traffic target detection method based on deep learning
CN116311094A
Cited By
Farm chicken detection method, device, equipment and medium
CN120014672A
Low-yield chicken coop distinguishing system and method, electronic equipment and storage medium
CN120047966A
