A lightweight method for detecting the laying posture of scallions in a scallion harvester

CN122434945BActive Publication Date: 2026-08-14SHANDONG AGRICULTURAL UNIVERSITY
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2026-06-24
Publication Date
2026-08-14

AI Technical Summary

Technical Problem

然而,在面向大葱角度分级等资源受限的工业边缘部署场景时,该框架仍存在诸多不足,首先,主干网络与颈部网络中的C2f模块采用全通道标准卷积,在细长目标背景占比较高、通道冗余明显的情况下,会产生较大的无效计算与访存开销

Benefits of technology

本申请以YOLOv8-OBB为基准模型,从特征提取、上下文建模和检测头优化三个层面进行协同改进,采用C2f_Faster特征提取模块利用部分卷积削减冗余计算,在SPPF中嵌入大核可分离注意力机制LSKA扩大感受野;设计OBB-LSDECD细节增强旋转检测头,融合参数共享与细节增强卷积强化边缘与方向特征表达。本申请不仅输出大葱的左倾、右倾、正常三类姿态,还精确输出旋转框的角度数值,从而为收获机输送带速度的动态定量调控提供依据。实验表明,本申请模型GOPD-YOLO以2.38M参数量和3.3 GFLOPs计算量,在大葱数据集上取得了93.42%的mAP@0.5和94.50%的召回率,模型体积仅4.9 MB,推理速度达94.1 FPS,满足大葱收获机边缘计算设备的实时部署需求。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122434945B_ABST
    Figure CN122434945B_ABST
Patent Text Reader

Abstract

This application discloses a lightweight scallion laying posture detection method for scallion harvesters, relating to the fields of deep learning and computer vision technology. The method includes: acquiring and preprocessing a scallion image dataset; labeling the scallion image dataset using rotated bounding boxes; dividing the labeled dataset into training, validation, and test sets; training a pre-built GOPD-YOLO model using the training set and validating it using the validation set to obtain the optimal lightweight scallion laying posture detection model; inputting the test set into the optimal lightweight scallion laying posture detection model for detection, and outputting the parameters of the rotated bounding boxes and the posture category; and determining the adjustment direction and amplitude of the conveyor belt speed based on the parameters of the rotated bounding boxes and the posture category. This application not only outputs three postures of scallions—left-tilted, right-tilted, and normal—but also accurately outputs the angle values ​​of the rotated bounding boxes, thus providing a basis for the dynamic quantitative control of the harvester's conveyor belt speed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the fields of deep learning and computer vision technology, specifically to a lightweight method for detecting the laying posture of scallions in a scallion harvester. Background Technology

[0002] With the development of smart agriculture and agricultural mechanization technology, the mechanized harvesting of slender vegetables such as scallions has become an important way to improve production efficiency. On a scallion harvester, after harvesting, the scallions need to be laid laterally on a conveyor belt and transported to the ground in a lateral posture to facilitate subsequent baling or picking operations. If the scallions' laying posture on the conveyor belt does not meet the requirements, it will directly affect the quality of subsequent processes, requiring immediate adjustment of the conveyor belt speed through the control system to achieve closed-loop control. In this closed-loop control process, it is not only necessary to determine whether the scallions are tilted to the left or right to determine the direction of conveyor belt speed adjustment, but also to obtain precise tilt angle values ​​to determine the adjustment range of the conveyor belt speed. Therefore, real-time, automatic detection of the actual laying posture of the scallions, and simultaneous output of posture category and precise angle information, is a key link in ensuring the efficient and stable operation of the scallion harvester.

[0003] However, existing attitude detection methods mainly rely on manual visual inspection or mechanical limiting devices, which suffer from bottlenecks such as strong subjectivity, poor adaptability, and low efficiency. These methods not only fail to meet the real-time detection requirements of high-speed harvesting operations but also cannot provide accurate angle quantification feedback for closed-loop control. Furthermore, while deep learning-based target detection technology has been widely used in agricultural vision tasks, research on rotation detection of slender agricultural products with strong directional priors remains insufficient. Traditional horizontal bounding boxes have significant limitations: when the target is tilted, the horizontal box includes a large amount of irrelevant background area and cannot accurately represent the true spatial extent and principal axis direction of slender targets.

[0004] To overcome the aforementioned shortcomings, rotation bounding box detection methods have been increasingly introduced into target detection tasks with directional attributes. YOLOv8-OBB is a representative rotation detection framework, demonstrating strong performance on multiple benchmarks thanks to its anchor-free design and C2f feature extraction module. However, in resource-constrained industrial edge deployment scenarios, such as those involving scallion angle grading, this framework still has several limitations. First, the C2f modules in the backbone and neck networks employ full-channel standard convolutions, which incur significant unnecessary computation and memory overhead when the background of slender targets is high and channel redundancy is obvious. Second, the SPPF module mainly relies on fixed-scale max pooling to construct the receptive field, making it difficult to effectively model long-range spatial dependencies in scenarios involving scallions where the target length occupies a large proportion of the image. Furthermore, the native detection head lacks explicit enhancement mechanisms for edge gradients, corner contours, and high-frequency directional features, leading to a significant increase in the regression error of the rotation box angle under complex deployment conditions.

[0005] Therefore, there is an urgent need to propose a rotating target detection method that combines lightweight, high-precision angle detection and real-time performance to meet the dual requirements of closed-loop control of scallion harvesters for attitude category and accurate angle information. Summary of the Invention

[0006] In order to solve the above-mentioned technical problems, this application proposes the following technical solution: This application provides a lightweight scallion laying posture detection method for scallion harvesters, including: A dataset of scallion images was acquired and preprocessed. The dataset was then labeled using rotated bounding boxes, and the labeled dataset was divided into a training set, a validation set, and a test set. The pre-built GOPD-YOLO model was trained using the training set and validated using the validation set to obtain the optimal lightweight scallion laying posture detection model. The test set is input into the optimal lightweight scallion laying posture detection model for detection, and the parameters and posture categories of the rotating box are output. The direction and magnitude of the conveyor belt speed adjustment are determined based on the parameters of the rotating frame and the posture category.

[0007] In one possible implementation, the rotated bounding box uses multiple parameters to represent the position and orientation of the target, calculated as follows: Where B represents the set of parameters of the rotated bounding box; The coordinates of the target center point; The width of the rotated bounding box; This represents the height of the rotated bounding box; The rotation angle of the target relative to the reference axis.

[0008] In one possible implementation, the GOPD-YOLO model includes an input terminal, a backbone network, a neck network, and a detection head. The input terminal receives an image of scallion spread to be detected and inputs the image to the backbone network. The backbone network includes a first convolutional downsampling layer, a first C2f_Faster feature extraction module, a second convolutional downsampling layer, a second C2f_Faster feature extraction module, a third convolutional downsampling layer, a third C2f_Faster feature extraction module, a fourth convolutional downsampling layer, a fourth C2f_Faster feature extraction module, and an SPPF_LSKA global context enhancement module, all connected in sequence. The second C2f_Faster feature extraction module, the third convolutional downsampling layer, and the SPPF_LSKA global context enhancement module output backbone features of different scales to the neck network, respectively. The neck network comprises a first upsampling layer, a first feature splicing layer, a fifth C2f_Faster feature extraction module, a second upsampling layer, a second feature splicing layer, a sixth C2f_Faster feature extraction module, a fifth convolutional downsampling layer, a third feature splicing layer, a seventh C2f_Faster feature extraction module, a fourth feature splicing layer, and an eighth C2f_Faster feature extraction module, connected in sequence. The second C2f_Faster feature extraction module is connected to the second feature concatenation layer, the third convolutional downsampling layer is connected to the first feature concatenation layer, the SPPF_LSKA global context enhancement module is connected to the first upsampling layer and the fourth feature concatenation layer respectively, the sixth C2f_Faster feature extraction module is connected to the first OBB-LSDECD detail enhancement rotation detection head, the seventh C2f_Faster feature extraction module is connected to the second OBB-LSDECD detail enhancement rotation detection head, and the eighth C2f_Faster feature extraction module is connected to the third OBB-LSDECD detail enhancement rotation detection head.

[0009] In one possible implementation, the C2f_Faster feature extraction module includes a first convolutional unit, a channel segmentation unit, a Faster Block processing unit, a feature concatenation unit, and a second convolutional unit connected in sequence. The Faster Block processing unit includes multiple Faster Blocks, each of which includes a partial convolutional unit, a concatenation unit, a third convolutional unit, a fourth convolutional unit, a fifth convolutional unit, and a residual connection unit. The concatenation unit is used to concatenate the input features of the Faster Block with the features output by the partial convolutional units, and the residual connection unit is used to perform residual fusion between the features output by the concatenation unit and the features output by the fifth convolutional unit.

[0010] In one possible implementation, the SPPF_LSKA global context enhancement module includes: an SPPF feature aggregation branch and an LSKA attention enhancement branch; the SPPF feature aggregation branch includes a first convolutional layer, multiple max pooling layers, a fifth feature concatenation layer, and a second convolutional layer connected in sequence; the LSKA attention enhancement branch includes a first deep convolutional layer, a second deep convolutional layer, a first dilated convolutional layer, a second dilated convolutional layer, and a third convolutional layer connected in sequence, the second convolutional layer being connected to the first deep convolutional layer, and the output of the LSKA attention enhancement branch being provided with an element-wise multiplication unit.

[0011] In one possible implementation, the loss function used when training the GOPD-YOLO model is: in, Total loss; The ProbIoU rotation box regression loss is based on the Bhattacharyya distance between Gaussian distributions; The binary cross-entropy classification loss is used. For distribution focus loss; , and These are the weight coefficients corresponding to the rotation box regression loss, classification loss, and distribution focus loss, respectively. Weights for the target scores obtained during the sample allocation phase; For positive sample index; and The first The predicted and actual rotated boxes corresponding to each positive sample; For real category labels; The predicted value output for the classification branch; For the Sigmoid function; For true continuous target values; and These are the left and right discrete boundaries of the interval containing the true continuous target value, respectively. and These represent the probabilities that the predicted value falls into the left and right discrete intervals, respectively.

[0012] In one possible implementation, the test set is input into the optimal lightweight scallion laying posture detection model for detection, and the parameters and posture categories of the rotating bounding box are output, including: The scallion images in the test set are input to the input end of the optimal lightweight scallion laying posture detection model according to the preset input size to obtain the input image to be detected; The input image to be detected is input into the backbone network, and then passes through multiple levels of convolutional downsampling layers and multiple C2f_Faster feature extraction modules for feature extraction, resulting in shallow high-resolution features, mid-level semantic features, and high-level semantic features. The C2f_Faster feature extraction module segments the input features along the channel dimension, performs spatial convolution only on a subset of channels, and preserves the remaining channels using identity mapping. The formula for calculating spatial convolution is: in, This indicates the number of floating-point operations required during the execution of a partial convolution; and These represent the height and width of the input feature map, respectively. This indicates the number of channels in the input feature map; This represents the side length of the convolution kernel; The convolutional results are concatenated with the preserved results and channels are fused to obtain lightweight feature extraction results; The high-level semantic features are input into the SPPF_LSKA global context enhancement module. First, multi-scale pooling and feature concatenation are performed through the SPPF feature aggregation branch to obtain multi-scale context fusion features. Then, spatial attention weights are generated through the LSKA attention enhancement branch. The spatial attention weights are multiplied element-wise with the multi-scale context fusion features to obtain global context enhancement features. The shallow high-resolution features, mid-level semantic features, and global context enhancement features are input into the neck network for multi-scale feature fusion to obtain a first-scale fused feature map, a second-scale fused feature map, and a third-scale fused feature map. The first scale fusion feature map, the second scale fusion feature map and the third scale fusion feature map are respectively input into the corresponding OBB-LSDECD detail enhancement rotating detection head. The detail enhancement of each scale fusion feature map is performed through the shared detection branch to obtain the enhanced inspection features. The enhanced detection features are input into the bounding box regression branch, the category prediction branch, and the angle prediction branch, respectively. The bounding box regression branch outputs the center coordinates of the rotating box, the width of the rotating box, and the height of the rotating box of the scallion target. The pose category prediction result of the scallion target is output through the category prediction branch, and the rotation angle prediction result is output through the angle prediction branch. The outputs of the bounding box regression branch, category prediction branch, and angle prediction branch are decoded to obtain the rotation box parameters and pose categories corresponding to the major onion targets in the test set.

[0013] In one possible implementation, the step of enhancing the details of the fused feature maps at each scale through a shared detection branch, and the calculation formula for the enhanced inspection features, is as follows: in, Indicates the first Scale-fused feature map; Represents the fused feature map Intermediate features after 1×1 convolution and group normalization; Indicates Enhanced detection features after processing by the detail enhancement module; This represents a feature transformation operation consisting of 1×1 convolution and group normalization. This indicates that the detail enhancement operations of differential augmented convolution and group normalization are performed on the input features; Indicates the feature scale index. These correspond to fused feature maps at different scales.

[0014] In one possible implementation, spatial attention weights are generated through the LSKA attention enhancement branch, and these spatial attention weights are multiplied element-wise with the multi-scale context fusion features to obtain the global context enhancement feature calculation formula: in, This represents the output features after processing by the LSKA attention enhancement branch; This represents the multi-scale context fusion feature output by the SPPF feature aggregation branch; Indicates by Spatial attention weights generated by 1×1 convolution; express Intermediate features after 1×3 depthwise convolution; express Intermediate features after 3×1 depthwise convolution; express Intermediate features after processing by a 1×5 depthwise convolution with a dilation rate of 2; express Intermediate features after processing by a 5×1 depthwise convolution with a dilation rate of 2; This represents a 1×1 convolution operation used to generate spatial attention weights; Indicates a depthwise convolution operation; This represents a depthwise convolution with a kernel size of 1×3; This represents a depthwise convolution with a kernel size of 3×1; This represents a depthwise convolution with a kernel size of 1×5 and a dilation rate d of 2. This represents a depthwise convolution with a kernel size of 5×1 and a dilation rate d of 2; d represents the dilation rate of the dilated convolution. This indicates element-wise multiplication.

[0015] In one possible implementation, the direction and magnitude of the conveyor belt speed adjustment are determined based on the parameters of the rotating frame and the attitude category, including: Obtain the center coordinates, width, height, rotation angle, and pose category of the rotating bounding box; The direction of conveyor belt speed adjustment is determined based on the posture category; When the posture category is left tilt, increase the conveyor belt speed; when the posture category is right tilt, decrease the conveyor belt speed; when the posture category is normal, maintain the current conveyor belt speed, and determine the adjustment range of the conveyor belt according to the value of the rotation angle.

[0016] Compared with the prior art, the beneficial effects of this application are as follows: This application uses YOLOv8-OBB as the baseline model and makes collaborative improvements in three aspects: feature extraction, context modeling, and detector head optimization. It employs the C2f_Faster feature extraction module to reduce redundant computation through partial convolution, and embeds a large kernel separable attention mechanism (LSKA) into SPPF to expand the receptive field. An OBB-LSDECD detail-enhanced rotation detector head is designed, fusing parameter sharing and detail-enhanced convolution to strengthen edge and orientation feature representation. This application not only outputs three poses of scallions—left-tilt, right-tilt, and normal—but also accurately outputs the angle values ​​of the rotation box, thus providing a basis for the dynamic quantitative control of the conveyor belt speed of the harvester. Experiments show that the proposed model GOPD-YOLO, with 2.38M parameters and 3.3 GFLOPs of computation, achieves 93.42% mAP@0.5 and 94.50% recall on the scallion dataset. The model size is only 4.9 MB, and the inference speed reaches 94.1 FPS, meeting the real-time deployment requirements of edge computing devices for scallion harvesters. Attached Figure Description

[0017] Figure 1 A flowchart illustrating a lightweight scallion laying posture detection method for a scallion harvester provided in this application embodiment; Figure 2 This is a schematic diagram of the overall structure of the GOPD-YOLO model provided in the embodiments of this application; Figure 3 This is a schematic diagram of the structure of the C2f_Faster feature extraction module provided in an embodiment of this application; Figure 4 A schematic diagram of the structure of the SPPF_LSKA global context enhancement module provided in the embodiments of this application; Figure 5 The loss change curves during the training process provided in the embodiments of this application are shown in the figure, where (a) is the training set box loss, (b) is the training set classification loss, (c) is the training set DFL loss, (d) is the validation set box loss, (e) is the validation set classification loss, and (f) is the validation set DFL loss. Figure 6 Precision-recall curves on the test set provided in the embodiments of this application; Figure 7 Precision-confidence curves provided for embodiments of this application; Figure 8 The confusion matrix provided in this application embodiment on the test set; Figure 9 The following is a visualization of the prediction results on the test set provided in the embodiments of this application, wherein (a), (c), (e) and (g) are model prediction result diagrams, and (b), (d), (f) and (h) are the actual labeled result diagrams of the corresponding samples; Figure 10 This is a comparison chart of ablation experiment results provided in the embodiments of this application; Figure 11 A comparison chart of the parameter values ​​of different models provided in the embodiments of this application with mAP@0.5. Detailed Implementation

[0018] The present solution will now be described in conjunction with the accompanying drawings and specific embodiments.

[0019] Figure 1 A flowchart illustrating a lightweight scallion laying posture detection method for a scallion harvester, provided in an embodiment of this application, is shown below. Figure 1 This embodiment of a lightweight scallion laying posture detection method for a scallion harvester includes: S101. Obtain the scallion image dataset and preprocess it. Use rotated bounding boxes to annotate the scallion image dataset and divide the annotated dataset into training set, validation set and test set.

[0020] In this embodiment, images of scallions placed at different angles are acquired, and the scallion targets are labeled using a rotated bounding box. The labeling information includes the center coordinates (x, y) of the rotated bounding box, the width w of the rotated bounding box, the height h of the rotated bounding box, and the rotation angle. The rotation bounding box uses five parameters to represent the target's position and orientation, calculated as follows: Where B represents the set of parameters of the rotated bounding box; The coordinates of the target center point, To rotate the bounding box width, The height of the rotated bounding box, Let be the rotation angle of the target relative to the reference axis. Pose categories include normal, left tilt, and right tilt. The labeled dataset is proportionally divided into training, validation, and test sets.

[0021] S102, the pre-built GOPD-YOLO model is trained using the training set and validated using the validation set to obtain the optimal lightweight scallion laying posture detection model.

[0022] In this embodiment, YOLOv8-OBB is used as the baseline model, and collaborative improvements are made from three levels: feature extraction, context modeling, and detection head optimization. The overall network structure of GOPD-YOLO is as follows: Figure 2As shown, it includes: an input end, a backbone network, a neck network, and a detection head. The input end receives the image of the scallion to be detected and inputs the image into the backbone network. The backbone network includes a first convolutional downsampling layer, a first C2f_Faster feature extraction module, a second convolutional downsampling layer, a second C2f_Faster feature extraction module, a third convolutional downsampling layer, a third C2f_Faster feature extraction module, a fourth convolutional downsampling layer, a fourth C2f_Faster feature extraction module, and an SPPF_LSKA global context enhancement module, which are connected in sequence. The second C2f_Faster feature extraction module, the third convolutional downsampling layer, and the SPPF_LSKA global context enhancement module output backbone features of different scales to the neck network, respectively. SPPF represents the fast spatial pyramid pooling module, LSKA represents the large separable convolutional kernel attention module, OBB-LSDECD represents the lightweight rotating target detection head module, and P3, P4, and P5 represent feature layer outputs of different scales.

[0023] The neck network comprises, in sequence, a first upsampling layer, a first feature concatenation layer, a fifth C2f_Faster feature extraction module, a second upsampling layer, a second feature concatenation layer, a sixth C2f_Faster feature extraction module, a fifth convolutional downsampling layer, a third feature concatenation layer, a seventh C2f_Faster feature extraction module, a fourth feature concatenation layer, and an eighth C2f_Faster feature extraction module. Specifically, the second C2f_Faster feature extraction module is connected to the second feature concatenation layer; the third convolutional downsampling layer is connected to the first feature concatenation layer; the SPPF_LSKA global context enhancement module is connected to both the first upsampling layer and the fourth feature concatenation layer; the sixth C2f_Faster feature extraction module is connected to the first OBB-LSDECD detail enhancement rotation detection head; the seventh C2f_Faster feature extraction module is connected to the second OBB-LSDECD detail enhancement rotation detection head; and the eighth C2f_Faster feature extraction module is connected to the third OBB-LSDECD detail enhancement rotation detection head. This detection head introduces parameter sharing between the classification and regression branches to eliminate redundant convolutional layers. At the same time, it adopts a detail enhancement convolution module, which integrates five branches: central difference, horizontal difference, vertical difference, angular difference, and ordinary 3×3 convolution. This explicitly enhances the ability to express edge contours, orientation-sensitive features, and local textures, thereby improving the accuracy of rotating box positioning and pose angle prediction in complex laying scenarios.

[0024] See Figure 3In the diagram, the Faster module represents the basic feature extraction unit in the C2f_Faster feature extraction module; partial convolution means performing convolution operations only on a portion of the channels; shortcut branch means the identity mapping preservation branch; and C represents the channel concatenation operation. The C2f_Faster feature extraction module in this embodiment represents an element-wise addition operation of features. It includes a first convolutional unit, a channel segmentation unit, a Faster Block processing unit, a feature concatenation unit, and a second convolutional unit connected in sequence. The Faster Block processing unit includes multiple Faster Blocks. Each Faster Block includes a partial convolutional unit, a concatenation unit, a third convolutional unit, a fourth convolutional unit, a fifth convolutional unit, and a residual connection unit. The concatenation unit is used to concatenate the input features of the Faster Block with the features output by the partial convolutional unit. The residual connection unit is used to perform residual fusion on the features output by the concatenation unit and the features output by the fifth convolutional unit.

[0025] The SPPF_LSKA global context enhancement module provided in this embodiment includes: an SPPF feature aggregation branch and an LSKA attention enhancement branch. The SPPF feature aggregation branch includes a first convolutional layer, multiple max-pooling layers, a fifth feature concatenation layer, and a second convolutional layer connected in sequence. LSKA decomposes the K×K large kernel convolution into cascaded one-dimensional horizontal depthwise convolutions, one-dimensional vertical depthwise convolutions, and depthwise separable dilated convolutions with dilation, expanding the effective receptive field and enhancing the perception of the overall contour and directional continuity of slender targets without significantly increasing computational overhead. The internal structure of the SPPF_LSKA module is as follows: Figure 4 As shown, the LSKA attention enhancement branch includes a first depthwise convolutional layer, a second depthwise convolutional layer, a first dilated convolutional layer, a second dilated convolutional layer, and a third convolutional layer connected in sequence. The second convolutional layer is connected to the first depthwise convolutional layer. The output of the LSKA attention enhancement branch is equipped with an element-wise multiplication unit. In this embodiment, a 1×3 depthwise convolution is first used, followed by a 3×1 depthwise convolution, then a 1×5 dilated convolution with a dilation rate of 2, and then a 5×1 dilated convolution with a dilation rate of 2. Finally, spatial attention weights are generated through a 1×1 convolution and multiplied element-wise with the original features.

[0026] During training, the SGD optimizer was used with an initial learning rate of 0.01 and a final learning rate of 0.0001, which decreased linearly with training. The input image size was fixed at 640×640 pixels. The loss function consisted of a weighted sum of three parts: the rotated bounding box regression loss, the classification loss, and the distribution focus loss. The total loss of the loss function was: in, Total loss; The ProbIoU rotation box regression loss is based on the Bhattacharyya distance between Gaussian distributions; The binary cross-entropy classification loss is used. For distribution focus loss; , and These are the weight coefficients corresponding to the rotation box regression loss, classification loss, and distribution focus loss, respectively.

[0027] The rotation bounding box regression loss is calculated based on ProbIoU: In the formula, Weights for the target scores obtained during the sample allocation phase; For positive sample index; and The first The predicted and actual rotated boxes corresponding to each positive sample; This represents the function for measuring the overlap of the rotated boxes.

[0028] The classification loss uses binary cross-entropy, and the calculation formula is as follows: in, For real category labels; The predicted value output for the classification branch; This is the Sigmoid function.

[0029] The distributed focus loss is used to refine the bounding box regression, and the calculation formula is as follows: In the formula, For true continuous target values; The left boundary of the interval containing the target value; The right boundary of the interval containing the target value; To predict the probability of falling into the left interval; To predict the probability of falling into the right-hand interval.

[0030] S103 inputs the test set into the optimal lightweight scallion laying posture detection model for detection, and outputs the parameters and posture category of the rotating box.

[0031] In this embodiment, scallion images from the test set are input to the input end of the optimal lightweight scallion laying posture detection model according to a preset input size to obtain the input image to be detected. The input image to be detected is then input to the backbone network, sequentially passing through multiple levels of convolutional downsampling layers and multiple C2f_Faster feature extraction modules for feature extraction, resulting in shallow high-resolution features, mid-level semantic features, and high-level semantic features. The C2f_Faster feature extraction module segments the input features along the channel dimension, and the calculation formula is as follows: in, For the portion of channels that participate in spatial convolution, accounting for 1 / 4, The channels that are directly reserved account for 3 / 4.

[0032] 3×3 spatial convolution is performed only on a subset of channels, while the remaining channels are directly passed through an identity mapping. This fully utilizes the feature redundancy between channels, significantly reducing the number of parameters and computational cost while maintaining feature expressiveness. The formula for spatial convolution is as follows: In the formula, This represents the number of floating-point operations required during the partial convolution process, with the input feature map size being [size missing]. The number of channels is The kernel size is Compared to standard convolution, PartialConv significantly reduces computational cost.

[0033] The convolutional results are concatenated with the retained results and channels are fused to obtain lightweight feature extraction results. The concatenated features after processing by PartialConv are as follows: in, This represents the feature concatenation result after PartialConv processing; This indicates a feature concatenation operation performed along the channel dimension; This represents a 3×3 convolution operation; This represents the partial channel features involved in the spatial convolution calculation; This represents the remaining channel features directly preserved through identity mapping.

[0034] The final calculation formula for the output through residual connection is: in, This indicates the characteristics of the output after residual connection; Represents input features; This indicates a partial convolution operation; This represents the feature transformation operation of a multilayer perceptron; This indicates that the regularization operation discards random paths. This represents the residual join operation, which involves adding elements one by one.

[0035] High-level semantic features are input into the SPPF_LSKA global context enhancement module. First, multi-scale pooling and feature concatenation are performed through the SPPF feature aggregation branch to obtain multi-scale context fusion features. Then, spatial attention weights are generated through the LSKA attention enhancement branch. These spatial attention weights are then multiplied element-wise with the multi-scale context fusion features to obtain the global context enhancement features. The calculation formula is as follows: in, This represents the output features after processing by the LSKA attention enhancement branch; This represents the multi-scale context fusion feature output by the SPPF feature aggregation branch; Indicates by Spatial attention weights generated by 1×1 convolution; express Intermediate features after 1×3 depthwise convolution; express Intermediate features after 3×1 depthwise convolution; express Intermediate features after processing by a 1×5 depthwise convolution with a dilation rate of 2; express Intermediate features after processing by a 5×1 depthwise convolution with a dilation rate of 2; This represents a 1×1 convolution operation used to generate spatial attention weights; Indicates a depthwise convolution operation; This represents a depthwise convolution with a kernel size of 1×3; This represents a depthwise convolution with a kernel size of 3×1; This represents a depthwise convolution with a kernel size of 1×5 and a dilation rate d of 2. This represents a depthwise convolution with a kernel size of 5×1 and a dilation rate d of 2; d represents the dilation rate of the dilated convolution. This indicates element-wise multiplication.

[0036] Shallow high-resolution features, mid-level semantic features, and global context enhancement features are input into the neck network for multi-scale feature fusion, resulting in a first-scale fused feature map, a second-scale fused feature map, and a third-scale fused feature map.

[0037] The first-scale fused feature map, the second-scale fused feature map, and the third-scale fused feature map are respectively input into the corresponding OBB-LSDECD detail enhancement rotating detection head. Detail enhancement is performed on each scale fused feature map through a shared detection branch to obtain the enhanced inspection features. The calculation formula is as follows: in, Indicates the first Scale-fused feature map; Represents the fused feature map Intermediate features after 1×1 convolution and group normalization (GN) processing; Indicates Enhanced detection features after processing by the detail enhancement module; This represents a feature transformation operation consisting of 1×1 convolution and group normalization. This indicates that the detail enhancement operations of differential augmented convolution and group normalization are performed on the input features; Indicates the feature scale index. These correspond to fused feature maps at different scales.

[0038] The enhanced detection features are input into the bounding box regression branch, the category prediction branch, and the angle prediction branch, respectively. The bounding box regression branch outputs the center coordinates, width, and height of the rotating box of the scallion target. The category prediction branch outputs the pose category prediction result of the scallion target. The angle prediction branch outputs the rotation angle prediction result.

[0039] The bounding box regression branch and the category prediction branch output the following respectively: in, This represents the predicted parameters of the rotated box output from the bounding box regression branch; This represents the pose category prediction result output by the category prediction branch; This indicates the enhanced detection features after processing by the DEConv-GN detail enhancement module; This represents a 1×1 convolution operation, used to linearly map input features and generate prediction results for the corresponding branches; Indicates the feature scale index.

[0040] The angle prediction branch is mapped to the range [-π / 4, 3π / 4] via the Sigmoid function: in, To predict the target's rotation angle; For angle prediction branch output; Use the Sigmoid activation function; Pi is a constant.

[0041] The DEConv_GN module internally fuses five types of differential convolutions: In the formula, Represents the central difference convolution feature. Represents horizontal difference convolution features. This represents the vertical difference convolution feature. Represents angular difference convolution features. This represents the features of a regular convolution branch.

[0042] Output after normalization and activation: Finally, the outputs of the bounding box regression branch, class prediction branch, and angle prediction branch are decoded to obtain the rotation box parameters and pose categories corresponding to the various onion targets in the test set. The calculation formula is as follows: in, This represents the set of parameters for the predicted rotating box corresponding to the target; The x-coordinate represents the predicted center point of the rotating frame; This represents the ordinate of the predicted center point of the rotating frame; This indicates the width of the predicted rotating frame; This indicates the predicted height of the rotating frame; This indicates the predicted rotation angle of the rotating frame.

[0043] S104, determine the adjustment direction and magnitude of the conveyor belt speed according to the parameters of the rotating frame and the posture category.

[0044] In this embodiment, the center coordinates, width, height, rotation angle, and attitude category of the rotating frame are obtained. The adjustment direction of the conveyor belt speed is determined according to the attitude category. When the attitude category is tilted to the left, the conveyor belt speed is increased; when the attitude category is tilted to the right, the conveyor belt speed is decreased; when the attitude category is normal, the current conveyor belt speed is maintained. The adjustment range of the conveyor belt is determined according to the value of the rotation angle, thereby realizing closed-loop quantitative control.

[0045] In addition, the detection method of this application was verified. The operating system of this embodiment is Windows 10, the hardware platform uses an Intel Core i9-7920X processor and an NVIDIA Quadro P4000 graphics card (8GB video memory), and the deep learning framework is PyTorch.

[0046] Following the aforementioned technical solution, a single-stalk scallion image dataset was constructed, primarily sourced from *Iron Ginger* scallions from Tai'an City, Shandong Province, China. During data acquisition, the camera was fixedly mounted above the work platform, with the lens approximately 0.78–0.84 m above the ground. A total of 1500 scallion images covering different placement angles and postures were acquired, labeled as normal, left-skewed, and right-skewed. The dataset was divided into a 7:2:1 ratio: a training set of 1050 images, a validation set of 300 images, and a test set of 150 images.

[0047] Subsequently, a GOPD-YOLO network model was constructed. The backbone and neck network replaced the original C2f modules with C2f_Faster feature extraction modules. The SPPF module at the end of the backbone network was embedded with an LSKA mechanism to form an SPPF_LSKA module. The detection head adopted an OBB-LSDECD structure. The improved model has 2.38M parameters, 3.3 GFLOPs of computation, and a model file size of only 4.9 MB.

[0048] During model training, the SGD optimizer was used with a momentum of 0.937, weight decay of 0.0005, an initial learning rate of 0.01, a final learning rate of 0.0001, and linear decay. The input image size was fixed at 640×640 pixels. The loss function consisted of a weighted average of ProbIoU bounding box regression loss, BCE classification loss, and DFL loss. The training run consisted of 100 epochs. The loss curve during training is shown below. Figure 5 As shown, Figure 5 In the figure, (a) represents the training set box loss, (b) represents the training set classification loss, (c) represents the training set DFL loss, (d) represents the validation set box loss, (e) represents the validation set classification loss, and (f) represents the validation set DFL loss. The original curve represents the actual loss change in each round during training, and the smoothed curve represents the loss change trend after smoothing. As can be seen from the figure, the training set box loss, training set classification loss, and training set DFL loss all show a rapid decreasing trend in the early stage of training, and then gradually tend to stabilize. At the same time, the validation set box loss, validation set classification loss, and validation set DFL loss also gradually converge and remain stable, without showing a significant upward trend. This indicates that the improved model has not experienced significant overfitting and has good convergence and stability.

[0049] The performance of the improved model was evaluated on the test set. The performance evaluation results on the test set are as follows: Figure 6 and Figure 7 As shown, Figure 6 In the diagram, precision represents the proportion of correctly predicted samples in the detection results, and recall represents the proportion of true targets that are correctly detected. mAP@0.5 represents the average precision under the condition that the intersection-over-union (IoU) threshold is 0.5. The closer the curve is to the upper right corner, the better the detection performance. Normal placement, left-tilted placement, and right-tilted placement represent three types of scallion placement postures, respectively.

[0050] Figure 7 In the model, confidence level represents the reliability of the model's predictions, while precision represents the proportion of correctly predicted samples. The precision-recall curves for each category show that the mAP@0.5 for normal placement, left-tilt placement, and right-tilt placement reaches 0.873, 0.940, and 0.982, respectively, with an overall mAP@0.5 of 0.932. The precision-confidence curve shows that when the confidence level reaches 0.905, the overall precision of the model approaches 1.0, indicating that the model has an extremely low false positive rate for high-confidence predictions.

[0051] Confusion matrix as follows Figure 8 As shown, the model achieved recall rates of 90%, 87%, and 97% for normal, left-tilted, and right-tilted placement categories, respectively. The mutual misclassification rates between the left-tilted and right-tilted placement categories were low, indicating that the OBB-LSDECD detail enhancement detector head can effectively capture the pose and orientation features of scallions. A visualization of the prediction results is provided below. Figure 9 As shown, Figure 9 In the figures, (a), (c), (e), and (g) are the model prediction results, and (b), (d), (f), and (h) are the actual annotation results for the corresponding samples. As can be seen from the figures, the prediction boxes of the improved model maintain a high degree of consistency with the actual annotations, and can accurately represent the pose direction and tilt angle of the scallion target.

[0052] To verify the effectiveness of each module, ablation experiments were conducted. Based on the YOLOv8-OBB framework, the experiments analyzed three aspects: the C2f_Faster feature extraction module, the SPPF_LSKA global context enhancement module, and the OBB-LSDECD detail enhancement rotation detection head. The contribution of each module to the model's detection performance was quantified through single-module, dual-module, and multi-module combinations. The ablation experiment results are shown in Table 1 and... Figure 10 As shown, Figure 10In this context, a single module combination represents the detection performance after introducing the C2f_Faster feature extraction module, the SPPF_LSKA global context enhancement module, or the OBB-LSDECD rotating detection head module, respectively; a dual module combination represents the detection performance after introducing two improved modules simultaneously; and all modules (GOPD-YOLO) represent the detection performance after introducing all improved modules simultaneously.

[0053] Table 1 Ablation Experiment Results In single-module experiments, C2f_Faster and SPPF_LSKA achieved mAP@0.5 of 94.2% and 94.3%, respectively. With only the OBB-LSDECD detector head included, mAP@0.5 was only 71.7%, indicating that relying solely on detector head enhancement is insufficient without high-quality feature support. In dual-module combinations, the combination of C2f_Faster and OBB-LSDECD performed best, achieving mAP@0.5 of 95.5% with only 1.67M parameters. With all three modules included, mAP@0.5 reached 96.4%, the highest among all ablation schemes, fully demonstrating the good synergistic and complementary effects among the three modules.

[0054] Table 2. Comparison results of different YOLO-OBB models on the scallion pose detection dataset. The improved model GOPD-YOLO of this application was compared with YOLOv8n / s / m / l-OBB and YOLOv11n / s-OBB under the same conditions, and the results are shown in Table 2. The parameter counts of different models and their correlation with mAP@0.5 are shown in Table 2. Figure 11As shown in the figure, the number of parameters represents the number of trainable parameters in the model, mAP@0.5 represents the mean accuracy under an IoU threshold of 0.5, and YOLOv8n, YOLOv8s, YOLOv8m, YOLOv8l, YOLOv11n, YOLOv11s, and GOPD-YOLO represent the object detection models compared. GOPD-YOLO achieved the highest mAP@0.5 (0.9342) with the smallest number of parameters (2.38M) and computational cost (3.3 GFLOPs). Compared to YOLOv8n-OBB, the number of parameters is reduced by 22.7%, the computational cost is reduced by 21.4%, the model size is compressed from 6.3 MB to 4.9 MB, a reduction of 22.2%, and the recall is improved by 3.8 percentage points. Compared to YOLOv11n-OBB, with the same computational cost, GOPD-YOLO further reduces the number of parameters by 10.5% and the model size by 10.9%. The results show that the method in this application achieves excellent overall performance in terms of detection accuracy, lightweight design, recall, and real-time performance.

[0055] Taking a scallion image as an example in this embodiment, the model outputs a leftward tilt posture category with a rotation angle θ = 15.3°. The control system determines the need to increase the conveyor belt speed based on the posture category and determines the increase amount based on the angle value of 15.3°, for example, increasing the conveyor belt speed by 7.65% using a scaling factor of 0.5. If the detection result is normal (θ ≈ 0°), the current conveyor belt speed is maintained. Through this closed-loop control mechanism, the scallion harvester can adjust the conveyor belt speed in real time to keep the scallions laid out laterally as much as possible.

[0056] In this embodiment, "multiple" refers to two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent the existence of A alone, the simultaneous existence of A and B, or the existence of B alone. A and B can be singular or plural. The character " / " generally indicates that the preceding and following related objects have an "or" relationship.

[0057] The above description is merely a specific embodiment of this application. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the protection scope of this application. The protection scope of this application should be determined by the protection scope of the claims.

Claims

1. A lightweight method for detecting the laying posture of scallions in a scallion harvester, characterized in that, include: A dataset of scallion images was acquired and preprocessed. The dataset was then labeled using rotated bounding boxes, and the labeled dataset was divided into a training set, a validation set, and a test set. The pre-built GOPD-YOLO model was trained using the training set and validated using the validation set to obtain the optimal lightweight scallion laying posture detection model. The GOPD-YOLO model includes an input terminal, a backbone network, a neck network, and a detection head. The input terminal receives an image of scallion spread to be detected and inputs the image to the backbone network. The backbone network includes a first convolutional downsampling layer, a first C2f_Faster feature extraction module, a second convolutional downsampling layer, a second C2f_Faster feature extraction module, a third convolutional downsampling layer, a third C2f_Faster feature extraction module, a fourth convolutional downsampling layer, a fourth C2f_Faster feature extraction module, and an SPPF_LSKA global context enhancement module, all connected in sequence. The second C2f_Faster feature extraction module, the third convolutional downsampling layer, and the SPPF_LSKA global context enhancement module output backbone features of different scales to the neck network, respectively. The neck network comprises a first upsampling layer, a first feature splicing layer, a fifth C2f_Faster feature extraction module, a second upsampling layer, a second feature splicing layer, a sixth C2f_Faster feature extraction module, a fifth convolutional downsampling layer, a third feature splicing layer, a seventh C2f_Faster feature extraction module, a fourth feature splicing layer, and an eighth C2f_Faster feature extraction module, connected in sequence. The second C2f_Faster feature extraction module is connected to the second feature concatenation layer, the third convolutional downsampling layer is connected to the first feature concatenation layer, the SPPF_LSKA global context enhancement module is connected to the first upsampling layer and the fourth feature concatenation layer respectively, the sixth C2f_Faster feature extraction module is connected to the first OBB-LSDECD detail enhancement rotation detection head, the seventh C2f_Faster feature extraction module is connected to the second OBB-LSDECD detail enhancement rotation detection head, and the eighth C2f_Faster feature extraction module is connected to the third OBB-LSDECD detail enhancement rotation detection head. The test set is input into the optimal lightweight scallion laying posture detection model for detection, and the parameters and posture categories of the rotating box are output. The adjustment direction and magnitude of the conveyor belt speed are determined based on the parameters of the rotating frame and the attitude category, including: Obtain the center coordinates, width, height, rotation angle, and pose category of the rotating bounding box; The direction of conveyor belt speed adjustment is determined based on the posture category; When the posture category is left tilt, increase the conveyor belt speed; when the posture category is right tilt, decrease the conveyor belt speed; when the posture category is normal, maintain the current conveyor belt speed, and determine the adjustment range of the conveyor belt according to the value of the rotation angle.

2. The lightweight scallion laying posture detection method for a scallion harvester according to claim 1, characterized in that, The rotated bounding box uses multiple parameters to represent the target's position and orientation, and the calculation formula is as follows: Where B represents the set of parameters of the rotated bounding box; The coordinates of the target center point; The width of the rotated bounding box; This represents the height of the rotated bounding box; The rotation angle of the target relative to the reference axis.

3. The lightweight scallion laying posture detection method for a scallion harvester according to claim 1, characterized in that, The C2f_Faster feature extraction module includes a first convolutional unit, a channel segmentation unit, a FasterBlock processing unit, a feature concatenation unit, and a second convolutional unit connected in sequence. The Faster Block processing unit includes multiple Faster Blocks, each of which includes a partial convolutional unit, a concatenation unit, a third convolutional unit, a fourth convolutional unit, a fifth convolutional unit, and a residual connection unit. The concatenation unit is used to concatenate the input features of the Faster Block with the features output by the partial convolutional units, and the residual connection unit is used to perform residual fusion between the features output by the concatenation unit and the features output by the fifth convolutional unit.

4. The lightweight scallion laying posture detection method for a scallion harvester according to claim 1, characterized in that, The SPPF_LSKA global context enhancement module includes: an SPPF feature aggregation branch and an LSKA attention enhancement branch; the SPPF feature aggregation branch includes a first convolutional layer, multiple max pooling layers, a fifth feature concatenation layer, and a second convolutional layer connected in sequence; the LSKA attention enhancement branch includes a first deep convolutional layer, a second deep convolutional layer, a first dilated convolutional layer, a second dilated convolutional layer, and a third convolutional layer connected in sequence, the second convolutional layer being connected to the first deep convolutional layer, and the output of the LSKA attention enhancement branch is provided with an element-wise multiplication unit.

5. The lightweight scallion laying posture detection method for a scallion harvester according to claim 1, characterized in that, The loss function used when training the GOPD-YOLO model is: in, Total loss; The ProbIoU rotation box regression loss is based on the Bhattacharyya distance between Gaussian distributions; The binary cross-entropy classification loss is used. For distribution focus loss; , and These are the weight coefficients corresponding to the rotation box regression loss, classification loss, and distribution focus loss, respectively. Weights for the target scores obtained during the sample allocation phase; For positive sample index; and The first The predicted and actual rotated boxes corresponding to each positive sample; For real category labels; The predicted value output for the classification branch; For the Sigmoid function; For true continuous target values; and These are the left and right discrete boundaries of the interval containing the true continuous target value, respectively. and These represent the probabilities that the predicted value falls into the left and right discrete intervals, respectively.

6. The lightweight scallion laying posture detection method for a scallion harvester according to claim 1, characterized in that, The test set is input into the optimal lightweight scallion laying posture detection model for detection, and the parameters and posture categories of the rotated bounding box are output, including: The scallion images in the test set are input to the input end of the optimal lightweight scallion laying posture detection model according to the preset input size to obtain the input image to be detected; The input image to be detected is input into the backbone network, and then passes through multiple levels of convolutional downsampling layers and multiple C2f_Faster feature extraction modules for feature extraction, resulting in shallow high-resolution features, mid-level semantic features, and high-level semantic features. The C2f_Faster feature extraction module segments the input features along the channel dimension, performs spatial convolution only on a subset of channels, and preserves the remaining channels using identity mapping. The formula for calculating spatial convolution is: in, This indicates the number of floating-point operations required during the execution of a partial convolution; and These represent the height and width of the input feature map, respectively. This indicates the number of channels in the input feature map; This represents the side length of the convolution kernel; The convolutional results are concatenated with the preserved results and channels are fused to obtain lightweight feature extraction results; The high-level semantic features are input into the SPPF_LSKA global context enhancement module. First, multi-scale pooling and feature concatenation are performed through the SPPF feature aggregation branch to obtain multi-scale context fusion features. Then, spatial attention weights are generated through the LSKA attention enhancement branch. The spatial attention weights are multiplied element-wise with the multi-scale context fusion features to obtain global context enhancement features. The shallow high-resolution features, mid-level semantic features, and global context enhancement features are input into the neck network for multi-scale feature fusion to obtain a first-scale fused feature map, a second-scale fused feature map, and a third-scale fused feature map. The first scale fusion feature map, the second scale fusion feature map and the third scale fusion feature map are respectively input into the corresponding OBB-LSDECD detail enhancement rotating detection head. The detail enhancement of each scale fusion feature map is performed through the shared detection branch to obtain the enhanced inspection features. The enhanced detection features are input into the bounding box regression branch, the category prediction branch, and the angle prediction branch, respectively. The bounding box regression branch outputs the center coordinates of the rotating box, the width of the rotating box, and the height of the rotating box of the scallion target. The pose category prediction result of the scallion target is output through the category prediction branch, and the rotation angle prediction result is output through the angle prediction branch. The outputs of the bounding box regression branch, category prediction branch, and angle prediction branch are decoded to obtain the rotation box parameters and pose categories corresponding to the various onion targets in the test set.

7. The lightweight scallion laying posture detection method for a scallion harvester according to claim 6, characterized in that, The formula for calculating the enhanced inspection features obtained by performing detail enhancement on the fused feature maps at each scale through shared detection branches is as follows: in, Indicates the first Scale-fused feature map; Represents the fused feature map Intermediate features after 1×1 convolution and group normalization; Indicates Enhanced detection features after processing by the detail enhancement module; This represents a feature transformation operation consisting of 1×1 convolution and group normalization. This indicates that the detail enhancement operations of differential augmented convolution and group normalization are performed on the input features; Indicates the feature scale index. These correspond to fused feature maps at different scales.

8. The lightweight scallion laying posture detection method for a scallion harvester according to claim 6, characterized in that, Spatial attention weights are generated through the LSKA attention enhancement branch, and these spatial attention weights are multiplied element-wise with the multi-scale context fusion features to obtain the global context enhancement feature calculation formula: in, This represents the output features after processing by the LSKA attention enhancement branch; This represents the multi-scale context fusion feature output by the SPPF feature aggregation branch; Indicates spatial attention weights; express Intermediate features after 1×3 depthwise convolution; express Intermediate features after 3×1 depthwise convolution; express Intermediate features after processing by a 1×5 depthwise convolution with a dilation rate of 2; express Intermediate features after processing by a 5×1 depthwise convolution with a dilation rate of 2; This represents a 1×1 convolution operation used to generate spatial attention weights; Indicates a depthwise convolution operation; This represents a depthwise convolution with a kernel size of 1×3; This represents a depthwise convolution with a kernel size of 3×1; This represents a depthwise convolution with a kernel size of 1×5 and a dilation rate d of 2. This represents a depthwise convolution with a kernel size of 5×1 and a dilation rate d of 2; d represents the dilation rate of the dilated convolution. This indicates element-wise multiplication.

Citation Information

Patent Citations

  • 3D printing defect detection method based on improved YOLOv10n

    CN121169830A

  • Improved YOLOv8n-based old people tumble detection method and system in complex light and shadow environment

    CN121861727A