Two-Stage Detection Algorithm for Plum Leaf Disease and Severity Assessment Based on Deep Learning

: Crop diseases significantly impact crop yields, and promoting specialized control of crop diseases is crucial for ensuring agricultural production stability. Disease identification primarily relies on human visual inspection, which is inefficient, inaccurate, and subjective. This study focused on the plum red spot ( Polystigma rubrum ), proposing a two-stage detection algorithm based on deep learning and assessing the severity of the disease through lesion coverage rate. The specific contributions are as follows: We utilized the object detection model YOLOv8 to strip leaves to eliminate the influence of complex backgrounds. We used an improved U-Net network to segment leaves and lesions. We combined Dice Loss with Focal Loss to address the poor training performance due to the pixel ratio imbalance between leaves and disease spots. For inconsistencies in the size and shape of leaves and lesions, we utilized ODConv and MSCA so that the model could focus on features at different scales. After verification, the accuracy rate of leaf recognition is 95.3%, and the mIoU, mPA, mPrecision, and mRecall of the leaf disease segmentation model are 90.93%, 95.21%, 95.17%, and 95.21%, respectively. This research provides an effective solution for the detection and severity assessment of plum leaf red spot disease under complex backgrounds.


Introduction
Leaf diseases are widespread and significantly impact crop quality and yield, often showing early symptoms on leaves [1], making leaf diseases crucial indicators for the early prevention and control of crop diseases.Plums, known for their rich nutritional content, are widely cultivated in China [2].However, during the cultivation process, plum trees are highly susceptible to various diseases [3].Mild infections can lead to a decline in fruit quality, while severe infections can cause tree weakening and inedible fruits [4,5], as with plum red spot [6].At present, the diagnosis of most plum diseases mainly depends on a visual assessment by plant disease experts, which is time-consuming and labour-intensive and easily interfered with by the subjective judgment of the diagnosticians.Especially in large-scale planting, if the infected leaves are not identified and removed promptly, the disease can quickly spread to other parts and lead to large-scale diseases [7,8].Therefore, the study of plum leaf disease detection is of great significance to agriculture, as it can guide growers in eradicating pathogens at an early stage, thus reducing the use of pesticides [9] and ensuring the safety of products.
Plum red spot [10,11] is caused by the infection of Polystigma rubrum (Pers.)DC., occurs more seriously in the current stage of plum cultivation, and produces greater harm.Summer To ensure the accurate detection of plum leaves and the data sufficiency of diseased leaves in the second stage, we used some stochastic data augmentation techniques, including rotation, translation, random cropping, adding noise, changing brightness, and flipping operations to expand the plum leaf dataset by ensuring that at least one operation worked, as shown in Figure 2. As much as possible, to simulate different light, complex and diverse environments were included to achieve the accurate detection of plum leaves in different environments.To ensure the accurate detection of plum leaves and the data sufficiency of diseased leaves in the second stage, we used some stochastic data augmentation techniques, including rotation, translation, random cropping, adding noise, changing brightness, and flipping operations to expand the plum leaf dataset by ensuring that at least one operation worked, as shown in Figure 2. As much as possible, to simulate different light, complex and diverse environments were included to achieve the accurate detection of plum leaves in different environments.

Data Acquisition and Processing
The experimental data in this study were collected from a plum plantation in Gulin County, Luzhou, Sichuan Province, using a Canon EOS60d camera to record in the summer of 2022.We shot from multiple angles to simulate the images of plum leaves collected by unmanned vehicles and drones under natural conditions in real life, as shown in Figure 1.The dataset included images of plum leaves of different ages, varieties, and weather environments.This study collected 447 images of plum leaves under natural conditions.To ensure the accurate detection of plum leaves and the data sufficiency of diseased leaves in the second stage, we used some stochastic data augmentation techniques, including rotation, translation, random cropping, adding noise, changing brightness, and flipping operations to expand the plum leaf dataset by ensuring that at least one operation worked, as shown in Figure 2. As much as possible, to simulate different light, complex and diverse environments were included to achieve the accurate detection of plum leaves in different environments.After detection of leaves by YOLOv8, we stripped the identified plum leaves and screened out 6321 images of leaves with red spot disease, as shown in Figure 3.We used the semantic segmentation annotation tool LabelMe to annotate red spot-diseased leaves and their lesions, and obtained the semantic segmentation dataset of plum red dot-diseased leaves.This dataset was then divided into training and validation sets with a 7:3 ratio.After detection of leaves by YOLOv8, we stripped the identified plum leaves and screened out 6321 images of leaves with red spot disease, as shown in Figure 3.We used the semantic segmentation annotation tool LabelMe to annotate red spot-diseased leaves and their lesions, and obtained the semantic segmentation dataset of plum red dot-diseased leaves.This dataset was then divided into training and validation sets with a 7:3 ratio.

Overall Algorithm Workflow
We propose a two-stage detection and severity assessment algorithm for plum leaf red spot disease, mainly consisting of three modules.Firstly, YOLOv8 is used to peel off a single diseased leaf from a complex background, and then it is sent to the disease segmentation model MOC_UNet to segment the leaves and disease spots.Finally, the coverage rate of disease spots is calculated by counting the number of disease spots and leaf pixels.Then the disease severity assessment results are output, as shown in Figure 4.

Overall Algorithm Workflow
We propose a two-stage detection and severity assessment algorithm for plum leaf red spot disease, mainly consisting of three modules.Firstly, YOLOv8 is used to peel off a single diseased leaf from a complex background, and then it is sent to the disease segmentation model MOC_UNet to segment the leaves and disease spots.Finally, the coverage rate of disease spots is calculated by counting the number of disease spots and leaf pixels.Then the disease severity assessment results are output, as shown in Figure 4.After detection of leaves by YOLOv8, we stripped the identified plum leaves and screened out 6321 images of leaves with red spot disease, as shown in Figure 3.We used the semantic segmentation annotation tool LabelMe to annotate red spot-diseased leaves and their lesions, and obtained the semantic segmentation dataset of plum red dot-diseased leaves.This dataset was then divided into training and validation sets with a 7:3 ratio.

Overall Algorithm Workflow
We propose a two-stage detection and severity assessment algorithm for plum leaf red spot disease, mainly consisting of three modules.Firstly, YOLOv8 is used to peel off a single diseased leaf from a complex background, and then it is sent to the disease segmentation model MOC_UNet to segment the leaves and disease spots.Finally, the coverage rate of disease spots is calculated by counting the number of disease spots and leaf pixels.Then the disease severity assessment results are output, as shown in Figure 4.

Plum Leaf Detection Model Based on YOLOv8
YOLO [30] is a one-stage object detection algorithm comprising three core components: neck, backbone, and head.The Yolo series algorithms can detect the position and category information of the target object simultaneously, allowing for end-to-end training and high-speed detection, making it suitable for detecting plum leaves.
YOLOv8 [25], a newer YOLO series algorithm, uses the C2f structure instead of the C3 structure of YOLOv5 [31] in Backbone and Neck, which ensures it is lightweight and at the same time obtains richer information about the gradient flow.Using the SPPF module reduces the computational amount to a certain extent and increases the Receptive Field.In terms of head components, the head part of YOLOv8 adopts a decoupled-head structure similar to that of YOLOX [32], which separates the classification and detection heads, and introduces an Anchor-Free Detection Head, which provides greater flexibility and can better adapt to targets with various shapes and sizes.As for the loss function, YOLOv8 uses VFL Loss as the classification loss and DFL Loss+CIOU Loss as the regression loss, which can somewhat improve the rate of convergence and performance of the model.Thus, YOLOv8 is suitable to be used as a plum leaf detection model in farmland scenarios.The structure of YOLOV8 is shown in Figure 5.

Plum Leaf Detection Model Based on YOLOv8
YOLO [30] is a one-stage object detection algorithm comprising three core components: neck, backbone, and head.The Yolo series algorithms can detect the position and category information of the target object simultaneously, allowing for end-to-end training and high-speed detection, making it suitable for detecting plum leaves.
YOLOv8 [25], a newer YOLO series algorithm, uses the C2f structure instead of the C3 structure of YOLOv5 [31] in Backbone and Neck, which ensures it is lightweight and at the same time obtains richer information about the gradient flow.Using the SPPF module reduces the computational amount to a certain extent and increases the Receptive Field.In terms of head components, the head part of YOLOv8 adopts a decoupled-head structure similar to that of YOLOX [32], which separates the classification and detection heads, and introduces an Anchor-Free Detection Head, which provides greater flexibility and can better adapt to targets with various shapes and sizes.As for the loss function, YOLOv8 uses VFL Loss as the classification loss and DFL Loss+CIOU Loss as the regression loss, which can somewhat improve the rate of convergence and performance of the model.Thus, YOLOv8 is suitable to be used as a plum leaf detection model in farmland scenarios.The structure of YOLOV8 is shown in Figure 5.  Semantic segmentation models like FCN [33], SegNet [34], PSPNet [35], DeepLab [36], and U-Net [37] are among the most representative.
U-Net is a semantic segmentation network for medical imaging applications inspired by FCN by Ciresan et al. in 2015.The U-Net algorithm is characterized by a "U-shaped" network structure composed of an Encoder and a Decoder.In U-Net, the skip connection mechanism is introduced to fuse the decoder's output features with the encoder's semantic features, which can effectively capture different levels of feature information and improve image segmentation accuracy and preserve details.Compared with other deep learning algorithms, U-Net can learn a highly robust network with less data.Therefore, it is especially suitable for few-shot, unbalanced data and tasks requiring detailed information retention.
The structure of the improved U-Net used in this paper, MOC_UNet, is shown in Figure 6.Image semantic segmentation is a crucial field in computer vision.It refers to pixellevel recognition of images, which means labelling the category of each pixel in the image.Semantic segmentation models like FCN [33], SegNet [34], PSPNet [35], DeepLab [36], and U-Net [37] are among the most representative.
U-Net is a semantic segmentation network for medical imaging applications inspired by FCN by Ciresan et al. in 2015.The U-Net algorithm is characterized by a "U-shaped" network structure composed of an Encoder and a Decoder.In U-Net, the skip connection mechanism is introduced to fuse the decoder's output features with the encoder's semantic features, which can effectively capture different levels of feature information and improve image segmentation accuracy and preserve details.Compared with other deep learning algorithms, U-Net can learn a highly robust network with less data.Therefore, it is especially suitable for few-shot, unbalanced data and tasks requiring detailed information retention.
The structure of the improved U-Net used in this paper, MOC_UNet, is shown in Figure 6.

Omni-Dimensional Dynamic Convolution Module
Most of our detection of diseased plum leaves is carried out in a complex background, surrounded by many interfering factors affecting the feature extraction of the network, resulting in the scale features of the diseased leaves themselves not being fully acquired; in addition, the detection of diseased plum leaves is mostly carried out outdoors, which requires higher detection accuracy and detection speed.To address the above problems, we chose ODConv, whose deformable convolution with extra offset can successfully use the potential of spatial information to completely obtain the information within the effective area of the sampling point, thus obtaining a better performance [38], and compared with other dynamic convolution algorithms, ODConv has only one convolution kernel, and the number of parameters is much smaller, which ensures efficiency while

Omni-Dimensional Dynamic Convolution Module
Most of our detection of diseased plum leaves is carried out in a complex back-ground, surrounded by many interfering factors affecting the feature extraction of the network, resulting in the scale features of the diseased leaves themselves not being fully acquired; in addition, the detection of diseased plum leaves is mostly carried out outdoors, which requires higher detection accuracy and detection speed.To address the above problems, we chose ODConv, whose deformable convolution with extra offset can successfully use the potential of spatial information to completely obtain the information within the effective area of the sampling point, thus obtaining a better performance [38], and compared with other dynamic convolution algorithms, ODConv has only one convolution kernel, and the number of parameters is much smaller, which ensures efficiency while ensuring accuracy.And its generalisation capability is sufficient for the outdoor detection of diseased plum leaves [39].
ODConv [28] can be regarded as a continuation of CondConv [40] (Conditionally Parameterized Convolution) and DyConv [41] (Dynamic Convolution).By leveraging a multi-dimensional attention mechanism to compute four types of attentions along all four dimensions of the kernel space in parallel, these attentions are multiplied by the convolution kernel W i .Thus, a linear combined convolution weighted according to multi-dimensional attentions is generated, as shown in Figure 7. Different convolution combinations provide performance guarantees for capturing rich contextual cues, enhancing the feature extraction ability of the network for leaves and red spots with different shapes and sizes, to capture the edges and textures of different regions in the image more accurately and improve the segmentation accuracy and detail performance.ODConv is calculated by the following formula: ensuring accuracy.And its generalisation capability is sufficient for the outdoor detection of diseased plum leaves [39].
ODConv [28] can be regarded as a continuation of CondConv [40] (Conditionally Parameterized Convolution) and DyConv [41] (Dynamic Convolution).By leveraging a multi-dimensional attention mechanism to compute four types of attentions along all four dimensions of the kernel space in parallel, these attentions are multiplied by the convolution kernel Wi.Thus, a linear combined convolution weighted according to multi-dimensional attentions is generated, as shown in Figure 7. Different convolution combinations provide performance guarantees for capturing rich contextual cues, enhancing the feature extraction ability of the network for leaves and red spots with different shapes and sizes, to capture the edges and textures of different regions in the image more accurately and improve the segmentation accuracy and detail performance.ODConv is calculated by the following formula: α wi , α fi , α ci , and α si denote the attention of four dimensions of the kernel, output channel, input channel, and space along the convolutional kernel W i , respectively.* denotes the convolution operation.

Multi-Scale Convolutional Attention Module
In the assessment of the severity of plum leaf disease by the ratio of the lesion area, the accurate segmentation of leaf and lesion is very important.Accurate boundary segmentation can ensure the accurate calculation of lesion coverage.Therefore, the model needs to capture and distinguish the edge features in detail.The MSCA attention mechanism can enhance the model's ability to perceive important information between image channels at multiple scales, especially in the processing of complex backgrounds and subtle spot edges, showing excellent performance.Qian et al. significantly improved the accuracy of density map estimation in cell-counting tasks through an innovative MSCA-UNet architecture, thereby enhancing the accuracy of cell counting [42].
As shown in Figure 8, the attention mechanism MSCA [29] consists of three parts: Firstly, local information is aggregated by depth-wise convolution to extract rich feature representations and expand the Receptive Field.Furthermore, multi-branch depth-wise strip convolution is used to capture multi-scale contextual information to α wi , α fi , α ci , and α si denote the attention of four dimensions of the kernel, output channel, input channel, and space along the convolutional kernel W i , respectively.* denotes the convolution operation.

Multi-Scale Convolutional Attention Module
In the assessment of the severity of plum leaf disease by the ratio of the lesion area, the accurate segmentation of leaf and lesion is very important.Accurate boundary segmentation can ensure the accurate calculation of lesion coverage.Therefore, the model needs to capture and distinguish the edge features in detail.The MSCA attention mechanism can enhance the model's ability to perceive important information between image channels at multiple scales, especially in the processing of complex backgrounds and subtle spot edges, showing excellent performance.Qian et al. significantly improved the accuracy of density map estimation in cell-counting tasks through an innovative MSCA-UNet architecture, thereby enhancing the accuracy of cell counting [42].
As shown in Figure 8, the attention mechanism MSCA [29] consists of three parts: Firstly, local information is aggregated by depth-wise convolution to extract rich feature representations and expand the Receptive Field.Furthermore, multi-branch depth-wise strip convolution is used to capture multi-scale contextual information to comprehensively perceive features at different scales and accurately segment the leaves and lesions with different sizes and shapes.Lastly, the outputs of the 1 × 1 convolution are used as the atten-tion weights to enhance the weights of leaves and disease spot features.Two depth-wise strip convolutions are used in each branch to simulate large kernel depth-wise convolutions with kernel sizes of 7, 11, and 21, respectively, to simulate different Receptive Fields.This structural design enables MSCA to process both local and global information, enhancing the robustness and accuracy of the model.Therefore, MSCA was applied in this study to effectively solve the shortcomings of tiny lesion capture challenges and inaccurate leaf edge segmentation in plum leaf disease segmentation.The expression for MSCA is as follows: where F and Out denote the input and output features, respectively; Att is the attention map; ⊗ is the multiplication operation of the element-wise matrix; and DWConv and Scale i are depth-wise convolution and ith branch, respectively.
comprehensively perceive features at different scales and accurately segment the leaves and lesions with different sizes and shapes.Lastly, the outputs of the 1 × 1 convolution are used as the attention weights to enhance the weights of leaves and disease spot features.Two depth-wise strip convolutions are used in each branch to simulate large kernel depth-wise convolutions with kernel sizes of 7, 11, and 21, respectively, to simulate different Receptive Fields.This structural design enables MSCA to process both local and global information, enhancing the robustness and accuracy of the model.Therefore, MSCA was applied in this study to effectively solve the shortcomings of tiny lesion capture challenges and inaccurate leaf edge segmentation in plum leaf disease segmentation.
The expression for MSCA is as follows: where F and Out denote the input and output features, respectively; Att is the attention map; ⊗ is the multiplication operation of the element-wise matrix; and DWConv and Scale i are depth-wise convolution and ith branch, respectively.

Combined Loss
The number of pixels in the three categories of background, disease spots, and leaves in the plum disease leaf dataset is unbalanced, leading to an imbalance in model training.Therefore, this study combines Focal Loss and Dice Loss as a new loss function, which can pay more attention to foreground targets and inaccurately categorised samples while paying attention to the overall loss.It is defined in the following formula: L is the constructed loss function, L F is Focal Loss, and L D is Dice Loss.
(1) Focal Loss [27]: Focal Loss decreases the loss of accurately classified samples without changing the loss of inaccurately classified samples.It is helpful to improve the accuracy of inaccurately classified samples by making the loss function tend to be inaccurately classified samples.The formula is as follows: where P t represents the model's predicted value, α t and γ are the two parameters that regulate the Focal Loss.
(2) Dice Loss [26]: Dice Loss can mitigate the negative effect of foreground and background imbalance in the sample, making the training pay more attention to the foreground region for mining.Its mathematical expression is as follows: |X∩Y| represents the number of intersecting elements between X and Y; |X| and |Y| represent the number of X and Y elements, respectively.

Disease Severity Assessment
As there are no clear criteria for grading the severity of plum red spot disease, existing studies on grading the severity of red dot disease on plum leaves have mainly been judged by counting the number of spots on the leaves, which lacks accuracy.Combining existing methods for assessing leaf disease severity, disease spot coverage can provide an effective index for quantitative assessment and realize the precise grading of disease severity [43].Considering the irregular shape of the spots and leaves, it is difficult to measure their areas manually.Therefore, this study used a method based on the number of pixels to calculate the areas of spots and leaves.
Using the trained MOC_UNet model to predict the diseased leaf images, we obtained the matrix after pixel point classification, where the pixel points took the values of 0, 1, and 2 to indicate the background pixels, healthy leaf pixels, and disease spot pixels, respectively.We used the sum of healthy leaf pixels and diseased spot pixels as the number of pixels of the intact leaf.By calculating the ratio of pixels of the diseased spot to pixels of the intact leaf, we can calculate the percentage of the area of the diseased spots in the leaf, and the calculation formula is as follows: S disease denotes the number of lesion pixels; the S leaf denotes the number of healthy leaf pixels.

Experimental and Evaluation Indicators
The experimental platform uses an Ubuntu (64-bit) operating system equipped with a 12-core Intel (R) Xeon (R) Platinum 8255C CPU @ 2.50 GHz processor.The GPU model is RTX3090, and the open-source deep learning framework Pytorch is used as the development environment.The Cuda version is 11.1, and the computer memory is 43 GB.
We used mean Average Precision (mAP), precision (Precision, P), and recall (Recall, R) as evaluation metrics for the plum leaf detection models, and mean Intersection over Union (mIoU), pixel accuracy (PA), precision (Precision, P), and recall (Recall, R) as evaluation metrics for plum leaf disease segmentation models.We also used the Matthews Correlation Coefficient (MCC) as a metric to evaluate the performance of different segmentation models.Table 1 shows the definitions of the parameters in the calculation formula of these evaluation indexes.mIoU is a standard metric for semantic segmentation, which is the mean ratio of the intersection and merge set of true labels and predicted values, and is calculated as follows: PA indicates the ratio of the number of correctly categorised pixels to the total number of pixels, calculated as follows: Precision indicates the probability that the prediction is an actual positive sample in a positive sample.The formula is as follows: Recall indicates the proportion of pixels that the model correctly determines to be in the positive category out of all the pixels that are actually in the positive category.The formula is as follows: Recall = TP TP + FN (11) AP denotes the integral of the P-index to the R-index.mAP refers to the average of the AP values for all categories.AP = The Matthews Correlation Coefficient is used to evaluate the quality of the model classification and is applicable to datasets with category imbalance, where a higher MCC indicates better performance and is calculated as follows: In order to compare the performance of different segmentation models in predicting disease spot coverage, we established a regression relationship between the disease spot coverage predicted by different models and the true measurements.We used the coefficient of determination R 2 and the Mean Absolute Percentage Error (MAPE) to evaluate the performance of the prediction effect.The larger the R 2 , the better the model fit, and the smaller the value of MAPE, the better the accuracy of the model.

Plum Leaf Detection Results
YOLOv8 is used to strip the leaves from the complex background, helping the subsequent model to accurately segment the disease.mAP, Precision, and Recall evaluate the performance of the plum leaf detection model.Higher values mean that the model is better at recognizing the plum leaves.The plum leaf detection results are shown in Figure 9.

Plum Leaf Detection Results
YOLOv8 is used to strip the leaves from the complex background, helping the subsequent model to accurately segment the disease.mAP, Precision, and Recall evaluate the performance of the plum leaf detection model.Higher values mean that the model is better at recognizing the plum leaves.The plum leaf detection results are shown in Figure 9.As seen in Figure 9, the mAP@0.5 of the plum leaf detection model based on YOLOv8 reaches 95.26%, with Precision and Recall at 96.9% and 90.05%, respectively.These results suggest that YOLOv8 can recognize plum leaves accurately in complex backgrounds.
In order to better demonstrate the detection effect of plum leaves, three of the detection results are shown in Figure 10.It can be seen that YOLOv8 can accurately recognize the plum leaves in the foreground and detect the edge parts of the leaves accurately.Thus, YOLOv8 can meet the detection of plum leaves in real agricultural scenarios.As seen in Figure 9, the mAP@0.5 of the plum leaf detection model based on YOLOv8 reaches 95.26%, with Precision and Recall at 96.9% and 90.05%, respectively.These results suggest that YOLOv8 can recognize plum leaves accurately in complex backgrounds.
In order to better demonstrate the detection effect of plum leaves, three of the detection results are shown in Figure 10.It can be seen that YOLOv8 can accurately recognize the plum leaves in the foreground and detect the edge parts of the leaves accurately.Thus, YOLOv8 can meet the detection of plum leaves in real agricultural scenarios.

Leaf Disease Segmentation Results
In order to further verify the reliability of the disease leaf dataset obtained in the first stage and the performance of the disease segmentation model MOC_UNet proposed in this study, we compare it with the most representative semantic segmentation models, including PSPNet, DeepLabV3+, Segformer, and HRNetv2.To ensure a fair comparison, the comparison process uses the same training strategy and computing environment.As shown in Table 2, compared with PSPNet and DeepLabV3+, the U-Net network is more

Leaf Disease Segmentation Results
In order to further verify the reliability of the disease leaf dataset obtained in the first stage and the performance of the disease segmentation model MOC_UNet proposed in this study, we compare it with the most representative semantic segmentation models, including PSPNet, DeepLabV3+, Segformer, and HRNetv2.To ensure a fair comparison, the comparison process uses the same training strategy and computing environment.As shown in Table 2, compared with PSPNet and DeepLabV3+, the U-Net network is more suitable for plum leaf and red spot segmentation, and our improved plum leaf disease segmentation model MOC_UNet has higher mIoU and mPA compared with other models, indicating a better segmentation effect is achieved by the improved U-Net model.And compared with other models, MOC_UNet has higher MCC, indicating that better classification results are achieved.So, in summary, MOC_UNet is more accurate at identifying and segmenting plum leaf red spot disease.To verify the effectiveness of the improved disease segmentation model MOC_UNet, we carried out ablation experiments.The experimental results are shown in Table 3.The model's performance with the Combined Loss function is significantly improved, demonstrating that the combination of Focal Loss and Dice Loss can effectively overcome the drawbacks caused by the imbalance of different categories of pixels.The configurations using ODConv are effectively improved on mIoU and mPA, which shows that ODConv can effectively enhance the model's feature extraction capability for disease spots and leaves with different shapes and sizes.Especially, the model using Combined Loss, ODConv and MSCA simultaneously exhibits superior effectiveness compared to the original network, and the mIoU, mPA, mPrecision, and mRecall of MOC_UNet increase 1.2%, 0.86%, 0.55%, and 0.86%, respectively.Therefore, it indicates that all of our improvements can significantly enhance the segmentation performance of the leaf disease segmentation model.Figure 11 demonstrates the comparison of the effect of MOC_UNet with different segmentation models for plum disease leaf segmentation, and it can be found that the PSPNet, DeepLabV3+, Segformer, HRNetv2, and UNet models all have the problem of lesion misdetection (Figure 11c-g).Meanwhile, due to the complexity of the background, the other segmentation models are less effective for the boundary segmentation of leaves and disease spots, while the leaf disease segmentation model MOC_UNet proposed in this study can well overcome the impact of the complex background on the image segmentation, it can segment leaves and disease spots accurately (Figure 11h), and the prediction results are similar to the labelled images.
√ √ √ 90.93% 95.21% 95.17% 95.21% Figure 11 demonstrates the comparison of the effect of MOC_UNet with different segmentation models for plum disease leaf segmentation, and it can be found that the PSPNet, DeepLabV3+, Segformer, HRNetv2, and UNet models all have the problem of lesion misdetection (Figure 11c-g).Meanwhile, due to the complexity of the background, the other segmentation models are less effective for the boundary segmentation of leaves and disease spots, while the leaf disease segmentation model MOC_UNet proposed in this study can well overcome the impact of the complex background on the image segmentation, it can segment leaves and disease spots accurately (Figure 11h), and the prediction results are similar to the labelled images.In order to test the effect of the leaf boundary prediction effect on the predicted lesion coverage, we predicted the lesion coverage of plum leaves in Figure 11 using the different models in Table 2, as shown in Table 4, and it can be observed that, due to the fact that there are misdetections in the boundary segmentation of leaves by PSPNet, DeepLabV3+, order to test the effect of the leaf boundary prediction effect on the predicted lesion coverage, we predicted the lesion coverage of plum leaves in Figure 11 using the different models in Table 2, as shown in Table 4, and it can be observed that, due to the fact that there are misdetections in the boundary segmentation of leaves by PSPNet, DeepLabV3+, U-Net, Segformer, and HRNetv2, this results in a large degree of deviation between the predicted and true measurements of lesion coverage.In contrast, MOC_UNet was more effective in boundary segmentation, so the predicted value of lesion coverage was closer to the true value.To further validate the reliability of the disease segmentation model MOC_UNet in predicting the plum leaf red spot coverage, we employed linear regression analysis to assess the relationship between the spot coverage predicted by the different models in Table 2 and the true measurements, which we tested using the test set.We used the coefficient of determination R 2 and Mean Absolute Percentage Error (MAPE) to evaluate the performance of the different models, as shown in Figure 12; the R2 for PSPNet, DeepLabV3+, HRNetv2, Segformer, U-Net, and MOC_UNet, respectively, were 0.70, 0.87, 0.92, 0.93, 0.93, and 0.96; and the MAPE were 30.97%,17.27%, 14.31%, 13.38%, 12.05%, and 8.76%, respectively.The disease segmentation model MOC_UNet has the largest R2 and the smallest MAPE, so we believe that the plum leaf spot coverage predicted by MOC_UNet is closer to the true value, which can effectively help farmers to accurately detect plum leaf disease and initially determine the severity of the disease.

The Results of the Disease Severity Assessment
To better demonstrate the process of disease severity assessment, we present three plum leaves with varying severity of red spot disease as Table 5.

The Results of the Disease Severity Assessment
To better demonstrate the process of disease severity assessment, we present three plum leaves with varying severity of red spot disease as Table 5.As Table 5 shows, disease coverage can clearly reflect the degree of disease proliferation and provide an intuitive indicator for assessing the severity of the disease, which can help growers realize precise disease control.

Discussion
Leaf disease detection, as one of the common methods for crop disease detection, can provide an important basis for early disease control.Traditional leaf disease detection mainly relies on the visual detection of relevant experts, with low accuracy and efficiency, and there is strong subjectivity, and it is difficult to rely on manual visual judgement to accurately and quantitatively assess the severity of the disease.Deep learning methods have been widely used for leaf disease detection, but the following shortcomings exist: (1) Most leaf disease detection algorithms only detect and localise the disease on the leaf [20] and cannot further assess the disease severity.(2) Most algorithms based on leaf disease segmentation are limited to simple backgrounds [21] or the case of a single leaf [22], ignoring the interference of complex backgrounds and multiple leaves in realistic scenes.The above limitations lead to the fact that most of the leaf disease detection algorithms have difficulty meeting the application of leaf disease detection in realistic scenes.
In this study, we explored a two-stage detection algorithm for red spot disease on plum leaves, addressing the shortcomings of research on leaf disease detection.We used the object detection model YOLOv8 to strip leaves, which can eliminate the interference of complex backgrounds.And we used the improved disease segmentation model MOC_UNet to segment the leaf and the disease spots accurately.Finally, by calculating the spot coverage, we made a preliminary determination of the disease severity.Compared with the existing deep learning methods, the two-stage detection algorithm  As Table 5 shows, disease coverage can clearly reflect the degree of disease proliferation and provide an intuitive indicator for assessing the severity of the disease, which can help growers realize precise disease control.

Discussion
Leaf disease detection, as one of the common methods for crop disease detection, can provide an important basis for early disease control.Traditional leaf disease detection mainly relies on the visual detection of relevant experts, with low accuracy and efficiency, and there is strong subjectivity, and it is difficult to rely on manual visual judgement to accurately and quantitatively assess the severity of the disease.Deep learning methods have been widely used for leaf disease detection, but the following shortcomings exist: (1) Most leaf disease detection algorithms only detect and localise the disease on the leaf [20] and cannot further assess the disease severity.(2) Most algorithms based on leaf disease segmentation are limited to simple backgrounds [21] or the case of a single leaf [22], ignoring the interference of complex backgrounds and multiple leaves in realistic scenes.The above limitations lead to the fact that most of the leaf disease detection algorithms have difficulty meeting the application of leaf disease detection in realistic scenes.
In this study, we explored a two-stage detection algorithm for red spot disease on plum leaves, addressing the shortcomings of research on leaf disease detection.We used the object detection model YOLOv8 to strip leaves, which can eliminate the interference of complex backgrounds.And we used the improved disease segmentation model MOC_UNet to segment the leaf and the disease spots accurately.Finally, by calculating the spot coverage, we made a preliminary determination of the disease severity.Compared with the existing deep learning methods, the two-stage detection algorithm  As Table 5 shows, disease coverage can clearly reflect the degree of disease proliferation and provide an intuitive indicator for assessing the severity of the disease, which can help growers realize precise disease control.

Discussion
Leaf disease detection, as one of the common methods for crop disease detection, can provide an important basis for early disease control.Traditional leaf disease detection mainly relies on the visual detection of relevant experts, with low accuracy and efficiency, and there is strong subjectivity, and it is difficult to rely on manual visual judgement to accurately and quantitatively assess the severity of the disease.Deep learning methods have been widely used for leaf disease detection, but the following shortcomings exist: (1) Most leaf disease detection algorithms only detect and localise the disease on the leaf [20] and cannot further assess the disease severity.(2) Most algorithms based on leaf disease segmentation are limited to simple backgrounds [21] or the case of a single leaf [22], ignoring the interference of complex backgrounds and multiple leaves in realistic scenes.The above limitations lead to the fact that most of the leaf disease detection algorithms have difficulty meeting the application of leaf disease detection in realistic scenes.
In this study, we explored a two-stage detection algorithm for red spot disease on plum leaves, addressing the shortcomings of research on leaf disease detection.We used the object detection model YOLOv8 to strip leaves, which can eliminate the interference of complex backgrounds.And we used the improved disease segmentation model MOC_UNet to segment the leaf and the disease spots accurately.Finally, by calculating the spot coverage, we made a preliminary determination of the disease severity.Compared with the existing deep learning methods, the two-stage detection algorithm  As Table 5 shows, disease coverage can clearly reflect the degree of disease proliferation and provide an intuitive indicator for assessing the severity of the disease, which can help growers realize precise disease control.

Discussion
Leaf disease detection, as one of the common methods for crop disease detection, can provide an important basis for early disease control.Traditional leaf disease detection mainly relies on the visual detection of relevant experts, with low accuracy and efficiency, and there is strong subjectivity, and it is difficult to rely on manual visual judgement to accurately and quantitatively assess the severity of the disease.Deep learning methods have been widely used for leaf disease detection, but the following shortcomings exist: (1) Most leaf disease detection algorithms only detect and localise the disease on the leaf [20] and cannot further assess the disease severity.(2) Most algorithms based on leaf disease segmentation are limited to simple backgrounds [21] or the case of a single leaf [22], ignoring the interference of complex backgrounds and multiple leaves in realistic scenes.The above limitations lead to the fact that most of the leaf disease detection algorithms have difficulty meeting the application of leaf disease detection in realistic scenes.
In this study, we explored a two-stage detection algorithm for red spot disease on plum leaves, addressing the shortcomings of research on leaf disease detection.We used the object detection model YOLOv8 to strip leaves, which can eliminate the interference of complex backgrounds.And we used the improved disease segmentation model MOC_UNet to segment the leaf and the disease spots accurately.Finally, by calculating the spot coverage, we made a preliminary determination of the disease severity.Compared with the existing deep learning methods, the two-stage detection algorithm  As Table 5 shows, disease coverage can clearly reflect the degree of disease proliferation and provide an intuitive indicator for assessing the severity of the disease, which can help growers realize precise disease control.

Discussion
Leaf disease detection, as one of the common methods for crop disease detection, can provide an important basis for early disease control.Traditional leaf disease detection mainly relies on the visual detection of relevant experts, with low accuracy and efficiency, and there is strong subjectivity, and it is difficult to rely on manual visual judgement to accurately and quantitatively assess the severity of the disease.Deep learning methods have been widely used for leaf disease detection, but the following shortcomings exist: (1) Most leaf disease detection algorithms only detect and localise the disease on the leaf [20] and cannot further assess the disease severity.(2) Most algorithms based on leaf disease segmentation are limited to simple backgrounds [21] or the case of a single leaf [22], ignoring the interference of complex backgrounds and multiple leaves in realistic scenes.The above limitations lead to the fact that most of the leaf disease detection algorithms have difficulty meeting the application of leaf disease detection in realistic scenes.
In this study, we explored a two-stage detection algorithm for red spot disease on plum leaves, addressing the shortcomings of research on leaf disease detection.We used the object detection model YOLOv8 to strip leaves, which can eliminate the interference of complex backgrounds.And we used the improved disease segmentation model MOC_UNet to segment the leaf and the disease spots accurately.Finally, by calculating the spot coverage, we made a preliminary determination of the disease severity.Compared with the existing deep learning methods, the two-stage detection algorithm  As Table 5 shows, disease coverage can clearly reflect the degree of disease proliferation and provide an intuitive indicator for assessing the severity of the disease, which can help growers realize precise disease control.

Discussion
Leaf disease detection, as one of the common methods for crop disease detection, can provide an important basis for early disease control.Traditional leaf disease detection mainly relies on the visual detection of relevant experts, with low accuracy and efficiency, and there is strong subjectivity, and it is difficult to rely on manual visual judgement to accurately and quantitatively assess the severity of the disease.Deep learning methods have been widely used for leaf disease detection, but the following shortcomings exist: (1) Most leaf disease detection algorithms only detect and localise the disease on the leaf [20] and cannot further assess the disease severity.(2) Most algorithms based on leaf disease segmentation are limited to simple backgrounds [21] or the case of a single leaf [22], ignoring the interference of complex backgrounds and multiple leaves in realistic scenes.The above limitations lead to the fact that most of the leaf disease detection algorithms have difficulty meeting the application of leaf disease detection in realistic scenes.
In this study, we explored a two-stage detection algorithm for red spot disease on plum leaves, addressing the shortcomings of research on leaf disease detection.We used the object detection model YOLOv8 to strip leaves, which can eliminate the interference of complex backgrounds.And we used the improved disease segmentation model MOC_UNet to segment the leaf and the disease spots accurately.Finally, by calculating the spot coverage, we made a preliminary determination of the disease severity.Compared with the existing deep learning methods, the two-stage detection algorithm As Table 5 shows, disease coverage can clearly reflect the degree of disease proliferation and provide an intuitive indicator for assessing the severity of the disease, which can help growers realize precise disease control.

Discussion
Leaf disease detection, as one of the common methods for crop disease detection, can provide an important basis for early disease control.Traditional leaf disease detection mainly relies on the visual detection of relevant experts, with low accuracy and efficiency, and there is strong subjectivity, and it is difficult to rely on manual visual judgement to accurately and quantitatively assess the severity of the disease.Deep learning methods have been widely used for leaf disease detection, but the following shortcomings exist: (1) Most leaf disease detection algorithms only detect and localise the disease on the leaf [20] and cannot further assess the disease severity.(2) Most algorithms based on leaf disease segmentation are limited to simple backgrounds [21] or the case of a single leaf [22], ignoring the interference of complex backgrounds and multiple leaves in realistic scenes.The above limitations lead to the fact that most of the leaf disease detection algorithms have difficulty meeting the application of leaf disease detection in realistic scenes.
In this study, we explored a two-stage detection algorithm for red spot disease on plum leaves, addressing the shortcomings of research on leaf disease detection.We used the object detection model YOLOv8 to strip leaves, which can eliminate the interference of complex backgrounds.And we used the improved disease segmentation model MOC_UNet to segment the leaf and the disease spots accurately.Finally, by calculating the spot coverage, we made a preliminary determination of the disease severity.Compared with the existing deep learning methods, the two-stage detection algorithm proposed in this study well overcomes the influence of a complex background and multiple leaves and is more suitable for real-life scenarios, and the algorithm for leaf spot segmentation is able to make a preliminary determination of disease severity, which can effectively help farmers to better and accurately grasp the severity of the disease and realise precise prevention and control of the disease.
The two-stage algorithm proposed in this study can be similarly extended to the detection and severity assessment of other leaf diseases.It also provides an effective method for related researchers to calculate the area of disease spots and diseased leaves.However, this study currently focuses only on the red spot disease of plum leaves, which still has limitations, such as less disease coverage and slower identification.We will continue to extend it to other plum diseases, such as plum black mold disease and bacterial leaf spot of plum, at a later stage.In addition, although the algorithm proposed in this study has high accuracy, it is difficult to meet the requirements for the real-time detection of plum leaf diseases due to its slow detection speed.We will also improve the detection speed and reduce the complexity of the network through network pruning in the later stage, so as to make it more suitable for practical agricultural production.

Conclusions
In order to detect red spot disease and assess the disease severity of plum leaves under a complex background, we proposed a two-stage recognization method.We used the YOLOv8 to strip plum leaves from complex backgrounds and then used the improved disease segmentation model MOC_UNet to segment leaves and red spots accurately.Finally, spot coverage was calculated to assess the severity of red spot disease.We combined Focal Loss with Dice Loss to eliminate the influence of the imbalance samples.ODConv was used to enhance the model's capability to extract leaf and spot features of various sizes and shapes, and MSCA was introduced to make the model better utilize the multi-scale feature information and enhance the model's ability to segment the boundary of the target area.The accuracy rate of leaf recognition is 95.3%, and the mIoU, mPA, mPrecision, and mRecall of the improved model MOC_UNet reached 90.93%, 95.21%, 95.17%, and 95.21%, respectively, which were improved by 1.2%, 0.86%, 0.55%, and 0.86%, respectively, compared to the original model.We also used regression analysis to compare the relationship between the lesion coverage predicted by different segmentation models and the true measurements.The coefficient of determination R 2 and the mean absolute percentage error MAPE of our proposed MOC_UNet were 0.96 and 8.76%, respectively, which had a larger R 2 and smaller MAPE compared to the other segmentation models, indicating that the predicted values of MOC_UNet for the disease spot coverage were more close to the real values, and that it could assess the severity of red spot disease on plum leaves more accurately.In summary, this paper proposed a two-stage method for high-precision detection and severity assessment of red spot disease on plum leaves.It can help growers to detect diseases early and help achieve precise prevention and control of diseases in actual agricultural production.

Data Availability Statement:
The data presented in this study are available on request from the corresponding author.

Figure 2 .
Figure 2. Comparison of plum leaf dataset before and after data augmentation.

Figure 2 .
Figure 2. Comparison of plum leaf dataset before and after data augmentation.Figure 2. Comparison of plum leaf dataset before and after data augmentation.

Figure 2 .
Figure 2. Comparison of plum leaf dataset before and after data augmentation.Figure 2. Comparison of plum leaf dataset before and after data augmentation.

Figure 4 .
Figure 4. Flow chart of disease detection.

Figure 4 .
Figure 4. Flow chart of disease detection.Figure 4. Flow chart of disease detection.

Figure 4 .
Figure 4. Flow chart of disease detection.Figure 4. Flow chart of disease detection.

Figure 8 .
Figure 8. MSCA structure diagram.2.4.4.Combined LossThe number of pixels in the three categories of background, disease spots, and leaves in the plum disease leaf dataset is unbalanced, leading to an imbalance in model training.Therefore, this study combines Focal Loss and Dice Loss as a new loss function, which can pay more attention to foreground targets and inaccurately categorised samples while

Figure 10 .
Figure 10.Effectiveness of YOLOv8 on the detection of plum leaves.

Table 1 .
Definitions of relevant calculation parameters for evaluation indicators.: positive samples predicted by the model to be in the positive category; TN: negative samples predicted by the model to be in the negative category; FP: negative samples predicted by the model to be in the positive category; FN: positive samples predicted by the model to be in the negative category; k denotes the number of sample categories. TP

Table 2 .
Comparison of evaluation metrics for different network model segmentation.

Table 3 .
Results of ablation experiments.

Table 4 .
Comparison of lesion coverage predictions from different models.

Table 5 .
Example of disease severity assessment.

Table 5 .
Example of disease severity assessment.

Table 5 .
Example of disease severity assessment.

Table 5 .
Example of disease severity assessment.

Table 5 .
Example of disease severity assessment.

Table 5 .
Example of disease severity assessment.

Table 5 .
Example of disease severity assessment.