Improved tomato target detection method and system based on YOLOv8n
By introducing phantom convolution, PSA module and SPPELAN module into the YOLOv8n model, and using improved technology of attention mechanism and WAFF module, the shortcomings of YOLOv8 in small object detection, occlusion and rotation robustness, computing resource requirements, etc. are solved. , achieving more efficient and accurate tomato target detection.
Patent Information
- Application Number
- CN202411624408.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-14
- Publication Date
- 2025-02-25
- Estimated Expiration
- 2044-11-14
AI Technical Summary
YOLOv8 has shortcomings in small object detection, occlusion and rotation robustness, computing resource requirements, and target positioning accuracy, which limits its use in specific application scenarios, especially when resources are limited or high requirements for small object detection. occasion.
By introducing phantom convolution into the feature extraction network and feature fusion network of the improved YOLOv8n model, and adding PSA module to the feature extraction network, replacing the SPPF module with the SPPELAN module, using the attention mechanism to enhance feature extraction and fusion, and using the WAFF module for Adaptive weighted features are fused and adaptive weight detection head is designed.
It improves the accuracy and speed of tomato target detection, enhances the detection ability of small targets and complex backgrounds, reduces the demand for computing resources, and improves the target positioning accuracy and detection robustness.
Smart Images

Figure 00000000_0000_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image processing, and in particular to an improved tomato target detection method and system based on YOLOv8n. Background Art
[0002] The use of efficient and accurate target detection technology to achieve automatic detection of tomatoes, accurate prediction of yield and monitoring of quality are of vital importance for agricultural production planning, market trend analysis and the stable development of the entire agricultural supply chain. It is of great significance to design an efficient target detection method for tomato detection.
[0003] With the rapid development of deep learning technology, especially the in-depth application of convolutional neural networks in the field of target detection, detection technology has achieved significant performance improvements. Among many target detection algorithms, the two-stage detection algorithm effectively generates candidate target regions in the image by introducing a candidate region generation network. Subsequently, combined with classifiers and regressors, these algorithms achieve target detection tasks and thus achieve high accuracy. The mask region convolutional neural network is further developed on the basis of target detection, adding a branch for generating object masks. This branch aims to accurately depict the outline of each object in the image and generate a pixel-level segmentation mask for each object. Although this method provides more detailed location information than traditional bounding boxes, it has certain limitations in tomato target detection applications in complex environments due to its large model structure and slow detection speed.
[0004] In contrast, the single-stage object detection algorithm does not need to rely on the region proposal network to generate candidate regions, and can directly complete the object classification and bounding box positioning in a single detection process, thereby achieving faster detection speed.
[0005] YOLOv8, as an advanced single-stage target detection algorithm, adopts a novel backbone network architecture and an efficient multi-scale detection strategy. The algorithm optimizes the network structure and computational process, and cleverly converts the target detection task into a regression problem. Through a highly integrated neural network, YOLOv8 can directly predict the category and location information of the target, significantly simplifying the detection process and achieving high-precision and fast detection.
[0006] As a model of single-stage detection algorithms, YOLOv8 not only has a fast detection speed, but also shows excellent detection performance, and can also show good adaptability in target detection in complex scenes. The algorithm pursues lightweight design while ensuring excellent detection results. Its practicality has been proven in many fields, including precision agriculture, industrial quality monitoring, and road target detection. YOLOv8 has demonstrated its wide application potential.
[0007] YOLOv8 has significant advantages in the field of target detection, but it also has some disadvantages and shortcomings. The main ones are poor detection effect on small targets: YOLOv8 is not as effective as some other target detection algorithms when dealing with small targets; Robustness to occlusion and rotation needs to be improved: The performance when dealing with occluded and rotated targets is also not as good as some other target detection algorithms; Requires higher computing resources: In order to achieve higher detection accuracy and faster detection speed, YOLOv8 requires higher computing resources; Target positioning accuracy is relatively low: Due to the use of a larger receptive field and a coarser feature map, the target positioning accuracy is relatively low; Difficult to detect dense targets: In dense target scenarios, YOLOv8 may find it difficult to accurately separate and detect multiple closely adjacent targets; Large model size: In some resource-constrained environments, how to further compress the model size is still a challenge; High training resource requirements: Training YOLOv8 requires a lot of computing resources, and the threshold is high for ordinary users; Multi-target detection needs to be optimized: Multi-target detection in dense scenarios still needs to be optimized to improve detection accuracy and robustness.
[0008] In summary, although YOLOv8 has advantages such as fast, efficient, and high precision in target detection, it still has some shortcomings in small target detection, occlusion and rotation robustness, and computing resource requirements. These shortcomings and deficiencies limit the use of YOLOv8 in specific application scenarios to a certain extent, especially in situations where resources are limited or small target detection requirements are high. Nevertheless, YOLOv8 is still a very effective target detection algorithm in many applications, especially when real-time performance and high precision are required. Summary of the invention
[0009] In view of the shortcomings of the prior art, the present invention provides a tomato target detection method and system based on YOLOv8n improvement to solve the problems raised in the above background technology.
[0010] To achieve the above object, the present invention provides the following technical solution: an improved tomato target detection method based on YOLOv8n, comprising the following steps:
[0011] Step S1: collecting the original image of tomatoes;
[0012] Step S2: construct an improved YOLOv8n model; the improved YOLOv8n model consists of a feature extraction network, a feature fusion network and a target detection head;
[0013] Phantom convolution is introduced into the feature extraction network; and a PSA module is added to the last layer of the feature extraction network; the SPPF module in the feature extraction network is replaced by an SPPELAN module; the feature extraction network consists of a first convolution layer, a second convolution layer, a first C2f module, a third convolution layer, a second C2f module, a first phantom convolution, a third C2f module, a second phantom convolution, an SPPELAN module and a PSA module connected in sequence;
[0014] Step S3: Input the collected original tomato image into the improved YOLOv8n model for target recognition to obtain a fusion feature map;
[0015] Step S4: Reconstruct the fused feature map to obtain a tomato target recognition image.
[0016] Further, the feature fusion network consists of a first attention enhancement module, a second attention enhancement module, a first upsampling module, a fourth convolutional layer, a fifth convolutional layer, a first WAFF module, a third phantom convolution, a second WAFF module, a fourth C2f module, a third WAFF module, a second upsampling module, a fifth C2f module, a sixth C2f module, a fourth phantom convolution, a fourth WAFF module, a seventh C2f module, a fifth phantom convolution, a fifth WAFF module and an eighth C2f module.
[0017] Furthermore, the target detection head is composed of a first adaptive weight detection head, a second adaptive weight detection head and a third adaptive weight detection head.
[0018] Furthermore, the processing flow of the feature extraction network is:
[0019] First, the original tomato image is input into the feature extraction network. The original tomato image passes through the first convolutional layer, the second convolutional layer, the first C2f module, the third convolutional layer, the second C2f module, the first phantom convolution, the third C2f module, the second phantom convolution, the SPPELAN module, and the PSA module in turn; the second convolutional layer, the second C2f module, the third C2f module, and the PSA module are used as the output of the feature extraction network.
[0020] Furthermore, the processing flow of the feature fusion network is:
[0021] The output of the second convolutional layer is input into the third phantom convolution; the output of the second C2f module is input into the first attention enhancement module; the output of the third C2f module is input into the second attention enhancement module, and the output of the second attention enhancement module is input into the fifth convolutional layer; the output of the PSA module is input into the fourth convolutional layer, the output of the fourth convolutional layer is input into the first upsampling module, the outputs of the first upsampling module and the fifth convolutional layer are input into the first WAFF module, the output of the first WAFF module is input into the fifth C2f module, and the output of the fifth C2f module is input into the second upsampling module; the outputs of the second upsampling module and the first attention enhancement module are input into the third WAFF module, and the output of the first upsampling module and the fifth convolutional layer are input into the third WAFF module. The outputs of the three WAFF modules are input into the fourth C2f module; the outputs of the fourth C2f module, the first attention enhancement module and the third phantom convolution are input into the second WAFF module, and the output of the second WAFF module is input into the sixth C2f module; the output of the sixth C2f module is input into the fourth phantom convolution; the outputs of the fourth phantom convolution, the fifth convolution layer and the fifth C2f module are input into the fourth WAFF module, and the output of the fourth WAFF module is input into the seventh C2f module; the output of the seventh C2f module is input into the fifth phantom convolution; the outputs of the fifth phantom convolution and the fourth convolution layer are input into the fifth WAFF module, and the output of the fifth WAFF module is input into the eighth C2f module;
[0022] The outputs of the sixth C2f module, the seventh C2f module, and the eighth C2f module are used as the outputs of the feature fusion network.
[0023] Furthermore, the processing flow of the target detection head is:
[0024] Input the output of the sixth C2f module to the first adaptive weight detection head, input the output of the seventh C2f module to the second adaptive weight detection head, and input the output of the eighth C2f module to the third adaptive weight detection head;
[0025] The output of the first adaptive weight detection head, the second adaptive weight detection head and the third adaptive weight detection head is a fused feature map.
[0026] Further, the tomato target detection system improved based on YOLOv8n is applied to the tomato target detection method improved based on YOLOv8n, including:
[0027] The acquisition module is used to acquire the original image of tomatoes;
[0028] A construction module is used to construct an improved YOLOv8n model; the improved YOLOv8n model consists of a feature extraction network, a feature fusion network and a target detection head;
[0029] Phantom convolution is introduced into the feature extraction network; and a PSA module is added to the last layer of the feature extraction network; the SPPF module in the feature extraction network is replaced by an SPPELAN module; the feature extraction network consists of a first convolution layer, a second convolution layer, a first C2f module, a third convolution layer, a second C2f module, a first phantom convolution, a third C2f module, a second phantom convolution, an SPPELAN module and a PSA module connected in sequence;
[0030] The target recognition module is used to input the collected original tomato image into the improved YOLOv8n model for target recognition and obtain a fusion feature map;
[0031] The reconstruction module is used to reconstruct the fused feature map to obtain the tomato target recognition image.
[0032] Compared with the existing technology, the present invention has the following beneficial effects:
[0033] (1) The present invention introduces phantom convolution into the feature extraction network and feature fusion network of the improved YOLOv8n model, designs a model specifically for tomato original image target detection, and improves the accuracy and speed of tomato original image target detection; the introduction of phantom convolution can increase the number of tomato original feature maps at a low cost, improve the efficiency and performance of the improved YOLOv8n model, and achieve lightweight.
[0034] (2) The present invention replaces the SPPELAN module with the SPPF module to capture more detailed target features, reduce information loss, and improve detection accuracy and control the amount of calculation through the local attention mechanism.
[0035] (3) The present invention enhances the PSA module's attention to the region of interest through the attention mechanism, reduces the computational burden, and improves the performance of the PSA module.
[0036] (4) The present invention uses an attention enhancement module to optimize the prior relationship processing between targets, reduce repeated detection frames, and improve feature extraction and context information richness under complex backgrounds.
[0037] (5) The present invention replaces the traditional multi-scale fusion with the adaptive weighted feature fusion module of the WAFF module, optimizes the feature weight distribution, enhances the feature expression, and ensures the feature stability.
[0038] (6) The present invention adopts the ASFFv5 module adaptive feature fusion technology to design an adaptive weight detection head, which effectively fuses the original feature maps of tomatoes at different scales, automatically adjusts the feature weights, and improves the detection accuracy and adaptability. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] Figure 1 This is a diagram of the network framework structure of the improved YOLOv8n model reconstruction of the present invention. DETAILED DESCRIPTION
[0040] The present invention is further described in detail below with reference to implementation cases and accompanying drawings.
[0041] like Figure 1 As shown in the figure, the tomato target detection method improved based on YOLOv8n includes the following steps:
[0042] Step S1: collecting the original image of tomatoes;
[0043] Step S2: construct an improved YOLOv8n model; the improved YOLOv8n model consists of a feature extraction network, a feature fusion network and a target detection head;
[0044] Phantom convolution is introduced into the feature extraction network; and a PSA module is added to the last layer of the feature extraction network; the SPPF module in the feature extraction network is replaced by an SPPELAN module; the feature extraction network consists of a first convolution layer, a second convolution layer, a first C2f module, a third convolution layer, a second C2f module, a first phantom convolution, a third C2f module, a second phantom convolution, an SPPELAN module and a PSA module connected in sequence;
[0045] Step S3: Input the collected original tomato image into the improved YOLOv8n model for target recognition to obtain a fusion feature map;
[0046] Step S4: Reconstruct the fused feature map to obtain a tomato target recognition image.
[0047] Among them, the feature fusion network consists of a first attention enhancement module, a second attention enhancement module, a first upsampling module, a fourth convolutional layer, a fifth convolutional layer, a first WAFF module, a third phantom convolution, a second WAFF module, a fourth C2f module, a third WAFF module, a second upsampling module, a fifth C2f module, a sixth C2f module, a fourth phantom convolution, a fourth WAFF module, a seventh C2f module, a fifth phantom convolution, a fifth WAFF module and an eighth C2f module.
[0048] The target detection head is composed of a first adaptive weight detection head, a second adaptive weight detection head and a third adaptive weight detection head.
[0049] Among them, the processing flow of the feature extraction network is:
[0050] First, the original tomato image is input into the feature extraction network. The original tomato image passes through the first convolutional layer, the second convolutional layer, the first C2f module, the third convolutional layer, the second C2f module, the first phantom convolution, the third C2f module, the second phantom convolution, the SPPELAN module, and the PSA module in turn; the second convolutional layer, the second C2f module, the third C2f module, and the PSA module are used as the output of the feature extraction network.
[0051] Among them, the processing flow of the feature fusion network is:
[0052] The output of the second convolutional layer is input into the third phantom convolution; the output of the second C2f module is input into the first attention enhancement module; the output of the third C2f module is input into the second attention enhancement module, and the output of the second attention enhancement module is input into the fifth convolutional layer; the output of the PSA module is input into the fourth convolutional layer, the output of the fourth convolutional layer is input into the first upsampling module, the outputs of the first upsampling module and the fifth convolutional layer are input into the first WAFF module, the output of the first WAFF module is input into the fifth C2f module, and the output of the fifth C2f module is input into the second upsampling module; the outputs of the second upsampling module and the first attention enhancement module are input into the third WAFF module, and the output of the first upsampling module and the fifth convolutional layer are input into the third WAFF module. The outputs of the three WAFF modules are input into the fourth C2f module; the outputs of the fourth C2f module, the first attention enhancement module and the third phantom convolution are input into the second WAFF module, and the output of the second WAFF module is input into the sixth C2f module; the output of the sixth C2f module is input into the fourth phantom convolution; the outputs of the fourth phantom convolution, the fifth convolution layer and the fifth C2f module are input into the fourth WAFF module, and the output of the fourth WAFF module is input into the seventh C2f module; the output of the seventh C2f module is input into the fifth phantom convolution; the outputs of the fifth phantom convolution and the fourth convolution layer are input into the fifth WAFF module, and the output of the fifth WAFF module is input into the eighth C2f module;
[0053] The outputs of the sixth C2f module, the seventh C2f module, and the eighth C2f module are used as the outputs of the feature fusion network.
[0054] Among them, the processing flow of the target detection head is:
[0055] Input the output of the sixth C2f module to the first adaptive weight detection head, input the output of the seventh C2f module to the second adaptive weight detection head, and input the output of the eighth C2f module to the third adaptive weight detection head;
[0056] The output of the first adaptive weight detection head, the second adaptive weight detection head and the third adaptive weight detection head is a fused feature map.
[0057] Among them, the tomato target detection system improved based on YOLOv8n is applied to the tomato target detection method improved based on YOLOv8n, including:
[0058] The acquisition module is used to acquire the original image of tomatoes;
[0059] A construction module is used to construct an improved YOLOv8n model; the improved YOLOv8n model consists of a feature extraction network, a feature fusion network and a target detection head;
[0060] Phantom convolution is introduced into the feature extraction network; and a PSA module is added to the last layer of the feature extraction network; the SPPF module in the feature extraction network is replaced by an SPPELAN module; the feature extraction network consists of a first convolution layer, a second convolution layer, a first C2f module, a third convolution layer, a second C2f module, a first phantom convolution, a third C2f module, a second phantom convolution, an SPPELAN module and a PSA module connected in sequence;
[0061] The target recognition module is used to input the collected original tomato image into the improved YOLOv8n model for target recognition and obtain a fusion feature map;
[0062] The reconstruction module is used to reconstruct the fused feature map to obtain the tomato target recognition image.
[0063] Among them, by utilizing the flexible modularity and phantom convolution characteristics of the improved YOLOv8n model, phantom convolution is introduced into the feature extraction network and feature fusion network of the improved YOLOv8n model, and seamlessly integrated into the existing convolutional neural network (CNN). A small amount of calculation is performed on the original tomato image through the convolutional neural network to generate the tomato original feature map (intrinsic feature maps), and then more tomato original feature maps (ghost feature maps) are generated from the tomato original feature map to enhance the efficiency and performance of phantom convolution; while improving the performance of phantom convolution, the phantom convolution is lightweight;
[0064] Phantom convolutions are able to reduce the computational cost of general convolutional layers while maintaining similar recognition performance, and can outperform state-of-the-art efficient deep models for fast inference on mobile devices.
[0065] Among them, the SPPF module is replaced by the SPPELAN module to capture more detailed target features at different scales of the original tomato image, thereby improving the accuracy of target feature detection and reducing the information loss of target features in the convolutional neural network (CNN) process; at the same time, since the local attention mechanism of the SPPELAN module has a small range and a relatively small amount of calculation, it will not increase the computational burden too much;
[0066] The SPPELAN module (Spatial Pyramid Pooling with Enhanced Local Attention Network), as an innovation proposed in the improved YOLOv8n model, has taken into account the compatibility issues with the improved YOLOv8n model. The SPPF module is replaced by the SPPELAN module, and the SPPELAN module can be easily integrated into the improved YOLOv8n model. By adjusting and optimizing the algorithm, the SPPELAN module can achieve more efficient target detection while maintaining or exceeding the detection accuracy of the SPPF module.
[0067] Among them, the attention mechanism of the PSA module (Partial self-attention) is used to enhance the attention of the PSA module to the region of interest in the tomato original feature map during the extraction of the tomato original feature map, measure the importance of each position of the region of interest in the tomato original feature map to the prediction of the PSA module, and only pay deep attention to the high-scoring positions of the tomato original feature map, which significantly reduces the computational burden. By enhancing the attention of the PSA module to the region of interest in the tomato original image during the extraction of the tomato original feature map, irrelevant interference is avoided and the overall performance of the PSA module is improved;
[0068] The attention mechanism of the PSA module is introduced to reduce the need to calculate the attention between pairs of tomato original image positions, thereby improving the efficiency of the attention mechanism; at the same time, due to its unique design and implementation, the PSA module is able to reduce the amount of calculation while maintaining accuracy; the attention mechanism of the PSA module focuses on the features of different positions in the original feature map of tomatoes, which is manifested in two aspects: polarization filtering and enhancement; polarization filtering maintains high resolution in channel and spatial dimensions, reducing information loss caused by dimensionality reduction; and enhancement uses a nonlinear function of the fine-grained regression output distribution to fit the output distribution of pixel-level tasks; the PSA module is combined with a convolutional neural network (CNN) to enhance the ability of the PSA module to extract the original feature map of tomatoes.
[0069] Among them, the attention enhancement module (FEM) is used to filter out unreasonable detection frames when processing the prior relationship between the objects in the original tomato image, thereby reducing the repeated detection frames in the original feature map of the tomato. By integrating the probabilistic knowledge of the target features into the original feature map of the tomato, the attention enhancement module can make more accurate judgments from the perspective of the target features. The learning of the original feature map of the tomato in a complex background by the attention enhancement module is enhanced to ensure the exhaustiveness of the extraction of the original feature map of the tomato and richer context information.
[0070] In the target detection task, due to its inherent characteristics, the original feature map of tomatoes is weakly represented after multiple upsampling, and may even disappear in the background; the attention enhancement module is used to enhance the feature representation of the original feature map of tomatoes, making the original feature map of tomatoes more prominent in detection; the attention enhancement module generates new original feature maps K and Q of tomatoes by convolution operation, and calculates new original feature maps K and Q of tomatoes by matrix multiplication and transposition operation, and further performs softmax function operation to obtain attention maps Aq and As; the attention maps Aq and As are used to calculate weighted features Esl and Eql, and finally the weighted features Esl and Eql are integrated into the final enhanced feature map E through reshaping and matrix multiplication operations; K represents the key original feature map of tomatoes, Q represents the query original feature map of tomatoes on Aq; Aq represents the attention map obtained after the softmax function operation is performed on the query original feature map of tomatoes Q, and As represents the attention map obtained after the softmax function operation is performed on the key original feature map of tomatoes K; Esl represents the original feature map of tomatoes; Eql represents the query feature map of E;
[0071] The attention enhancement module performs a softmax function operation to obtain attention maps Aq and As; the softmax function operation is a common activation function, which converts the new original tomato feature maps K and Q into probability distributions, and further performs a softmax function operation to obtain attention maps Aq and As; the attention maps Aq and As are used to calculate the weighted features Esl and Eql; the weighted features Esl and Eql are obtained by weighted summation of the original tomato feature map according to the weights of the attention map, and the attention maps Aq and As can better highlight the feature representation of the original tomato feature map; finally, the attention enhancement module integrates the weighted features Esl and Eql into the final enhanced feature map E through reshaping and matrix multiplication operations; the reshaping operation can change the shape of the original tomato feature map to adapt to subsequent processing steps; and the matrix multiplication can combine the features at different positions of the attention maps Aq and As to obtain a more representative feature representation.
[0072] The adaptive weighted feature fusion module of the WAFF module (Weight allocation Feature fusion) is used to replace the original multi-scale feature fusion method. The WAFF module is used to perform weighted fusion on the original tomato feature map after the convolution layer and pooling operation, optimize the weight allocation of the original tomato feature map of different scales, enhance the expressiveness of the original tomato feature map, and obtain the fused original tomato feature map; the final output fused original tomato feature map is subjected to batch normalization operation to ensure the stability and consistency of the output features;
[0073] The WAFF module calculates the spatial correlation of the original feature map of tomatoes at each scale, uses the channel attention mechanism to improve the scale invariance of the original feature map of tomatoes, and adaptively fuses the features of adjacent scales; the original feature maps of tomatoes from different branches are processed through specific pooling operations, such as maximum pooling and average pooling, to extract features at different spatial scales; the original feature maps of tomatoes from each branch after convolutional layers and pooling operations are weighted fused through learnable weights; these weights are calculated through the softmax function to ensure that the sum of all weights is 1, thereby retaining the relative importance of the original original feature map of tomatoes.
[0074] By using the adaptive feature fusion technology of the ASFFv5 module, an adaptive weight detection head suitable for target detection tasks in complex environments is designed. The adaptive weight detection head can effectively fuse the fused tomato original feature maps of different scales. The feature fusion strategy of adaptive weight can automatically adjust the weight distribution of features of different scales according to the characteristics of the input fused tomato original feature map and the target size, which helps to better capture the detailed information of the fused tomato original feature map at different scales, thereby significantly improving the detection accuracy of the ASFFv5 module; improving the adaptability of the algorithm to complex natural environments and enhancing the detection performance;
[0075] AWD (Adaptive weight detection head) adaptive weight detection head, relying on the feature extraction network and feature fusion network to extract three different scales of tomato original feature maps, the three different scales of tomato original feature maps correspond to large, medium and small scales respectively, the three different scales of tomato original feature maps each capture the visual information of tomatoes at different resolutions, and send them to the ASFFv5 module for further processing. The ASFFv5 module can adaptively adjust the weights between the different scales of tomato original feature maps to achieve more effective feature fusion and obtain the fused feature map; after feature fusion, not only the details and structural information of the original tomato image are retained, but also the semantic expression is richer and more comprehensive; the adaptive weight detection head effectively and adaptively fuses the different scales of tomato original feature maps, adjusts the weights of different scale features according to the characteristics of the fused tomato original feature map and the target size, and improves the accuracy of the ASFFv5 module in detecting tomato original images in complex scenes. The adaptability of the ASFFv5 module to different sizes of tomato original images in complex agricultural scenes is improved, and the generalization ability and robustness are further enhanced.
[0076] Ablation experiment:
[0077] In order to test the effectiveness of each improved module in this method for tomato target detection tasks in complex environments, this study uses the improved YOLOv8n model as the baseline network, and conducts ablation tests on each improved module on public tomato datasets and self-built tomato datasets; the main evaluation indicators of the test include bounding box accuracy, recall rate, mean average precision mAP50, and mean average precision mAP50-95; as shown in Table 1:
[0078] Table 1 Test data table
[0079]
[0080] According to the analysis of the experimental data table (above), on the public tomato dataset, after replacing the SPPF module with the SPPELAN module, the recall rate and average precision mAP50 increased by 3.7% and 0.7% respectively, and the computational complexity was reduced by 1.23%; after introducing the PSA module and the attention enhancement module (FEM), the recall rate increased by 2.5% and 1.2% respectively; using the WAFF module to replace the original feature fusion strategy, the recall rate increased by 2.0%, the average precision mAP50 increased by 0.5%, and the average precision mAP50-95 increased by 0.6%; using the adaptive weight detection head (AWD) to replace the original detection head, the bounding box accuracy and average precision mAP50 increased by 1.7% and 0.4% respectively; introducing ghost convolution (GhostConv), the recall rate increased by 2.1%, and the computational complexity was reduced by 4.94%. Based on the above improvement measures, on the public tomato dataset, this method maintains the bounding box accuracy while slightly increasing the amount of computation, and achieves 5.8%, 1.4%, and 3.0% improvements in recall, mean average precision mAP50, and mean average precision mAP50-95, respectively. This shows that each improvement measure has a positive impact on the improvement of the overall performance of the model.
[0081] The public tomato dataset, Tomato Detection, is used to enable the improved YOLOv8n model to identify clear tomato targets, and it is used as the basic dataset for pre-training the improved YOLOv8n model. The improved YOLOv8n model will load the weights trained on this dataset to obtain preliminary tomato recognition capabilities. After that, further training will be performed on tomato targets in complex environments on the self-built dataset. This method can not only ensure the training quality, but also significantly shorten the training time of the improved YOLOv8n model.
[0082] We collected pictures from a vegetable planting base in Jiangxi Province and built a tomato dataset (Tomato_accuracy), which includes 152 high-resolution tomato images captured in complex environments. The self-built tomato dataset not only includes the states of tomatoes in a variety of complex environments, but also covers all key factors that may affect tomato target detection in the real environment. These factors include but are not limited to lighting changes, occlusion, background complexity, etc., making the dataset highly similar to the complex environment in which tomatoes are located in the real world.
[0083] Although embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present invention, and that the scope of the present invention is defined by the appended claims and their equivalents.
Claims
1. The improved tomato target detection method based on YOLOv8n is characterized by: The steps include: Step S1: collecting the original image of tomatoes; Step S2: construct an improved YOLOv8n model; the improved YOLOv8n model consists of a feature extraction network, a feature fusion network and a target detection head; Phantom convolution is introduced into the feature extraction network; and a PSA module is added to the last layer of the feature extraction network; the SPPF module in the feature extraction network is replaced by an SPPELAN module; the feature extraction network consists of a first convolution layer, a second convolution layer, a first C2f module, a third convolution layer, a second C2f module, a first phantom convolution, a third C2f module, a second phantom convolution, an SPPELAN module and a PSA module connected in sequence; The feature fusion network consists of a first attention enhancement module, a second attention enhancement module, a first upsampling module, a fourth convolutional layer, a fifth convolutional layer, a first WAFF module, a third phantom convolution, a second WAFF module, a fourth C2f module, a third WAFF module, a second upsampling module, a fifth C2f module, a sixth C2f module, a fourth phantom convolution, a fourth WAFF module, a seventh C2f module, a fifth phantom convolution, a fifth WAFF module, and an eighth C2f module; The processing flow of the feature fusion network is: The output of the second convolutional layer is input into the third phantom convolution; the output of the second C2f module is input into the first attention enhancement module; the output of the third C2f module is input into the second attention enhancement module, and the output of the second attention enhancement module is input into the fifth convolutional layer; the output of the PSA module is input into the fourth convolutional layer, the output of the fourth convolutional layer is input into the first upsampling module, the outputs of the first upsampling module and the fifth convolutional layer are input into the first WAFF module, the output of the first WAFF module is input into the fifth C2f module, and the output of the fifth C2f module is input into the second upsampling module; the outputs of the second upsampling module and the first attention enhancement module are input into the third WAFF module, and the output of the first upsampling module and the fifth convolutional layer are input into the third WAFF module. The outputs of the three WAFF modules are input into the fourth C2f module; the outputs of the fourth C2f module, the first attention enhancement module and the third phantom convolution are input into the second WAFF module, and the output of the second WAFF module is input into the sixth C2f module; the output of the sixth C2f module is input into the fourth phantom convolution; the outputs of the fourth phantom convolution, the fifth convolution layer and the fifth C2f module are input into the fourth WAFF module, and the output of the fourth WAFF module is input into the seventh C2f module; the output of the seventh C2f module is input into the fifth phantom convolution; the outputs of the fifth phantom convolution and the fourth convolution layer are input into the fifth WAFF module, and the output of the fifth WAFF module is input into the eighth C2f module; The outputs of the sixth C2f module, the seventh C2f module, and the eighth C2f module are used as the outputs of the feature fusion network; Step S3: Input the collected original tomato image into the improved YOLOv8n model for target recognition to obtain a fusion feature map; Step S4: Reconstruct the fused feature map to obtain a tomato target recognition image.
2. The tomato target detection method based on YOLOv8n improvement according to claim 1, characterized in that: The target detection head consists of a first adaptive weight detection head, a second adaptive weight detection head and a third adaptive weight detection head.
3. The tomato target detection method based on YOLOv8n improvement according to claim 2 is characterized in that: The processing flow of the feature extraction network is: First, the original tomato image is input into the feature extraction network. The original tomato image passes through the first convolutional layer, the second convolutional layer, the first C2f module, the third convolutional layer, the second C2f module, the first phantom convolution, the third C2f module, the second phantom convolution, the SPPELAN module, and the PSA module in turn; the second convolutional layer, the second C2f module, the third C2f module, and the PSA module are used as the output of the feature extraction network.
4. The tomato target detection method based on YOLOv8n improvement according to claim 3 is characterized in that: The processing flow of the target detection head is: Input the output of the sixth C2f module to the first adaptive weight detection head, input the output of the seventh C2f module to the second adaptive weight detection head, and input the output of the eighth C2f module to the third adaptive weight detection head; The output of the first adaptive weight detection head, the second adaptive weight detection head and the third adaptive weight detection head is a fused feature map.
5. The tomato target detection system improved based on YOLOv8n is applied to the tomato target detection method improved based on YOLOv8n according to any one of claims 1 to 4, characterized in that: include: The acquisition module is used to acquire the original image of tomatoes; A construction module is used to construct an improved YOLOv8n model; the improved YOLOv8n model consists of a feature extraction network, a feature fusion network and a target detection head; Phantom convolution is introduced into the feature extraction network; and a PSA module is added to the last layer of the feature extraction network; the SPPF module in the feature extraction network is replaced by an SPPELAN module; the feature extraction network consists of a first convolution layer, a second convolution layer, a first C2f module, a third convolution layer, a second C2f module, a first phantom convolution, a third C2f module, a second phantom convolution, an SPPELAN module and a PSA module connected in sequence; The target recognition module is used to input the collected original tomato image into the improved YOLOv8n model for target recognition and obtain a fusion feature map; The reconstruction module is used to reconstruct the fused feature map to obtain the tomato target recognition image.
Citation Information
Patent Citations
Road damage detection method based on improved YOLOv7
CN118212572A
Remote sensing image target detection method based on attention mechanism and multi-scale feature fusion
CN118298263A