Abstract
In response to the subjective issues, inconsistent quality standards, high labor intensity and low sorting efficiency during the drying process of green pepper, an improved YOLOv11 algorithm was proposed for quality detection. A multi-scale edge enhancement module (MEEM) is introduced into the backbone network, replacing the original basic C3K2 module with C3K2-MEEM to enhance the extraction of detailed features in images of dried green Sichuan pepper and prevent missed detections, false detections, and boundary confusion. The LRSA module is integrated into the 10th layer of the backbone network to improve the clarity of the tumor-like texture of the Sichuan pepper and reduce the influence of impurities, automatically allocating attention based on feature similarity to preserve local information. In the neck layer, the DPCF module is added to the FPN+PAN feature fusion stage to achieve multi-scale feature collaboration, meeting the detection requirements of dried green Sichuan pepper. The results show that the accuracy recall rate, mean average precision, and model size of the improved MLD-YOLOv11 algorithm are 92.1%, 96.6%, 95.6%, and 11.06 MB, respectively. Compared with the training results of the original YOLOv11 model, the average accuracy of the improved model has increased by 2.2 percentage points, and GFLOPs have definitely decreased by 2 G, with parameter reduction of approximately 3.10%. Compared with other mainstream models, the MLD-YOLOv11 model has significant advantages in terms of mean average precision, model size, and floating point operations per second, making it more suitable for industrial applications and providing an efficient, accurate, and lightweight solution for the quality detection of dried green Sichuan pepper.
1. Introduction
Sichuan pepper (Zanthoxylum schinifolium) is a unique and important economic crop in China, belonging to the genus Zanthoxylum of the Rutaceae family [1,2]. Due to its distinctive numbing taste and aroma, it plays a significant role in enhancing food quality [3], and also has high efficacy in antioxidation, anti-tumor, and anti-inflammatory activities [4,5,6]. In 2023, the total output of Sichuan pepper exceeded 600,000 tons [7]. Many counties and districts in Chongqing have taken Sichuan pepper as a key industry for poverty alleviation and income increase. For instance, Jiangjin District and Dianjiang County in Chongqing have developed Sichuan pepper planting bases, where farmers implement intensive management, and the majority of the varieties are Nine-Leaf green Sichuan pepper [8,9,10]. However, the planting conditions of Sichuan pepper bases across various regions of Chongqing vary greatly, and management levels are uneven, resulting in significant differences in Sichuan pepper yields among different production areas. High-yield regions can reach , while low-yield regions are less than [11]. Traditional quality sorting of dried green Sichuan pepper [12,13,14,15] mainly relies on manual vision and experience, which brings about numerous problems such as high labor intensity, low sorting efficiency, and strong subjectivity, thereby seriously affecting industrial scale and standardization. With the development of intelligent IoT systems, integrating lightweight deep learning models into real industrial scenarios has become increasingly important [16]. Efficient resource allocation and scalable computing frameworks are also critical for deploying deep learning models in practical intelligent systems [17]. Target detection algorithm plays a major role in machine vision systems [18,19], effectively improving the quality of green Sichuan pepper through precise positioning and defect screening, thus enhancing the level of industrial intelligence.
In recent years, scholars at home and abroad have carried out a large amount of research on improving algorithms for detecting crops. Pearson C T et al. [20] developed a technology for detecting defects in pistachios based on imaging algorithms. This technology can accurately identify shell stains and moldy or infested kernels, and precisely remove defective kernels. Blasco J et al. [21] conducted online non-destructive detection of oranges, peaches, and apples based on the SHIVA vision system, using Bayesian discriminant analysis to precisely segment the targets, achieving good results in size measurement, color analysis, stem positioning, and defect detection. Bennedsen B et al. [22] developed a machine vision system using the apple pedicel and calyx axis as features, employing threshold segmentation, artificial neural networks, and principal component analysis to detect surface defects. After evaluating multiple varieties, the defect detection rate was improved. However, there are relatively few studies on directly applying general object detection models to the defect detection of dried green Sichuan pepper. Li Xuanxuan et al. [23] proposed a fusion technology combining YOLOv11 and image processing to extract the peak phenotypic features of wheat awns. This method improved the detection accuracy to 96.00% and the mAP50 to 98.70%, which were 6.6 and 2.8 percentage points higher than those of the original model, respectively. Shixiong Yang et al. [24] proposed an advanced recognition method for corn leaf blight based on YOLOv8 by adding a fine-neck module and a GAM attention module. The improved YOLOv8 model showed increases of 3.79% in P, 4.65% in R, and 3.56% in mAP50 [25]. Based on the improved YOLOv11 algorithm for fire detection during cotton harvesting, by integrating the MobileNetV2 network and the CBAM-ECA visual attention mechanism, as well as optimizing the original C3k2 block using partial convolution techniques, the results showed that detection accuracy increased by 1.4%, 3%, and 1.9% respectively, and the average precision (mAP) was further improved by 2.4%. Daozong Sun et al. [26] developed a lightweight network based on YOLOv8 for tobacco pest detection. By integrating the SimAM attention mechanism module and the VoV-GSCSP module, the mAP-kp indexes increased by 1%, 2.7%, and 2.4%, respectively. Yang Fei et al. [27] used the appearance and morphological characteristics of pepper seeds and closed-eye peppers to determine separation thresholds for various impurities. Using the Canny edge detection operator and a secondary filling algorithm improved the detection accuracy of pepper seeds. Although the above studies provide methodological references for the quality detection of green Sichuan pepper, the detection of defects in actual dried green Sichuan pepper faces the following challenges: first, the defect features of green Sichuan pepper are very small (such as slight browning and uneven color), and the contrast with the background and normal areas is low; second, the complex natural light environment can cause unstable image quality, affecting the performance of the model.
The original generic YOLOv11 detection model cannot accurately capture the extremely small size of dried green Sichuan pepper, nor distinguish the subtle color distribution differences between normal fruits and browning defects, resulting in frequent false positives and false negatives. Therefore, the research scheme of our improved YOLOv11 network model is built entirely around these two core characteristics and innovates from the following three aspects to achieve accurate defect identification. In order to achieve accurate identification of dried green Sichuan pepper with various defects, the improvement plan innovates from three aspects: constructing a multi-scale edge enhancement module (MEEM), introducing a local region self-attention mechanism (LRSA), and designing a detail-preserving context fusion module (DPCF). This scheme not only provides technical and theoretical support for the quality grading and defect screening of green Sichuan pepper, but also enables the effective detection of various defects in dried green Sichuan pepper. Moreover, it lays the foundation for algorithm research in the development of intelligent sorting equipment.
2. Materials and Methods
2.1. Experimental Data
2.1.1. Data Materials and Drying Equipment
The experimental data were collected from the “Nine-Leaf Green” variety of Sichuan pepper cultivated in Jiangjin. The collection period was from 1–10 November 2025. Prior to image acquisition, the samples required drying. During the drying process, 50 g of fresh Sichuan pepper was first tested using a moisture content detector at 105 °C via the constant weight method. The sample was then dried until its moisture content fell below 15%w.b. to be considered qualified. For the subsequent samples, a hot air convection drying device was used, and the drying process lasted for 6 h until the green Sichuan pepper was completely dried. The complete preparation process of the dried Sichuan pepper samples is shown in Figure 1.
Figure 1.
Preparation process of dried green Sichuan pepper samples.
The experimental platform is a self-made dark box image acquisition system. The equipment used in this system mainly includes an industrial camera (Hikrobot Co., Ltd., Hangzhou, China; model: HIKROBOT MV-CS200-10UC) with a resolution of 5472 × 3648 and color capture capability; a data interface (USB3.0, compatible with USB2.0); a lens (manufactured by Hikrobot, model HIKROBOT MVL-KF1224M-25MP); an LED light source and its corresponding controller; and a computer. The material of the device is aluminum alloy. Its sizes are 30 × 30 mm (450 mm × 4 pieces, 400 mm × 3 pieces, 460 mm × 2 pieces). It is manufactured through CNC cutting and modular assembly to ensure structural stability and dimensional consistency. Actual image acquisition was performed using the above-mentioned equipment with the specified parameters to obtain the required images.
2.1.2. Data Acquisition and Preprocessing
From 15–25 November 2025, experimental images of dried Sichuan green peppercorns were acquired using a customized closed dark box imaging platform. The samples were taken from three different harvest batches in Jiangjin, Chongqing, to ensure diversity of the dataset. The resolution of all images was adjusted to 5000 × 3600.
The acquired images were processed using random rotation, Gaussian blur, and random brightness adjustment [28] to simulate the effects of different perspectives and lighting conditions, thereby enhancing the generalization ability and robustness of the model. Eventually, 1120 labeled sample images were obtained. The size of this dataset is similar to that of studies related to agricultural products [29,30,31], and it meets the requirements for model training and generalization verification. The image processing results are shown in Figure 2. All images were manually annotated by one trained professional annotator using LabelImg software (PyCharm v2022.3.3) in YOLO format, and any inconsistent annotations were corrected by agricultural product inspection experts.
Figure 2.
Data-enhanced images: (a) origin; (b) random rotation; (c) random brightness adjustment; (d) Gaussian blur.
The entire dataset was randomly divided into a training set (896 images), a validation set (112 images) and a test set (112 images) in an 8:1:1 ratio. Five independent repeated experiments were conducted using a “stratified random partition strategy” to evaluate the average accuracy (with an average value of 96.2 ± 0.7%). Defect annotations were divided into two types: brown spots and seeds. In terms of category distribution, this dataset contains 22,075 samples of brown spot defects and 10,923 samples of seed defects, totaling 32,998 annotated defect samples. The classification of defect annotations is shown in Figure 3.
Figure 3.
Labeled defect images of dried green Sichuan pepper: (a) normal; (b) brown; (c) seed.
2.2. Experimental Environment and Parameter Settings
The hardware configuration for the experimental model consisted of an Intel Core Ultra 9 285K CPU (3.70 GHz) and an NVIDIA GeForce RTX 5090 GPU (32 GB VRAM). The software environment included Windows 11, the PyTorch (v2.11.0+cpu) deep learning framework, the YOLOv11 network model, and Python (v3.14.2).
During training, the input image resolution was set to 640 × 640 pixels, the number of epochs was 250, and the batch size was 16. Training was conducted on the GPU, and all hyperparameters were set to the default values of YOLOv11. The initial learning rate was 0.001, with a learning rate decay of 0.01, momentum of 0.937, weight decay of 0.0005, and warmup momentum of 0.8.
2.3. Evaluation Metrics
In this study, precision (P), recall (R), and mAP@0.5 were used as evaluation metrics for detection accuracy. Precision reflects the model’s ability to avoid false detections, recall reflects the ability to avoid missed detections, and mAP provides a comprehensive evaluation of overall performance. Model complexity and efficiency were evaluated by the number of parameters, FLOPs, and model size. The evaluation metrics for the model’s recognition speed include the number of parameters, floating point operations (FLOPs), model size, and model weight size.
The relevant formulas are as follows:
In the above formula, Tp represents the number of correctly detected targets; Fp represents the number of samples that were falsely detected in the image; Tp + Fp represents the total number of targets predicted in the image (regardless of correctness); represents the number of defect green Sichuan pepper samples in the image that were not correctly detected; N represents the number of categories, and the dataset studied in this paper has 2 categories, that is, N = 2.
3. Results
3.1. YOLOv11 Model Framework
3.1.1. YOLOv11 Network
Released by Ultralytics in the second half of 2024, the overall network structure of YOLOv11 consists of four components: the input, backbone network, feature fusion neck, and prediction head. It is a neural network that integrates multiple tasks such as object detection, semantic segmentation, and image classification [32]. In the network, the newly added C2PSA module is based on the C2f structure, but it replaces the inner C2f module with a C3k2 module and introduces the PSA (Position-Sensitive Attention) mechanism. In contrast to the C2f module, when the hyperparameter c3k is set to True, the bottleneck block is replaced with C3k; otherwise, it remains C2f. The C3k allows users to define the size of the convolutional block, which differs from the original C3k module. The C2PSA module enhances feature extraction capabilities by introducing the PSA attention mechanism, which integrates multi-head attention and a feed-forward network (FFN), enabling the model to extract key features more effectively. Additionally, the module selectively adds residual connections (shortcuts) to optimize gradient propagation and improve training performance. Through the FFN, the model can map input features to a higher-dimensional space, thereby learning richer feature representations and capturing complex nonlinear relationships, as shown in Figure 4. The input image size at is 640 × 640 pixels.
Figure 4.
YOLOv11 network structure.
3.1.2. Improvement of the Network Model
The network model for the quality detection of dried green Sichuan pepper is based on the structure shown in Figure 4. The overall framework after improvement is illustrated in Figure 5. The model is named MLD-YOLOv11, and the optimizations include the following three aspects: (1) MEEM: The ordinary convolution in the C3K2 module is replaced with the MEEM, which enhances the recognition accuracy of target contours and enables the extraction of more edge detail features. (2) LRSA module: LRSA is integrated with the C2PSA module in the YOLOv11 network. It strengthens the capture of local details, compensates for the lack of key information in small targets and complex scenes, and improves detection accuracy. (3) DPCF module: The DPCF module is added to the YOLO architecture to optimize multi-scale feature fusion. First, it uses dynamic gating to avoid the fixed weighting of high- and low-resolution features in FPN, only preserving the details of small and occluded targets. Second, it differentially fuses details and semantic information based on regional feature requirements, reducing the false detection rate in complex scenes. In addition, the computational cost of the module is relatively low and does not affect real-time detection performance.
Figure 5.
Network architecture of MLD-YOLOv11: Input denotes the input layer; Conv represents the basic convolutional layer; Concat is the feature concatenation module; SPPF stands for spatial pyramid pooling; Max pool refers to maximum pooling; C3K2_MEEM combines C3 structure with K2 convolution and MEEM; C2PSA_LRSA integrates C2f with PSA and LRSA as an improved module; PSABlock is the pyramid split attention module; Layer Norm indicates the layer normalization layer; Window Attention denotes the window self-attention layer; ConvFFN is the convolutional feed-forward network; Bottleneck_MEEM merges the bottleneck structure with MEEM as a feature fusion module; DPCF is the detection prediction convolution fusion module; Output is the output layer.
3.2. Multi-Scale Edge Enhancement Module
Due to the drying process, the edges of dried green Sichuan pepper become blurred, making it difficult to effectively capture the fine edge features and multi-scale details of the green Sichuan pepper. To enhance the backbone network’s ability to extract detailed features from dried green Sichuan pepper images and avoid missed detections, false detections, and boundary confusion, this paper proposes to replace the ordinary convolution in the C3K2 module with the MEEM, which can provide richer and more accurate detail features, as shown in Figure 6.
Figure 6.
MEEM module.
This module uses 1 × 1 convolutional layers to process local features into preliminary edge features. The feature map (where C represents the number of channels, and H and W are the dimensions of the feature map) output by the backbone network is passed through three groups of average pooling layers with different strides to obtain feature maps at small, medium, and large scales. The edge features obtained at each scale are processed by edge enhancers, and the enhanced multi-scale feature maps are upsampled to the original size, then weighted and fused with the original feature map of the backbone network to achieve complementary details. The calculation formula for the final enhanced feature map is:
In the formula, represents bilinear upsampling, and represents the learnable weight coefficients that balance the contributions of edge features at different scales.
3.3. Local Region Self-Attention Mechanism
In this study, the local region self-attention (LRSA) mechanism is integrated into the base network structure of YOLOv11 to enhance the detection accuracy of dried green Sichuan pepper. Its structure is shown in Figure 7. This mechanism is centered on self-attention, which enhances the correlation between tokens within a local region. When processing fine features such as image texture and edges, LRSA can adaptively adjust the attention distribution based on the characteristics of each position, thereby more effectively preserving and utilizing surrounding local information.
Figure 7.
Local region self-attention.
This module references the method of HPINet and uses overlapping patches to enhance feature interaction. The input feature data are operated on three weight matrices, respectively. These weight matrices are shared across different patches, meaning that no matter which local area of the image, the same weight matrices are used. The data obtained after projection are sent to the multi-head self-attention mechanism for processing. The output features are obtained through MSA operations. Finally, the local area information focused by LRSA is obtained.
The feature map (where C refers to the number of channels, and H and W represent the sizes of the feature map) generated by the backbone network is first divided into non-overlapping local windows. The features of each window are unfolded into a token sequence ( is the number of tokens in the window, and k is the side length of the window). Then, the attention weights of the tokens within the window are calculated, focusing on key features such as continuous regions of pepper texture.
The relevant formulas are as follows:
In the formulas, represents the attention weights, and represents the locally enhanced features after weighting.
Finally, the enhanced token sequence is restored to a feature map and fused with the original features.
The relevant formulas are as follows:
In the formula, represents the output projection, which restores the feature dimension from dk to C to match the original number of channels. WindowReverse indicates reshaping the token sequence back to the feature map size. α represents the fusion coefficient (typically ranging from 0.5 to 1).
3.4. Context Fusion Module for Detail Preservation
After the multi-scale fusion process, the feature information of small targets in the dried green Sichuan pepper dataset will be damaged. Therefore, in this study, the DPCF module is introduced in the feature fusion part, as shown in Figure 8, to solve the dual contradictions of “detail loss” and “semantic redundancy” through an adaptive fusion strategy.
Figure 8.
PCF module.
This module is used in the decoder to fuse the high-resolution features hi from skip connections with the upsampled low-resolution features . It employs a trainable parameter to generate spatial gating weights through the sigmoid function. These weights determine the proportion of low-resolution context information and high-resolution detail information at each spatial location.
The relevant formulas are as follows:
The gated weight is utilized to perform a weighted summation of high- and low-resolution features, achieving dynamic fusion. When approaches 1, the model emphasizes contextual information; when it approaches 0, it focuses more on detailed information.
The relevant formulas are as follows:
In the formula, represents the low-resolution feature obtained after upsampling, which is derived from the deep backbone network (e.g., upsampling from 20 × 20 × C to 80 × 80 × C); hi is the high-resolution feature obtained through skip connections, coming from the shallow backbone network (e.g., 80 × 80 × C); indicates the fused feature (whose shape remains consistent with the input), and is not the weight of the high-resolution detail feature but is complementary to . The fused feature parts are concatenated, and final feature refinement is completed through a convolutional module.
4. Comparison of Experimental Results After Improvements to YOLOv11
4.1. Comparison of Experimental Results After Improvement of YOLOv11
To validate the optimization results of each approach for the quality inspection of dried green Sichuan pepper, the effectiveness of the multi-scale edge enhancement MEEM, the local region self-attention mechanism LRSA, and the detail-preserving context fusion DPCF module was studied based on the benchmark network structure of YOLOv11. The experimental results are shown in Table 1.
Table 1.
Comparison of experimental results after YOLOv11 improvement.
By replacing the multi-scale feature extraction in the backbone of the original YOLOv11 model with the C3k2_MEEM instead of the ordinary C3k2 module, the mean average precision of the improved network model increased by 1.1 percentage points, although the model size increased to some extent. This demonstrates that the MEEM module effectively addresses the issue of “weak edge features” and improves object detectability (particularly for small objects and those with distinct contours). After the deep feature processing SPPF (spatial pyramid pooling fast) in the algorithm, the original ScConv feature compression module was replaced with C2PSA_LRSA. The improved network model achieved a 0.4 percentage point increase in mean average precision (mAP), with a slight increase in model size. This demonstrates that LRSA (local region self-attention) effectively addresses the issue of “insufficient feature correlation in complex backgrounds” and enhances the discriminative power of features. By introducing the DPCF module into the head section of the algorithm to replace the original fusion method (such as the fusion layers in P3 and P4), the average accuracy of the improved network model increased by 0.4 percentage points, while the model size saw a slight increase. This demonstrates that DPCF module can address the issue of “detail loss in multi-scale fusion” and strike a balance between the need for fine-grained details and the need for coarse-grained context.
As shown in Figure 9 and Table 1, all improved models maintained the same F1 score of 0.94 as the baseline model, indicating that the overall detection accuracy did not decrease. It is worth noting that the optimal confidence threshold of the final proposed model was reduced from 0.478 to 0.314, a decrease of 34.3%. This significantly improved detection sensitivity for low-confidence targets (such as occlusion, edge blurring, low light, and small volume).
Figure 9.
F1-confidence curves comparison between YOLOv11 and MLD-YOLOv11: (a) YOLOv11; (b) MLD-YOLOv11.
The overall mAP@0.5 of the MLD-YOLOv11 model proposed in this paper reaches 0.956, which is 2.2 percentage points higher than the baseline model YOLOv11 (0.934), as shown in Figure 10. For these two detection categories, the AP of brown objects improved slightly from 0.969 to 0.977, while the AP of seeds improved significantly from 0.898 to 0.929. This effectively compensates for the performance bottleneck of the baseline model in detecting small and difficult targets (i.e., seed). The PR curve of the proposed model is always higher than that of the baseline model throughout the recall range, indicating that this model maintains a better precision–recall balance, ensuring high detection accuracy and a low false-negative rate.
Figure 10.
Precision–recall curves comparison between YOLOv11 and MLD-YOLOv11: (a) YOLOv11; (b) MLD-YOLOv11.
4.2. Ablation Experiments
This study proposes three improvement methods: MEEM, LRSA, and DPCF. Ablation experiments were conducted using a custom-built dataset of dried Sichuan peppercorns, and the results are shown in Table 2. (1) Single-module validation: Introducing the MEEM increased the mAP by 1.1 percentage points, increased the model size by 0.94 MB, and decreased the GFLOPs by 0.7 G. The parameter count of the improved model increased by 9.3% relative to the baseline. While it showed the most significant improvement in accuracy, it also imposed a certain computational burden. When used alone, the LRSA module increased mAP by only 0.4 percentage points. Compared with the baseline model, the proposed model introduces a 2.7% increment in parameters. While the increase in model size was minimal, its standalone effect was limited. Similarly, introducing the DPCF module alone increased mAP by 0.4 percentage points, However, the model size increased by 0.53 MB, while the GFLOPs decreased by a definite 1.3 G, and the model parameters increased by 5.4%, resulting in a significant reduction in computational load, though the structure is relatively complex. (2) Model combination: Combining MEEM with LRSA increased the mAP by 1.3 percentage points, with a GFLOP count of 7.6, the model parameters increased by 11.6%, demonstrating synergistic effects. When MEEM is combined with DPCF, the mAP actually decreases to 93.8%, the model parameters increase by 14.3%, and the model size and computational cost are relatively high, indicating potential structural redundancy or conflicts. When LRSA is combined with DPCF, the mAP is significantly higher than the baseline by 1.9 percentage points, the model parameters increase by 7.7%, and both the computational cost (7.1 GFLOPs) and model size (11.12 MB) fall within reasonable ranges, demonstrating outstanding synergy. (3) The full module combination (MEEM+LRSA+DPCF) improves the mAP by 2.2 percentage points. Compared with the baseline model, the number of parameters in this improved model decreases from 2.58 M to 2.50 M, representing a decrease of approximately 3.10%, achieved a certain degree of lightweight. The inference speed slightly decreases from 526 FPS to 454 FPS. The combined effect of these three components further integrates their respective strengths to maximize detection performance.
Table 2.
Ablation experimental results.
From the results of the ablation experiments, it can be observed that when only the MEEM or DPCF module is introduced, the model’s accuracy rate P shows a slight decrease (by 0.6% and 0.3%, respectively), while the recall rate R and mAP@0.5 improve significantly. This is a typical trade-off phenomenon between accuracy and recall in deep learning: the MEEM enhances the ability to extract edge features of subtle defects, and the DPCF module optimizes the multi-scale feature fusion effect, enabling the model to identify more difficult samples (such as tiny mold on the surface of green pepper, uneven color defects, and overlapping targets) that were missed by the baseline model. Although a small number of confusing samples are wrongly classified as positive examples, resulting in a slight decrease in accuracy, the improvement in recall rate is greater. Therefore, the comprehensive indicator mAP@0.5 still shows an upward trend.
In addition, due to the complexity of scene transformations after data augmentation of the dried green pepper dataset collected in this study, overfitting of the model during the training process is the most core concern. Therefore, this study plotted the relevant curves for the model training and validation process. The specific training results are shown in Figure 11.
Figure 11.
Curves related to the training and validation process of the MLD-YOLOv11 model.
As can be seen from Figure 11, during the training and validation processes, the loss curve shows a trend of rapid decline followed by gradual flattening, while the validation metric curves such as Precision, Recall, and mAP (mean average precision) show a trend of rapid increase followed by gradual stabilization. This indicates that there is no overfitting problem in the model construction process based on MLD-YOLOv11 for the quality detection of dried green pepper, and the model has good convergence and excellent generalization ability within 200 training cycles.
To more intuitively evaluate the actual recognition performance of the MLD-YOLOv11 model for the quality detection of dried green pepper on various categories, this study has drawn the confusion matrix of the model, as shown in Figure 12. It can be seen that the model based on MLD-YOLOv11 for the quality detection of dried green pepper has the best recognition performance on the “brown” category, followed by the “seed” category.
Figure 12.
Confusion matrix of the quality detection model for dried green pepper.
This paper tests the improved algorithm and conducts a comparative experiment on the samples in the dried green pepper dataset. The test results are shown in Figure 13. Sample images are input into the original model for training. After testing, two different target boxes are marked for verification, and the results show the number of different target boxes used for verification. By comparing the test set of the original model with that of the improved MLD-YOLOv11 model, it can be seen that there are a few false detections and missed detections, the confidence of the model’s prediction is higher, and the recognition effect is better.
Figure 13.
Comparison of detection performance after YOLOv11 enhancement: Jap.1 originally contained 23 “brown” and 18 “seed” samples. Before improvement, one sample was missed and one sample was misidentified; after improvement, there were no missed or misidentified samples. Jap.2 originally had 104 “seed” samples; both before and after improvement, no missed or misidentified samples were observed. Jap.3 originally contained 90 “brown” samples, with the rest being qualified green Sichuan peppercorns. Before improvement, two samples were misidentified; after improvement, only one sample was misidentified. Jap.4 originally had 93 “seed” samples. Before improvement, two samples were missed; after improvement, there were no missed or misidentified samples. The red arrows indicate the cases that were misidentified, while the green arrows represent the cases that were missed.
4.3. Comparison of Experimental Results of Different Network Models
The self-created dataset of dried green Sichuan pepper was applied to test the current mainstream network structures such as YOLOv6, YOLOv8, YOLOv9t, YOLOv10n and YOLOv12. The test results are shown in Table 3, which verify that the MLD-YOLOv11 model proposed in this paper is comprehensively superior to the detection effects of the above-mentioned mainstream network models. Specifically, the precision of 92.1%, recall of 96.6%, and mean average precision of 95.6% are significantly higher than those of other network structure models, demonstrating excellent detection capability and robustness.
Table 3.
Comparison test results with current mainstream methods.
4.4. Comparison and Discussion with Existing Studies
Deep learning technology has been widely applied in the research of appearance defect detection for various agricultural products. For instance, one study [28] constructed a dataset of green tea buds and leaves for grading and used the ResNet50 classification model to achieve automatic grading into four quality levels with an accuracy of 89.6%. Another study [33] addressed the impurity issue of dried green pepper by using YOLOv8n to identify three types of impurities such as pepper seeds and fruit stalks, with an mAP@0.5 of 0.881. A third study [34] improved the U-Net model to detect internal cracks in rice, achieving an identification accuracy of 90.5%.
However, these studies share three common limitations: first, they all developed custom models for single agricultural products without verifying cross-category generalization ability, resulting in poor model reusability. Second, most existing methods focus on fresh or minimally processed agricultural products and do not fully consider the surface shrinkage and uneven coloration caused by the drying process, leading to a significant deficiency in the recognition of subtle defects in dried agricultural products. Third, most models have a large number of parameters and slow inference speed, with weak adaptability.
To address these shortcomings, the MLD-YOLOv11 model was proposed for the quality inspection of dried green pepper. The results showed that P was 92.1%, R was 96.6%, mAP50 was 95.6%, the number of parameters was 2.50 M, and GFLOPs were 6.3 G. This effectively solves the problem of difficult recognition of subtle surface defects and false detections caused by uneven coloration in dried green pepper, significantly reducing the false detection rate and missed detection rate. In summary, the method proposed in this study outperforms existing similar agricultural product detection methods in terms of detection accuracy, defect coverage, and real-time performance.
At the industrial deployment level, the model has only 2.5 M parameters and 6.3 G GFLOPs, which allows it to be directly deployed on low-cost edge devices such as Jetson Nano and RK3588 without the need for high-performance GPUs. Based on the latest edge deployment benchmarks of the YOLO series [35,36,37], it can achieve 30–40 FPS on Jetson Nano and over 150–200 FPS on RK3588, fully meeting the real-time processing requirements of the green pepper sorting line.
5. Conclusions
In response to the actual detection requirements for the quality of dried green Sichuan pepper, this study proposed a non-destructive detection method for the quality of dried green Sichuan pepper based on the improved YOLOv11. By introducing three modules, namely the multi-scale edge enhancement module (MEEM), the local region self-attention mechanism (LRSA), and the detail-preserving context fusion module (DPCF), the model’s ability to detect defects in dried green Sichuan pepper was enhanced.
The experimental results indicate that MLD-YOLOv11 significantly improves the detection speed of the quality of dried green Sichuan pepper, with high detection accuracy, strong robustness, and high adaptability. The average detection accuracy for the quality of dried green Sichuan pepper is 95.6%. Compared with mainstream network models such as YOLOv6, YOLOv8, YOLOv9t, YOLOv10n and YOLOv12, the mAP values have increased by 4.2, 4.4, 6.8, and 8.4 percentage points, respectively. The algorithm proposed in this paper has the advantages of high detection accuracy and fast processing speed, demonstrating promising application prospects. It can provide a basis for subsequent quality detection of dried green Sichuan pepper and can also be applied to the real-time identification of mold spots in dried wolfberries, the detection of breakage defects in dried chili peppers, and other defect detections in agricultural products, thereby providing crucial algorithmic support for precision agriculture and food safety traceability.
Author Contributions
Conceptualization, B.L. and M.L.; methodology, M.L. and C.L.; software, M.L. and C.L.; validation, M.L. and H.R.; formal analysis, M.L.; investigation, M.L. and C.L.; resources, B.L., H.R. and Z.Z.; writing—original draft preparation, B.L. and M.L.; writing—review and editing, Z.Z.; visualization, M.L.; supervision, B.L., G.P. and Z.Z.; project administration, B.L., H.R., G.P. and Z.Z.; funding acquisition, B.L. and Z.Z. All authors have read and agreed to the published version of the manuscript.
Funding
This research was funded by the National Natural Science Foundation of China (Grant number 32401733), the Science and Technology Research Program of Chongqing Municipal Education Commission (Grant number KJZD-K202501306), and the 2025 Chongqing Agricultural Machinery R&D, Manufacturing, Promotion, and Application Integration Pilot Project (Grant number NYNCBNJYTH-CQ202505).
Institutional Review Board Statement
Not applicable.
Data Availability Statement
The original contributions presented in this study are included in the article. Further inquiries can be directed to the corresponding author.
Acknowledgments
The authors would like to thank all the reviewers who participated in the review.
Conflicts of Interest
The authors declare no conflicts of interest.
References
- Zhang, W.T. Study on the Quality of Fresh Green Pepper under Different Storage Conditions and the Development of Green Pepper Products. Master’s Thesis, Chengdu University, Chengdu, China, 2024. Available online: https://xueshu.baidu.com/ndscholar/browse/detail?paperid=1f6y02h09q6600h0s26b0cd010057177&site=xueshu_se (accessed on 17 April 2026).
- Liu, C.D.; Zhang, H.P. Multi-Scale Evolution of Porosity in Zanthoxylum schinifolium Stack during Convective Drying from Macro to Micro-Scale Characteristics. Trans. Chin. Soc. Agric. Eng. 2026, 42, 372. [Google Scholar] [CrossRef]
- Gao, X.Q.; Zhang, L.Z.; Fu, L. The Influence of Pepper Extract on the Quality of Pork Patties. China Condiment 2019, 44, 89. [Google Scholar]
- Lei, L.; He, Q.C. Ameliorative Effect of Zanthoxylum Bungeanum (Sichuan Pepper) on Pain and Its Influence on Inflammatory Mediators. World Clin. Drugs 2023, 44, 32–38. [Google Scholar] [CrossRef]
- Gong, Y.; Huang, Y.; Zhou, L.; Shi, X.; Guo, Z.; Wang, M.; Jiang, W. Chemical Composition and Antifungal Activity of the Fruit Oil of Zanthoxylum bungeanum Maxim. (Rutaceae) from China. J. Essent. Oil Res. 2009, 21, 174–178. [Google Scholar] [CrossRef] [Scilit]
- Nooreen, Z.; Kumar, A.; Bawankule, D.U.; Tandon, S.; Ali, M.; Xuan, T.D.; Ahmad, A. New Chemical Constituents from the Fruits of Z Anthoxylum armatum and Its in Vitro Anti-Inflammatory Profile. Nat. Prod. Res. 2019, 33, 665–672. [Google Scholar] [CrossRef] [Scilit]
- Liang, Y.; Li, J.J. The Current Situation, Countermeasures and Suggestions for the Development of the Thornless Pepper Industry. Mod. Hortic. 2023, 46, 54. [Google Scholar] [CrossRef]
- Yang, L.S. Nutrient Management Status and Optimal Fertilization of Zanthoxylum Armatum v. Novemfolius Chongqing. Master’s Thesis, Southwest University, Chongqing, China, 2019. Available online: https://d.wanfangdata.com.cn/thesis/Ch1UaGVzaXNOZXdTb2xyOVMyMDI2MDQxNTE0Mjg1MRIJRDAxNzcwODM3GghrZHdydGtxbA%3D%3D (accessed on 17 April 2026).
- Wang, H. Research on Technological Innovation and Quality Enhancement in Pepper Cultivation. Hebei Agric. Mach. 2025, 3, 127–129. [Google Scholar] [CrossRef]
- Zhao, S.Y.; Kong, F.M. Impact of Nitrogen Fertilization on Soil Properties, Fruit Yield, and Quality in Chongqing Nine-Leaf Green Prickly Ash (Zanthoxylum armatum Var. Novemfolius) Plantations of Jiangjin Region, Chongqing. Non-Wood For. Res. 2025, 43, 150–160. [Google Scholar] [CrossRef]
- Bian, H.; He, X.W. The Current Situation and Countermeasures of the Nine-Leaf Green Pepper Industry Development in Jiangjin District. Anhui Agric. Sci. Bull. 2016, 22, 71–72. [Google Scholar] [CrossRef]
- Peng, L.L.; Kuang, M.; Li, S.R. Study on Nutrition Nhange Rule and Nutrition Diagnosis of Zanthoxylum armatum Var. Novemfolius Leaves. South China For. Sci. 2024, 52, 18–24. [Google Scholar] [CrossRef]
- Rao, S.Q.; Xu, F.H.; Fu, Q.Q. Effect of Drying Methods on Drying Characteristics and Quality of Zanthoxylum schinifolium Sieb. et Zucc. J. Food Sci. Technol. 2020, 43, 156–170. [Google Scholar] [CrossRef]
- Zhuo, K.L.; Dong, L.; Li, T.D.; Chen, F. Research Status of Preservation and Processing Technology of Zanthoxylum schinifolium in China. Sci. Technol. Food Ind. 2025, 56, 413–420. [Google Scholar] [CrossRef]
- Xue, H.L.; Wang, N.; Niu, T.T. BP Neural Network Simulation and Quality of Convection and Radiation Parallel Drying of Dahongpao Zanthoxylum bungeanum Maxim. Food Ferment. Ind. 2024, 50, 265–273. [Google Scholar] [CrossRef]
- Wu, X.; Dong, J.; Bao, W.; Zou, B.W. Augmented Intelligence of Things for Emergency Vehicle Secure Trajectory Prediction and Task Offloading. IEEE Internet Things J. 2024, 11, 36030–36043. [Google Scholar] [CrossRef] [Scilit]
- Wu, X.; Wang, H.H.; Tan, W.; Wei, D.S. Dynamic Allocation Strategy of VM Resources with Fuzzy Transfer Learning Method. Peer-Peer Netw. Appl. 2020, 13, 2201–2213. [Google Scholar] [CrossRef] [Scilit]
- Zhu, Y.; Xia, X.; Zhou, J. Detection and Gradation of Sweet Potato Storage Roots by Machine Vision and Deep Learning. Smart Agric. Technol. 2026, 14, 101962. [Google Scholar] [CrossRef] [Scilit]
- Su, Z.P.; Zhou, L. Research on the Application of Machine Vision Detection Technology in Fruit and Vegetable Procurement. Ind. Innov. Res. 2025, 9, 102–104. [Google Scholar]
- Pearson, T.C.; Doster, M.A.; Michailides, T.J. Automated Detection of Pistachio Defects by Machine Vision. Appl. Eng. Agric. 2001, 17, 729–732. [Google Scholar] [CrossRef] [Scilit]
- Blasco, J.; Aleixos, N.; Moltó, E. Machine Vision System for Automatic Quality Grading of Fruit. Biosyst. Eng. 2003, 85, 415–423. [Google Scholar] [CrossRef] [Scilit]
- Bennedsen, B.S.; Peterson, D.L. Performance of a System for Apple Surface Defect Identification in Near-Infrared Images. Biosyst. Eng. 2005, 90, 419–431. [Google Scholar] [CrossRef] [Scilit]
- Li, X.; Zhang, Z.; Wang, J.; Liu, L.; Liu, P. Research on Wheat Spike Phenotype Extraction Based on YOLOv11 and Image Processing. Agriculture 2025, 15, 2295. [Google Scholar] [CrossRef] [Scilit]
- Yang, S.; Yao, J.; Teng, G. Corn Leaf Spot Disease Recognition Based on Improved YOLOv8. Agriculture 2024, 14, 666. [Google Scholar] [CrossRef] [Scilit]
- Shi, Z.; Wu, F.; Han, C.; Song, D.; Wu, Y. Detection Model for Cotton Picker Fire Recognition Based on Lightweight Improved YOLOv11. Agriculture 2025, 15, 1608. [Google Scholar] [CrossRef] [Scilit]
- Sun, D.; Zhang, K.; Zhong, H.; Xie, J.; Xue, X.; Yan, M.; Wu, W.; Li, J. Efficient Tobacco Pest Detection in Complex Environments Using an Enhanced YOLOv8 Model. Agriculture 2024, 14, 353. [Google Scholar] [CrossRef] [Scilit]
- Yang, F.; Zhu, S.P.; Qiu, Q.M. Prickly Ash Appearance Quality Detection Based on Computer Vision and Its Implementation in MATLAB. Trans. Chin. Soc. Agric. Eng. 2008, 24, 198–202. [Google Scholar] [CrossRef]
- Yin, C.; Su, Y.H. Detection of the Quality of Famous Green Tea Based on Improved YOLOv5s. J. Agric. Eng. 2023, 39, 179. [Google Scholar] [CrossRef]
- Fang, X.F. Corn Seed Appearance Quality Estimation Based on Improved YOLO V4. J. Agric. Mach. Sci. 2022, 53, 226. [Google Scholar] [CrossRef]
- Xiao, R. Research on Apple Stem Detection Method Based on Attention Enhanced YOLO. J. Agric. Mech. Res. 2026, 48, 174–180. [Google Scholar] [CrossRef]
- Hua, H.J. Multi-Class Defect Target Detection for Transmission Lines Based on Improved YOLOv7. Electron. Sci. Technol. 2025, 38, 16–24. [Google Scholar] [CrossRef]
- Zhu, R.H.; Wang, X.Y. Real-Time Detection Method for Potato Surface Defects Based on YOLOv11-MML. J. Agric. Eng. 2025, 41, 117–126. [Google Scholar] [CrossRef]
- Yang, F. Study on Prickly Ash Appearance Quality Detection Based on Machine Vision. Master’s Thesis, Southwest University, Chongqing, 2008. [Google Scholar]
- Zheng, H.D.; Liu, M.H. Rice Fissure Detection Using Computer Vision. J. Agric. Eng. 2006, 22, 129. [Google Scholar] [CrossRef]
- Tan, X.; Fan, W.Y. Design of Traffic Sign Recognition System Based on RK3588S Controller and YOLOv11 Algorithm. West. China Commun. Sci. Technol. 2025, 9, 180–183. [Google Scholar] [CrossRef]
- Lin, Y.H. Visual Solution for the Intelligent Logistics Handling Competition Question Based on RK3588 and YOLOv5. Pract. Electron. 2025, 33, 27. [Google Scholar] [CrossRef]
- Li, Y.D. Research on Strawberry Recognition and Detection Method Based on Deep Learning. Master’s Thesis, Shanxi Agricultural University, Jinzhong, China, 2024. Available online: https://d.wanfangdata.com.cn/thesis/Ch1UaGVzaXNOZXdTb2xyOVMyMDI2MDQxNTE0Mjg1MRIJRDAzODc3OTk5GggxbThmYWh2cw%3D%3D (accessed on 17 April 2026).
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2026 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license.












