Strawberry ripeness detection method based on improved YOLOv8 model

CN122949233APending Publication Date: 2026-10-20XUZHOU NORMAL UNIVERSITY
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510353111.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-25
Publication Date
2026-10-20

AI Technical Summary

Technical Problem

[0003]然而,现有的YOLOv8模型在草莓成熟度检测中存在以下问题:小目标检测能力不足:草莓果实较小,尤其是在复杂背景下,YOLOv8容易漏检或误检

Benefits of technology

[0036]本发明采用特征融合金字塔网络AFPN作为现有的YOLOv8模型的检测头,增强特征金字塔的表达能力,能更好地适应目标的多尺度变化,并通过将可变形注意力机制DAttention融入C2f模块模型能够在不同尺度和形变条件下更加精准地关注目标,提高对不同成熟度草莓的检测能力,特别是在复杂背景、遮挡、光照变化较大的环境下仍能保持较高的检测精度。结果表明经过改进的YOLOv8模型网络在Precision、Recall和mAP方面都有很好的表现,与现有的YOLOv5模型相比有提高。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure FT_1
    Figure FT_1
  • Figure FT_2
    Figure FT_2
  • Figure FT_3
    Figure FT_3
Patent Text Reader

Abstract

This invention relates to a strawberry maturity detection method based on an improved YOLOv8 model, specifically comprising: Step 1, acquiring strawberry images to obtain a strawberry dataset, labeling the dataset, classifying strawberry states as flowers, immature, and mature, preprocessing the images, and dividing the preprocessed images into a validation set, a test set, and a training set; Step 2, improving the YOLOv8 model to obtain an improved YOLOv8 model; Step 3, training the improved model using images from the training set to obtain the optimal weights; Step 4, applying the optimal weights to the test set to obtain the model evaluation index. This invention improves the existing YOLOv8 model by employing a feature fusion pyramid network and a deformable attention mechanism, which can more effectively enhance the model's feature extraction capability and improve detection performance.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the fields of computer vision and agricultural technology, and in particular to a method and system for detecting strawberry maturity based on an improved YOLOv8 model. By introducing a deformable attention mechanism and an improved multi-scale feature fusion module, this invention improves the accuracy and efficiency of strawberry maturity detection, making it especially suitable for classification tasks involving the flowering, immature, and mature states of strawberries. Background Technology

[0002] Strawberry maturity detection is a crucial step in agricultural production, directly impacting harvest time and quality. Traditional methods rely primarily on manual observation, which is inefficient and highly subjective. With the development of deep learning technology, computer vision-based object detection algorithms are increasingly being applied in agriculture, especially the YOLO (You Only Look Once) series of models, which are widely used for fruit detection tasks due to their efficiency and accuracy.

[0003] However, the existing YOLOv8 model has the following problems in strawberry maturity detection: Insufficient small target detection capability: Strawberry fruits are small, especially against complex backgrounds, making YOLOv8 prone to missed or false detections. Poor adaptability to complex scenes: YOLOv8 performs poorly in complex scenes such as occlusion and multiple targets. Insufficient multi-scale feature fusion: Strawberry maturity detection requires processing fruits of different scales, and YOLOv8 still has room for improvement in multi-scale feature fusion.

[0004] To address the aforementioned issues, this invention proposes a strawberry maturity detection method and system based on an improved YOLOv8. By introducing a dynamic attention mechanism and an improved multi-scale feature fusion module, the model's detection capability in complex scenarios is enhanced, especially in the classification task of strawberry flowering, immature, and mature states, where it performs better. Summary of the Invention

[0005] The purpose of this invention is to provide a strawberry maturity detection method based on an improved YOLOv8 model. It optimizes the existing YOLOv8 model by combining a deformable attention mechanism with a multi-scale fusion pyramid network (FPN), which can more effectively extract multi-scale features, improve the model's ability to detect strawberries of different maturity levels, and enhance detection accuracy and robustness.

[0006] The technical solution adopted in this invention is a strawberry maturity detection method based on an improved YOLOv8 model, which is implemented according to the following steps:

[0007] Step 1: Acquire strawberry images, perform image preprocessing, divide the preprocessed images into training set, validation set, and test set, and perform data augmentation;

[0008] Step 2: Improve the YOLOv8 model to obtain a YOLOv8 model with enhanced feature extraction capabilities;

[0009] Step 3: Train the improved YOLOv8 model using images from the training set to obtain the optimal weights;

[0010] Step 4: Apply the optimal weights to the test set, calculate the model evaluation index, and finally use it for the strawberry maturity detection task.

[0011] The invention is further characterized in that:

[0012] Step 1 is as follows:

[0013] Step 1.1: Collect strawberry images of different sizes, colors, shapes, poses, brightness, shadows, and occlusion levels as the raw dataset;

[0014] Step 1.2 involves sequentially flipping, adding noise, applying motion blur, randomly adjusting brightness, and augmenting the strawberry images in the original dataset.

[0015] Step 1.3 involves manually labeling the strawberry images in the original dataset after the enhancement in Step 1.2 using the LabelImg software, assigning a category to each strawberry image. Each strawberry image must contain at least one category.

[0016] Step 1.4: Use a Python script to convert the XML file obtained in Step 1.3 into a TXT file, and then divide it into a validation set, a test set, and a training set.

[0017] In step 1, the ratio of the training set, validation set, and test set is 8:1:1.

[0018] Step 2 involves improving the YOLOv8 model by integrating the feature fusion pyramid network module into the detection head, replacing the original YOLOv8 neck network and detection head with the improved detection head, and adding a deformable attention mechanism to the C2f module in the YOLOv8 model backbone network.

[0019] Step 3 specifically involves:

[0020] Step 3.1: Use the strawberry images in the training set as input to the improved YOLOv8 model, and use a Conv module with 64 channels and a 3×3 kernel size to extract features, and perform feature dimensionality reduction and normalization.

[0021] Step 3.2: The feature map extracted in step 3.1 is then processed by a Conv module with 128 channels and a kernel size of 3×3 for feature extraction and feature dimensionality reduction.

[0022] Step 3.3: The feature map after dimensionality reduction in step 3.2 is then enhanced with a C2f module of 128 channels to improve its feature representation capability.

[0023] Step 3.4: The feature map processed in step 3.3 is then used for feature extraction and feature dimensionality reduction through a Conv module with 256 channels and a 3×3 kernel size.

[0024] Step 3.5: The feature map processed in step 3.4 is then enhanced with a C2f module of 256 channels to improve its feature representation.

[0025] Step 3.6: The feature map processed in step 3.5 is then used for feature extraction and feature dimensionality reduction through a Conv module with 512 channels and a 3×3 kernel size.

[0026] Step 3.7: The feature map processed in step 3.6 is then enhanced with a C2f module of 512 channels to improve its feature representation.

[0027] Step 3.8: The feature map processed in step 3.7 is then used for feature extraction and feature dimensionality reduction through a Conv module with 1024 channels and a 3×3 kernel size.

[0028] Step 3.9: The feature map processed in step 3.8 is then passed through the C2f_DAttention module with 1024 channels to enhance its feature representation ability and to improve the model's detection accuracy for strawberry maturity targets by utilizing the self-attention mechanism.

[0029] Step 3.10: The feature map from step 3.9 is then fused with multi-scale information through an SPPF module with a pooling kernel size of 5 to optimize the feature representation;

[0030] In steps 3.11 and 3.10, the feature maps are used for target detection through the Detect_AFPN module, and combined with the different scale features output from steps 3.3, 3.5 and 3.7 to improve the performance of strawberry maturity detection.

[0031] Step 3.12: Following the process in steps 3.1-3.11, the improved YOLOv8 model is trained using strawberry images from the training set. During training, the CIoU loss function is used as the loss function for the improved YOLOv8 model. By setting the maximum number of iterations, batch size, initial learning rate, weight decay coefficient, optimizer, and data path of the improved YOLOv8 model, the improved YOLOv8 model is obtained after training.

[0032] The C2f module with the deformable attention mechanism is specifically modified by adjusting the Bottleneck structure within the C2f module to embed the deformable attention mechanism. Specifically, after a 1×1 convolutional layer (stride 1), a DAttention mechanism is added, and then the processed features are concatenated with the Bottleneck structure in the C2f module along the channel dimension (dim=1).

[0033] The maximum number of iterations is 200, the batch size is 16, the initial learning rate is 0.01, the optimizer uses stochastic gradient descent (SGD), and the weight decay coefficient is 0.0005.

[0034] The validation set is used to test the performance of the improved YOLOv8 model.

[0035] The beneficial effects of this invention are:

[0036] This invention employs the Feature Fusion Pyramid Network (AFPN) as the detection head of the existing YOLOv8 model, enhancing the expressive power of the feature pyramid and enabling it to better adapt to multi-scale changes in the target. Furthermore, by integrating the deformable attention mechanism (DAttention) into the C2f module model, it can more accurately focus on the target under different scales and deformation conditions, improving the detection capability for strawberries at different maturity levels. It maintains high detection accuracy, especially in environments with complex backgrounds, occlusion, and significant lighting variations. Results show that the improved YOLOv8 model network performs well in terms of precision, recall, and mAP, demonstrating improvements compared to the existing YOLOv5 model. Attached Figure Description

[0037] Figure 1 This is a flowchart of the strawberry fruit recognition method based on the improved YOLOv8n of this invention;

[0038] Figure 2 This is the original network structure diagram of YOLOv8n in existing technology;

[0039] Figure 3 This is a diagram of the AFPN feature fusion pyramid network structure in existing technologies;

[0040] Figure 4 This is a network structure diagram of the Deformable Attention mechanism in existing technologies;

[0041] Figure 5 This is a diagram of the C2f-DA attention network structure of this invention;

[0042] Figure 6 This is a diagram of the improved YOLOv8 network structure of this invention; Detailed Implementation

[0043] The present invention will now be described in detail with reference to the accompanying drawings and specific embodiments.

[0044] Example 1

[0045] This invention relates to a strawberry maturity detection method based on an improved YOLOv8 model, which is implemented according to the following steps:

[0046] like Figure 1 As shown, step 1 involves acquiring strawberry images, performing image preprocessing, and then dividing the preprocessed images into a validation set, a test set, and a training set; specifically:

[0047] Step 1.1: Collect strawberry images of different sizes, colors, shapes, poses, brightness, shadows, and occlusion levels as the raw dataset;

[0048] Step 1.2 involves sequentially flipping, adding noise, applying motion blur, randomly adjusting brightness, and augmenting the strawberry images in the original dataset.

[0049] Step 1.3 involves manually labeling the strawberry images in the original dataset after the enhancement in Step 1.2 using the LabelImg software, assigning a category to each strawberry image. Each strawberry image must contain at least one category.

[0050] Step 1.4: Use a Python script to convert the XML file obtained in Step 1.3 into a TXT file, and then divide it into a validation set, a test set, and a training set.

[0051] Step 2, specifically improving the YOLOv8 model, involves: integrating the feature fusion pyramid network module into the detection head, replacing the original YOLOv8 neck network and detection head with the improved detection head, and adding a deformable attention mechanism to the C2f module in the YOLOv8 model backbone network.

[0052] Step 3: Train the improved YOLOv8 model using images from the training set to obtain the optimal weights; specifically:

[0053] Step 3.1: Use the strawberry images in the training set as input to the improved YOLOv8 model, and use a Conv module with 64 channels and a 3×3 kernel size to extract features, and perform feature dimensionality reduction and normalization.

[0054] Step 3.2: The feature map extracted in step 3.1 is then processed by a Conv module with 128 channels and a kernel size of 3×3 for feature extraction and feature dimensionality reduction.

[0055] Step 3.3: The feature map after dimensionality reduction in step 3.2 is then enhanced with a C2f module of 128 channels to improve its feature representation capability.

[0056] Step 3.4: The feature map processed in step 3.3 is then used for feature extraction and feature dimensionality reduction through a Conv module with 256 channels and a 3×3 kernel size.

[0057] Step 3.5: The feature map processed in step 3.4 is then enhanced with a C2f module of 256 channels to improve its feature representation.

[0058] Step 3.6: The feature map processed in step 3.5 is then used for feature extraction and feature dimensionality reduction through a Conv module with 512 channels and a 3×3 kernel size.

[0059] Step 3.7: The feature map processed in step 3.6 is then enhanced with a C2f module of 512 channels to improve its feature representation.

[0060] Step 3.8: The feature map processed in step 3.7 is then used for feature extraction and feature dimensionality reduction through a Conv module with 1024 channels and a 3×3 kernel size.

[0061] Step 3.9: The feature map processed in step 3.8 is then passed through the C2f_DAttention module with 1024 channels to enhance its feature representation ability and to improve the model's detection accuracy for strawberry maturity targets by utilizing the self-attention mechanism.

[0062] Step 3.10: The feature map from step 3.9 is then fused with multi-scale information through an SPPF module with a pooling kernel size of 5 to optimize the feature representation;

[0063] In steps 3.11 and 3.10, the feature maps are used for target detection through the Detect_AFPN module, and combined with the different scale features output from steps 3.3, 3.5 and 3.7 to improve the performance of strawberry maturity detection.

[0064] Step 3.12: Following the process in steps 3.1-3.11, the improved YOLOv8 model is trained using strawberry images from the training set. During training, the CIoU loss function is used as the loss function for the improved YOLOv8 model. By setting the maximum number of iterations, batch size, initial learning rate, weight decay coefficient, optimizer, and data path of the improved YOLOv8 model, the improved YOLOv8 model is obtained after training.

[0065] Step 4: Apply the optimal weights to the test set to obtain the model evaluation index, and use the evaluated and improved YOLOv8 model to detect strawberry maturity.

[0066] Example 2

[0067] Based on Example 1, the maximum number of iterations is 200, the batch size is 16, the initial learning rate is 0.01, the optimizer uses stochastic gradient descent (SGD), and the weight decay coefficient is 0.0005.

[0068] Example 3

[0069] To verify the effectiveness of this method, this experiment collected strawberry images under different conditions from multiple agricultural image databases and actual harvesting environments, totaling 1000 images with varying sizes, colors, shapes, poses, brightness, shadows, and occlusion levels. For ease of training, the images were uniformly scaled to the same size and saved in JPG format. To improve the model's generalization ability and prevent overfitting, this experiment employed data augmentation methods (horizontal flipping, vertical flipping, Gaussian noise, motion blur, and random brightness adjustment) to expand the 1000 images to 7048 images.

[0070] The growth stages of strawberries can be divided into three phases: flowering, immature, and mature. Data annotation was performed manually using LabelImg software. This involved selecting strawberry targets in each image and labeling them with their corresponding maturity category, such as flowering, immature, or mature. The requirement for the labeled dataset was that each image must contain at least one labeled strawberry target to ensure data completeness and accuracy. Furthermore, to improve annotation quality, all annotated data was saved in Extensible Annotation Language (XML) format, and the dataset was divided into training, validation, and test sets in an 8:1:1 ratio.

[0071] The existing YOLOv8 model has four different network structures, such as... Figure 2As shown, these are YOLOv8s, YOLOv8m, YOLOv8l, and YOLOv8n, respectively. These four different network structures have different feature extraction modules, convolutional kernels, model sizes, and model parameters. They consist of four parts: the backbone, the neck network, and the head network.

[0072] The backbone network is responsible for feature extraction, employing a series of convolutional and deconvolutional layers, along with residual connections and bottleneck structures to reduce network size and improve performance. This part uses C2f modules as its basic building blocks; compared to YOLOv5's C3 modules, C2f modules have fewer parameters and superior feature extraction capabilities. Specifically, C2f modules reduce redundant parameters and improve computational efficiency through more efficient structural design. Furthermore, the backbone includes common improvement techniques such as depthwise separable convolution and dilated convolution to further enhance feature extraction capabilities. The neck network is responsible for multi-scale feature fusion, enhancing feature representation capabilities by fusing feature maps from different stages of the backbone. Specifically, the YOLOv8 Neck section includes the following components: the SPPF (Spatial Pyramid Pooling Fast) module for pooling operations at different scales, concatenating feature maps of different scales to improve the detection capability for targets of different sizes; the PAA (Probabilistic Anchor Assignment) module for intelligently assigning anchor boxes to optimize the selection of positive and negative samples and improve the training effect of the model; and the PAN (Path Aggregation Network) module for path aggregation of features at different levels, enhancing the expressive power of feature maps through bottom-up and top-down paths. The Head section is responsible for the final object detection and classification tasks, including a detection head and a classification head. The detection head contains a series of convolutional and deconvolutional layers to generate detection results. These layers are responsible for predicting the bounding box regression value and the confidence score of the target presence for each anchor box. The classification head uses global average pooling to classify each feature map, reducing the dimensionality of the feature maps and outputting the probability distribution for each class. The feature values ​​of the classification head can be matched to specific types of classification tasks.

[0073] To balance the performance and real-time requirements of the model in practical agricultural applications, this paper selects YOLOv8n as the benchmark model. However, in the complex strawberry growing environment, factors such as the dense distribution of strawberry fruits, changes in posture, leaf occlusion, and fruit overlap still pose challenges to the detection task, especially on the highly diverse strawberry maturity dataset, where the performance of the benchmark model still needs improvement.

[0074] This invention improves upon the existing YOLOv8n model by incorporating a feature fusion pyramid network module into the detection head, replacing the original YOLOv8 neck network and detection head to more effectively achieve multi-scale feature fusion. A deformable attention mechanism is added to the C2f module of the YOLOv8 backbone network to enhance the model's feature extraction capabilities for occluded and overlapping targets in complex environments. Through these improvements, the model's detection accuracy and robustness in strawberry maturity detection tasks are enhanced, while also maintaining real-time performance, resulting in an improved YOLOv8n model.

[0075] The training process according to step 3 in Example 1 is as follows:

[0076] Strawberry images from the training set were used as input to the improved YOLOv8 model. Features were extracted using a 64-channel Conv module with a 3×3 kernel, followed by dimensionality reduction and normalization. Then, features were extracted again using a 128-channel Conv module with a 3×3 kernel, and dimensionality reduction was performed. Next, a 128-channel C2f module was used to enhance feature representation. This process was repeated three times: first, feature extraction was performed using a 256-channel Conv module with a 3×3 kernel, and dimensionality reduction was performed again; second, a 256-channel C2f module was used to enhance feature representation; and finally, a 512-channel Conv module with a 3×3 kernel was used for feature extraction and normalization. Dimensionality reduction is performed; then, the feature representation capability is enhanced by the C2f module with 512 channels; then, the feature extraction and dimensionality reduction are performed by the Conv module with 1024 channels and a 3×3 kernel size; then, the feature representation capability is enhanced by the C2f_DAttention module with 1024 channels, and the self-attention mechanism is used to improve the model's detection accuracy for strawberry maturity targets; then, multi-scale information fusion is performed by the SPPF module with a pooling kernel size of 5 to optimize feature representation; finally, the target detection is performed by the Detect_AFPN_P2345_Custom module, and the different scale features output from the second, fourth, and sixth layers are combined to improve the strawberry maturity detection performance.

[0077] Adjust the parameters in the YOLOv8 related files: image input size is 640 pixels × 640 pixels, maximum number of iterations is 200, batch size is 16, initial learning rate is 0.01, the optimizer uses stochastic gradient descent (SGD), the weight decay coefficient is 0.0005, and the data path is modified; analyze the feature extraction capability of strawberry fruit through model results.

[0078] In the original YOLOv8 network, the neck network employs top-down and bottom-up path fusion of features to achieve efficient multi-scale feature representation and optimize object detection performance. To further enhance the feature representation capability of the detection head, this scheme introduces a Feature Fusion Pyramid Network (AFPN) module into the detection head, such as... Figure 3 As shown, this module enhances the interaction and information fusion capabilities of features at different scales. It effectively learns the importance weights of features at different scales and dynamically adjusts the feature flow, enabling shallow and deep features to interact more fully and improving the model's object detection performance. Simultaneously, the feature fusion pyramid network extracts semantic information from low-level features from higher-level features, enhancing the model's ability to identify strawberries at different maturity levels and improving detection accuracy and robustness.

[0079] Furthermore, in the YOLOv8 backbone network, the C2f module is a crucial component for feature extraction. To enhance feature extraction capabilities, this scheme introduces a Deformable Attention Mechanism (DAM) into the C2f module, such as... Figure 4 As shown, this mechanism enables adaptive spatial transformation of input features, allowing the model to focus on the most discriminative regions while reducing interference from irrelevant background information. By dynamically learning attention weights, DAM enhances the model's ability to focus on strawberries at different maturity levels, enabling it to accurately distinguish strawberries at different maturity stages even in complex environments, thus improving detection robustness and generalization ability.

[0080] This study comprehensively evaluated the performance of the strawberry maturity detection task by improving the YOLOv8 network structure. The main model evaluation metrics used included: accuracy (P), recall (R), and mean AP (mAP). Accuracy (P) measures the proportion of correctly detected strawberry samples, while recall (R) measures the proportion of correctly detected strawberry samples out of all real samples. The combined measure of P and R is mean AP, which is the average accuracy (mAP) for different strawberry maturity categories, used to measure the overall detection performance of the model. Its calculation formula is as follows:

[0081]

[0082]

[0083]

[0084]

[0085] Where TP (True Positive) represents the number of strawberry samples correctly detected by the model, FP (False Positive) represents the number of incorrect samples that the model misdetected as strawberries, FN (False Negative) represents the number of true strawberry samples that the model failed to detect, and n is the total number of categories.

[0086] Specifically, the improved YOLOv8 model is as follows: Figure 5 As shown, the accuracy in strawberry maturity detection is 91.5%, the recall is 84.3%, and the mAP (0.5 threshold) reaches 93%. The improved YOLOv8 model, on the same test set, achieves an accuracy of 89.7%, a recall of 90.5%, and an mAP (0.5 threshold) of 93.9%, while reducing the number of parameters from 3 million to 2.5 million. Compared to the original model, the improved scheme improves recall and average accuracy by 6.2% and 0.9%, respectively. These results demonstrate that this scheme, based on YOLOv8, improves the accuracy and robustness of strawberry maturity detection by optimizing the detection head structure and backbone network feature extraction capabilities, making it more suitable for practical agricultural applications.

[0087] Experimental analysis was conducted on strawberry maturity detection. To facilitate intuitive analysis of the model's detection results, flowering, immature, and mature strawberry fruits were labeled separately. The results show that the improved YOLOv8 model can detect strawberries of different maturity levels with high confidence even in complex backgrounds. It also possesses the ability to detect small target strawberries and accurately detect strawberries in multiple locations. This indicates that the improved model outperforms the original YOLOv8 model in both feature representation and target detection capabilities, effectively improving detection accuracy and robustness.

[0088] Comprehensive experimental analysis results show that the improved YOLOv8 model demonstrates significant superiority in strawberry maturity detection. This model not only enhances the detection capability for strawberries at different maturity levels but also strengthens the feature extraction capability for targets in complex scenarios, making the model more practical and reliable in real-world agricultural applications.

Claims

1. A strawberry maturity detection method based on an improved YOLOv8 model is implemented according to the following steps: Step 1: Collect strawberry images. Obtain strawberry datasets by taking strawberry images in the field and crawling strawberry fruit images from the Internet. Label the datasets and classify the strawberry status into flowers, immature and ripe. Then, preprocess the obtained strawberry images and divide the preprocessed images into validation set, test set and training set. Step 2: Improve the YOLOv8 model to obtain the improved YOLOv8 model; Step 3: Train the improved model using images from the training set to obtain the optimal weights; Step 4: Apply the optimal weights to the test set to obtain the model evaluation index.

2. The method according to claim 1, characterized in that, Step 1 specifically involves: Step 1.1: Collect strawberry images of different sizes, colors, shapes, poses, brightness, shadows, and occlusion levels as the raw dataset; Step 1.2 involves sequentially flipping, adding noise, applying motion blur, randomly adjusting brightness, and augmenting the strawberry images in the original dataset. Step 1.3 involves manually labeling the strawberry images in the original dataset after enhancement in Step 1.2 using the LabelImg software, marking the category on each strawberry image. Each strawberry image must contain at least one category. Step 1.4: Use a Python script to convert the XML file obtained in Step 1.3 into a TXT file, and then divide it into a validation set, a test set, and a training set.

3. The strawberry maturity detection method based on the improved YOLOv8 model according to claim 2, characterized in that, The ratio of the training set, validation set, and test set is 8:1:

1.

4. The strawberry maturity detection method based on the improved YOLOv8 model according to claim 1, characterized in that, The specific improvements to the YOLOv8 model in step 2 are as follows: the feature fusion pyramid network module is integrated into the detection head, the original YOLOv8 neck network and detection head are replaced with the improved detection head, and a deformable attention mechanism is added to the C2f module in the backbone network of the YOLOv8 model.

5. The strawberry maturity detection method based on the improved YOLOv8 model according to claim 4, characterized in that, Step 3 specifically involves: Step 3.1: Use the strawberry images in the training set as input to the improved YOLOv8 model, and use a Conv module with 64 channels and a 3×3 kernel size to extract features, and perform feature dimensionality reduction and normalization. Step 3.2: The feature map extracted in step 3.1 is then processed by a Conv module with 128 channels and a kernel size of 3×3 for feature extraction and feature dimensionality reduction. Step 3.3: The feature map after dimensionality reduction in step 3.2 is then enhanced with a C2f module of 128 channels to improve its feature representation capability. Step 3.4: The feature map processed in step 3.3 is then used for feature extraction and feature dimensionality reduction through a Conv module with 256 channels and a 3×3 kernel size. Step 3.5: The feature map processed in step 3.4 is then enhanced with a C2f module of 256 channels to improve its feature representation. Step 3.6: The feature map processed in step 3.5 is then used for feature extraction and feature dimensionality reduction through a Conv module with 512 channels and a 3×3 kernel size. Step 3.7: The feature map processed in step 3.6 is then enhanced with a C2f module of 512 channels to improve its feature representation. Step 3.8: The feature map processed in step 3.7 is then used for feature extraction and feature dimensionality reduction through a Conv module with 1024 channels and a 3×3 kernel size. Step 3.9: The feature map processed in step 3.8 is then passed through the C2f_DAttention module with 1024 channels to enhance its feature representation ability and to improve the model's detection accuracy for strawberry maturity targets by utilizing the self-attention mechanism. Step 3.10: The feature map from step 3.9 is then fused with multi-scale information through an SPPF module with a pooling kernel size of 5 to optimize the feature representation; Step 3.11 Finally, the feature map from step 3.10 is used for target detection through the Detect_AFPN module, and combined with the different scale features output from steps 3.3, 3.5 and 3.7 to improve the performance of strawberry maturity detection.

6. The strawberry maturity detection method based on the improved YOLOv8 model according to claim 5, characterized in that, The C2f module with the added Deformable Attention mechanism specifically involves incorporating the Deformable Attention mechanism into the feature extraction process of the C2f module. Deformable convolution is used to enhance feature adaptability, enabling the model to focus more on the target region of the strawberry fruit and to exchange information in the feature channel dimension to improve feature expression capabilities.

7. The strawberry maturity detection method based on the improved YOLOv8 model according to claim 6, characterized in that, The maximum number of iterations is 200, the batch size is 16, the initial learning rate is 0.01, the optimizer uses stochastic gradient descent (SGD), and the weight decay coefficient is 0.0005.

8. The strawberry maturity detection method based on the improved YOLOv8 model according to claim 1, characterized in that, The experimental test set was used to evaluate the performance of the trained improved YOLOv8 model.