Broiler chicken heat stress behavior detection method based on improved YOLOv11 and progressive training

CN122990798APending Publication Date: 2026-10-27YANGZHOU UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611154415.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-07-31
Publication Date
2026-10-27

AI Technical Summary

Technical Problem

[0007]本发明的目的是提供一种基于改进YOLOv11与递进训练的肉鸡热应激行为检测方法,解决YOLO在复杂的平养环境下识别肉鸡热应激行为时混淆标注框背景与目标这一难题,且提高了肉鸡喘息行为的识别的精度

Benefits of technology

[0058]与现有技术相比,本发明的有益效果在于:使用超分辨率增强小目标细粒度特征,使用Transformer模块提高模型精度,使用分阶段迁移学习训练策略提高模型的稳定性。区别于传统的体温计测温,本发明无需捕捉鸡只,消除了因人为接触带来的应激干扰,结果更能反映真实的生理状态。利用机器视觉算法,精准定位异常行为人的的个体,避免漏检,尤其适合平养模式下大群管理的需求。因为是非侵入式部署,改造成本低,无需大规模改造现有鸡舍结构,易于在老旧平养鸡舍中推广。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122990798A_ABST
    Figure CN122990798A_ABST
Patent Text Reader

Abstract

The application discloses a kind of meat chicken heat stress behavior detection methods based on improved YOLOv11 and progressive training in the field of computer vision, comprising the following steps, S1, obtain original image data set, image data set is screened and super-resolution reconstruction is carried out, and feature labeling is carried out, and the normalized data set containing mask and label frame label respectively is obtained;S2, the improved YOLOv11 feature extraction backbone network is constructed, and the backbone network is based on the double-layer attention module with dynamic routing function and the cross-stage feature fusion module is constructed;S3, obtain pre-training weight and load it to backbone network, freeze its parameters at the same time, the network part outside backbone network is preliminarily trained, and migration weight is obtained;S4, when S3 training is completed after the preset training period, automatically trigger training supervision mode switching, and the label reading of data set is switched from detection frame label to segmentation mask label.The precision of the identification of broiler panting behavior is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to a method for detecting heat stress behavior in broilers based on an improved YOLOv11 and progressive training in the field of computer vision technology. Background Technology

[0002] It is predicted that the poultry industry will continue to be the largest production sector in the livestock industry. Chickens are the most efficient poultry in converting feed and other resources into edible products. USDA forecasts show that global broiler production will reach 109.614 million tons in 2026, an increase of 1.92%; exports will reach 14.693 million tons, an increase of 3.34%; and imports will reach 12.003 million tons, an increase of 4.51%. The four major producing countries or regions continue to lead in chicken production. In 2025, the broiler production in the United States, China, Brazil, and the European Union reached 21.812 million tons, 16.2 million tons, 15.45 million tons, and 11.82 million tons respectively, achieving varying degrees of growth compared to 2024, with increases of 2.20%, 5.54%, 3.00%, and 0.78% respectively. The combined output of the four major producing countries or regions reached 65.282 million tons, an increase of 1.86 million tons, or 2.93%, compared to 63.422 million tons in 2024.

[0003] Heat stress can trigger strong physiological responses in broilers, thereby increasing their morbidity and mortality. Therefore, monitoring the effects of heat stress and taking timely measures is a crucial aspect of the rearing process.

[0004] Traditional techniques primarily include environmental parameter monitoring, laboratory biochemical analysis, and physiological indicator monitoring. Regarding physiological indicators, body temperature is the most direct marker of heat stress; intestinal morphology changes, with decreased villus height and increased crypt depth, leading to intestinal barrier damage; air sacs aid heat exchange during panting; and behavioral changes include reduced food intake, increased water consumption, drooping wings, and decreased activity. Traditional health monitoring mainly relies on invasive sensors such as physiological sensors to collect data, combined with veterinary knowledge for early warning. While effective, this approach is often complex to implement.

[0005] With breakthroughs in computing power, deep learning has developed rapidly. In recent years, the research and application of deep learning in poultry face detection has become an important research direction. Deep learning, through end-to-end learning, has overcome the limitations of image morphology algorithms, which heavily rely on prior human knowledge and the experience-dependent and generalization bottlenecks of machine learning feature design. Therefore, non-invasive detection methods based on computer vision have become an excellent solution. However, most current image recognition models are developed for larger animals such as pigs, cattle, and sheep, making it difficult to directly transfer them to the recognition of poultry such as broilers. The small size of poultry poses a significant challenge to the accuracy of recognition.

[0006] Computer vision-based methods, with the YOLO series as the mainstream, stand out for their lightweight design and speed. However, in high-density floor-raised or free-range chicken flocks, the birds are highly clustered, and there is severe mutual occlusion between individuals. In this context, standard bounding box detection often fails because a single bounding box may contain parts of multiple chickens, or even mistake the background for the target. Summary of the Invention

[0007] The purpose of this invention is to provide a method for detecting heat stress behavior in broilers based on an improved YOLOv11 and progressive training, which solves the problem of YOLO confusing the background and target of the bounding box when identifying heat stress behavior in broilers under complex floor rearing conditions, and improves the accuracy of identifying panting behavior in broilers.

[0008] To achieve the above objectives, this invention provides a method for detecting heat stress behavior in broilers based on improved YOLOv11 and progressive training, comprising the following steps:

[0009] S1. Obtain the original image dataset, perform image filtering and super-resolution reconstruction on the image dataset, and perform feature annotation to obtain a normalized dataset containing both mask and bounding box annotations.

[0010] S2. Construct an improved YOLOv11 feature extraction backbone network. The backbone network is built based on a two-layer attention module with dynamic routing function and a cross-stage feature fusion module.

[0011] S3. Obtain the pre-trained weights and load them into the backbone network, while freezing their parameters. Perform preliminary training on the network parts outside the backbone network to obtain the transfer weights.

[0012] S4. When the training of S3 completes the preset training cycle, the training supervision mode will be automatically switched, and the annotation reading of the dataset will be switched from the detection box annotation to the segmentation mask annotation.

[0013] S5. Unfreeze the improved feature extraction backbone network, load the transfer weights obtained in S3, and train it in combination with the adjusted annotation mapping strategy in S4 to obtain the final target detection model.

[0014] As a further improvement to the present invention, S1 is specifically described below.

[0015] S1.1 Data acquisition: The video of broilers under heat stress in a floor-raised environment was recorded by a camera. A tripod was used, and the shooting angle was 30 degrees downward from above, relying on natural light. The raw video data obtained totaled 8 hours of video. After data cleaning and preprocessing, 600 sets of raw image sequences were obtained by extracting key frames.

[0016] S1.2 For the original images obtained from S1.1, based on the visibility of the target and the clarity of the image, images that do not exhibit heat stress behavior or motion blur are removed, and finally, dataset images that meet the task characteristics are selected; the selected image features should include effectively preserved details of breathing behavior.

[0017] S1.3 For the dataset images selected from S1.2, based on the YOLO segment mask annotation specification, the open-source tool LabelMe is used to annotate their key features; the core label for beak panting behavior is defined, and targets with long-term beak opening behavior in the video context are labeled as panting, generating the initial annotation file;

[0018] S1.4 For the dataset images selected from S1.3, the dataset images are optimized using a diffusion-based super-resolution algorithm, which enhances edge and texture clarity and magnifies and restores the contours of small targets. This helps convolutional neural networks and Transformers extract more discriminative deep features, significantly improving the recognition rate of small targets. The open-source tool labelme2yolo is used for normalization, converting the images into normalized txt annotation files that conform to the YOLO annotation specifications. Two normalization processes with different settings are required to obtain detect format annotation files for the bounding boxes used in the first stage of training and segment format mask annotation files for the masks used in the second stage of training. After this step, the dataset of different ROI regions of the target boxes and mask segments after data augmentation is obtained.

[0019] As a further improvement of the present invention, the normalization algorithm formula for the normalization processing in S1.4 is as follows: Let the original width of the image be W, the height be H, and the pixel horizontal and vertical coordinates of the center point of the target box in the image be... and Then the normalized values ​​are written into the txt annotation file. and It is given by the following formula:

[0020] ;

[0021] The formula for converting a segment mask format annotation file to a detect rectangle format is as follows:

[0022] Let the mask region be M, which contains all pixels or normalized coordinate points belonging to the target. Then the corresponding bounding box... It is given by the following formula:

[0023] .

[0024] As a further improvement to the present invention, S2 is specifically described below.

[0025] S2.1. The backbone of the YOLOv11 model is redesigned with a new structure. A two-layer attention module with BiFormer dynamic routing function is added. BiFormer realizes content-aware dynamic sparse attention through a two-layer mechanism of coarse-grained region routing and fine-grained token attention, which greatly reduces the amount of computation while maintaining long-distance dependencies.

[0026] S2.2. Based on the new structure modified in S2.1, the C3k2 module in the 8th layer of the original network structure is replaced with the C3k2_BiFormer attention module to obtain the optimized network structure. The input size passed from the 7th layer of the network structure is the original image that has been preprocessed by proportional scaling and padding to obtain an input image with a height of H and a width of W, both of which are integer multiples of 32. After passing through the first 7 layers of the network, the size is downsampled to 1 / 32 of the preprocessed image. The number of channels is limited by the maximum number of channels of the network and is fixed at 512, denoted as [C, H, W], where C is the number of channels, H is the height after preprocessing, and W is the width after preprocessing. The input feature map here is [512, H / 32, W / 32].

[0027] As a further improvement of the present invention, the mathematical expression of the two-layer attention BiFormer module of the dynamic routing function in S2.1 is as follows: first, the region is filtered by coarse-grained routing, and then the attention output is calculated by fine-grained calculation.

[0028] First-level coarse-grained region routing: Divides the feature map into... For each non-overlapping region, semantic similarity is first calculated at the region level, and then the most relevant regions for each query region are dynamically selected. By selecting candidate regions and filtering out a large number of irrelevant regions, dynamic sparsity of query adaptiveness is achieved.

[0029] The second layer of fine-grained attention: only on the union of the selected candidate regions, fine-grained token-level attention calculation is performed, while local context enhancement is introduced to supplement local information;

[0030] Assume the input feature map is Where C is the number of channels, and H and W are the height and width of the image; first, the query (Q), key (K), and value (V) tensors are obtained through linear transformation:

[0031] ;

[0032] Then, these tensors are partitioned in spatial dimensions as follows: Each region contains non-overlapping regions, and each region contains One Token;

[0033] To assess the correlation between regions at a macro level, it is necessary to extract global features for each region; region-level queries are generated by averaging the tokens within each region. s and keys :

[0034] ;

[0035] calculate The affinity matrix is ​​obtained by calculating the correlation scores between each pair of regions. , the elements This indicates the degree of attention paid by region i to region j:

[0036] ;

[0037] For each query region i, by searching... In the i-th row, find the k regions with the highest scores, where It contains the index of the k target regions that need to be focused on in the i-th region:

[0038] ;

[0039] For the i-th region, according to the index Collect the keys and values ​​of the corresponding k regions and concatenate them into a new key-value matrix:

[0040] ;

[0041] Finally, standard multi-head self-attention computation is performed at the token level; within the i-th region. Only with the aggregated and Effect:

[0042] .

[0043] As a further improvement of the present invention, C3k2_BiFormer in S2.2 is a hybrid module that combines convolutional neural networks and visual attention mechanisms; it combines the original C3k2 feature extraction module of YOLO with the core attention mechanism of BiFormer.

[0044] The overall module is a typical residual structure. Assuming the input feature map is X, the intermediate feature Y is obtained by extracting the "high-frequency details" of local features through the parent class C3k2 based on matrix multiplication and convolution kernel sliding.

[0045] ;

[0046] Then, BRA based on dynamic sparse graph routing is used. The BRA module adopts... and The operation extracts the global "low-frequency context," and finally uses addition to superimpose features in the same vector space.

[0047] .

[0048] As a further improvement to the present invention, the specific content of S3 is as follows.

[0049] S3.1 Experimental Environment Preparation; The hardware equipment used is a computer capable of providing high computing performance; In terms of the software environment, the PyTorch deep learning framework was used.

[0050] S3.2. Based on the network structure obtained in S2.2, in the experimental environment of step 3.2, the network model structure constructed in S2.2 is trained on the training and validation sets of the data augmented bounding box labeled dataset constructed in S1.2. The official pre-trained weights of the YOLOv11 model are introduced, and the original YOLOv11 model optimizer is modified and replaced with the SGD optimizer. The first ten layers of the backbone network are frozen.

[0051] As a further improvement to the present invention, the specific content of S4 is as follows.

[0052] S4.1 When the first stage of training in S3.2 reaches the preset convergence threshold or completes the preset training cycle, the best model training weights are automatically saved. The model trained by S3.2 is a pre-trained model that allows the model to quickly adapt to new datasets and custom network structures while protecting the pre-trained weights of the backbone network.

[0053] S4.2 Trigger the redirection of the data loading interface, switch the dataset annotation reading logic from mask ROI to bounding box ROI, so as to realize the task transfer from basic feature learning to refined target perception.

[0054] As a further improvement to the present invention, the specific content of S5 is as follows.

[0055] S5.1 Based on the optimal model training weights obtained in S3.3, the network model structure constructed in S2.2 is used to train the model on the training and validation sets of the data augmented mask-annotated dataset constructed in S1.4, the learning rate is lowered, and all backbone networks are unfrozen.

[0056] S5.2 When the second stage of training has no improvement within 100 training cycles or has completed the preset training cycle; save the corresponding experimental results, calculate the training performance index corresponding to the optimal round, and save the best model training weights.

[0057] S5.3. Using the optimal model training weights from S5.2, the network model structures built in S4.3 and S2.2 are used to test the model performance on the training and validation sets of the data-augmented masked dataset built in S1.4. The performance metrics on the test set are calculated, and the relevant experimental results are saved. At the same time, a Python script is written to implement visualization, merging the real target boxes and the predicted boxes generated by the model in each test set image onto a single image for subsequent analysis and comparison.

[0058] Compared with existing technologies, the advantages of this invention are: using super-resolution to enhance fine-grained features of small targets, using the Transformer module to improve model accuracy, and using a staged transfer learning training strategy to improve model stability. Unlike traditional thermometer temperature measurement, this invention eliminates the need to capture chickens, thus avoiding stress interference from human contact, and the results more accurately reflect the true physiological state. Utilizing machine vision algorithms, it accurately locates individuals exhibiting abnormal behavior, avoiding missed detections, and is particularly suitable for the needs of large-scale flock management in floor-raised chicken houses. Because it is a non-invasive deployment, the modification cost is low, requiring no large-scale alteration of existing chicken house structures, making it easy to promote in old floor-raised chicken houses. Attached Figure Description

[0059] Figure 1 This is a diagram of the overall architecture of the present invention.

[0060] Figure 2 This is a schematic diagram illustrating the present invention.

[0061] Figure 3 This is a structural diagram of the improved yolov11 of this invention.

[0062] Figure 4 This is a two-layer attention graph for the routing of this invention.

[0063] Figure 5 This is a schematic diagram of the detection results of the present invention. Detailed Implementation

[0064] The present invention will be further described below with reference to the accompanying drawings:

[0065] like Figure 1-5 The method for detecting heat stress behavior in broilers based on improved YOLOv11 and progressive training, as shown, includes the following steps:

[0066] S1. Obtain the original image dataset, perform image filtering and super-resolution reconstruction on the image dataset, and perform feature annotation to obtain a normalized dataset containing both mask and bounding box annotations.

[0067] S1.1 Data acquisition: The video of broilers under heat stress in a floor-raised environment was recorded by a camera. A tripod was used, and the shooting angle was 30 degrees downward from above, relying on natural light. The raw video data obtained totaled 8 hours of video. After data cleaning and preprocessing, 600 sets of raw image sequences were obtained by extracting key frames.

[0068] S1.2 For the original images obtained from S1.1, based on the visibility of the target and the clarity of the image, images that do not exhibit heat stress behavior or motion blur are removed, and finally, dataset images that meet the task characteristics are selected; the selected image features should include effectively preserved details of breathing behavior.

[0069] S1.3 For the dataset images selected from S1.2, based on the YOLO segment mask annotation specification, the open-source tool LabelMe is used to annotate their key features; the core label for beak panting behavior is defined, and targets with long-term beak opening behavior in the video context are labeled as panting, generating the initial annotation file;

[0070] S1.4 For the dataset images selected from S1.3, the dataset images are optimized using a diffusion-based super-resolution algorithm, which enhances edge and texture clarity and magnifies and restores the contours of small targets. This helps convolutional neural networks and Transformers extract more discriminative deep features, significantly improving the recognition rate of small targets. The open-source tool labelme2yolo is used for normalization processing, converting the images into normalized txt annotation files that conform to the YOLO annotation specifications. Two normalization processes with different settings are required to obtain detect format annotation files for the bounding boxes used in the first stage of training and segment format mask annotation files for the masks used in the second stage of training. After this step, the dataset of different ROI regions of the target boxes and mask segments after data augmentation is obtained.

[0071] The normalization algorithm formula for normalization processing is as follows: Let the original width of the image be W, the height be H, and the pixel x-coordinate and y-coordinate of the center point of the target box in the image be... and Then the normalized values ​​are written into the txt annotation file. and It is given by the following formula:

[0072] ;

[0073] The formula for converting a segment mask format annotation file to a detect rectangle format is as follows:

[0074] Let the mask region be M, which contains all pixels or normalized coordinate points belonging to the target. Then the corresponding bounding box... It is given by the following formula:

[0075] .

[0076] By employing a relative coordinate normalization strategy, the absolute pixel coordinates of the target are transformed into relative proportional coordinates independent of image resolution. Therefore, although the absolute pixel size of the image changes significantly after super-resolution reconstruction, the normalized bounding box dataset and the masked dataset maintain spatial consistency. This avoids the secondary coordinate mapping calculations caused by image enlargement, improving image feature clarity while ensuring the robustness of multi-granularity feature annotations.

[0077] S2. Construct an improved YOLOv11 feature extraction backbone network. The backbone network is built based on a two-layer attention module with dynamic routing function and a cross-stage feature fusion module.

[0078] S2.1. The backbone of the YOLOv11 model is redesigned with a new structure, adding a two-layer attention module with BiFormer dynamic routing functionality. BiFormer achieves content-aware dynamic sparse attention through a two-layer mechanism of coarse-grained region routing and fine-grained token attention, which significantly reduces computational cost while maintaining long-distance dependencies.

[0079] The mathematical expression for the BiFormer module of dynamic routing function is as follows: first, coarse-grained routing is used to filter regions, and then fine-grained attention output is calculated.

[0080] First-level coarse-grained region routing: Divides the feature map into... For each non-overlapping region, semantic similarity is first calculated at the region level, and then the most relevant regions for each query region are dynamically selected. By selecting candidate regions and filtering out a large number of irrelevant regions, dynamic sparsity of query adaptiveness is achieved.

[0081] The second layer of fine-grained attention: only on the union of the selected candidate regions, fine-grained token-level attention calculation is performed, while local context enhancement is introduced to supplement local information;

[0082] Assume the input feature map is Where C is the number of channels, and H and W are the height and width of the image; first, the query (Q), key (K), and value (V) tensors are obtained through linear transformation:

[0083] ;

[0084] Then, these tensors are partitioned in spatial dimensions as follows: Each region contains non-overlapping regions, and each region contains One Token;

[0085] To assess the correlation between regions at a macro level, it is necessary to extract global features for each region; region-level queries are generated by averaging the tokens within each region. s and keys :

[0086] ;

[0087] calculate The affinity matrix is ​​obtained by calculating the correlation scores between each pair of regions. , the elements This indicates the degree of attention paid by region i to region j:

[0088] ;

[0089] For each query region i, by searching... In the i-th row, find the k regions with the highest scores, where It contains the index of the k target regions that need to be focused on in the i-th region:

[0090] ;

[0091] For the i-th region, according to the index Collect the keys and values ​​of the corresponding k regions and concatenate them into a new key-value matrix:

[0092] ;

[0093] Finally, standard multi-head self-attention computation is performed at the token level; within the i-th region. Only with the aggregated and Effect:

[0094] .

[0095] BiFormer's greatest advantage lies in its simultaneous pursuit of high performance and high computational efficiency, particularly excelling in dense prediction tasks and significantly outperforming traditional self-attention and most existing sparse attention mechanisms. Unlike ordinary Transformers, it doesn't impose excessive computational burden, making it suitable for integration into object detection networks with high real-time requirements. In complex scenarios such as detecting heat stress behavior in broiler chickens raised in floor environments, this module typically significantly reduces both false negative and false positive rates.

[0096] S2.2. Based on the new structure modified in S2.1, the C3k2 module in the 8th layer of the original network structure is replaced with the C3k2_BiFormer attention module to obtain the optimized network structure. The input size passed from the 7th layer of the network structure is the original image that has been preprocessed by proportional scaling and padding to obtain an input image with a height of H and a width of W, both of which are integer multiples of 32. After passing through the first 7 layers of the network, the size is downsampled to 1 / 32 of the preprocessed image. The number of channels is limited by the maximum number of channels of the network and is fixed at 512, denoted as [C, H, W], where C is the number of channels, H is the height after preprocessing, and W is the width after preprocessing. The input feature map here is [512, H / 32, W / 32].

[0097] C3k2_BiFormer is a hybrid module that combines convolutional neural networks and visual attention mechanisms; it combines YOLO's original C3k2 feature extraction module with BiFormer's core attention mechanism.

[0098] The overall module is a typical residual structure. Assuming the input feature map is X, the intermediate feature Y is obtained by extracting the "high-frequency details" of local features through the parent class C3k2 based on matrix multiplication and convolution kernel sliding.

[0099] ;

[0100] Then, BRA based on dynamic sparse graph routing is used. The BRA module adopts... and The operation extracts the global "low-frequency context," and finally uses addition to superimpose features in the same vector space.

[0101] .

[0102] S3. Obtain the pre-trained weights and load them into the backbone network, while freezing their parameters. Perform preliminary training on the network parts outside the backbone network to obtain the transfer weights.

[0103] S3.1 Experimental Environment Preparation; The hardware equipment used is a computer capable of providing high computing performance; In terms of the software environment, the PyTorch deep learning framework was used.

[0104] S3.2. Based on the network structure obtained in S2.2, in the experimental environment of step 3.2, the network model structure constructed in S2.2 is trained on the training and validation sets of the data augmented bounding box labeled dataset constructed in S1.2. The official pre-trained weights of the YOLOv11 model are introduced, and the original YOLOv11 model optimizer is modified and replaced with the SGD optimizer. The first ten layers of the backbone network are frozen.

[0105] The official pre-trained weights are trained on large-scale datasets such as COCO, and the backbone network has learned rich low-level general features such as edges, colors, and basic shapes. However, if used directly, the lack of transition between the pre-trained weights and the new task detection head leads to severe gradient impacts that cause the model to forget the pre-trained features.

[0106] Step-by-step fine-tuning serves as a buffer and warm-up. Referencing LoRA's frozen backbone allows these general features to remain stable, enabling the model to focus on learning task-specific high-level features and fully utilize the general dataset of the pre-trained model.

[0107] The first stage involves the supervisory signal used to roughly locate the detected bounding box and to avoid catastrophic forgetting during training increments. Here, the learned focus is on "where the object is roughly located." Prioritizing the resolution of the "where is the target" question provides accurate region-of-interest biases for subsequent tasks.

[0108] S4. After the preset training cycle is completed in S3, the training supervision mode will be automatically switched, and the annotation reading of the dataset will be switched from the detection box annotation to the segmentation mask annotation.

[0109] S4.1 When the first stage of training in S3.2 reaches the preset convergence threshold or completes the preset training cycle, the best model training weights are automatically saved. The model trained by S3.2 is a pre-trained model that allows the model to quickly adapt to new datasets and custom network structures while protecting the pre-trained weights of the backbone network.

[0110] S4.2 Trigger the redirection of the data loading interface, switch the dataset annotation reading logic from mask ROI to bounding box ROI, so as to realize the task transfer from basic feature learning to refined target perception.

[0111] After the first phase of training, the head has adapted well to the task. At this point, the backbone is unfrozen, and the supervision signal is changed to fine-tuned mask segmentation with lower noise using polygon segmentation annotations. Full model fine-tuning is then performed with a smaller learning rate. Training continues based on the new backbone. This liberated full parameter update eliminates the task gap caused by different annotation methods and accelerates global convergence.

[0112] S5. Unfreeze the improved feature extraction backbone network, load the transfer weights obtained in S3, and train it in combination with the adjusted annotation mapping strategy in S4 to obtain the final target detection model.

[0113] S5.1 Based on the optimal model training weights obtained in S3.3, the network model structure constructed in S2.2 is used to train the model on the training and validation sets of the data augmented mask-annotated dataset constructed in S1.4, the learning rate is lowered, and all backbone networks are unfrozen.

[0114] S5.2 When the second stage of training has no improvement within 100 training cycles or has completed the preset training cycle; save the corresponding experimental results, calculate the training performance index corresponding to the optimal round, and save the best model training weights.

[0115] S5.3. Using the optimal model training weights from S5.2, the network model structures built in S4.3 and S2.2 are used to test the model performance on the training and validation sets of the data-augmented masked dataset built in S1.4. The performance metrics on the test set are calculated, and the relevant experimental results are saved. At the same time, a Python script is written to implement visualization, merging the real target boxes and the predicted boxes generated by the model in each test set image onto a single image for subsequent analysis and comparison.

[0116] In this invention, the improved model structure diagram is as follows: Figure 3 As shown, YOLO11's core principle is to treat object detection, segmentation, and other tasks as a unified regression problem, directly outputting the object's location and category through a single forward propagation. In terms of structural design, the backbone network incorporates the lighter and more efficient C3k2 block, enabling it to capture multi-scale spatial features with fewer parameters and computational cost. Simultaneously, it is the first to integrate a C2PSA module and SPFF at the end of the backbone network, using a spatial attention mechanism to allow the model to highly focus on key regions of interest in the image, significantly improving the recognition accuracy for small targets and complex occluded objects.

[0117] The BiFormer dynamic routing function's two-layer attention module, which features a new structural design in the Backbone section, achieves content-aware dynamic sparse attention through a two-layer mechanism of coarse-grained region routing and fine-grained token attention, significantly reducing computational cost while maintaining long-distance dependencies.

[0118] BiFormer routing's two-layer attention graph is as follows: Figure 4 As shown, the first layer, coarse-grained region mapping, divides the feature map into S×S non-overlapping regions. Semantic similarity is calculated at the region level, dynamically selecting the top K most relevant candidate regions for each query region, filtering out a large number of irrelevant regions to achieve adaptive dynamic sparsity for the query. The second layer, fine-grained attention, performs refined token-level attention calculations only on the union of the selected candidate regions. Local context enhancement is also introduced to supplement local information.

[0119] BiFormer's greatest advantage lies in its simultaneous pursuit of high performance and high computational efficiency, particularly excelling in dense prediction tasks and significantly outperforming traditional self-attention and most existing sparse attention mechanisms. Unlike ordinary Transformers, it doesn't impose excessive computational burden, making it suitable for integration into object detection networks with high real-time requirements. In complex scenarios such as detecting heat stress behavior in broiler chickens raised in floor environments, this module typically significantly reduces both false negative and false positive rates.

[0120] Table 1 shows the setup for the ablation experiment.

[0121]

[0122] From E1 to E6, modules are added to the model one by one. The purpose is to verify the contribution of each individual module to the final performance by gradually adding or removing modules from the model. E1: Only the base model yolov11m is used; E2: A dataset augmented with super-resolution data is added to the base model; E3, based on E2, further integrates a Bi-former attention module; E4: Based on E3, pretrained weights are introduced; E5, based on the network structure of E4, adopts a staged training strategy; E6 is the final complete scheme proposed in this invention. It superimposes training strategies for different ROI region datasets on top of all the previous strategies.

[0123] Table 2 shows the results of the ablation experiment.

[0124]

[0125] E1 serves as the baseline model, with its mAP50 providing the foundation for all subsequent comparisons. E2's super-resolution module helped the model see more details, successfully identifying more previously difficult-to-detect targets. However, it may have also introduced some artifacts or noise, leading to a slight increase in false positives. Overall, it's a positive gain. E3's attention mechanism enhanced the targeting of feature extraction, suppressing some false positives introduced by the super-resolution module, resulting in more accurate bounding box regression, thus achieving a local high in overall mAP. E4's introduction of YOLO's official pre-trained weights led to outliers, causing a significant decline in core metrics. This is a very typical phenomenon. Directly loading pre-trained weights doesn't always bring improvement because there are significant domain differences between the pre-training dataset and the current model structure, disrupting the well-learned feature space. E5's phased training strategy led to a comprehensive recovery in metrics. This strategy effectively mitigated the negative impact of pre-trained weights in E4. E6's training strategy using different ROI region datasets resulted in a leap in metrics, with all metrics experiencing explosive growth.

[0126] Table 3 shows the results of the comparative experiment.

[0127]

[0128] The experiment results are compared between the improved YOLOv11 model (referred to as "ours" in the table) and other models in the YOLO series. It can be seen that the improved YOLOv11 model has a higher mAP50 value than YOLOv11, and its recognition performance is superior to all models in the YOLO series, achieving an mAP50 of 0.854, which is at a practically usable level. Therefore, the improved model enhances recognition accuracy, demonstrating its advanced nature and effectiveness.

[0129] This invention is not limited to the above embodiments. Based on the technical solutions disclosed herein, those skilled in the art can make some substitutions and modifications to some of the technical features without creative effort, and all such substitutions and modifications are within the protection scope of this invention.

Claims

1. A method for detecting heat stress behavior in broilers based on improved YOLOv11 and progressive training, characterized in that: Includes the following steps, S1. Obtain the original image dataset, perform image filtering and super-resolution reconstruction on the image dataset, and perform feature annotation to obtain a normalized dataset containing both mask and bounding box annotations. S2. Construct an improved YOLOv11 feature extraction backbone network. The backbone network is built based on a two-layer attention module with dynamic routing function and a cross-stage feature fusion module. S3. Obtain the pre-trained weights and load them into the backbone network, while freezing their parameters. Perform preliminary training on the network parts outside the backbone network to obtain the transfer weights. S4. When the training of S3 completes the preset training cycle, the training supervision mode will be automatically switched, and the annotation reading of the dataset will be switched from the detection box annotation to the segmentation mask annotation. S5. Unfreeze the improved feature extraction backbone network, load the transfer weights obtained in S3, and train it in combination with the adjusted annotation mapping strategy in S4 to obtain the final target detection model.

2. The method for detecting heat stress behavior in broilers based on improved YOLOv11 and progressive training according to claim 1, characterized in that: The specific content of S1 is as follows: S1.1 Data acquisition: The video of broilers under heat stress in a floor-raised environment was recorded by a camera. A tripod was used, and the shooting angle was 30 degrees downward from above, relying on natural light. The raw video data obtained totaled 8 hours of video. After data cleaning and preprocessing, 600 sets of raw image sequences were obtained by extracting key frames. S1.2 For the original images obtained from S1.1, based on the visibility of the target and the clarity of the image, images that do not exhibit thermal stress behavior or motion blur are removed, and finally, dataset images that meet the task characteristics are selected. The selected image features should include details of breathing behavior that are effectively preserved; S1.3 For the dataset images selected from S1.2, based on the YOLO segment mask annotation specification, the open-source tool LabelMe is used to annotate their key features; the core label for beak panting behavior is defined, and targets with long-term beak opening behavior in the video context are labeled as panting, generating the initial annotation file; S1.4 For the dataset images selected from S1.3, the dataset images are optimized using a diffusion-based super-resolution algorithm, which enhances edge and texture clarity and magnifies and restores the contours of small targets. This helps convolutional neural networks and Transformers extract more discriminative deep features, significantly improving the recognition rate of small targets. The open-source tool labelme2yolo is used for normalization processing, converting the images into normalized txt annotation files that conform to the YOLO annotation specifications. Two normalization processes with different settings are required to obtain detect format annotation files for the bounding boxes used in the first stage of training and segment format mask annotation files for the masks used in the second stage of training. After this step, the dataset of different ROI regions of the target boxes and mask segments after data augmentation is obtained.

3. The method for detecting heat stress behavior in broilers based on improved YOLOv11 and progressive training according to claim 2, characterized in that: The normalization algorithm formula in S1.4 is as follows: Let the original width of the image be W, the height be H, and the pixel x-coordinate and y-coordinate of the center point of the target box in the image be... and Then the normalized values ​​are written into the txt annotation file. and It is given by the following formula: ; The formula for converting a segment mask format annotation file to a detect rectangle format is as follows: Let the mask region be M, which contains all pixels or normalized coordinate points belonging to the target. Then the corresponding bounding box... It is given by the following formula: 。 4. The method for detecting heat stress behavior in broilers based on improved YOLOv11 and progressive training according to claim 3, characterized in that: The specific details of S2 are as follows. S2.

1. The backbone of the YOLOv11 model is redesigned with a new structure. A two-layer attention module with BiFormer dynamic routing function is added. BiFormer realizes content-aware dynamic sparse attention through a two-layer mechanism of coarse-grained region routing and fine-grained token attention, which greatly reduces the amount of computation while maintaining long-distance dependencies. S2.

2. Based on the new structure modified in S2.1, the C3k2 module in the 8th layer of the original network structure is replaced with the C3k2_BiFormer attention module to obtain the optimized network structure. The input size passed from the 7th layer of the network structure is the original image that has been preprocessed by proportional scaling and padding to obtain an input image with a height of H and a width of W, both of which are integer multiples of 32. After passing through the first 7 layers of the network, the size is downsampled to 1 / 32 of the preprocessed image. The number of channels is limited by the maximum number of channels of the network and is fixed at 512, denoted as [C, H, W], where C is the number of channels, H is the height after preprocessing, and W is the width after preprocessing. The input feature map here is [512, H / 32, W / 32].

5. The method for detecting heat stress behavior in broilers based on improved YOLOv11 and progressive training according to claim 4, characterized in that: The mathematical expression for the BiFormer module of dynamic routing function in S2.1 is as follows: first, the region is filtered by coarse-grained routing, and then the attention output is calculated by fine-grained calculation. First-level coarse-grained region routing: Divides the feature map into... For each non-overlapping region, semantic similarity is first calculated at the region level, and then the most relevant regions for each query region are dynamically selected. By selecting candidate regions and filtering out a large number of irrelevant regions, dynamic sparsity of query adaptiveness is achieved. The second layer of fine-grained attention: only on the union of the selected candidate regions, fine-grained token-level attention calculation is performed, while local context enhancement is introduced to supplement local information; Assume the input feature map is Where C is the number of channels, and H and W are the height and width of the image; first, the query (Q), key (K), and value (V) tensors are obtained through linear transformation: ; Then, these tensors are partitioned in spatial dimensions as follows: Each region contains non-overlapping regions, and each region contains One Token; To assess the correlation between regions at a macro level, it is necessary to extract global features for each region; region-level queries are generated by averaging the tokens within each region. s and keys : ; calculate The affinity matrix is ​​obtained by calculating the correlation scores between each pair of regions. , the elements This indicates the degree of attention paid by region i to region j: ; For each query region i, by searching... In the i-th row, find the k regions with the highest scores, where It contains the index of the k target regions that need to be focused on in the i-th region: ; For the i-th region, according to the index Collect the keys and values ​​of the corresponding k regions and concatenate them into a new key-value matrix: ; Finally, standard multi-head self-attention computation is performed at the token level; within the i-th region. Only with the aggregated and Effect: 。 6. The method for detecting heat stress behavior in broilers based on improved YOLOv11 and progressive training according to claim 5, characterized in that: In S2.2, C3k2_BiFormer is a hybrid module that combines convolutional neural networks and visual attention mechanisms; it combines YOLO's original C3k2 feature extraction module with BiFormer's core attention mechanism. The overall module is a typical residual structure. Assuming the input feature map is X, the intermediate feature Y is obtained by extracting "high-frequency details" of local features through the parent class C3k2 based on matrix multiplication and convolution kernel sliding. ; Then, BRA based on dynamic sparse graph routing is used. The BRA module adopts... and The operation extracts the global "low-frequency context," and finally uses addition to superimpose features in the same vector space: 。 7. The method for detecting heat stress behavior in broilers based on improved YOLOv11 and progressive training according to claim 6, characterized in that: The specific details of S3 are as follows. S3.1 Experimental Environment Preparation; The hardware equipment used is a computer capable of providing high computing performance; In terms of the software environment, the PyTorch deep learning framework was used. S3.

2. Based on the network structure obtained in S2.2, in the experimental environment of step 3.2, the network model structure constructed in S2.2 is trained on the training and validation sets of the data augmented bounding box labeled dataset constructed in S1.

2. The official pre-trained weights of the YOLOv11 model are introduced, and the original YOLOv11 model optimizer is modified and replaced with the SGD optimizer. The first ten layers of the backbone network are frozen.

8. The method for detecting heat stress behavior in broilers based on improved YOLOv11 and progressive training according to claim 7, characterized in that: The specific content of S4 is as follows. S4.1 When the first stage of training in S3.2 reaches the preset convergence threshold or completes the preset training cycle, the best model training weights are automatically saved. The model trained by S3.2 is a pre-trained model that allows the model to quickly adapt to new datasets and custom network structures while protecting the pre-trained weights of the backbone network. S4.2 Trigger the redirection of the data loading interface, switch the dataset annotation reading logic from mask ROI to bounding box ROI, so as to realize the task transfer from basic feature learning to refined target perception.

9. A method for detecting heat stress behavior in broilers based on improved YOLOv11 and progressive training, as described in claim 8, characterized in that: The specific details of S5 are as follows. S5.1 Based on the optimal model training weights obtained in S3.3, the network model structure constructed in S2.2 is used to train the model on the training and validation sets of the data augmented mask-annotated dataset constructed in S1.4, the learning rate is lowered, and all backbone networks are unfrozen. S5.2 When the second stage of training has no improvement within 100 training cycles or has completed the preset training cycle; save the corresponding experimental results, calculate the training performance index corresponding to the optimal round, and save the best model training weights. S5.

3. Using the optimal model training weights from S5.2, the network model structures built in S4.3 and S2.2 are used to test the model performance on the training and validation sets of the data-augmented masked dataset built in S1.

4. The performance metrics on the test set are calculated, and the relevant experimental results are saved. At the same time, a Python script is written to implement visualization, merging the real target boxes and the predicted boxes generated by the model in each test set image onto a single image for subsequent analysis and comparison.