Paddy field rice plant accurate counting method and system based on improved YOLO

By improving the A2DC-YOLO counting method of the YOLO model, the problems of strong background interference and insufficient feature extraction in paddy rice plant counting are solved. It achieves efficient and accurate plant counting under algae coverage and water light reflection environment, and is suitable for paddy rice yield prediction and seedling monitoring.

CN121904019APending Publication Date: 2026-04-21ANHUI AGRICULTURAL UNIVERSITY
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
ANHUI AGRICULTURAL UNIVERSITY
Filing Date
2026-01-15
Publication Date
2026-04-21

AI Technical Summary

Technical Problem

Existing technologies for counting rice plants in paddy fields suffer from problems such as strong background interference, insufficient feature extraction, low counting accuracy, and poor robustness. In particular, it is difficult to achieve efficient and accurate plant counting in complex environments such as algae cover and water light reflection.

Method used

An improved YOLO model is adopted, and an A2DC-YOLO counting method is constructed, including an A2D feature processing module, a CARAFE upsampling module, and a density-adaptive DA-SoftNMS post-processing strategy, to perform feature extraction, detail preservation, and dynamic filtering, forming a full-link optimization that adapts to the complex environment of paddy fields.

Benefits of technology

It significantly improves the robustness and accuracy of counting in paddy field environments, effectively penetrates algae obstruction and water light reflection interference, preserves detailed plant information, adapts to the complex scene of uneven distribution in rice fields, and achieves efficient and accurate plant counting.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121904019A_ABST
    Figure CN121904019A_ABST
Patent Text Reader

Abstract

The invention discloses a paddy field rice plant accurate counting method and system based on improved YOLO, and relates to the technical field of computer vision crop counting. The method comprises the following steps: constructing a data set; constructing an A2DC-YOLO counting model; performing improvement and optimization by taking YOLOv12m as a reference model; an original A2C2f module is replaced by an A2D feature processing module, and the A2D feature processing module embeds a dual-frequency aggregation feedforward network (DFFN) into an ABlock to form a space-frequency dual-optimization feature extraction structure; the method comprises the following steps: replacing native nearest neighbor up-sampling with a CARAFE up-sampling module, and dynamically generating an exclusive up-sampling core by the CARAFE up-sampling module; designing a density adaptive DA-SoftNMS post-processing strategy, and dynamically adjusting an IoU threshold value based on the density of a local area detection frame; training and optimizing the model; and rice plant counting reasoning. Through core module innovation and full-link technology optimization, accurate feature extraction, intact detail reservation and post-processing self-adaption are realized, and the problems of low counting precision and poor robustness in the prior art are solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of computer vision crop counting technology, and particularly relates to a method and system for accurate counting of paddy rice plants based on an improved YOLO. Background Technology

[0002] As rice is the main food source for more than half of the world's population, accurate yield forecasting is crucial for food security and agricultural planning. Plant counting is the core step in yield forecasting, but traditional manual counting methods have inherent drawbacks such as high labor costs, long processing times, and the risk of damaging crops, making them unsuitable for large-scale agricultural production.

[0003] With the popularization of UAV remote sensing technology, automated counting solutions have become the mainstream approach. However, rice grows in a special paddy field environment, which is prone to algae growth, and the water surface reflects sunlight, resulting in image backgrounds containing messy algae shapes and interference from light spots and bright spots, significantly increasing the difficulty of machine recognition and counting.

[0004] While existing deep learning object detection algorithms have seen some applications in agricultural counting, such as the YOLO series, RiceNet, and P2PNet-EFF models, they still have several limitations: First, most models are designed for dryland crops, and their core logic does not match the tillering characteristics and leaf spreading morphology of rice, making them difficult to adapt to paddy field scenarios. Second, even counting models designed for rice do not adequately consider interference factors such as algae cover, image texture distortion caused by water reflection, and differences in plant distribution density, resulting in insufficient robustness. Third, traditional models suffer from insufficient feature extraction (over-reliance on spatial domain features, making it difficult to distinguish between clump-together plants and plants in low-light environments), loss of upsampling details (mechanical pixel duplication leads to blurred edges), and rigid post-processing strategies (fixed thresholds lead to false detections or false negatives), resulting in insufficient counting accuracy and stability. Therefore, developing an accurate rice plant counting method for paddy fields has become an urgent need for the development of smart agriculture.

[0005] To address the complex characteristics of paddy field environments, this invention develops a precise rice plant counting method based on UAV remote sensing technology and deep learning. This method is applicable to smart agriculture scenarios such as rice yield prediction and seedling monitoring in complex field environments. Through core module innovation and end-to-end technology optimization, this rice plant counting method achieves accurate feature extraction, excellent detail preservation, and adaptive post-processing, enabling efficient and accurate rice plant counting in complex scenarios and solving the problems of low counting accuracy and poor robustness in existing technologies. Summary of the Invention

[0006] The purpose of this invention is to provide a method and system for accurate counting of paddy rice plants based on an improved YOLO, so as to solve the problems of strong background interference, insufficient feature extraction, low counting accuracy and poor robustness of existing crop target detection technologies in paddy rice counting, as mentioned in the background art.

[0007] To achieve the above objectives, the present invention employs the following technical solution: In its first aspect, this invention proposes a method for accurate counting of paddy rice plants in paddy fields based on an improved YOLO, comprising the following steps: S1. Constructing a dataset: Collect high frame rate video sequences covering the seedling and tillering stages of rice, extract frames, crop, filter, and label the high frame rate video sequences to obtain rice image samples, and expand the sample size through data augmentation operations to obtain a dataset; S2. Construct the A2DC-YOLO counting model; improve and optimize it using YOLOv12m as the baseline model; The original A2C2f module was replaced with the A2D feature processing module. In the A2D feature processing module, the dual-frequency aggregation feedforward network DFFN was embedded in ABlock to form a space-frequency dual-optimized feature extraction structure, which strengthens the expression of rice plant features. The native nearest neighbor upsampling is replaced with the CARAFE upsampling module. The CARAFE upsampling module dynamically generates a dedicated upsampling kernel to preserve detailed information about rice plants. Design a density-adaptive DA-SoftNMS post-processing strategy to dynamically adjust the IoU threshold based on the density of the detection boxes in local regions; S3. Model Training and Optimization: Design a loss function and use the dataset to perform end-to-end training of the A2DC-YOLO counting model; S4. Rice Plant Counting Inference: Deploy and train an A2DC-YOLO counting model with optimal model weights to perform inference on the rice image to be detected and output the rice plant count results.

[0008] Preferably, the video acquisition in step S1 is as follows: The drone used was equipped with a high-definition camera (such as the DJI Air 2S), and the shooting parameters met the requirements for stable image quality. The drone was operated to cruise over the paddy fields in a zigzag pattern, shooting between 9-11 AM and 3-6 PM at a height of 1-3 meters to avoid overexposure or excessive shadows caused by direct sunlight, ensuring that the characteristics of the rice plants were clearly identifiable in the images. The collected videos needed to cover both the seedling and tillering stages of the rice, fully recording the plant morphology and distribution in the field.

[0009] Preferably, the acquisition of rice image samples in step S1 is as follows: S101. Video frame extraction: Extract the original image from the acquired video at a frequency of 1 frame / second. The resolution of the original image is not less than 4096×2160. S102. Image cropping and filtering: Perform batch cropping of the original image at fixed positions to obtain 640×640 resolution sub-images, and manually filter out blurry or severely occluded invalid images, retaining valid images; S103. Use semi-supervised data annotation technology to annotate rice images, use the LabelImg tool to annotate the bounding boxes of rice plants in YOLO format, and generate a txt format annotation file. Preferably, the semi-supervised data annotation technique in S103 is as follows: S1031. Manually labeled small sample subset: Select no less than 20% of the samples from the filtered valid images, and use the LabelImg tool to label the bounding boxes of rice plants in YOLO format to form an initial labeled subset; S1032. Initial Model Training: Train the initial object detection network model based on the initial labeled subset; S1033. Candidate pseudo-label generation: Using the trained initial object detection network model, the remaining unlabeled valid images are automatically inferred to generate a large number of candidate pseudo-labels for rice plant bounding boxes. S1034. Pseudo-label correction: Manually check candidate pseudo-labels, correct missing labels, incorrect labels, and boundary box offset errors, and generate a complete YOLO format txt annotation file. Preferably, the data augmentation operation in S1 is as follows: The labeled dataset was expanded by methods such as mirroring (horizontal and vertical), adjusting brightness (±15%), and adjusting contrast (±10%), ultimately resulting in no fewer than 2,600 valid images and corresponding annotation files.

[0010] Preferably, in S1, the dataset is divided into a training set (for model parameter learning), a validation set (for hyperparameter tuning), and a test set (for performance evaluation) according to a preset ratio of 7:1.5:1.5. The division is based on "groups" to ensure that each group of images belongs to only one subset, thus avoiding data leakage.

[0011] Preferably, the A2D feature processing module in S2 is specifically as follows: The ABlock+DFFN structure is obtained by improving the original A2C2f module ABlock; the Area Attention structure is retained in the ABlock+DFFN structure to capture region association features, and the dual-frequency aggregation feedforward network DFFN is added to replace the original MLP structure. The dual-frequency aggregation feedforward network (DFFN) achieves parallel operation of two branches through a split operation: one branch extracts high-frequency detail features through 1×1 convolution, and the other branch captures low-frequency global information through 3×3 depth convolution. Furthermore, the processing procedure of the ABlock+DFFN structure is as follows: Input features After processing by Area Attention, a first residual connection is performed with the original features to obtain: ; Will Flattening out the spatial dimensions, we obtain ; High-frequency detail features are extracted using 1×1 convolution:

[0012] Capture low-frequency global information using 3×3 depthwise convolution:

[0013] After element-wise fusion of the bi-branch features, the spatial dimension is reshaped by linear layer dimensionality reduction to obtain:

[0014] and A second residual fusion is performed to obtain the final enhanced features:

[0015] in, This is the final enhanced feature output by the ABlock+DFFN structure. Preferably, the CARAFE upsampling module in S2 is specifically as follows: The CARAFE upsampling module includes a kernel prediction module and a content-aware reconstruction module; The kernel prediction module dynamically generates a dedicated upsampling kernel based on the input features, focusing on key areas of the rice plant's outline and texture; The content-aware reorganization module uses a 5×5 large receptive field to capture contextual information of rice plants and separate the outlines of adhering rice plants. Furthermore, the processing procedure of the CARAFE upsampling module is as follows: Input rice feature map (shape is) The number of channels is reduced from 1×1 convolution. Compress to To obtain compression features :

[0016] Compression characteristics Convolutional layers extract key information and predict dynamic upsampling kernels:

[0017] in, This is the upsampling factor. For core size, The upsampling kernel is dynamically generated and normalized; The original feature map is expanded by window to obtain neighborhood features, and then the upsampled feature map is obtained by weighted summation using a dynamic kernel. :

[0018] The upsampling kernel size is set to 5×5, the receptive field is 5×5, and the channel compression ratio is 1 / 4-1 / 2 to ensure that the increase in computational load does not exceed 1%. Preferably, the density-adaptive DA-SoftNMS post-processing strategy in S2 is as follows: Input a set of detection boxes and their corresponding scores, and filter valid detection boxes through iterative loops; in each iteration, select the detection box with the highest score, calculate the number of detection boxes in its local area, which represents the plant density in that area and serves as the local density; The IoU threshold is dynamically adjusted based on local density: when the density is higher than the dense threshold, a stricter IoU threshold is used to suppress repeated detection in dense areas; when the density is lower than the dense threshold, a more lenient IoU threshold is used to reduce missed detection of plants in sparse areas. The score of overlapping detection boxes is reduced by combining the Gaussian decay function to avoid missing real rice plants; at the same time, a global fallback IoU threshold is introduced to ensure the stability of the screening process when the dynamic threshold deviates. Furthermore, the processing procedure of the density-adaptive DA-SoftNMS post-processing strategy is as follows: Input detection box set and corresponding score set Initialize the reserved set ; Iterative processing: Determine the score set The index corresponding to the highest score m=argmax( ) Select the set of detection boxes Corresponding index m detection box (i.e., the detection box with the highest current score); Detection box Add to the reserved set and from Remove from ,from Remove the corresponding score from the middle ; Calculate the detection box The number of remaining bounding boxes within the local area (radius = 80-120px), localcount; Dynamically set the IoU threshold: if localcount ≥ (in If the density threshold represents the plant distribution density in a local area, then the IoU threshold is set. ( (This is the IoU threshold for dense regions, used to suppress repeated detection in dense regions); if localcount < Then set the IoU threshold. ( (This is a threshold for the sparse region to avoid missed detections in the sparse region). right Each remaining detection box : calculate and The intersection and union ratio of iou ( ); According to Gaussian decay function (in (The attenuation coefficient is used to balance the suppression strength and the risk of missed detection.) The detection frame is then updated. The score; Remove "Updated score is lower than confidence threshold (range 0.1-0.2)" or "iou( )> "Detection box At the same time remove The corresponding score; Repeat the above iterative steps until the set of detection boxes is complete. If empty, the final set will be retained. The number of detection frames contained therein is the accurate count result of rice plants.

[0019] Preferably, the loss function designed in S3 is as follows: loss function The weighted sum of classification loss, regression loss, and confidence loss is as follows:

[0020] Classification loss :

[0021] in, This is a true category label for rice plants. To predict class probabilities, This represents the total number of samples in a single batch. Regression loss :

[0022] in, Predict bounding boxes for the model. The actual bounding boxes are manually labeled. The Euclidean distance is the center of the frame. The length of the diagonal of the minimum bounding box of the two frames. For balance coefficient, Aspect ratio consistency parameter; Confidence loss :

[0023] in, This is the true confidence level label. To predict confidence levels, This represents the total number of test frames in a single batch. Preferably, the model training and optimization in S3 are as follows: Configure the experimental environment: use PyTorch 2.1 as the deep learning framework, rely on CUDA to achieve GPU acceleration, and integrate the Ultralytics library to support model training and evaluation; the hardware configuration should meet the following requirements: GPU memory of no less than 24GB, CPU cores of no less than 16 cores, and memory of no less than 60GB.

[0024] The training parameters were set as follows: fixed seed 42, input image size 640×640, batch size 16-32, number of training epochs 200-400, SGD optimizer, initial learning rate 0.005-0.01, weight decay using the default values ​​of YOLO network, confidence threshold of 0.001 during training, IoU threshold of 0.6, and confidence threshold of 0.3-0.5 for testing and evaluation.

[0025] Training process: An end-to-end training method is adopted. The model parameters are learned through the training set, and the counting accuracy and positioning accuracy are monitored in real time on the validation set. The model weights with the best performance on the validation set are saved as the final inference model.

[0026] Preferably, the rice plant counting reasoning in S4 is as follows: The optimal model, after training, is deployed to perform inference on newly input UAV rice images: the model extracts anti-interference features through the A2D feature extraction module, preserves details through CARAFE upsampling, and then filters effective detection boxes through DA-SoftNMS, finally outputting accurate rice plant count results.

[0027] In a second aspect, this invention proposes a precise counting system for paddy rice plants based on an improved YOLO model, including the A2DC-YOLO counting model. The A2DC-YOLO counting model includes a backbone network, a neck network, and a head detection head. The backbone network includes an A2D feature processing module, which adopts an ABlock+DFFN structure for spatial-frequency dual-optimized feature extraction; the backbone network is used for feature extraction at different scales. The Neck network includes a CARAFE upsampling module and an A2D feature processing module. The CARAFE upsampling module includes a kernel prediction module and a content-aware reconstruction module, which are used to dynamically generate a dedicated kernel for feature enhancement during upsampling. The Neck network sequentially performs feature concatenation, upsampling, and A2D operations on the basic features output by the Backbone network to form feature branches corresponding to different levels such as P3, P4, and P5. Meanwhile, the targeted processing of high-scale features is based on the fusion results of features at other levels. That is, targeted processing is carried out through independent A2D operations, feature concatenation, and convolution operations, which ultimately correspond to the detection box level to ensure the information integrity and representation ability of high-scale features. The Head detection head includes a density-adaptive DA-SoftNMS post-processing unit. The Head detection head is used to decouple multi-scale features and then mark detection boxes. The density-adaptive DA-SoftNMS post-processing unit dynamically adjusts the IoU threshold based on the local region detection box density.

[0028] Compared with the prior art, the beneficial effects of the present invention are: (1) The core innovation of this invention lies in constructing an A2D feature processing module with frequency domain decoupling, a content-aware CARAFE upsampling mechanism, and a density-adaptive DA-SoftNMS post-processing strategy, forming a full-link optimization from feature enhancement and detail preservation to dynamic selection; at the same time, it constructs the Anno-Rice dataset containing rice seedling and tillering stages to ensure the effectiveness of model training. This invention significantly improves the robustness and accuracy of counting in complex paddy field environments through module collaborative optimization.

[0029] (2) The feature extraction method of the present invention has strong anti-interference ability: the A2D feature processing module integrates spatial-frequency domain dual features, effectively penetrates the interference of algae shading and water light reflection, strengthens the expression of rice plant texture and contour features, and significantly improves the recognition accuracy of sticky plants and low light environment.

[0030] (3) The method in this invention has high detail retention accuracy: CARAFE upsampling dynamically generates a dedicated kernel, avoiding edge blurring caused by mechanical copying, accurately retaining plant density and edge information, and providing a reliable feature basis for counting.

[0031] (4) The post-processing adaptive capability of the method in this invention is excellent: DA-SoftNMS is based on the regional density dynamic adjustment screening rule, which perfectly solves the contradiction between false detection and false detection caused by fixed threshold, and adapts to the complex scenario of uneven distribution in rice fields.

[0032] (5) The technical solution of the method in this invention is highly feasible and has wide applicability: all improved modules are built on mature deep learning frameworks, with clear parameter settings and a clear dataset construction process, which facilitates engineering implementation and promotion. It is suitable for rice seedling and tillering stages, and is resistant to various complex interferences such as algae and light spots, and can meet the rice counting needs of paddy fields in different regions and planting modes. Attached Figure Description

[0033] Figure 1 This is a schematic diagram illustrating the collection and processing of the Anno-Rice dataset in this invention; Figure 2 This is a block diagram of the overall structure of the A2DC-YOLO counting model in this invention; Figure 3 This is a structural comparison diagram between the improved A2D feature processing module and the original A2C2f module in this invention; Figure 4 This is a schematic diagram illustrating the working principle of the improved CARAFE upsampling mechanism in this invention. Figure 5 This is a schematic diagram of the mathematical principle of DA-SoftNMS post-processing in this invention; Figure 6 This diagram illustrates the counting performance of the improved A2DC-YOLO counting model and the baseline model in rice paddies with different characteristics. Detailed Implementation

[0034] 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, and 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.

[0035] Example 1: The practical application of the method for accurate counting of rice plants in paddy fields is as follows: Step 1: Experimental Preparation (1) Hardware environment; The system utilizes a high-definition imaging drone (model: DJI Air 3) equipped with a 1-inch CMOS sensor high-definition camera; the computing hardware configuration includes: GPU (NVIDIA RTX 4080, 16GB VRAM), CPU (Intel Xeon W-2245, 8 cores and 16 threads), memory (32GB DDR4), and storage (512GB SSD) to ensure sufficient computing power for data processing and model training.

[0036] (2) Software environment; The deep learning framework is based on PyTorch 2.2 and uses CUDA 12.4 for GPU acceleration. The auxiliary tools include: Ultralytics 8.3.0 (model training and inference), LabelImg 1.8.7 (manual annotation), OpenCV 4.8.1 (image preprocessing), and NumPy 1.26.2 (numerical computation).

[0037] Step 2: Dataset Construction and Semi-Supervised Annotation (1) Data acquisition; A rice demonstration field (covering both seedling and tillering stages) was selected as the data collection area; the drone's flight altitude was controlled at 1.2-2.0m, and the filming times were 8:30-10:30 AM and 3:30-5:30 PM (to avoid interference from strong light reflection); a total of 20 video clips were collected. Figure 1 The image shows the collection and processing of the Anno-Rice dataset.

[0038] (2) Image preprocessing; Frames were extracted from the captured video at a rate of 1 frame per second, and 450 original images (4096×2160 resolution) were obtained through initial screening. The original images were then batch-cropped into sub-images with a resolution of 640×640. Invalid images with blurriness or occlusion exceeding 30% were manually screened out, and finally 1300 valid sub-images were retained.

[0039] (3) Semi-supervised annotation process; ① Manually labeled small sample subset: 20% (260 images) of the 1300 valid sub-images were selected as the initial labeled samples. The LabelImg tool was used to label the bounding boxes of rice plants in YOLO format to form the initial labeled subset; ② Initial model training: Based on the initial labeled subset, train a basic YOLOv12n lightweight model with 150 training epochs and a batch size of 8 to complete the parameter learning of the initial model; ③ Candidate pseudo-label generation: Using the trained YOLOv12n model, the remaining 1040 unlabeled sub-images are automatically inferred to generate candidate pseudo-labels for rice plant bounding boxes. ④ Pseudo-label correction: Candidate pseudo-labels are manually checked, with a focus on correcting annotations that are "missing, incorrect, or have bounding box offsets exceeding 10px". This process ultimately produces a complete YOLO format txt annotation file for 1300 images.

[0040] (4) Data augmentation and partitioning; The dataset was expanded by "horizontal and vertical mirroring, brightness adjustment, and contrast adjustment", resulting in 2600 valid images. These images were then divided into a training set (for parameter learning), a validation set (for hyperparameter tuning), and a test set (for performance evaluation) in a ratio of 7:1.5:1.5, with the division based on "image groups" to avoid data leakage.

[0041] Step 3: Core Improvement - Building the A2DC-YOLO Counting Model: Using YOLOv12m as the baseline model, and addressing the core challenges of rice counting in paddy fields, three innovative modules were implemented to create a fully optimized counting model. The overall structure of the A2DC-YOLO counting model is as follows: Figure 2 As shown.

[0042] (1) A2D feature processing module (feature enhancement core); To address the issue that the original YOLOv12m A2C2f module over-relies on spatial domain features and struggles to penetrate interference and distinguish adherent plants, a dual-frequency aggregation feedforward network (DFFN) is embedded into ABlock to replace the original MLP structure, constructing a spatial-frequency dual-optimized feature extraction module. See [link to relevant documentation] Figure 3 This is to improve the A2D module structure compared with the original A2C2f module structure.

[0043] Specifically, the Area Attention structure is retained to capture region-related features. After the input features are processed by it, a first residual connection is made with the original features to avoid feature loss. The features after flattening the spatial dimensions are fed into DFFN, and a split operation is performed to achieve parallel dual branches: one branch extracts high-frequency detail features (such as rice leaf texture and tiller outline) through 1×1 convolution, and the other branch captures low-frequency global information (such as the overall distribution of the plant) through 3×3 depth convolution. After element-level fusion, the bi-branch features are reduced in dimensionality by a linear layer to reshape the spatial dimension. Then, they are fused with the output of the first residual connection to form an enhanced feature, which strengthens the ability to express plant features under interference conditions.

[0044] The overall processing procedure of the spatial-frequency dual-optimized feature extraction module is as follows:

[0045]

[0046]

[0047]

[0048]

[0049] in, As input features, This is the result of the first residual connection. Features after flattening out spatial dimensions High-frequency characteristics It is a low-frequency characteristic. The features are those obtained after dual-frequency fusion and dimensionality reduction. These are the enhanced features of the module's final output.

[0050] (2) CARAFE upsampling mechanism (details preserved in the core); To address the issue of blurred feature map edges and loss of detail caused by mechanically copying pixels in native nearest neighbor upsampling, a content-aware CARAFE upsampling strategy is introduced to dynamically adapt to rice plant features. The working principle of the improved CARAFE upsampling mechanism is as follows: Figure 3 As shown.

[0051] Specifically, the mechanism consists of two parts: the Kernel Prediction Module and the Content-aware Reassembly Module.

[0052] The kernel prediction module dynamically generates a dedicated upsampling kernel based on input features, focusing on key areas such as the outline and texture of rice plants, rather than mechanically processing all areas. The content-aware reconstruction module uses a large 5×5 receptive field to effectively capture plant contextual information and separate adhered plant outlines.

[0053] The processing procedure of the CARAFE upsampling module is as follows:

[0054]

[0055]

[0056] in, Input feature map (shape) ), These are the characteristics after channel compression. For dynamically generated and normalized upsampling kernels, This is the upsampling factor. For core size, The upsampled feature map (shape) ).

[0057] By reducing the number of parameters through channel compression, the computational load increases only slightly (no more than 1%), balancing accuracy and efficiency.

[0058] (3) DA-SoftNMS post-processing strategy (dynamic filtering core); To address the contradiction of "high threshold missed detection and low threshold false detection" caused by the fixed threshold of traditional NMS, a density-adaptive DA-SoftNMS post-processing strategy is designed to adapt to the complex scenario of uneven plant distribution in rice fields.

[0059] Specifically, the first step is to input the set of detection boxes and their corresponding scores. Valid detection boxes are then filtered through iterative loops to ensure the accuracy of the counting results. In each iteration, the detection box with the highest score is selected first, and the number of detection boxes (i.e., density) in its local area (radius 80-120px) is calculated to characterize the plant density in that area.

[0060] Subsequently, the IoU threshold is dynamically adjusted based on local density: When the density is higher than the dense threshold ( When using a stricter IoU threshold, ), to suppress duplicate detection in dense regions; When the density is below the dense threshold, a more lenient IoU threshold is used. This reduces the chance of missing plants in sparse areas.

[0061] Finally, a Gaussian decay function is used to attenuate the scores of overlapping detection boxes to avoid missing real plants; at the same time, a global fallback IoU threshold is introduced ( This ensures the stability of the screening process when the dynamic threshold deviates.

[0062] See Figure 5 The specific algorithm flow is as follows: Initialize the reserved set Input detection box set and corresponding score set .

[0063] when If not empty, repeat the following steps: a. Determine the score set The index corresponding to the highest score m=argmax( ) Select the set of detection boxes Corresponding index m detection box (i.e., the detection box with the highest current score); b. Place the detection box Add to the reserved set and from Remove from ,from Remove the corresponding score from the middle ; c. Calculate the detection frame The number of remaining detection boxes within the local area (radius 80-120px), localcount, is used as a representation of the plant density in that area; d. Dynamically set the IoU threshold: If localcount ≥ ( (For dense thresholds), then set ( (IoU threshold for dense regions); If localcount < Then set ( (IoU threshold for the sparse region). At the same time This serves as a global fallback threshold and is activated when the dynamic threshold exceeds a reasonable range. e. to Each remaining detection box : i. Calculation and The intersection and union ratio of iou ( ); ii. According to the Gaussian decay function ( Updated for attenuation coefficient The score; iii. Remove "Updated score is lower than confidence threshold (range 0.1-0.2)" or "iou( )> "Detection box At the same time remove The corresponding score; When the loop ends ( (If empty), output the set to retain. The number of detection frames contained in the data represents the count of rice plants.

[0064] Step 4: Model Training and Optimization The A2DC-YOLO counting model, based on YOLOv12m, has a total training epoch of 300. The core configuration includes: input size 640×640, batch size 16, optimizer SGD (momentum = 0.937, weight decay = 0.0005), initial learning rate 0.01, and a cosine annealing learning rate scheduler. The specific training process is as follows: ① Freezing phase (epochs 1-60) Freeze rule: Freeze all parameters of the backbone network (gradients set to zero). Only train the improved module and detection head parameters: Keep the parameters of the backbone network's BN layer fixed to avoid destroying the pre-trained features.

[0065] Loss function: The total training loss is a weighted sum of the classification loss, regression loss, and confidence loss, consistent with YOLOv12m:

[0066] Classification loss (BCEWithLogitsLoss):

[0067] in, The true category label for rice plants (binary classification: 1=rice, 0=background). To predict class probabilities, This represents the total number of samples in a single batch.

[0068] Regression loss (CIoULoss):

[0069] in, Predict bounding boxes for A2DC-YOLO. The actual bounding boxes are manually labeled. The Euclidean distance is the center of the frame. The length of the diagonal of the minimum bounding box of the two frames. For balance coefficient, This is a parameter for aspect ratio consistency.

[0070] Confidence loss (BCEWithLogitsLoss):

[0071] in, The true confidence level label (including target = 1, excluding = 0). To predict confidence levels, This represents the total number of test frames in a single batch.

[0072] Improved module gradient update (SGD core logic): SGD gradient descent is performed only on the improved module parameters, with the learning rate kept at the initial value of 0.01 (cosine annealing decay is not initiated, and the first stage is fixed):

[0073] in, (Initial learning rate) (Weight decay coefficient) To improve the loss gradient of module parameters.

[0074] Taking the A2D module as an example, its dual-frequency feedforward network (DFFN) parameters Gradient formula:

[0075] in, (Output from A2D module) Includes high-frequency branches With low-frequency branch The gradient of the parameters.

[0076] Data augmentation: Enable YOLOv12 native Mosaic (4-image stitching), MixUp, and random affine transformation (rotation ±5°, scaling 0.8-1.2x, translation ±10%) to improve the anti-interference capability of the improved module.

[0077] ② Thawing of all parameters (epochs 61-270) Unfreeze rules: Unfreeze the backbone network parameters and enable full parameter training: Optimize and improve the global adaptability of the module to the benchmark model.

[0078] Cosine annealing learning rate scheduling (start-up decay): Starting from epoch 61, the cosine annealing scheduler is activated, and the learning rate decays periodically according to the following formula (period = 210 epochs, covering the current phase + the next phase): in, In this phase (epochs 61-270), the learning rate decreases from 0.01 to around 0.0002, which ensures the magnitude of parameter updates while avoiding oscillations.

[0079] Full-parameter gradient update (SGD): All parameters are uniformly subjected to SGD gradient descent, as shown in the following formula:

[0080] in, The learning rate after cosine annealing decay in the current epoch. The loss gradient is the one with all parameters.

[0081] Taking the CARAFE upsampling module as an example, its dynamic kernel prediction parameters Gradient formula:

[0082] in, (CARAFE output) For dynamically generated upsampling kernels, It is the weighted gradient of the dynamic kernel and neighborhood features.

[0083] Data augmentation: Keep Mosaic and other augmentations enabled to enrich data distribution and improve model generalization.

[0084] Performance monitoring: Every 10 epochs, “Count MAE” and “Detection mAP50” are calculated on the validation set, and the parameter update trend is recorded to avoid overfitting.

[0085] ③ Fine-tuning phase (epochs 271-300, the last 30 rounds) Learning rate scheduling (cosine annealing for finalization): The learning rate continues to decay according to the cosine annealing formula mentioned above, decreasing from 0.0002 to 0.0001 in this stage. Substituting into the formula... This ensures that parameter fine-tuning is gentle and avoids disrupting the already adapted feature mapping.

[0086] Data augmentation switch: Turn off Mosaic augmentation to eliminate feature differences between training and inference scenarios, allowing the model to adapt to real drone image input.

[0087] Improved module fine-tuning: The focus is on optimizing the auxiliary training logic of DA-SoftNMS post-processing (although post-processing is an operation in the inference stage, it indirectly constrains the quality of the detection boxes through the loss function), while fine-tuning the core parameters of A2D and CARAFE: For the A2D module, the focus is on optimizing the weights for dual-frequency feature fusion to ensure a balance between high-frequency details (rice leaf texture) and low-frequency global features (plant distribution).

[0088] in, The gradient update formula for the fusion weights (learnable parameters, initial value = 1.0) is as follows:

[0089] For the CARAFE upsampling module, fine-tuning the dynamic kernel size adaptation parameters ensures that the 5×5 kernel receptive field accurately covers the outline of the rice plant:

[0090] in, (Core size, constrained between 4 and 6 during fine-tuning).

[0091] Weight saving rules: Every 5 epochs, the validation set count (MAE, Mean Absolute Error) is calculated using the following formula:

[0092] in, To verify the total number of images in the set, For the first The images were manually counted to determine the true values. Count the model predictions; save the model weights with the minimum MAE. , as the final reasoning model.

[0093] Experimental verification: The A2DC-YOLO counting model trained and optimized in Example 1 above was used, with YOLOv12m as the baseline model. To compare the counting performance of the two models on paddy field images with different characteristics, this invention collected images of four different complex paddy field environments: abundant green algae, high reflectivity, a combination of green algae and dense rice, and red algae with extensive shadowing. The rice counting results are as follows: Figure 6 As shown, Figure 6 (a) Figure 6 (b) Figure 6 (c) Figure 6 (d) Rice detection results corresponding to the above four complex paddy field environment images.

[0094] It can be seen that, Figure 6 (a) Figure 6 (b) Figure 6 (c) The rice counting error in YOLOv12m is relatively large, and there are cases where other interfering environments are identified as rice. Figure 6 In (d), YOLOv12m cannot identify rice plants and struggles to distinguish between adhered plants and plants in low-light conditions. It is evident that the rice identification results in this invention are more accurate. Addressing the complex challenges of algae interference, water reflection, and plant adhesion in paddy field rice counting during UAV remote sensing monitoring, this invention significantly improves the robustness and accuracy of counting in complex paddy field environments through module collaborative optimization. This provides high-quality technical support for smart agriculture rice yield prediction and has broad practical application value.

[0095] The above description is only for the purpose of helping to understand the method and core essence of the present invention, but the scope of protection of the present invention is not limited thereto. For those skilled in the art, any equivalent substitutions or modifications made to the technical solution and inventive concept disclosed in the present invention within the scope of the technology disclosed in the present invention should be covered within the scope of protection of the present invention. Therefore, the content of this specification should not be construed as a limitation of the present invention.

Claims

1. A method for accurate counting of paddy rice plants in paddy fields based on an improved YOLO, characterized in that: Includes the following steps: S1. Constructing a dataset: Collect high frame rate video sequences covering the seedling and tillering stages of rice, extract frames, crop, filter, and label the high frame rate video sequences to obtain rice image samples, and expand the sample size through data augmentation operations to obtain a dataset; S2. Construct the A2DC-YOLO counting model; improve and optimize it using YOLOv12m as the baseline model; The original A2C2f module was replaced with the A2D feature processing module. In the A2D feature processing module, the dual-frequency aggregation feedforward network DFFN was embedded in ABlock to form a space-frequency dual-optimized feature extraction structure, which strengthens the expression of rice plant features. The native nearest neighbor upsampling is replaced with the CARAFE upsampling module. The CARAFE upsampling module dynamically generates a dedicated upsampling kernel to preserve detailed information about rice plants. Design a density-adaptive DA-SoftNMS post-processing strategy to dynamically adjust the IoU threshold based on the density of the detection boxes in local regions; S3. Model Training and Optimization: Design a loss function and use the dataset to perform end-to-end training of the A2DC-YOLO counting model; S4. Rice Plant Counting Inference: Deploy and train an A2DC-YOLO counting model with optimal model weights to perform inference on the rice image to be detected and output the rice plant count results.

2. The method for accurate counting of paddy rice plants based on improved YOLO according to claim 1, characterized in that, The rice image sample is obtained in step S1 as follows: S101. Video frame extraction: Extract the original image from the acquired video at a frequency of 1 frame / second; S102. Image cropping and filtering: Perform batch cropping of the original image at fixed positions, and manually filter out blurry or severely occluded invalid images, retaining valid images; S103. Use semi-supervised data annotation technology to annotate rice images.

3. The method for accurate counting of paddy rice plants based on the improved YOLO according to claim 2, characterized in that, The semi-supervised data annotation technique in S103 is as follows: S1031. Manually labeled small sample subset: Select no less than 20% of the samples from the filtered valid images, and use the LabelImg tool to label the bounding boxes of rice plants in YOLO format to form an initial labeled subset; S1032. Initial Model Training: Train the initial object detection network model based on the initial labeled subset; S1033. Candidate pseudo-label generation: Using the trained initial object detection network model, the remaining unlabeled valid images are automatically inferred to generate a large number of candidate pseudo-labels for rice plant bounding boxes. S1034. Pseudo-label correction: Manually check candidate pseudo-labels, correct missing labels, incorrect labels, and boundary box offset errors, and generate a complete YOLO format txt annotation file.

4. The method for accurate counting of paddy rice plants based on improved YOLO according to claim 1, characterized in that, The A2D feature processing module in S2 is as follows: The ABlock+DFFN structure is obtained by improving the original A2C2f module ABlock; the AreaAttention structure is retained in the ABlock+DFFN structure to capture region association features, and a dual-frequency aggregation feedforward network DFFN is added to replace the original MLP structure. The dual-frequency aggregation feedforward network (DFFN) achieves parallel operation of two branches through a split operation: one branch extracts high-frequency detail features through 1×1 convolution, and the other branch captures low-frequency global information through 3×3 depth convolution.

5. The method for accurate counting of paddy rice plants based on improved YOLO according to claim 4, characterized in that, The processing procedure for the ABlock+DFFN structure is as follows: Input features After processing by Area Attention, a first residual connection is performed with the original features to obtain: ; Will Flattening out the spatial dimensions, we obtain ; High-frequency detail features are extracted using 1×1 convolution: Capture low-frequency global information using 3×3 depthwise convolution: After element-wise fusion of the bi-branch features, the spatial dimension is reshaped by linear layer dimensionality reduction to obtain: and A second residual fusion is performed to obtain the final enhanced features: in, This is the final enhanced feature output by the ABlock+DFFN structure.

6. The method for accurate counting of paddy rice plants based on improved YOLO according to claim 1, characterized in that, The CARAFE upsampling module in S2 is specifically as follows: The CARAFE upsampling module includes a kernel prediction module and a content-aware reconstruction module; The kernel prediction module dynamically generates a dedicated upsampling kernel based on the input features, focusing on key areas of the rice plant's outline and texture; The content-aware reorganization module uses a 5×5 large receptive field to capture contextual information of rice plants and separate the outlines of adhering rice plants.

7. The method for accurate counting of paddy rice plants based on improved YOLO according to claim 6, characterized in that, The processing procedure of the CARAFE upsampling module is as follows: Input rice feature map The number of channels is reduced from 1×1 convolution. Compress to To obtain compression features : Compression characteristics Convolutional layers extract key information and predict dynamic upsampling kernels: in, This is the upsampling factor. For core size, The upsampling kernel is dynamically generated and normalized; The original feature map is expanded by window to obtain neighborhood features, and then the upsampled feature map is obtained by weighted summation using a dynamic kernel. : The upsampling kernel size is set to 5×5, the receptive field is 5×5, and the channel compression ratio is 1 / 4-1 / 2 to ensure that the increase in computational load does not exceed 1%.

8. The method for accurate counting of paddy rice plants based on improved YOLO according to claim 1, characterized in that, The density-adaptive DA-SoftNMS post-processing strategy in S2 is as follows: Input a set of detection boxes and their corresponding scores, and filter valid detection boxes through iterative loops; in each iteration, select the detection box with the highest score, calculate the number of detection boxes in its local area, which represents the plant density in that area and serves as the local density; The IoU threshold is dynamically adjusted based on local density: when the density is higher than the dense threshold, a stricter IoU threshold is used to suppress repeated detection in dense areas; when the density is lower than the dense threshold, a more lenient IoU threshold is used to reduce missed detection of plants in sparse areas. The score of overlapping detection boxes is reduced by combining the Gaussian decay function to avoid missing real rice plants; At the same time, a global fallback IoU threshold is introduced.

9. The method for accurate counting of paddy rice plants based on improved YOLO according to claim 1, characterized in that, The model training and optimization in S3 are detailed below: loss function The weighted sum of classification loss, regression loss, and confidence loss is as follows: Classification loss : in, This is a true category label for rice plants. To predict class probabilities, This represents the total number of samples in a single batch of each category. Regression loss : in, Predict bounding boxes for the model. The actual bounding boxes are manually labeled. The Euclidean distance is the center of the frame. The length of the diagonal of the minimum bounding box of the two frames. For balance coefficient, Aspect ratio consistency parameter; Confidence loss : in, This is the true confidence level label. To predict confidence levels, This represents the total number of test frames in a single batch. The training parameters are set as follows: The fixed seed is 42, the input image size is 640×640, the batch size is 16-32, the number of training epochs is 200-400, the optimizer is SGD, the initial learning rate is 0.005-0.01, the weight decay is the default value of YOLO network, the confidence threshold during training is 0.001, the IoU threshold is 0.6, and the confidence threshold for testing and evaluation is 0.3-0.

5.

10. The precise counting system for paddy rice plants based on the improved YOLO, obtained by the method according to any one of claims 1-9, is characterized in that... Including the A2DC-YOLO counting model; The A2DC-YOLO counting model includes a backbone network, a neck network, and a head detection head. The backbone network includes an A2D feature processing module, which adopts an ABlock+DFFN structure for spatial-frequency dual-optimized feature extraction; the backbone network is used for feature extraction at different scales. The Neck network includes a CARAFE upsampling module and an A2D feature processing module. The CARAFE upsampling module includes a kernel prediction module and a content-aware reconstruction module, which are used to dynamically generate a dedicated kernel for feature enhancement during upsampling. The Neck network forms corresponding feature branches for processing the basic features of different scales output by the Backbone network. In each feature branch, feature concatenation, upsampling, and A2D operations are performed sequentially. At the same time, high-scale features are processed based on the fusion results of low-scale features through independent A2D operations, feature concatenation, and convolution operations, and finally correspond to the detection box level to obtain multi-scale features. The Head detection head includes a density-adaptive DA-SoftNMS post-processing unit. The Head detection head is used to decouple multi-scale features and then mark detection boxes. The density-adaptive DA-SoftNMS post-processing unit dynamically adjusts the IoU threshold based on the local region detection box density.