A strawberry fruit detection system and method based on improved YOLOv8n network

By improving the optimization of YOLOv8n network structure and loss function, the contradiction between the parameter quantity and detection accuracy of the computer vision fruit detection model is solved, and efficient and accurate automatic detection of strawberry fruit detection is achieved.

CN120299034BActive Publication Date: 2025-09-05HEZHOU UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510462519.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-04-14
Publication Date
2025-09-05
Estimated Expiration
2045-04-14

AI Technical Summary

Technical Problem

The existing computer vision fruit detection model has high calculation cost under high parameters, and the detection accuracy is insufficient in lightweight models, resulting in low detection efficiency and high false detection rate, making it difficult to achieve efficient and accurate automated detection in strawberry fruit detection.

Method used

The improved YOLOv8n network structure is adopted, including the backbone network, the neck network and the prediction head network. Through the receptive field attention convolution module, the cross-stage double convolution feature fusion module, the extrusion excitation network and the multi-scale parallel convolution feature fusion module, the feature extraction and prediction process are optimized, and the dynamic weighted cross-comparison loss function optimization training process is introduced.

Benefits of technology

It significantly improves the detection performance and accuracy of strawberry fruit detection, reduces calculation costs, improves the generalization ability and real-time nature of the model, and solves the bottlenecks in speed and performance of traditional models.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120299034B_ABST
    Figure CN120299034B_ABST
Patent Text Reader

Abstract

The present invention discloses a strawberry fruit detection system and method based on an improved YOLOv8n network, wherein the improved YOLOv8n network structure includes a backbone network, a neck network, and a prediction head network connected in sequence. A receptive field attention convolution module is used in the backbone network to replace the standard convolution, thereby improving network performance and significantly improving detection performance in strawberry fruit detection. At the same time, the introduction of a squeeze excitation network strengthens the backbone network's ability to learn strawberry color and shape features. At the same time, the optimized decoupling head design of YOLOv8 better adapts to the needs of classification and regression tasks, avoids interference that may be caused by shared parameters, and improves the accuracy and generalization ability of the model. In addition, a multi-scale parallel convolution cross-stage double convolution feature fusion module maintains a large receptive field while reducing memory access costs, reducing computational costs and improving efficiency, thereby solving the bottleneck problem of traditional models in speed and performance.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of computer vision technology, and in particular relates to a strawberry fruit detection system and method based on an improved YOLOv8n network. Background Art

[0002] With the rapid development of agricultural technology, modern agricultural production management models centered on intelligence and automation are increasingly becoming the mainstream direction of industry development. As a representative high-value-added cash crop, strawberries have attracted considerable attention due to their short growth cycle and strong market demand. However, their production has long faced challenges such as inefficient manual harvesting, high labor costs, and difficulty in quality control. In particular, traditional manual inspection methods are not only inefficient and labor-intensive, but also susceptible to subjective judgment, making it difficult to guarantee the objectivity and accuracy of test results.

[0003] Therefore, existing technologies have replaced manual inspection with computer vision, effectively improving fruit detection efficiency and reducing harvesting costs. YOLOv8, an integrated and improved version of the YOLO family, utilizes an anchor-free detection mechanism that directly predicts object centers rather than relying on predefined anchor boxes. This simplifies training and accelerates the post-processing step of non-maximum suppression (NMS), improving detection speed and accuracy. However, in the practical application of the YOLOv8 network to fruit detection, increasing the number of model parameters generally improves feature extraction capabilities and enhances detection accuracy for small fruit objects or complex occlusions. However, overly large models can increase computational costs, impact real-time performance, and increase the risk of overfitting. Especially when training data is limited, lightweight models, while having fewer parameters and faster inference speed, may have reduced ability to distinguish densely packed fruit or morphologically similar distractors (such as leaves) due to insufficient feature representation, resulting in missed or false detections. This leads to a conflicting relationship between the number of model parameters and detection accuracy in existing computer vision fruit detection models. Summary of the Invention

[0004] The technical problem to be solved by the present invention is to overcome the defects of the computer vision fruit detection method in the prior art, such as high computational cost in high-parameter models and insufficient detection accuracy in lightweight models, thereby providing a strawberry fruit detection system and method based on an improved YOLOv8n network.

[0005] An improved YOLOv8n network structure for strawberry fruit detection, including a backbone network (Backbone), a neck network (Neck), and a prediction head network (Head) connected in sequence;

[0006] The backbone network includes a connected receptive field attention convolution module (RFAConv), a cross-stage dual convolution feature fusion module (C2f), a squeeze excitation network (SENet), and a fast spatial pyramid pooling module (SPPF); the receptive field attention convolution module is used to obtain feature maps in the height and width directions of the input feature map, form an attention weight map based on the feature maps in the height and width directions, and use it to weight the input feature map to form an output feature map; the cross-stage dual convolution feature fusion module is used to extract a basic feature map from the input feature map, pass the basic feature map through the bottleneck layer to generate a deep feature map, and fuse the basic feature map with the deep feature map to form an output feature map; the squeeze excitation network is used to adjust the weights of each channel of the input feature map through the channel attention mechanism to obtain the output feature map; the fast spatial pyramid pooling module is used to pool the input feature map multiple times, and splice the input feature map and the pooling result along the channel dimension to form an output feature map;

[0007] The neck network includes a connected multi-scale parallel convolution cross-stage double convolution feature fusion module (C2f_InceptionNext), a feature splicing module (Concat), an upsampling module (Upsample), and a standard convolution module (Conv); the multi-scale parallel convolution cross-stage double convolution feature fusion module is used to extract a basic feature map from the input feature map, pass the basic feature map through a multi-scale parallel convolution layer to generate a multi-scale feature map, and fuse the basic feature map with the multi-scale feature map to form an output feature map; the feature splicing module is used to splice the feature maps output by different branches to form a spliced ​​feature map; the upsampling module is used to improve the resolution of the input feature map to form an output feature map; the standard convolution module is used to convolve the input feature map to form an output feature map;

[0008] The prediction head network includes multiple detection head modules (Detect); the detection head module is used to receive the feature map output by the neck network and form an original prediction value, including a bounding box, confidence and category probability.

[0009] Furthermore, the backbone network includes a first receptive field attention convolution module, a second receptive field attention convolution module, a first cross-stage dual convolution feature fusion module, a third receptive field attention convolution module, a second cross-stage dual convolution feature fusion module, a fourth receptive field attention convolution module, a third cross-stage dual convolution feature fusion module, a fifth receptive field attention convolution module, a fourth cross-stage dual convolution feature fusion module, and a fast spatial pyramid pooling module, which are connected in sequence.

[0010] Furthermore, the neck network includes a first upsampling module, a first feature splicing module, a first multi-scale parallel convolution cross-stage dual convolution feature fusion module, a second upsampling module, a second feature splicing module, a second multi-scale parallel convolution cross-stage dual convolution feature fusion module, a first standard convolution module, a third feature splicing module, a third multi-scale parallel convolution cross-stage dual convolution feature fusion module, a second standard convolution module, a fourth feature splicing module, and a fourth multi-scale parallel convolution cross-stage dual convolution feature fusion module, which are connected in sequence; the first upsampling module is connected to the output end of the fast spatial pyramid pooling module, the first feature splicing module is connected to the output end of the third cross-stage dual convolution feature fusion module, the second feature splicing module is connected to the output end of the second cross-stage dual convolution feature fusion module, the third feature splicing module is connected to the output end of the first multi-scale parallel convolution cross-stage dual convolution feature fusion module, and the fourth feature splicing module is connected to the output end of the fast spatial pyramid pooling module.

[0011] Furthermore, the prediction head network includes a first detection head module, a second detection head module, and a third detection head module; the first detection head module is connected to the output end of the second multi-scale parallel convolution cross-stage double convolution feature fusion module, the second detection head module is connected to the output end of the third multi-scale parallel convolution cross-stage double convolution feature fusion module, and the third detection head module is connected to the output end of the fourth multi-scale parallel convolution cross-stage double convolution feature fusion module.

[0012] Furthermore, the receptive field attention convolution module is used to: expand the number of channels through group convolution operation; adjust the feature map size through normalization and nonlinear activation function ReLU processing; perform average pooling operations on the feature map in the height and width directions respectively to generate an intermediate feature map; splice two intermediate feature maps, fuse them through a convolution layer, and generate a fused feature map; normalize and nonlinearly transform the fused feature map, divide it into two feature maps, generate an attention weight map through convolution operation and Sigmoid function respectively, weight the input feature map based on the attention weight map, and generate an output feature map through a convolution layer.

[0013] A strawberry fruit detection system based on an improved YOLOv8n network includes a preprocessing module, an improved YOLOv8n network, and a post-processing module; the preprocessing module is used to process an input image and generate an original feature map; the improved YOLOv8n network has the structure described above and is used to process the original feature map and obtain an original prediction value; the post-processing module is used to process the original prediction value and obtain a prediction result.

[0014] Furthermore, the preprocessing module includes a dimensional normalization unit and a numerical normalization unit; the dimensional normalization unit is used to adapt the image size of the input image to the preset input dimension of the improved YOLOv8n network, and the numerical normalization unit is used to constrain the pixel data distribution of the input image to the [0,1] interval through linear transformation of the pixel values.

[0015] Furthermore, the post-processing module includes a distance intersection-over-union (IoU) non-maximum suppression module, and the distance intersection-over-union (IoU) non-maximum suppression includes a sorting unit, an iterative selection unit, a distance intersection-over-union (IoU) calculation unit, and a filtering unit; the sorting unit is used to arrange the original prediction values ​​in descending order based on the confidence scores of the candidate boxes, the iterative selection unit is used to select the candidate boxes with the highest confidence scores that are not currently suppressed starting from the highest score and add them to the prediction results, the distance intersection-over-union (IoU) calculation unit is used to calculate the distance intersection-over-union (IoU) of the remaining candidate boxes and the candidate box with the highest confidence score, and the filtering unit is used to suppress the candidate boxes whose distance intersection-over-union (IoU) with the candidate box with the highest confidence score is greater than a preset threshold.

[0016] A strawberry fruit detection method based on an improved YOLOv8n network comprises the following steps: training the improved YOLOv8n network; inputting an input image into a strawberry fruit detection system based on the improved YOLOv8n network to obtain a prediction result, wherein the strawberry fruit detection system based on the improved YOLOv8n network is as described above; and using a dynamic weighted intersection-over-union loss function as the loss function for training the improved YOLOv8n network.

[0017] Furthermore, the loss function for training the improved YOLOv8n network is a dynamic weighted intersection-over-union loss function expressed as:

[0018] ;

[0019] in, represents the dynamic weighted intersection-over-union ratio, represents the power form of the intersection-over-union loss, γ represents the focusing parameter, represents the weight factor;

[0020] At a width of W g and height H g In the closed frame, and Represents the center coordinate of the prediction box, and Represents the center coordinate of the real box, and the weight factor is expressed as:

[0021] .

[0022] Beneficial effects: The present invention discloses a strawberry fruit detection system and method based on an improved YOLOv8n network, wherein the improved YOLOv8n network structure includes a backbone network, a neck network, and a prediction head network connected in sequence, the backbone network includes a connected receptive field attention convolution module, a cross-stage double convolution feature fusion module, a squeeze excitation network, and a fast spatial pyramid pooling module, and the neck network includes a multi-scale parallel convolution cross-stage double convolution feature fusion module, a feature splicing module, an upsampling module, and a standard convolution module; the receptive field attention convolution module replaces the standard convolution, improving network performance, and significantly improving detection performance in strawberry fruit detection; at the same time, the introduction of the squeeze excitation network strengthens the backbone network's ability to learn strawberry color and shape features, and at the same time, the optimized decoupling head design of YOLOv8 better adapts to the requirements of classification and regression tasks, avoids the interference that may be caused by shared parameters, and improves the accuracy and generalization ability of the model. In addition, the multi-scale parallel convolution cross-stage double convolution feature fusion module reduces memory access costs while maintaining a large receptive field, reducing computational costs and improving efficiency, solving the bottlenecks of traditional CNN in speed and performance. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.

[0024] Figure 1 This is a schematic block diagram of the structure of the strawberry fruit detection system of the present invention;

[0025] Figure 2 This is a schematic block diagram of the structure of the receptive field attention convolution module of the improved YOLOv8n network of the present invention;

[0026] Figure 3 A schematic block diagram of the structure of the squeeze excitation network of the improved YOLOv8n network of the present invention;

[0027] Figure 4 This is a schematic block diagram of the structure of the multi-scale parallel convolutional layer of the improved YOLOv8n network of the present invention.

[0028] Figure 5 This is a schematic block diagram of the structure of the cross-stage dual convolution feature fusion module of the improved YOLOv8n network of the present invention. DETAILED DESCRIPTION

[0029] To make the above-mentioned objects, features, and advantages of the present application more clearly understood, the specific embodiments of the present application are described in detail below with reference to the accompanying drawings. The following description sets forth many specific details to facilitate a full understanding of the present application. However, the present application can be implemented in many other ways than those described herein, and those skilled in the art can make similar improvements without violating the scope of the present application. Therefore, the present application is not limited to the specific embodiments disclosed below.

[0030] In the description of this application, it should be understood that the terms "first" and "second" are used for descriptive purposes only and should not be understood to indicate or imply relative importance or implicitly specify the number of technical features indicated. Therefore, a feature defined as "first" or "second" may explicitly or implicitly include at least one of such features. In the description of this application, "plurality" means at least two, for example, two, three, etc., unless otherwise specifically defined.

[0031] Example 1:

[0032] Reference Figures 1 to 4 As shown, this embodiment provides an improved YOLOv8n network structure for strawberry fruit detection, including a backbone network (Backbone), a neck network (Neck), and a prediction head network (Head) connected in sequence;

[0033] The backbone network includes a connected receptive field attention convolution module (RFAConv), a cross-stage dual convolution feature fusion module (C2f), a squeeze excitation network (SENet), and a fast spatial pyramid pooling module (SPPF); the receptive field attention convolution module is used to obtain feature maps in the height and width directions of the input feature map, form an attention weight map based on the feature maps in the height and width directions, and use it to weight the input feature map to form an output feature map; the cross-stage dual convolution feature fusion module is used to extract a basic feature map from the input feature map, pass the basic feature map through the bottleneck layer to generate a deep feature map, and fuse the basic feature map with the deep feature map to form an output feature map; the squeeze excitation network is used to adjust the weights of each channel of the input feature map through the channel attention mechanism to obtain the output feature map; the fast spatial pyramid pooling module is used to pool the input feature map multiple times, and splice the input feature map and the pooling result along the channel dimension to form an output feature map;

[0034] The neck network includes a connected multi-scale parallel convolution cross-stage double convolution feature fusion module (C2f_InceptionNext), a feature splicing module (Concat), an upsampling module (Upsample), and a standard convolution module (Conv); the multi-scale parallel convolution cross-stage double convolution feature fusion module is used to extract a basic feature map from the input feature map, pass the basic feature map through a multi-scale parallel convolution layer to generate a multi-scale feature map, and fuse the basic feature map with the multi-scale feature map to form an output feature map; the feature splicing module is used to splice the feature maps output by different branches to form a spliced ​​feature map; the upsampling module is used to improve the resolution of the input feature map to form an output feature map; the standard convolution module is used to convolve the input feature map to form an output feature map;

[0035] The prediction head network includes multiple detection head modules (Detect); the detection head module is used to receive the feature map output by the neck network and form an original prediction value, including a bounding box, confidence and category probability.

[0036] Specifically, the backbone network includes a first receptive field attention convolution module, a second receptive field attention convolution module, a first cross-stage dual convolution feature fusion module, a third receptive field attention convolution module, a second cross-stage dual convolution feature fusion module, a fourth receptive field attention convolution module, a third cross-stage dual convolution feature fusion module, a fifth receptive field attention convolution module, a fourth cross-stage dual convolution feature fusion module, and a fast spatial pyramid pooling module, which are connected in sequence.

[0037] The neck network includes a first upsampling module, a first feature splicing module, a first multi-scale parallel convolution cross-stage dual convolution feature fusion module, a second upsampling module, a second feature splicing module, a second multi-scale parallel convolution cross-stage dual convolution feature fusion module, a first standard convolution module, a third feature splicing module, a third multi-scale parallel convolution cross-stage dual convolution feature fusion module, a second standard convolution module, a fourth feature splicing module, and a fourth multi-scale parallel convolution cross-stage dual convolution feature fusion module, which are connected in sequence; the first upsampling module is connected to the output end of the fast spatial pyramid pooling module, the first feature splicing module is connected to the output end of the third cross-stage dual convolution feature fusion module, the second feature splicing module is connected to the output end of the second cross-stage dual convolution feature fusion module, the third feature splicing module is connected to the output end of the first multi-scale parallel convolution cross-stage dual convolution feature fusion module, and the fourth feature splicing module is connected to the output end of the fast spatial pyramid pooling module.

[0038] The prediction head network includes a first detection head module, a second detection head module, and a third detection head module; the first detection head module is connected to the output end of the second multi-scale parallel convolution cross-stage double convolution feature fusion module, the second detection head module is connected to the output end of the third multi-scale parallel convolution cross-stage double convolution feature fusion module, and the third detection head module is connected to the output end of the fourth multi-scale parallel convolution cross-stage double convolution feature fusion module.

[0039] In this embodiment, the receptive field attention convolution module is used to: input feature map size is C×H×W, and the number of channels is expanded to CK through group convolution operation 2 , so the new feature map size CK 2 ×H×W; resize the feature map to C×KH×W through normalization and ReLU nonlinear activation function processing; perform average pooling operations on the feature map in both height and width directions to generate an intermediate feature map; concatenate the two intermediate feature maps, with sizes of C×1×KW and C×KH×1, respectively, and fuse them through a convolutional layer to generate a fused feature map of size C×(KW + KH)×1; normalize and nonlinearly transform the fused feature map, splitting it into two feature maps, and generate attention weight maps based on the attention weight maps. The input feature map is weighted based on the attention weight maps, and the output feature map is generated through a convolutional layer. The receptive field attention convolution module introduces a dynamic receptive field mechanism and an attention mechanism, enabling the convolution operation to adaptively adjust the receptive field size, thereby better capturing target features of different scales. In this embodiment, the spatial features of the input feature map have a size of C×H×W and are composed of non-overlapping sliding windows. When a 3×3 convolution kernel is used to extract features, each 3×3 window in the receptive field spatial features represents a receptive field slider. The height and width of the converted receptive field spatial features are tripled, and the size is expanded to 3C×3H×3W. The receptive field area is expanded, thereby better capturing multi-scale information.

[0040] Reference Figure 5As shown, the cross-stage dual-convolutional feature fusion module is used to optimize feature extraction, enhancement, and multi-scale feature fusion. It extracts a basic feature map from the input feature map, passes it through a bottleneck layer to generate a deep feature map, and then fuses the basic and deep feature maps to form an output feature map. Specifically, it uses convolutional layers to extract basic features from the input feature map. The generated feature map is then split into two paths: one path is directly fed into the feature concatenation layer (Concat), while the other path is processed through multiple bottleneck layers for deep processing. The bottleneck layer, which includes convolution, normalization, and activation functions, excels at capturing complex features and is particularly suitable for objects at multiple scales and in complex backgrounds. Finally, the two feature paths are merged in the feature concatenation layer, effectively integrating multi-level information and improving the detection capability of multi-scale objects. The depth of the model is controlled by the depth_multiple parameter, which allows for flexible adjustment of the number of bottleneck layers to achieve the optimal balance between accuracy and computational complexity. By adjusting the number of bottleneck layers, the cross-stage dual-convolutional feature fusion module can dynamically optimize the network depth according to specific task requirements, making it suitable for scenarios with limited computing resources. In addition, the spliced ​​feature maps are processed by additional convolutional layers to enhance feature expression capabilities and provide high-quality input for subsequent tasks.

[0041] In this embodiment, the Squeeze-and-Excitation Network (SENet) is an innovative convolutional neural network architecture that incorporates an attention mechanism at the channel level. By modeling the dynamic dependencies between feature channels, this network significantly improves the model's representational capabilities and classification performance without significantly increasing the computational burden. Its core concept is to adaptively learn weight coefficients for each feature channel, thereby enhancing key features and suppressing redundant information. The Squeeze-and-Excitation Network achieves feature recalibration through two key operations: squeeze and excitation. In the squeeze phase, global average pooling aggregates the spatial information of each channel into a scalar representation to capture global context. Subsequently, the excitation phase utilizes fully connected layers and nonlinear activation functions to learn the complex dependencies between channels and generate adaptive weights. Ultimately, these weights dynamically adjust the original features, enabling the network to focus on the most discriminative features, significantly improving the model's expressive power.

[0042] Specifically, for any input X mapped to a feature map U∈ This work implements feature recalibration by constructing a squeeze-excitation network. This module adaptively adjusts the original feature map by dynamically learning channel attention weights. Its core process consists of two serial operations:

[0043] In the Squeeze operation, global information is embedded and global average pooling (GAP) is used to compress the spatial dimension (H×W) of the feature map U to generate a channel statistical descriptor z∈ This operation converts the two-dimensional feature response U∈ of each channel into Aggregated into a scalar representation, effectively capturing the global spatial distribution of channel features:

[0044] ;

[0045] The Squeeze operation eliminates redundant position-sensitive information by compressing the spatial dimension and constructs channel-level statistics with a global receptive field, providing a basis for subsequent channel correlation modeling.

[0046] Channel weights are generated in the Excitation operation, and an adaptive gating mechanism based on the bottleneck layer is designed to learn the nonlinear dependencies between channels through a two-layer fully connected network. Specifically: the first layer performs dimensionality reduction and applies ReLU activation, and the second layer restores the dimensionality and generates normalized weights s∈[0,1] through the Sigmoid function. C .

[0047] Finally, the learned channel weights s are applied to the original feature map U to obtain a recalibrated feature map, which is then input into the subsequent network layer. This gating mechanism enables the model to explicitly model channel importance, strengthen discriminative features, and suppress redundant information.

[0048] The squeeze-excitation network's attention mechanism achieves adaptive recalibration of feature channels by explicitly modeling inter-channel dependencies. Compared to traditional convolutional operations, this lightweight structure automatically assesses the importance of information across channels, selectively enhancing key features while suppressing redundant or interfering information. Integrating this mechanism into the YOLOv8n backbone network requires only a lightweight structure consisting of two fully connected layers after the convolutional layers. This mechanism achieves feature recalibration through global information aggregation and adaptive weight assignment. This improvement significantly enhances the model's sensitivity to subtle strawberry fruit features (such as surface texture and color variation due to maturity). This improvement is particularly effective in complex orchard environments, effectively distinguishing target features against similarly colored backgrounds and reducing false detections caused by foliage occlusion and illumination variations. Because the newly added structural parameters are relatively small compared to the original network, the detection model's feature discrimination and localization accuracy in dense fruit scenes are systematically optimized with minimal computational overhead.

[0049] Reference Figure 1As shown, in this embodiment, the backbone network structure contains a complex structure of ten layers, which can efficiently extract features. However, the introduction of a squeeze-excitation network in each layer will significantly increase the computational burden and model complexity, which is not ideal for application scenarios with limited resources. Therefore, in practical applications, it is necessary to weigh the performance improvement brought by the attention mechanism and the computational cost.

[0050] To balance the accuracy and efficiency of the model, this paper designed three schemes, adding the squeeze-excitation network to the first and third layers, the third and fifth layers, and the fifth and seventh layers, respectively. After comparative tests, the optimal introduction method was selected as the basis for subsequent model improvements, as shown in Table 1. In this embodiment, the introduction of the squeeze-excitation network is not counted in the number of layers of the backbone network.

[0051] Table 1: SENet improvement comparison experimental results

[0052]

[0053] As can be seen, through comparative experiments on optimization schemes at different levels of the YOLOv8n network architecture, this embodiment identifies the optimal improvement strategy for this dataset. Experimental results show that while adjustments to the shallow network (first and third layers) slightly improve the mean average precision (mAP50) by 0.12 percentage points, they result in decreases in detection precision (Precision) and recall (Recall) by 0.53% and 0.21%, respectively, indicating that shallow parameter optimization can easily lead to negative fluctuations in basic detection performance. In contrast, the deep network (fifth and seventh layers) optimization scheme demonstrates significant advantages, improving Precision by 0.55%, Recall by 0.73%, and achieving a breakthrough 0.83% improvement in mAP50. Notably, while improvements to the mid-layer network (third and fifth layers) increase Precision and Recall by 0.15% and 0.18%, respectively, they are accompanied by an unusual 0.35% decrease in mAP50, indicating that these layer adjustments weaken the model's ability to adapt to multi-scale objects. Based on the above-mentioned depth-dependent characteristics (deep optimization contributes 98.7% to the overall performance improvement), as the preferred embodiment of this invention, the fifth and seventh layers are finally selected as the integration positions of the squeeze excitation network to optimize the detection effect by enhancing the deep feature extraction capability.

[0054] In this embodiment, the multi-scale parallel convolutional layer (InceptionNeXt) integrates the multi-scale feature extraction mechanism of the classic Inception module with the large-kernel deep convolution design concept of ConvNeXt, achieving a balance between computational efficiency and model performance. The kernel decomposition strategy of the multi-scale parallel convolutional layer decouples the traditional large-size convolution kernel into a multi-path combination of small kernels while preserving the identity mapping property of key channels. Specifically, its core module uses a three-way parallel structure to process 3×3, 1×k, and k×1 convolution kernels, respectively. The remaining parts are directly transferred through the identity mapping, reducing memory access costs while maintaining a large receptive field. In the core network of this improved YOLOv8n network, the multi-scale parallel convolutional layer is introduced into the cross-stage dual convolutional feature fusion module, forming a multi-scale parallel convolution cross-stage dual convolutional feature fusion module. This module overcomes the speed and performance bottlenecks of the traditional model and achieves efficient image classification.

[0055] Example 2:

[0056] This embodiment provides a strawberry fruit detection system based on an improved YOLOv8n network, including a preprocessing module, an improved YOLOv8n network, and a post-processing module; the preprocessing module is used to process an input image and generate an original feature map; the improved YOLOv8n network has a structure as described in Example 1 and is used to process the original feature map to obtain an original prediction value; the post-processing module is used to process the original prediction value to obtain a prediction result.

[0057] Specifically, the preprocessing module includes a dimensional normalization unit and a numerical normalization unit; the dimensional normalization unit is used to adapt the image size of the input image to the preset input dimension of the improved YOLOv8n network, and the numerical normalization unit is used to constrain the pixel data distribution of the input image to the [0,1] interval through linear transformation of the pixel values.

[0058] In this embodiment, the post-processing module includes a distance intersection over union (DIoU-NMS) non-maximum suppression module, and the distance intersection over union (DIoU-NMS) non-maximum suppression includes a sorting unit, an iterative selection unit, a distance intersection over union (DIoU) calculation unit, and a filtering unit; the sorting unit is used to arrange the original prediction values ​​in descending order based on the confidence scores of the candidate boxes, the iterative selection unit is used to select the candidate boxes with the highest confidence scores that are not currently suppressed starting from the highest score and add them to the prediction results, the distance intersection over union (DIoU) calculation unit is used to calculate the distance intersection over union (DIoU) of the remaining candidate boxes and the candidate box with the highest confidence score, and the filtering unit is used to suppress the candidate boxes whose distance intersection over union (DIoU) with the candidate box with the highest confidence score is greater than a preset threshold.

[0059] Specifically, DIoU-NMS uses DIoU as the NMS criterion and also considers the distance between the center points of the two boxes as the evaluation criterion. Let the Euclidean distance between the center points of the two bounding boxes be d, and the diagonal length of the minimum enclosing rectangle containing the two bounding boxes be c. The calculation formula of DIoU is:

[0060] .

[0061] Example 3:

[0062] This embodiment provides a strawberry fruit detection method based on an improved YOLOv8n network, comprising the following method steps: training the improved YOLOv8n network; inputting an input image into a strawberry fruit detection system based on the improved YOLOv8n network to obtain a prediction result, wherein the strawberry fruit detection system based on the improved YOLOv8n network is as described in Example 2; and the loss function for training the improved YOLOv8n network is a dynamic weighted intersection-over-union (Wise-IoU) loss function.

[0063] Specifically, the loss function for training the improved YOLOv8n network is a dynamic weighted intersection-over-union loss function expressed as:

[0064] ;

[0065] in, represents the dynamic weighted intersection-over-union ratio, represents the power form of the intersection-over-union loss, γ represents the focusing parameter, represents the weight factor;

[0066] At a width of W g and height H g In the closed frame, and Represents the center coordinate of the prediction box, and Represents the center coordinate of the real box, and the weight factor is expressed as:

[0067] .

[0068] In this embodiment, the dynamic weighted intersection-over-union loss function redefines the quality evaluation criteria of the anchor frame by introducing outliers, and effectively reduces the competitiveness of high-quality anchor frames during the training process through the gradient gain distribution strategy, while significantly reducing the harmful gradient effects that may be caused by low-quality samples.

[0069] In this example, the improved YOLOv8n network is optimized in the following ways: (1) the receptive field attention convolution module is used in the backbone network instead of the standard convolution; (2) the squeeze excitation network is introduced in the backbone network to enhance the backbone network's ability to learn the color and shape features of strawberries; (3) the convolution layer in the bottleneck layer of the cross-stage dual convolution feature fusion module of the neck network is replaced with multi-scale parallel convolution. Ablation experiments are conducted on the strawberry dataset. The experimental environment and parameters of each experiment are consistent. The experimental results are shown in Table 2.

[0070] Table 2: Ablation experiment results

[0071]

[0072] As can be seen from the ablation experiment results, different improvement combinations all show improvements compared to the baseline model. Using the receptive field attention convolution module instead of the standard convolution can significantly improve the performance of the model, but the model size increases slightly; the squeeze excitation network strengthens the backbone network's ability to learn the color and shape features of strawberries, effectively improving the accuracy without increasing the size of the model; the multi-scale parallel convolution layer can effectively reduce the amount of computation, significantly reducing the model size while increasing performance. When any two improvement measures are introduced at the same time, the overall performance of the model is still significantly better than the baseline model, thus verifying the effectiveness of each improvement measure. While maintaining high-precision feature extraction capabilities, this detection method effectively resolves the contradiction between the number of traditional model parameters and detection accuracy, achieving high-precision detection in the working conditions of strawberry fruit detection with low computing resource consumption.

[0073] The technical features of the above-mentioned embodiments can be combined arbitrarily. In order to make the description concise, not all possible combinations of the technical features in the above-mentioned embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0074] The above-described embodiments merely represent several implementation methods of the present application. While the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the patent application. It should be noted that a person of ordinary skill in the art may make various modifications and improvements without departing from the spirit of the present application, and these modifications and improvements fall within the scope of protection of the present application. Therefore, the scope of protection of the present patent application shall be determined by the appended claims.

Claims

1. An improved YOLOv8n network structure for strawberry fruit detection, characterized in that: It includes a backbone network, a neck network, and a prediction head network connected in sequence; The backbone network includes a connected receptive field attention convolution module, a cross-stage dual convolution feature fusion module, a squeeze excitation network, and a fast spatial pyramid pooling module; the receptive field attention convolution module is used to obtain feature maps in the height and width directions of the input feature map, form an attention weight map based on the feature maps in the height and width directions, and use it to weight the input feature map to form an output feature map; the cross-stage dual convolution feature fusion module is used to extract a basic feature map from the input feature map, pass the basic feature map through the bottleneck layer to generate a deep feature map, and fuse the basic feature map with the deep feature map to form an output feature map; The squeeze excitation network is used to adjust the channel weights of the input feature map through the channel attention mechanism to obtain the output feature map; the fast spatial pyramid pooling module is used to pool the input feature map multiple times and splice the input feature map and the pooling result along the channel dimension to form the output feature map; The backbone network includes a first receptive field attention convolution module, a second receptive field attention convolution module, a first cross-stage double convolution feature fusion module, a third receptive field attention convolution module, a second cross-stage double convolution feature fusion module, a fourth receptive field attention convolution module, a third cross-stage double convolution feature fusion module, a fifth receptive field attention convolution module, a fourth cross-stage double convolution feature fusion module, and a fast spatial pyramid pooling module, which are connected in sequence; The receptive field attention convolution module is used to: expand the number of channels through group convolution operations; adjust the size of the feature map through normalization and nonlinear activation function ReLU processing; perform average pooling operations on the feature map in the height and width directions respectively to generate an intermediate feature map; splice the two intermediate feature maps, fuse them through a convolution layer, and generate a fused feature map; normalize and nonlinearly transform the fused feature map, split it into two feature maps, generate an attention weight map through convolution operations and Sigmoid functions respectively, weight the input feature map based on the attention weight map, and generate an output feature map through a convolution layer; The neck network includes a connected multi-scale parallel convolution cross-stage double convolution feature fusion module, a feature splicing module, an upsampling module, and a standard convolution module; the multi-scale parallel convolution cross-stage double convolution feature fusion module is used to extract a basic feature map from the input feature map, pass the basic feature map through a multi-scale parallel convolution layer to generate a multi-scale feature map, and fuse the basic feature map with the multi-scale feature map to form an output feature map; The feature splicing module is used to splice the feature maps output by different branches to form a spliced ​​feature map; the upsampling module is used to improve the resolution of the input feature map to form an output feature map; the standard convolution module is used to convolve the input feature map to form an output feature map; The prediction head network includes multiple detection head modules; the detection head module is used to receive the feature map output by the neck network to form an original prediction value, including a bounding box, confidence and category probability.

2. An improved YOLOv8n network structure for strawberry fruit detection according to claim 1, characterized in that, The neck network includes a first upsampling module, a first feature splicing module, a first multi-scale parallel convolution cross-stage dual convolution feature fusion module, a second upsampling module, a second feature splicing module, a second multi-scale parallel convolution cross-stage dual convolution feature fusion module, a first standard convolution module, a third feature splicing module, a third multi-scale parallel convolution cross-stage dual convolution feature fusion module, a second standard convolution module, a fourth feature splicing module, and a fourth multi-scale parallel convolution cross-stage dual convolution feature fusion module, which are connected in sequence; the first upsampling module is connected to the output end of the fast spatial pyramid pooling module, the first feature splicing module is connected to the output end of the third cross-stage dual convolution feature fusion module, the second feature splicing module is connected to the output end of the second cross-stage dual convolution feature fusion module, the third feature splicing module is connected to the output end of the first multi-scale parallel convolution cross-stage dual convolution feature fusion module, and the fourth feature splicing module is connected to the output end of the fast spatial pyramid pooling module.

3. An improved YOLOv8n network structure for strawberry fruit detection according to claim 2, characterized in that, The prediction head network includes a first detection head module, a second detection head module, and a third detection head module; the first detection head module is connected to the output end of the second multi-scale parallel convolution cross-stage double convolution feature fusion module, the second detection head module is connected to the output end of the third multi-scale parallel convolution cross-stage double convolution feature fusion module, and the third detection head module is connected to the output end of the fourth multi-scale parallel convolution cross-stage double convolution feature fusion module.

4. A strawberry fruit detection system based on an improved YOLOv8n network, characterized in that: The invention comprises a preprocessing module, an improved YOLOv8n network and a post-processing module; the preprocessing module is used to process the input image and generate an original feature map; the structure of the improved YOLOv8n network is as described in any one of claims 1 to 3, and is used to process the original feature map to obtain an original prediction value; the post-processing module is used to process the original prediction value to obtain a prediction result.

5. A strawberry fruit detection system based on an improved YOLOv8n network according to claim 4, characterized in that, The preprocessing module includes a dimensional normalization unit and a numerical normalization unit; the dimensional normalization unit is used to adapt the image size of the input image to the preset input dimension of the improved YOLOv8n network, and the numerical normalization unit is used to constrain the pixel data distribution of the input image to the [0,1] interval through linear transformation of pixel values.

6. A strawberry fruit detection system based on an improved YOLOv8n network according to claim 4, characterized in that, The post-processing module includes a distance intersection-over-union (IoU) non-maximum suppression module, and the distance intersection-over-union (IoU) non-maximum suppression includes a sorting unit, an iterative selection unit, a distance intersection-over-union (IoU) calculation unit, and a filtering unit; the sorting unit is used to arrange the original prediction values ​​in descending order based on the confidence scores of the candidate boxes, the iterative selection unit is used to select the candidate boxes with the highest confidence scores that are not currently suppressed starting from the highest score and add them to the prediction results, the distance intersection-over-union (IoU) calculation unit is used to calculate the distance intersection-over-union (IoU) of the remaining candidate boxes and the candidate box with the highest confidence score, and the filtering unit is used to suppress the candidate boxes whose distance intersection-over-union (IoU) with the candidate box with the highest confidence score is greater than a preset threshold.

7. A strawberry fruit detection method based on an improved YOLOv8n network, characterized in that: The method comprises the following steps: training an improved YOLOv8n network; inputting an input image into a strawberry fruit detection system based on the improved YOLOv8n network to obtain a prediction result, wherein the strawberry fruit detection system based on the improved YOLOv8n network is as described in any one of claims 4 to 6; and the loss function for training the improved YOLOv8n network is a dynamic weighted intersection-over-union loss function.

8. A strawberry fruit detection method based on an improved YOLOv8n network according to claim 7, characterized in that, The loss function for training the improved YOLOv8n network is a dynamic weighted intersection-over-union loss function expressed as: ; in, represents the dynamic weighted intersection-over-union ratio, represents the power form of the intersection-over-union loss, γ represents the focusing parameter, represents the weight factor; At a width of W g and height H g In the closed frame, and Represents the center coordinate of the prediction box, and Represents the center coordinate of the real box, and the weight factor is expressed as: 。

Citation Information

Patent Citations

  • Lightweight target detection network and method based on YOLO and electronic equipment

    CN115546620A

  • Fruit detection method and system in complex environment based on improved YOLOv8n and application

    CN118537718A