Prunus mira detection method in complex scene based on improved YOLOv8

By improving the YOLOv8 model and combining the EMA module, AFPN, and MPDIoU loss function, the accuracy problem of plum detection in complex scenarios was solved, achieving efficient identification of small target fruits and supporting intelligent harvesting.

CN117612158BActive Publication Date: 2026-11-24CHONGQING NORMAL UNIVERSITY
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311627597.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-11-30
Publication Date
2026-11-24
Estimated Expiration
2043-11-30

AI Technical Summary

Technical Problem

Existing target detection methods are not ideal for detecting green plums in complex scenarios, especially for small target fruits with low recognition rate and easy to miss detection, making it difficult to meet the needs of intelligent harvesting.

Method used

An improved YOLOv8 model is adopted, which improves feature representation and localization accuracy by adding an EMA module to the backbone network, replacing PAFPN with AFPN, and introducing the MPDIoU loss function, thereby enhancing the detection capability of small targets.

Benefits of technology

It improves the accuracy and efficiency of green plum detection, effectively identifies small target fruits, and supports intelligent harvesting of green plums.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117612158B_ABST
    Figure CN117612158B_ABST
Patent Text Reader

Abstract

This invention discloses a method for detecting green plums in complex scenes based on an improved YOLOv8, comprising: S1. acquiring green plum images under different scene conditions to form an image dataset; S2. performing data augmentation processing on the image dataset to obtain an augmented dataset; S3. constructing an improved YOLOv8 target detection model, training the target detection model using the dataset to obtain a trained target detection model; S4. inputting the green plum image to be detected into the trained target detection model, and outputting the detected green plum information. This invention can improve the accuracy of green plum detection, effectively identify green plum images containing small target fruits, and improve the detection effect of small targets.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of small target detection, specifically to a method for detecting green plums in complex scenarios based on an improved YOLOv8. Background Technology

[0002] Green plums are a fruit widely cultivated in southwestern China, possessing high economic value and market demand. However, with the increasing market demand for green plums, the harvesting process faces numerous challenges. Due to the large scale of green plum cultivation, the small size of the fruit, and its dense distribution, traditional manual harvesting is not only time-consuming and labor-intensive but may also damage the fruit.

[0003] Currently, intelligent object detection methods based on convolutional neural networks (CNNs) are being gradually applied to harvesting operations. Existing object detection methods mainly rely on the feature combination and abstraction of receptive fields at different scales by convolutional kernels. Due to the characteristics of green plums, such as leaves and fruit colors being very similar, dense fruit distribution, abundant branches and leaves, and relatively small fruit size, existing object detection methods suffer from problems such as the easy omission of green plums and unsatisfactory extraction of small targets. Therefore, to solve these problems, a green plum detection method based on improved YOLOv8 for complex scenes is needed, which can improve the accuracy of green plum detection, effectively identify green plum images containing small target fruits, and improve the detection effect of small targets. Summary of the Invention

[0004] In view of this, the purpose of this invention is to overcome the defects in the prior art and provide a method for detecting green plums in complex scenes based on improved YOLOv8, which can improve the accuracy of green plum detection, effectively identify green plum images containing small target fruits, and improve the detection effect of small targets.

[0005] The present invention provides a method for detecting crisp plums in complex scenarios based on improved YOLOv8, comprising the following steps:

[0006] S1. Collect images of crisp plums under different scene conditions to form an image dataset;

[0007] S2. Perform data augmentation on the image dataset to obtain the augmented dataset;

[0008] S3. Construct an improved YOLOv8 object detection model, train the object detection model using the dataset, and obtain a trained object detection model;

[0009] S4. Input the image of the green plum to be tested into the trained target detection model and output the detected green plum information.

[0010] Furthermore, the data enhancement processing includes image brightness adjustment, image flipping, and image translation.

[0011] Furthermore, step S2 also includes: performing slice enhancement processing on the distant view images in the enhanced dataset.

[0012] The distant view image is cut into multiple overlapping small images, each with a size of n×n pixels. Then, the small images are labeled using annotation software. A rectangular frame is drawn online to completely encompass the entire green plum, and a txt file containing the position information of the green plum rectangular frame is generated. The txt file stores the position information of the four corners of the labeled area rectangular frame and the annotation type information.

[0013] Furthermore, the improved YOLOv8 object detection model uses YOLOv8s-p2 as the base network, adds EMA to the backbone network of YOLOv8s-p2 to achieve pixel-level attention allocation; adopts AFPN instead of PAFPN to support direct feature fusion of non-adjacent layers; and replaces the CIoU loss function in the detection head of YOLOv8s-p2 with the MPDIoU loss function.

[0014] Furthermore, EMA extracts the original feature map X∈R of the green plum from the network. C×H×W As input, and along X∈R C×H×W The channel dimension is used to divide the number of channels into G groups, resulting in a set of G sub-feature maps:

[0015] [X0,X1,...X i ,...X G-1 ], where sub-feature maps H and W represent the dimensions in the vertical and horizontal directions, respectively; C represents the number of channels.

[0016] The sub-feature maps of these G groups are fed into two parallel sub-networks respectively;

[0017] The first subnetwork is a branch with a 1×1 convolutional kernel. Processing is performed in the 1×1 branch to generate the first 1×H×W spatial attention weight map.

[0018] The second subnetwork is a branch with a 3×3 convolutional kernel. Processing is performed in the 3×3 branch to generate the second 1×H×W spatial attention weight map.

[0019] The first and second spatial attention weight maps are added together. The resulting weight map is then processed using the Sigmoid function to generate a new attention weight map. The new attention weight map is then used to perform matrix multiplication on the sub-feature maps to output a feature map that highlights the target region of the crisp plum.

[0020] Furthermore, processing is performed in the 1×1 branch to generate the first 1×H×W spatial attention weight map, specifically including:

[0021] The sub-feature maps are subjected to one-dimensional average pooling in both the horizontal and vertical dimensions to generate corresponding feature maps. and Then the generated feature map and The feature maps are stitched together along the vertical dimension, and a 1×1 convolutional kernel is used to establish the connection between channel and spatial location information. The feature maps are decomposed into two feature maps in different spatial directions. After being processed by the Sigmoid activation function, attention weight maps in the horizontal and vertical dimensions are generated.

[0022] The sub-feature map is updated by performing matrix multiplication with the attention weight map in the horizontal and vertical dimensions. The updated sub-feature map is used as the intermediate feature map of the green plum. After GroupNorm, the intermediate feature map is subjected to Avgpool and Softmax operations in sequence to obtain the softmax feature map. The softmax feature map and the output of the sub-feature map after processing by a 3×3 convolution kernel are then subjected to matrix multiplication to generate the first 1×H×W spatial attention weight map.

[0023] Furthermore, processing is performed in the 3×3 branch to generate a second 1×H×W spatial attention weight map, specifically including:

[0024] After the sub-feature map is processed by a 3×3 convolution kernel, it is then subjected to two operations: Avgpool and Softmax. The feature map after Softmax is then multiplied by the feature map after GroupNorm in the 1×1 branch to generate the second 1×H×W spatial attention weight map.

[0025] Furthermore, AFPN's fusion process starts with two adjacent low-level features and progressively incorporates high-level features into the fusion process. After each fusion, a new feature map is generated as one of the inputs for the next fusion.

[0026] Furthermore, in the process of multi-level feature fusion, adaptive spatial fusion is used to assign different spatial weights to features at different levels.

[0027] Furthermore, the MPDIoU loss function L is determined according to the following formula. MPDIoU :

[0028] L MPDIoU =1-MPDIoU;

[0029] in, A and B represent the ground truth bounding box and the detection bounding box, respectively, and w and h represent the width and height of the target image, respectively; the target image is an image that includes both the ground truth bounding box and the detection bounding box.

[0030]

[0031]

[0032] This represents the coordinates of the top-left and bottom-right corners of point A. These represent the coordinates of the top left and bottom right corners of point B.

[0033] The beneficial effects of this invention are as follows: This invention discloses an improved YOLOv8-based method for detecting small green plums in complex scenes. Using YOLOv8s-p2 as the base network, an improved YOLOv8 model suitable for detecting small green plum targets in complex scenes is designed. Firstly, an efficient multi-scale attention module is added to the backbone network to improve the model's foreground-background differentiation ability. Secondly, the path aggregation feature pyramid network is replaced with a progressive feature pyramid, and low-level and high-level features are fused through adaptive weights to enhance feature representation ability. Finally, MPDIoU is introduced as a regression loss function to improve the model's localization accuracy, thereby effectively identifying green plum images containing small target fruits, improving the detection effect of small targets, and providing technical support for realizing intelligent harvesting of green plums. Attached Figure Description

[0034] The present invention will be further described below with reference to the accompanying drawings and embodiments:

[0035] Figure 1 This is a schematic diagram illustrating the enhancement of distant view image slices according to the present invention;

[0036] Figure 2 This is a schematic diagram of the improved YOLOv8 target detection model network structure of the present invention;

[0037] Figure 3 This is a diagram of the EMA network structure of the present invention;

[0038] Figure 4 This is a schematic diagram of the progressive feature pyramid network of the present invention;

[0039] Figure 5 This is a schematic diagram of the feature fusion process of the AFPN of the present invention;

[0040] Figure 6 This is a schematic diagram of the parameters of the MPDIoU loss function of the present invention. Detailed Implementation

[0041] The present invention will be further described below with reference to the accompanying drawings, as shown in the figures:

[0042] The present invention provides a method for detecting crisp plums in complex scenarios based on improved YOLOv8, comprising the following steps:

[0043] S1. Collect images of crisp plums under different scene conditions to form an image dataset;

[0044] S2. Perform data augmentation on the image dataset to obtain the augmented dataset;

[0045] S3. Construct an improved YOLOv8 object detection model, train the object detection model using the dataset, and obtain a trained object detection model;

[0046] S4. Input the image of the green plum to be tested into the trained target detection model and output the detected green plum information.

[0047] It should be noted that the detection method of this invention can be used for fruits that are small in size, have a color similar to that of leaves or branches, and have relatively dense fruit, leaves, or branches.

[0048] In this embodiment, in step S1, a specific agricultural technology demonstration park can be selected to analyze the mature green plums. The longitude, latitude, and altitude of this demonstration park are 106.221°, 29.753°, and 353m, respectively. Analysts used the cameras of a Redmi K40 and an OPPO Reno6 Pro+ smartphone to photograph each green plum tree from both distant and close-up views, and from both front and backlighting, at distances ranging from 0.1m to 1.5m. The collected images included various target fruit morphologies, such as single, unobstructed target fruits, overlapping fruits, and target fruits obscured by branches and leaves. Furthermore, factors such as lighting and weather conditions were considered. The collected data included green plum images taken at different times of day, under different lighting conditions, and from different angles, with a shooting duration of 6 hours. After screening, a total of 475 images with clear outlines and textures were obtained, with image resolutions of 3000×4000, 4000×3000, 6144×8192, and 8192×6144 pixels.

[0049] Green plums occupy very few pixels in high-resolution images, thus this image dataset falls under the category of small object detection. The dataset contains diverse images covering different shooting distances, viewpoints, and background conditions to simulate real-world harvesting scenarios. The 475 actual images were randomly divided into training, validation, and test sets in a 7:2:1 ratio for training and evaluating the object detection model.

[0050] In this embodiment, in step S2, to improve the learning ability of the object detection model, a series of standard data augmentation operations are first performed on the training set, including image brightness adjustment, image flipping, and image translation, resulting in 990 enhanced images. Image brightness adjustment includes both brightness enhancement and brightness reduction.

[0051] In distant images, the number of pixels occupied by the green plum fruit is relatively small, especially when fed into object detection models. Images larger than 640×640 pixels are compressed to 640×640 pixels, resulting in even fewer visible pixels of the green plum fruit in distant images. To address this issue, this invention performs slice enhancement on distant images.

[0052] Step S2 further includes: performing slice enhancement processing on the enhanced distant images in the dataset.

[0053] like Figure 1 As shown, the distant image is sliced ​​into multiple overlapping small images, each with a size of 640×640 pixels. Distant image slicing enhancement can help the model learn the features and contextual information of the small target, the crisp plum, more comprehensively, and improve the model's robustness and generalization ability to small targets.

[0054] Then, the small image was annotated using the annotation software MAKE SENSE. A rectangle was drawn online to completely encompass the entire plum, and a txt file containing the position information of the plum rectangle was generated. The file name was the same as the image name. The txt file stored the position information of the four corners of the annotated area rectangle and the annotation type information.

[0055] In this embodiment, the YOLOv8s-p2 object detection network consists of three parts: a backbone, a neck feature fusion network, and a prediction head. This invention improves the network in three aspects to enhance detection accuracy and efficiency, specifically targeting the characteristics of the plum dataset. Specifically: In the backbone, an EMA module is introduced, which enables pixel-level attention allocation, enhancing feature selectivity and discriminative power, thereby effectively reducing missed detections; in the neck, AFPN is used instead of PAFPN. AFPN supports direct feature fusion of non-adjacent layers, preserving small target feature information and preventing its loss and degradation, thus improving detection performance; in the head, MPDIoU loss function is used instead of CIoU loss function. MPDIoU loss function simplifies the similarity comparison between bounding boxes by minimizing the distance between the top-left and bottom-right corners of the predicted and ground truth bounding boxes, improving localization accuracy and efficiency. The improved YOLOv8 object detection model network structure proposed in this invention is as follows: Figure 2 As shown.

[0056] In this embodiment, in the target detection task, the attention mechanism is usually used to focus on the target region and suppress interference from non-target regions such as the background, thereby improving the accuracy of target detection. For crops like the green plum, where the fruit and leaf colors are highly similar, the interference from background factors is particularly significant. To address this issue, this invention introduces an EMA module and embeds it into the C2f structure of YOLOv8s-p2. This module groups and learns the number of channels in the input feature map, making full use of the feature information within each channel. In addition, EMA introduces two different sizes of convolutional kernels as parallel sub-networks, realizing the fusion of multi-scale feature information of the green plum. Simultaneously, two-dimensional global average pooling is performed on the two sub-networks to encode global information, thereby capturing pixel-level pairwise relationships. This process establishes long-distance dependencies between channels and space, enhancing the feature representation ability of regions of interest in the feature map. The network structure of EMA is as follows: Figure 3 As shown.

[0057] EMA extracts the original feature map X∈R of the green plum from the network. C×H×W As input, and along X∈R C×H×W The channel dimension is used to divide the number of channels into G groups, resulting in a set of G sub-feature maps:

[0058] [X0,X1,...X i ,...X G-1 ], where sub-feature maps H and W represent the dimensions in the vertical and horizontal directions, respectively; C represents the number of channels.

[0059] The sub-feature maps of these G groups are fed into two parallel sub-networks respectively;

[0060] The first sub-network is a branch with a 1×1 convolution kernel. Processing is performed in the 1×1 branch to generate the first 1×H×W spatial attention weight map. The 1×1 branch contains two parallel paths. The first parallel path performs one-dimensional global average pooling on the feature information in the horizontal dimension (X), as shown in Equation (1), while the second parallel path performs one-dimensional global average pooling on the feature information in the vertical dimension (Y), as shown in Equation (2), thereby capturing long-distance dependencies and location information in different spatial dimensions.

[0061]

[0062]

[0063] Where, x c (H,i) represents the input feature at the i-th position in the horizontal dimension of the c-th channel, x c(j,W) represents the input feature at the j-th position in the vertical dimension of the c-th channel. This represents the feature of the c-th channel after one-dimensional global average pooling in the horizontal dimension. This represents the feature of the c-th channel after one-dimensional global average pooling in the vertical dimension.

[0064] The second subnetwork is a branch with a 3×3 convolutional kernel. Processing is performed in the 3×3 branch to generate the second 1×H×W spatial attention weight map.

[0065] The first and second spatial attention weight maps are added together. The resulting weight map is then processed using the Sigmoid function to generate a new attention weight map. The new attention weight map is then used to perform matrix multiplication on the sub-feature maps to output a feature map that highlights the target region of the crisp plum.

[0066] In this embodiment, processing is performed in the 1×1 branch to generate the first 1×H×W spatial attention weight map, specifically including:

[0067] The sub-feature maps are subjected to one-dimensional average pooling in both the horizontal and vertical dimensions to generate corresponding feature maps. and Then the generated feature map and The feature maps are stitched together along the vertical dimension, and a 1×1 convolutional kernel is used to establish the connection between channel and spatial location information. The feature maps are decomposed into two feature maps in different spatial directions. After being processed by the Sigmoid activation function, attention weight maps in the horizontal and vertical dimensions are generated.

[0068] The sub-feature map is updated by performing matrix multiplication operations between the attention weight map in the horizontal and vertical dimensions and the sub-feature map. Specifically, the attention weight map in the horizontal dimension is first multiplied with the sub-feature map to update the sub-feature map for the first time, and then the attention weight map in the vertical dimension is multiplied with the sub-feature map after the first update to update the sub-feature map for the second time.

[0069] The updated sub-feature map is used as the intermediate feature map of the green plum. After GroupNorm, the intermediate feature map undergoes Avgpooling and Softmax operations in sequence to obtain the softmax feature map. The softmax feature map and the output of the sub-feature map after processing with a 3×3 convolution kernel are then multiplied by a matrix, as shown in R. 1×C / G ×R C / G×H×WThe first 1×H×W spatial attention weight map is generated. Avgpool performs two-dimensional global average pooling on the intermediate feature map to fuse global spatial information and channel information, resulting in a C / G×1×1 feature map, as shown in equation (3).

[0070]

[0071] Where, x c (i,j) represents the input feature at position (i,j) in the spatial dimension of the c-th channel, z c This represents the feature of the c-th channel after two-dimensional global average pooling.

[0072] In this embodiment, processing is performed in the 3×3 branch to generate a second 1×H×W spatial attention weight map, specifically including:

[0073] After the sub-feature maps are processed by a 3×3 convolution kernel, Avgpool and Softmax operations are performed sequentially. The feature map after Softmax is then multiplied by the feature map after GroupNorm in the 1×1 branch, resulting in a matrix multiplication operation of the form R. 1 ×C / G ×R C / G×H×W A second 1×H×W spatial attention weight map is generated to enable cross-space information interaction.

[0074] In this embodiment, Feature Pyramid Network (FPN) is a feature fusion technique commonly used in object detection. It can combine and generate feature maps at different scales, thereby improving the model's detection capability and robustness against targets of different sizes and proportions. With the development of object detection technology, many methods have emerged to improve FPN and further enhance model performance. YOLOv8s-p2 uses PAPPN, which adds a bottom-up feature fusion path to FPN to more effectively capture and integrate feature information at different scales. However, the bottom-up feature fusion path still has a problem: low-level feature information is lost and degraded during transmission and interaction.

[0075] For small objects like plums, low-level features can provide more spatial and detailed information, which helps improve the model's ability to detect small objects. Therefore, this invention introduces AFPN to replace PAFPN, thereby retaining more low-level feature information during the feature fusion stage.

[0076] The fusion process of AFPN starts with two adjacent low-level features and progressively incorporates high-level features. Each fusion generates a new feature map, which serves as one of the inputs for the next fusion. The fusion process is as follows: Figure 4 As shown.

[0077] AFPN extracts a set of features at different scales from each feature layer of the backbone network, denoted as {C2, C3, C4, C5}. First, it fuses the low-level features C2 and C3, then adds C4 for further fusion, and finally fuses all four layers together to obtain {P2, P3, P4, P5}. This achieves direct fusion of features at different scales and retains more low-level feature information for the prediction stage. This progressive feature fusion avoids significant semantic gaps between non-adjacent layers.

[0078] In the multi-level feature fusion process, adaptive spatial fusion (ASF) is used to assign different spatial weights to features at different levels, enhancing the importance of key layer features and mitigating the influence of conflicting information from different objects. The feature fusion process at three levels (C2, C3, C4) is as follows: Figure 5 As shown, before fusion, the corresponding layers are upsampled or downsampled to make the feature maps the same size, and then adaptive spatial fusion is performed. Figure 5 The adaptive fusion of the three feature maps is shown in Equation (4):

[0079]

[0080] in, This represents the feature vector at position (i,j) where the nth layer feature map is fused to the lth layer feature map. The spatial weights representing the features of the three levels of the l-th layer are learnable parameters and satisfy equation (5). It is the result feature vector.

[0081]

[0082] In this embodiment, the CIoU loss is used for bounding box regression in the YOLOv8s-p2 base network. However, when the center point and aspect ratio of the predicted box and the ground truth box are the same, but their width and height values ​​are different, the CIoU loss function cannot effectively optimize the predicted box. To solve this problem, this invention introduces the MPDIoU loss function, which can accelerate the model's fitting of the positional relationship between the predicted box and the ground truth box, especially in the case of overlapping occlusion, it can more accurately locate the target. The idea of ​​the MPDIoU loss function is to minimize the distance between the top-left corner and the bottom-right corner of the predicted box and the ground truth box, thereby improving model performance and localization accuracy. Figure 6 This is a diagram illustrating the MPDIoU parameters. The lower left box represents the ground truth bounding box, and the upper right box represents the predicted bounding box.

[0083] The MPDIoU loss function L is determined according to the following formula.MPDIoU :

[0084] L MPDIoU =1-MPDIoU;

[0085] in, A and B represent the ground truth bounding box and the detection bounding box, respectively, and w and h represent the width and height of the target image, respectively; the target image is an image that includes both the ground truth bounding box and the detection bounding box.

[0086]

[0087]

[0088] This represents the coordinates of the top-left and bottom-right corners of point A. These represent the coordinates of the top left and bottom right corners of point B.

[0089] To achieve accurate detection of ripe green plums, this invention improves the YOLOv8s-p2 network in three aspects to enhance the efficiency and accuracy of green plum detection. First, an EMA attention module is added to the backbone network to improve the model's ability to perceive green plums. Second, PAFPN is replaced with AFPN, which enhances feature representation by adaptively fusing low-level and high-level features. Finally, MPDIoU is introduced as a regression loss function to improve the model's localization accuracy.

[0090] Analysis results on a self-built green plum dataset show that the average accuracy of the detection model of this invention reaches 87.5%, which is 1.8% higher than that of the original YOLOv8s-p2. In comparative tests with models such as RT-DETR, YOLOv7-tiny, and YOLOv5s, the detection model of this invention exhibits the best overall performance, demonstrating high detection accuracy when handling green plum images with complex backgrounds, overlapping fruits, and those containing small distant fruits.

[0091] The detection model of this invention meets both accuracy and real-time requirements, and can be deployed on the vision system of an automated harvesting robot. This helps to realize the automated harvesting of crisp plums, reduce manual labor, and provide technical support for the intelligent harvesting of crisp plums.

[0092] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit it. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention, and all such modifications or substitutions should be covered within the scope of the claims of the present invention.

Claims

1. A method for detecting crisp plums in complex scenarios based on improved YOLOv8, characterized in that: Includes the following steps: S1. Collect images of crisp plums under different scene conditions to form an image dataset; S2. Perform data augmentation on the image dataset to obtain the augmented dataset; Step S2 further includes: performing slice enhancement processing on the enhanced distant images in the dataset. The distant view image is cut into multiple overlapping small blocks, each block having a size of [size missing]. The pixels are then used to annotate small areas of the image. A rectangle is drawn online to completely encompass the entire plum, and a txt file containing the position information of the plum rectangle is generated. The txt file stores the position information of the four corners of the annotated area rectangle and the annotation type information. S3. Construct an improved YOLOv8 object detection model, train the object detection model using the dataset, and obtain a trained object detection model; The improved YOLOv8 object detection model uses YOLOv8s-p2 as its base network. An EMA is added to the backbone of YOLOv8s-p2, and the EMA is embedded into the C2f structure of YOLOv8s-p2 to achieve pixel-level attention allocation. AFPN is used instead of PAFPN to support direct feature fusion of non-adjacent layers. The CIoU loss function in the detection head of YOLOv8s-p2 is replaced with the MPDIoU loss function. S4. The image of the green plum to be tested is input into the trained object detection model, and the detected green plum information is output.

2. The method for detecting crisp plums in complex scenarios based on improved YOLOv8 according to claim 1, characterized in that: The data enhancement processing includes image brightness adjustment, image flipping, and image translation.

3. The method for detecting crisp plums in complex scenarios based on improved YOLOv8 according to claim 1, characterized in that: EMA extracts the original feature map of the green plum from the network. As input, and along The channel dimension is used to divide the number of channels into G groups, resulting in a set of G sub-feature maps: Among them, sub-feature maps H and W represent the dimensions in the vertical and horizontal directions, respectively; Indicates the number of channels; The sub-feature maps of these G groups are fed into two parallel sub-networks respectively; The first sub-network has a convolution kernel of 1. The branch of 1, in 1 Process in branch 1 to generate the first image 1. H Spatial attention weight map of W; The second sub-network has 3 convolutional kernels. The branch of 3, in 3 Process in branch 3 to generate the second image 1. H W's spatial attention weight map; The first and second spatial attention weight maps are added together. The resulting weight map is then processed using the Sigmoid function to generate a new attention weight map. The new attention weight map is then used to perform matrix multiplication on the sub-feature maps to output a feature map that highlights the target region of the crisp plum.

4. The method for detecting crisp plums in complex scenarios based on improved YOLOv8 according to claim 3, characterized in that: In 1 Process in branch 1 to generate the first image 1. H The spatial attention weight map of W specifically includes: The sub-feature maps are subjected to one-dimensional average pooling in both the horizontal and vertical dimensions to generate corresponding feature maps. and Then, the generated feature map and Stitching along the vertical dimension, using 1 1. The convolutional kernel establishes the connection between channel and spatial location information, decomposes the feature maps into two different spatial directions, and after processing by the Sigmoid activation function, it generates attention weight maps in the horizontal and vertical dimensions. The sub-feature map is updated by performing matrix multiplication with the attention weight maps in the horizontal and vertical dimensions. This updated sub-feature map is then used as the intermediate feature map for the green plum. After GroupNorm, the intermediate feature map undergoes Avgpooling and Softmax operations to obtain the Softmaxed feature map. Finally, the Softmaxed feature map is compared with the sub-feature map using a 3x3 matrix multiplication process. The output after processing by 3 convolution kernels is subjected to matrix multiplication to generate the first 1-dimensional matrix. H Spatial attention weight map of W.

5. The method for detecting crisp plums in complex scenarios based on improved YOLOv8 according to claim 3, characterized in that: In 3 Process in branch 3 to generate the second image 1. H The spatial attention weight map of W specifically includes: Sub-feature map after 3 After processing with 3 convolutional kernels, Avgpooling and Softmax operations are performed sequentially. The feature map after Softmax is then compared with that of 1. In branch 1, the feature map after GroupNorm is subjected to matrix multiplication to generate the second feature map. H Spatial attention weight map of W.

6. The method for detecting crisp plums in complex scenarios based on improved YOLOv8 according to claim 1, characterized in that: The fusion process of AFPN starts with two adjacent low-level features and gradually incorporates high-level features into the fusion process. After each fusion, a new feature map is generated as one of the inputs for the next fusion.

7. The method for detecting crisp plums in complex scenarios based on improved YOLOv8 according to claim 6, characterized in that: In the process of multi-level feature fusion, adaptive spatial fusion is used to assign different spatial weights to features at different levels.

8. The method for detecting crisp plums in complex scenarios based on improved YOLOv8 according to claim 1, characterized in that: The MPDIoU loss function is determined according to the following formula. : ; in, ; , These represent the ground truth bounding box and the detection bounding box, respectively. , These represent the width and height of the target image, respectively; the target image is an image that includes both ground truth bounding boxes and detection bounding boxes. ; ; represent The coordinates of the top left corner and the bottom right corner. represent The coordinates of the top left corner and the bottom right corner.