Abstract
To address the low efficiency and high subjectivity of manual inspection of Astragalus slices, as well as the limited fine-grained detection accuracy caused by the visual similarity between the characteristic radial “chrysanthemum heart” texture and minor defects such as insect damage and mold, this study proposes a lightweight intelligent detection model named Astra-YOLO. A dataset consisting of 622 original Astragalus slice images from four categories was divided into training, validation, and test sets at a ratio of 8:1:1. Data augmentation was applied exclusively to the training set, resulting in a total of 3110 images. Based on YOLOv11n, three targeted improvements were introduced: GhostConv lightweight convolution was employed to reduce model parameters and computational cost; the parameter-free SimAM attention mechanism was integrated to suppress interference from complex textures and enhance defect feature representation; and Wise-IoU v3 was adopted to improve bounding box regression for precise localization of small defects. The experimental results demonstrate that Astra-YOLO achieves superior performance with only 2.53 million parameters and 6.20 GFLOPs. The model attains an mAP@0.5 of 92.7%, an mAP@0.5:0.95 of 73.8%, a precision of 92.4%, and a recall of 92.1%. These results indicate that Astra-YOLO effectively balances lightweight design and detection accuracy, outperforming the baseline model and other improved variants, thereby providing reliable technical support for industrial online inspection and automated quality grading of Astragalus slices.
1. Introduction
Astragalus membranaceus, as a major traditional Chinese medicinal herb, occupies a core position in clinical applications such as tonifying qi and yang and stabilizing the exterior to stop sweating [1]. China is the world’s largest producer of Astragalus, accounting for over 95% of global production value. As the world’s sole exporter of Chinese herbal decoction pieces, China’s annual production capacity of Astragalus slices is expected to reach approximately 90,000 tonnes by 2025. During planting, cutting, storage and transportation, Astragalus slices are highly susceptible to surface defects, including fracture, insect damage and mold [2], which seriously degrade product quality, medicinal value and market price. Faced with large-scale production and strict quality requirements for decoction pieces, researchers urgently need to develop fast, accurate and non-destructive automatic defect detection methods to improve the market competitiveness and intelligent processing level of Astragalus decoction pieces.
Machine vision technology, due to its speed, objectivity, and non-destructive nature, has been widely applied in the automated sorting and quality assessment of agricultural products, industrial goods, and traditional Chinese medicinal materials [3]. In the early development of automated sorting equipment and visual inspection, scholars often relied on traditional image processing and basic machine vision methods. Representative studies include the construction of an automatic sorting system for white mushrooms [4], the design of an online sorting device for cottonseed quality [5], the detection of defect patterns on citrus peels [6], and the quality inspection of corn shoots [7]. However, traditional algorithms have limited generalization ability when dealing with unstructured defects and complex backgrounds. In recent years, deep learning algorithms represented by the YOLO series have demonstrated significant advantages in the fields of object detection and defect recognition, thanks to their exceptional feature extraction capabilities. They have not only been successfully applied to defect detection in Qiu Yue pears [8] and stem positioning in precision agriculture [9] but have also achieved significant results in the automatic sorting and classification of tomatoes [10]. With the continuous evolution of network architectures, the improved YOLOv8 and the latest YOLOv11 models have shown greater potential in tackling complex segmentation and recognition tasks, such as online detection of damage rates in semi-fed peanut combine harvesters based on YOLOv8-Seg [11], and instance segmentation of tomato defects [12], corn leaf diseases [13], and rice leaf diseases [14] based on YOLOv11. Their improved architectures have even demonstrated high robustness in underwater target detection in complex environments [15]. Nevertheless, directly deploying deep learning models on online inspection pipelines still faces two major challenges. First, industrial-grade production demands highly lightweight model design and fast real-time inference speed. To address this, researchers have developed lightweight YOLOv5n-based models for asparagus mechanical injury detection [16] and cottonseed damage classification [17], as well as the FasterNet-YOLO algorithm for real-time detection of steel surface defects [18]. Secondly, fine defects share high visual similarity with background textures, so conventional models are susceptible to noise interference. To this end, scholars have continuously explored targeted improvements, such as using innovative networks like FA-SD-YOLO to achieve rapid and precise detection of complex textured targets like Astragalus slices [19], further promoting the industrialization of intelligent detection technology towards high speed and high precision.
To address the aforementioned challenges, this paper selects the latest iteration of the YOLO series, YOLOv11n, as the benchmark model [20,21]. YOLOv11 has inherent advantages in feature fusion efficiency and multi-scale detection, but its application potential in the field of traditional Chinese medicine defect detection has not yet been fully explored. To further overcome the interference of complex textures in Astragalus and meet the industrial lightweight deployment requirements, this study proposes a defect detection method for Astragalus slices based on the YOLOv11n architecture (named Astra-YOLO). The specific research content includes: (1) collecting and annotating a dataset of 3110 images of astragalus slices, covering four types of targets—fractures, insect damage, mold, and normal “chrysanthemum heart” textures—filling the gap in validation data in this field; (2) to address the challenges of excessive model parameters and high computational complexity restricting industrial deployment, the high visual similarity between the unique radial “chrysanthemum heart” texture of Astragalus and minor defects, and severe localization errors for small defects in Astragalus slice detection, this work introduces three targeted improvements—partial standard convolutional layers are replaced with GhostConv lightweight convolution to reduce model scale and reduce computational burden while retaining key lesion features, the parameter-free three-dimensional spatial weight reconstruction mechanism simAM is integrated at the deep network end to suppress the activation of background physiological textures and enhance lesion feature expression without extra parameters, and Wise-IoU v3 is adopted as the bounding box regression loss in the detection head to dynamically adjust positioning error penalties, alleviating small-target localization inaccuracy and improving fine-grained detection precision for minor defects such as mold and insect damage; (3) through systematic multi-module ablation experiments and deep feature map (Grad-CAM heatmap) visualization analysis, we analyze the performance advantages and spatial focusing characteristics of this parameter-free perception strategy under low computational overhead, verifying its feasibility for deployment in industrial edge devices. The complete research pipeline of the proposed Astra-YOLO method is illustrated in Figure 1.
Figure 1.
Overall technical roadmap of the Astra-YOLO model in the defect detection of Astragalus slices.
2. Materials and Methods
2.1. Test Sample
On 10 January 2026, 622 samples of Astragalus slices were procured from the Astragalus planting base in Longxi County, Dingxi City, Gansu Province, for experimental use as test samples. The samples exhibited various external defects. Referring to the “Standard for the Classification and Grading of Chinese Herbal Medicines Part 4: Astragalus” (T/CACM 1021.4-2018) [22] issued by the China Association of Chinese Medicine and considering the actual defect characteristics of Astragalus slices, we categorized the main defects into three categories: first, fracture induced by mechanical stress during processing, cutting, transportation, and storage; second, mold growth formed under inappropriate temperature and humidity conditions during storage; and third, insect damage occurring throughout the storage period.
2.2. Computer Vision System
This study constructed a dedicated image acquisition system for Astragalus slices integrated inside a light-shielding dark box, as shown in Figure 2, to capture surface defects, such as fractures, insect damage, and mold. The core components include an industrial camera, a low-distortion lens, dual-side LED supplementary lighting groups, a sample stage, and a backend image processing workstation. The imaging unit adopts a vertical imaging configuration, with a 3072 × 2048 (6-megapixel) CMOS industrial camera (Model: MV-CU060-10GM, manufactured by Hikvision, Hangzhou, China) mounted directly above the sample stage. The optical axis is perpendicular to the plane of the sample stage plane and is fitted with 12 mm fixed-focus low-distortion industrial lens (Model:MVL-HF1224M-10MP, manufactured by Hikvision, Hangzhou, China). The object distance (from the lens to the surface of the sample) is fixed at 350 mm to achieve imaging that balances field of view and imaging resolution. To highlight the “chrysanthemum heart” fiber texture and insect holes on the cross-section of Astragalus slices, the system adopts a symmetric illumination arrangement. During operation, the test Astragalus slices are placed on a stable stage, and the captured raw images are sent to the computer in real-time backend via a USB 3.0 high-speed interface. The self-developed improved YOLOv11 algorithm is used to perform real-time processing and classification, and the detection results are simultaneously displayed on the monitor.
Figure 2.
Hardware composition of the Astragalus slice online computer vision inspection system.
2.3. Image Acquisition and Dataset Construction
2.3.1. Data Collection
To obtain clear surface images of Astragalus slices, each independent slice sample was placed flat on the sample stage, and front-view images were captured under uniform symmetric lighting to fully present the radial “chrysanthemum heart” texture and surface defect features.
A total of 622 original surface images were collected from 622 independent Astragalus slice samples, covering four categories: Fracture, Insect, Mold, and Intact. All images were stored in JPG format with a resolution of 3072 × 2048 pixels. Typical images of each category are shown in Figure 3.
Figure 3.
Typical images of different defect types in Astragalus slices.
2.3.2. Dataset Construction
First, using the annotation tool LabelImg v1.8.6, rectangular bounding boxes were labeled for four classes (Fracture, Insect, Mold and Intact) on all original 622 raw images of Gansu Astragalus slices (Figure 4). Corresponding annotation files were generated to store bounding box coordinates and category labels. Second, the 622 annotated original images were randomly divided into training, validation and test sets at a ratio of 8:1:1 via sample-level stratified sampling. Specifically, all data derived from the same slice sample (including all augmented versions generated from this sample) were assigned to exactly one subset, with no cross-subset sample overlap, which fundamentally eliminates the risk of data leakage. The validation and test sets retained the original raw images without any modification or augmentation to ensure the model evaluation was conducted on completely unseen real data. To expand sample diversity, alleviate overfitting and improve model generalization performance, random data augmentation operations (random rotation, horizontal flipping, brightness variation and Gaussian noise addition, Figure 5) were exclusively implemented on the training set. As illustrated in Figure 6, data augmentation effectively balanced the class distribution of the training set: the number of samples in the four categories ranged from 731 to 766. Ultimately, the processed dataset consists of 2986 augmented training images, 62 raw validation images and 62 raw test images, summing up to 3110 images in total.
Figure 4.
LabelImg manual labeling for Astragalus slice defect annotation.
Figure 5.
Visual comparison of original and augmented Astragalus slice images.
Figure 6.
Sample quantity distribution of Astragalus slices in the augmented training set.
2.4. Astra-YOLO Model for Astragalus Slices Defect Detection
Currently, object detection approaches are categorized into two mainstream types: two-stage and single-stage detectors. Lightweight single-stage algorithms balance speed and accuracy, making them suitable for industrial online inspection scenarios. The YOLOv11n model, with high accuracy, real-time response, and portability [20,21], is selected as the foundational model. To address the challenges of Astragalus slice detection, three optimizations are introduced to YOLOv11n: SimAM attention, GhostConv lightweight convolution, and Wise-IoU v3 loss function. SimAM, a parameter-free attention mechanism [23], enhances feature reconstruction without adding parameters, unlike SE [24] and CBAM [25]. GhostConv [26] replaces partial standard convolutions to reduce model size and computational overhead for edge deployment. Wise-IoU v3 [27] improves localization accuracy for minor defects by dynamically adjusting bounding box error penalties. These optimizations achieve synergistic improvements in accuracy, lightweight design, and localization, adapting the model to industrial online inspection requirements.
2.4.1. Overall Structure of the Astra-YOLO Model
This study optimizes the C3k2 module with SimAM attention and adopts GhostConv lightweight convolution to reduce redundant parameters, realizing effective lightweight design. Figure 7 presents the architecture of the proposed Astra-YOLO model based on YOLOv11n, which consists of five core stages: Input, Backbone, Neck, Head, and Output, corresponding to data preprocessing, feature extraction, multi-scale feature fusion, detection prediction, and result visualization, respectively. The Input stage processes original and augmented Astragalus slice images, which are fed into the Backbone network. The Backbone, constructed with stacked GhostConv lightweight convolutions, C3k2 modules, SPFF and C2PSA modules, extracts basic features while reducing parameters and computational overhead by replacing partial standard convolutions with GhostConv. The Neck builds a multi-scale feature pyramid via Upsample and Concat operations to fuse Backbone outputs. Part of the original C3k2 modules is replaced with improved C3k2-SimAM modules to enhance defect feature focus, with SimAM improving multi-scale feature expression; GhostConv is also adopted to further reduce computational cost during fusion. The Head includes three parallel Detect branches for multi-scale target detection and classification. Notably, the Wise-IoU (WIoU) loss function is embedded in the detection heads to enhance bounding box regression performance and elevate localization precision for minor defects, such as insect damage and mold spots. The Output stage generates predicted defect bounding boxes, class labels, and SimAM attention heatmaps, visualizing the model’s focus on critical regions. These optimizations balance lightweight design, feature enhancement, and localization accuracy, making Astra-YOLO suitable for the stringent requirements of online Astragalus slice detection.
Figure 7.
Network architecture of improved Astra-YOLO based on original YOLOv11n.
2.4.2. GhostConv
To further achieve lightweight design and meet the real-time inference and edge deployment demands for online detection of Astragalus slices, this paper introduces the GhostConv lightweight convolution module in the feature extraction and feature fusion stages of Astra-YOLO. Figure 8 illustrates its core working principle. As shown in the figure, the input feature map first undergoes a small number of standard convolutions to generate a set of intrinsic feature maps that capture the core information of the input. These intrinsic features are then used to generate additional “ghost” feature maps via a series of low-cost linear operations (denoted as Ø1, Ø2, …, Øk). In the final stage, these two groups of feature maps are concatenated to form the final output feature map.
Figure 8.
Internal feature extraction principle of lightweight GhostConv convolution.
The mathematical expressions and specific convolution types adopted in GhostConv are defined below. Given the input feature map X, the intrinsic features are first generated via 1 × 1 pointwise convolution:
Subsequently, each intrinsic feature is processed by 3 × 3 depthwise convolution to implement low-cost linear transformation for ghost feature generation:
The final output feature map is obtained by feature concatenation:
In this implementation, the primary convolution branch employs pointwise convolution, and all low-cost linear operation branches utilize depthwise convolution, which is consistent with the structure shown in Figure 8.
By replacing most redundant standard convolution operations with this linear generation strategy, GhostConv greatly reduces model parameters and computational overhead while retaining defect feature extraction performance. It effectively improves the model’s inference efficiency, making it well-suited for lightweight deployment demands of industrial online inspection scenarios.
2.4.3. simAM Attention Module
Figure 9 illustrates the core working principle of the SimAM attention module [22], which aims to achieve efficient focusing and fine-grained extraction of key features. The SimAM module is based on the input feature map X (with dimensions C × W × H) and generates multiple sets of intermediate feature maps with different channel and spatial distributions through feature generation operations. This enriches the diversity of feature dimension representation while keeping the spatial dimensions (width W and height H) unchanged. Subsequently, the module constructs a dual-path processing structure in parallel: one path is the Expansion path, which performs sequential expansion of the generated intermediate feature maps along the channel dimension, further covering the full-dimensional information of the features; the other path is the Fusion path, which deeply integrates cross-channel feature information. Finally, the module outputs the feature map H’ after attention-weighted aggregation, which both expands the coverage of features through the Expansion path and enhances the retention and transmission of key target information through the Fusion path. Compared to traditional attention mechanisms, the SimAM module achieves precise focusing on target areas with lower computational complexity, effectively boosting the model’s overall performance to differentiate easily confused features such as Astragalus slices with defects and normal textures, thereby providing more discriminative feature inputs for subsequent object detection tasks.
Figure 9.
Structural schematic of simAM attention module.
2.4.4. Wise-IoU v3 Loss
In the defect detection task of Astragalus medicinal slices, the surface of the slices exhibits naturally complex patterns of “chrysanthemum heart” and color variations. Moreover, insect damage and mold are tiny-sized defects. The manual annotation process is prone to minor deviations in the size and position of the annotation boxes. There are a large number of difficult samples and low-quality annotated samples in the training set. Although the traditional CIoU loss function comprehensively considers regression factors such as overlap area, center point distance, and aspect ratio during model training, it excessively amplifies the bounding box fitting error of low-quality defect samples, resulting in negative gradient impacts. At the same time, CIoU applies equal training weights to all samples, which cannot distinguish the differences between difficult and easy samples, seriously interfering with the feature learning of minor defects and ultimately degrading the overall detection and localization performance of the model.
To address the aforementioned issues, this paper introduces Wise-IoU v3 as the bounding box regression loss function, which is developed based on the basic framework of Wise-IoU v1.
Wise-IoU v1 first introduces a distance attention mechanism to alleviate the internal competition among high-quality anchor boxes, focusing on optimizing the regression ability of general-quality samples. Its calculation is composed of three parts:
The weighted loss of Wise-IoU v1 is defined as:
The distance attention factor RwIoU is calculated as:
where x and y denote the center coordinates of the predicted bounding box, and xgt and ygt denote the center coordinates of the ground truth box. Wg and Hg are the width and height of the minimum enclosing box of the two boxes, respectively. The asterisk (*) indicates that this term does not participate in gradient updates to avoid disrupting the gradient flow of distance loss.
The basic IoU loss is:
Based on the above mechanism, Wise-IoU v3 further introduces outlier assessment and constructs a non-monotonic focusing coefficient, which allocates lower gradient gains to low-quality anchor boxes with high outlier degrees. Meanwhile, it weakens the competitive effect between high-quality anchor boxes, guiding the model to focus more on valid defect-related anchor boxes during training, which is perfectly suitable for the micro-defect regression tasks of Astragalus slices.
The final loss function of Wise-IoU v3 is defined as:
where r is the non-monotonic focusing coefficient, calculated as:
Here, α and δ are the hyperparameters controlling the shape of the focusing coefficient, and β is the outlier degree, defined as:
where L*IoU denotes the maximum LIoU value among all samples in a batch. The outlier degree β reflects the deviation of a sample from the average regression quality: samples with larger β are low-quality outliers caused by annotation deviations or difficult defects.
Hyperparameter configuration for Equation (5): For our task, the hyperparameters in the non-monotonic focusing coefficient are set as: α = 1.9, δ = 3. Rationale for parameter selection:
These values are first referenced from the original Wise-IoU v3 implementation, which are proven effective in general object detection tasks. To adapt the loss function to our specific scenario (small defects and low-quality annotations in Astragalus slices), we further conducted ablation experiments on the validation set to verify the optimal configuration. The selected values α = 1.9 and δ = 3 can effectively suppress the gradient interference of low-quality outliers while maintaining the regression ability of high-quality anchor boxes, achieving the highest mAP@0.5 on our validation set.
This dynamic weight adjustment mechanism can effectively suppress the training interference caused by annotation bias and low-quality hard samples and significantly improve the localization accuracy of micro-defects in Astragalus slices and the overall detection performance.
2.5. Experimental Platform and Training Parameters
For fair and credible experimental comparisons, we used the same experimental platform to train and test all models. The hardware setup includes an Intel Core i7-14700K @ 3.40 GHz CPU, an NVIDIA GeForce RTX 4080 SUPER GPU, 16 GB RAM and a 500 GB solid-state drive, with Windows 11 as the operating system. Python 3.12, OpenCV 4.10.0 and the PyTorch 2.2.0 framework form the core of our software environment. For all training tasks, we unified the input image size to 640 × 640, set the batch size to 32 and assigned 8 threads for data loading. Through preliminary experiments, the final training hyperparameters were determined. To ensure full model convergence for complex Astragalus slice defect detection, the maximum training epoch was set to 350, and an early stopping mechanism with a patience of 50 was applied to prevent overfitting and avoid unexpected termination caused by training fluctuations. All models in this study completed the full 350 training epochs without triggering early stopping. We adopt the Stochastic Gradient Descent (SGD) optimizer to update model parameters. The initial learning rate was fixed at 0.01, and the weight decay coefficient is set to 0.0005. All detailed training configurations are listed in Table 1.
Table 1.
Training environment and parameter settings for Astragalus slice defect detection.
2.6. Model Evaluation Metrics
To make a comprehensive evaluation of model effectiveness in detecting defects in Astragalus slices, this study selects five evaluation metrics: Average Precision (AP), Recall (R), Mean Average Precision (mAP), Model Parameters (Params), and Giga Floating Point Operations (GFLOPs). These five metrics reflect the model’s performance from multiple dimensions, including detection accuracy, recall rate, detection speed, and model complexity. The calculation formulas are summarized as follows:
where P represents precision, which measures the proportion of samples correctly detected as positive among all positive predictions. TP (True Positives) is the number of correctly detected positive samples, and FP (False Positives) is the number of negative samples incorrectly predicted as positive.
where AP (Average Precision) is the area under the Precision–Recall (P–R) curve, which summarizes the precision values of a single category across all possible recall values R. P(R) represents the precision at a given recall rate R.
where mAP (mean Average Precision) is calculated as the mean AP value for all classes, and it reflects the model’s comprehensive detection performance. APi corresponds to the average precision of the i-th category, while n represents the total number of categories.
In this study, we strictly followed the COCO object detection evaluation standard for mAP calculation. Specifically, mAP@0.5 is computed using AP values obtained at an Intersection over Union (IoU) threshold of 0.5, while mAP@0.5:0.95 is the mean of AP values across IoU thresholds ranging from 0.5 to 0.95 with a step size of 0.05.
During model inference and evaluation, the confidence threshold is set to 0.25, and the Non-Maximum Suppression (NMS) IoU threshold is set to 0.45 to filter redundant detection boxes. All metric calculations are performed using the official evaluation script provided by Ultralytics YOLOv11 to ensure result consistency and reproducibility.
where R refers to the recall rate. This metric measures the proportion of correctly detected true positive samples across all true positives. FN (False Negatives) denotes true positive samples that are misjudged as negative samples, namely missed detections.
where GFLOPs (Giga Floating-Point Operations) reflect the computational complexity of the model, reflecting the number of floating-point operations required for inference and determining the model’s inference speed. Mi is the spatial dimension of the feature map at the i-th layer, Ki is the size of the convolution kernel at the i-th layer, Ci−1 and Ci are the number of input and output channels at the i-th layer, respectively, and O(⋅) is the asymptotic notation used to characterize the order of computational complexity.
where Params denotes the total number of learnable parameters, and it can reflect the model’s size and computational complexity. The definitions of Ki, Ci−1, and Ci are the same as those in Equation (5), and O(⋅) is the asymptotic notation for parameter counting complexity.
3. Results and Analysis
3.1. YOLOv11 Model Performance Comparison
To compare the performance differences of various lightweight models in the YOLOv11 series for the task of detecting defects in Astragalus slices, three models—YOLOv11n, YOLOv11s, and YOLOv11m—were selected. Training and testing were conducted under the same experimental environment and dataset partition, with the experimental results shown in Table 2. The results show that the YOLOv11n model, with 2.60 M parameters and 6.40 GFLOPs, achieved 90.8% mAP@0.5, 72.1% mAP@0.5:0.95, 90.2% precision, and 89.4% recall. Its parameter count is only 27.7% of YOLOv11s (9.40 M) and 12.9% of YOLOv11m (20.1 M), while its computational complexity (6.40 GFLOPs) accounts for only 29.6% of YOLOv11s (21.6 GFLOPs) and 9.4% of YOLOv11m (68.2 GFLOPs). Despite this significant reduction in model scale, YOLOv11n maintains competitive detection accuracy: its mAP@0.5 (90.8%) is only 0.8 percentage points lower than YOLOv11s (91.6%) and 1.3 percentage points lower than YOLOv11m (92.1%). For mAP@0.5:0.95, which reflects the localization performance of small defects, YOLOv11n achieves 72.1%, showing a slight gap compared to YOLOv11s (73.5%) and YOLOv11m (74.8%), but still delivers reliable performance for the task of detecting tiny defects in Astragalus slices. It is better suited to the stringent requirements of model size and real-time performance for online detection of Astragalus slices and thus has been selected as the foundational model for subsequent improvement research.
Table 2.
Detection performance comparison of YOLOv11 (n, s, m) for Astragalus slice defect detection.
3.2. Comparison of Different Attention Mechanisms
To verify the advantages of the improved algorithm in this paper, a comparison was conducted between the YOLOv11n benchmark model and models incorporating ECA, SE, CBAM, and CA attention mechanisms, as well as YOLO-simAM, with the results shown in Table 3. The results illustrate that all compared models maintained mAP@0.5 values from 90.8% to 91.4%, but the fine-grained detection metrics mAP@0.5:0.95 of traditional attention mechanisms (ECA/SE/CBAM/CA) showed a significant decline, with the maximum drop reaching 0.9 percentage points. YOLOv11n-simAM, without introducing additional learnable parameters and with minimal computational overhead, achieved the best overall performance. Meanwhile, mAP@0.5 increased to 91.4%, and mAP@0.5:0.95 increased to 72.6%, effectively overcoming the fine-grained accuracy loss caused by traditional attention mechanisms, achieving a better balance between lightweight design and detection performance.
Table 3.
Detection performance comparison of multiple attention modules replaced in the YOLOv11n.
3.3. Comparison of Lightweight Convolutional Model Selection
To verify the selection rationality of the GhostConv lightweight module, the original YOLOv11n model was compared with the models that incorporate MobileNet Block, ShuffleNet Block, and GhostConv. The results are presented in Table 4. The experiments indicate that GhostConv not only significantly reduces the model parameters and computational cost but also retains the defect feature extraction capability to the maximum extent. Both mAP@0.5 and mAP@0.5:0.95 remain at the optimal level, which better meets the lightweight deployment demands for industrial online detection of Astragalus slices.
Table 4.
Detection performance comparison of multiple lightweight convolution modules replaced in the YOLOv11n.
3.4. Comparison of Loss Function Selection
To verify the optimization performance of Wise-IoU v3 on minor defects, a comparative experiment was conducted among GIoU, DIoU, CIoU, SIoU, and Wise-IoU v3. Table 5 lists all experimental results. It demonstrates that Wise-IoU v3 can effectively alleviate the deviation of small-target bounding boxes and markedly boost detection precision for minor defects, like insect damage and mold. Compared with the baseline CIoU, its mAP@0.5 increased from 90.8% to 91.3%, while the improvement in mAP@0.5:0.95 is the most significant, rising from 72.2% to 73.2%.
Table 5.
Detection performance comparison of diverse loss functions applied in the YOLOv11n.
3.5. Ablation Experiment
To validate the independent effectiveness and collaborative gains of SimAM, GhostConv, and Wise-IoU v3, eight sets of ablation experiments with controlled variables were designed. The results are presented in Table 6 (columns 1, 2, and 3 correspond to SimAM, GhostConv, and Wise-IoU v3, respectively). The experiments showed that each individual module yielded considerable performance improvements over the baseline YOLOv11n (90.8% mAP@0.5, 72.1% mAP@0.5:0.95): SimAM and GhostConv both boosted mAP@0.5 by 0.6 percentage points, while Wise-IoU v3 achieved the largest gain in small-target localization, raising mAP@0.5:0.95 by 1.1 percentage points. Two-module combinations exhibited evident collaborative optimization, outperforming individual modules with larger performance gains. Finally, Astra-YOLO—the proposed model integrating all three modules—reached the global optimum: it achieved 92.7% mAP@0.5 (+1.9 percentage points vs. baseline) and 73.8% mAP@0.5:0.95 (+1.7 percentage points) while reducing parameters to 2.53 M and computational complexity to 6.20 GFLOPs, striking the optimal balance between lightweight design and detection accuracy.
Table 6.
Ablation experiment of each module in Astra-YOLO.
To eliminate the influence of random network initialization and data partitioning, each group in the ablation experiments was evaluated over five independent runs. We reported the mean value and standard deviation (Std) of mAP@0.5 to quantify the stability of performance improvements. An independent sample t-test was further conducted to examine whether the performance differences between each improved group and the baseline YOLOv11n were statistically significant. The statistical results are summarized in Table 7.
Table 7.
Statistical analysis of ablation experiment results (five independent runs).
As presented in Table 7, although the mAP@0.5 improvements introduced by individual modules are relatively marginal (ranging from 0.5% to 0.7%), all groups exhibited small standard deviations (≤0.25%), indicating high stability across repeated experiments. The t-test results confirmed that all improved groups achieve statistically significant gains (p < 0.05) compared with the baseline, ruling out the possibility that the observed improvements stemmed merely from random experimental fluctuations.
For combined module groups, the performance gains accumulated progressively with the integration of different lightweight components. The final proposed Astra-YOLO achieved a 1.9% improvement in mAP@0.5 over the baseline while maintaining stable performance across multiple runs. These results fully validated the effectiveness of each proposed module and their synergistic effects in boosting detection performance.
3.6. Model Detection Effect Analysis
To evaluate the performance of the improved model in detecting defects in Astragalus slices, this study conducted a visual analysis of the detection results (as shown in Figure 10). The results indicated that the model could accurately identify and locate four types of targets: fractures, insect damage, intact, and moldy. Among them, for well-preserved slices with distinct features, the model demonstrated extremely high recognition performance, with detection confidence scores all above 0.90. For defects with smaller lesions, such as mold and insect damage, the model was still able to achieve precise localization, showcasing strong deep feature extraction capabilities. Although there were slight differences in delineating fracture boundaries, the overall detection accuracy was excellent. Overall, this improved model could effectively handle various defect types of Astragalus slices, satisfying the requirements for accurate and efficient detection in practical industrial scenarios.
Figure 10.
Astra-YOLO detection visualization of four different defect types for Astragalus slices.
3.6.1. Visual Comparison on Hard Confusing Samples
To intuitively demonstrate the superiority of our improved Astra-YOLO over the baseline YOLOv11n when dealing with Astragalus slices featuring easily confused chrysanthemum texture, three representative difficult samples were selected for comparative detection visualization, as illustrated in Figure 11.
Figure 11.
Detection comparison of hard samples: YOLOv11n vs. Astra-YOLO.
False Positive (FP) suppression (the first row): For the sample with genuine insect damage, baseline YOLOv11n produced redundant erroneous bounding boxes, accompanied by a low confidence of 0.43 for the true insect lesion. By contrast, benefiting from simAM attention and GhostConv feature optimization, Astra-YOLO removed the false-positive redundant box and only localized the actual insect defect with a higher confidence of 0.71, which greatly suppresses texture-induced false positive errors and improves detection confidence of real defects.
False Negative (FN) elimination (the second row): The baseline completely failed to detect the dark mold spot, resulting in missed detections. Relying on Wise-IoU v3 loss optimized for small-object regression, our Astra-YOLO successfully captured the mold area with a high confidence of 0.92 and remedied the baseline’s under-detection issue.
Prediction confidence promotion (the third row): For fully intact Astragalus slices without any defect, Astra-YOLO achieved higher classification confidence (0.88) than the baseline YOLOv11n (0.79). This improvement proved the proposed model extracted more discriminative feature information to distinguish intact tissues from complex background textures.
3.6.2. Detection Result Analysis
Table 8 summarizes the category-specific Precision, Recall, mAP@0.5 and mAP@0.5:0.95 of the proposed Astra-YOLO for four Astragalus slice categories.
Table 8.
Category-wise detection metrics of Astra-YOLO on four Astragalus slice categories.
Among all categories, intact samples with easily confused chrysanthemum-core texture achieved the optimal detection performance, with a Precision of 92.8%, a Recall of 93.7% and an mAP@0.5 of 94.1%. The outstanding accuracy of intact category demonstrates that the embedded simAM and GhostConv effectively suppress false-positive misclassification caused by irregular natural texture, which effectively addressed the core confusion challenge between normal chrysanthemum patterns and real insect/mold defects. By contrast, fracture defects yielded relatively lower detection metrics, as diverse irregular edge shapes and scattered tiny fracture features increased localization difficulty during feature extraction.
3.7. Model Visualization Analysis
The weak interpretability of convolutional neural networks makes it difficult to directly observe their internal decision-making logic. To visually verify the feature focusing effect of the proposed Astra-YOLO model, Grad-CAM heatmaps of the last convolutional layer were generated for the baseline YOLOv11n and Astra-YOLO, and the feature extraction performance was compared, as shown in Figure 12. In the heatmaps, the dark red region represented the key focus area of the model for the target.
Figure 12.
Comparison of Grad-CAM heatmaps for YOLOv11n and Astra-YOLO on four types of Astragalus slice samples.
The experimental results showed that the baseline YOLOv11n is easily disturbed by the radial physiological texture of the “chrysanthemum heart” on Astragalus slices. The feature extraction range is scattered, and the exhibited response to defect features, such as mold and insect damage, is insufficient, resulting in offset or over-expanded highlighted regions. By contrast, the Astra-YOLO model proposed in this study collaboratively integrated GhostConv lightweight convolution, parameter-free SimAM attention mechanism embedded in the detection head, and Wise-IoU v3 loss function. It demonstrated outstanding performance in texture interference decoupling and defect feature focusing. The dark red highlighted regions accurately converge on the real defect edges, effectively eliminating the interference of normal physiological textures highly similar to defect features.
The visualization results not only intuitively verified that the simAM-based three-dimensional spatial weight reconstruction strategy can effectively suppress background texture interference and enhance key defect feature expression but also confirmed the rationality of the collaborative optimization of GhostConv and Wise-IoU v3. From the perspective of model interpretability, it provided strong support for the improvement of fine-grained detection accuracy and localization performance of Astra-YOLO.
The Grad-CAM heatmaps in Figure 10 intuitively visualized the feature activation regions of the baseline YOLOv11n and the proposed Astra-YOLO from a qualitative perspective. To further quantitatively evaluate the feature focusing capability, we calculated the Intersection over Union (IoU) between the high-activation regions of Grad-CAM and the ground truth bounding box on the entire test set.
Specifically, we set the activation threshold to 0.5 to binarize the Grad-CAM feature maps and extract valid high-activation areas. The IoU between the binarized activation regions and manually annotated ground truth box was computed for each sample, and the final result took the average value over all test images. A larger average IoU indicates that the model’s activated features are more concentrated on real defect areas, meaning better localization performance. The quantitative results are listed in Table 9.
Table 9.
Quantitative evaluation of Grad-CAM feature focusing via IoU.
3.8. Comparison with State-of-the-Art Lightweight Models
As listed in Table 10, Astra-YOLO achieved the smallest parameter count while obtaining the highest detection accuracy among all competing lightweight models. Compared with EfficientDet-D0, MobileNetV3-YOLO and multiple tiny YOLO variants, the gradual improvement of detection metrics verified the effectiveness of our improved lightweight modules.
Table 10.
Comparison against state-of-the-art lightweight detection methods.
To further verify the lightweight and real-time advantages of Astra-YOLO, we tested its inference speed on NVIDIA RTX 4080 GPU with an input size of 640 × 640. After excluding warm-up iterations, the baseline YOLOv11n achieved an average speed of 667 FPS, while our proposed Astra-YOLO reached 588 FPS, demonstrating its better suitability for industrial online detection scenarios requiring low latency.
4. Discussion
The surface texture of Astragalus slices is complex, with its natural “chrysanthemum heart” radial growth pattern highly resembling early mold and insect holes in terms of feature expression, posing a core challenge for automated defect detection. Currently, research on defect recognition of Traditional Chinese Medicine (TCM) materials mainly relies on traditional image processing algorithms or early deep learning models. For instance, Gao et al. [28] adopted YOLOv3 to detect TCM slices and achieved a detection accuracy of 96%, while Zhang et al. [29] realized multi-dimensional quality evaluation of ginseng appearance via deep learning methods.
In recent years, a series of improved YOLO variants have been proposed for TCM and agricultural product detection. Aiming at ginseng appearance quality detection, Zhang et al. [30] constructed DGS-YOLOv8 by combining the SimAM attention mechanism and lightweight network structures, which effectively enhanced feature extraction capability for TCM features; nevertheless, the model still has a relatively large parameter count and cannot be well deployed on embedded sorting terminals. In the field of agricultural defect detection, Han et al. [31] verified the effectiveness of lightweight convolution modules and Wise-IoU loss function on apple disease recognition, realizing model compression, yet this framework is not specifically optimized for the intricate texture characteristics of TCM slices.
In general, most existing TCM detection models either suffer from excessive parameter counts or lack targeted design for complex texture interference. Therefore, achieving extreme lightweight design while maintaining high detection accuracy is a key and urgent challenge for online real-time detection of TCM materials.
Three improved modules form a cascaded synergistic pipeline in Astra-YOLO. GhostConv reduces computation for lightweight feature extraction and reserves computing budget for subsequent modules; parameter-free SimAM suppresses chrysanthemum texture noise and highlights subtle defect features on compact feature maps; Wise-IoU v3 optimizes bounding box regression to ease localization bias of tiny targets. This layered cooperation fundamentally drives the performance gains in ablation experiments.
Combining the three components on YOLOv11n, Astra-YOLO achieved 2.53 M parameters and 6.20 GFLOPs, with mAP@0.5 = 92.7%, mAP@0.5:0.95 = 73.8%, Precision = 92.4%, and Recall = 92.1%. It outperformed vanilla YOLOv11n and variants with SE/CBAM/CA attention, alleviating fine-grained accuracy drop caused by complex background. In addition, head-only simAM embedding delivered the best anti-interference capacity against chrysanthemum texture compared with backbone or full-network embedding.
The mild incremental performance improvement matches our plug-and-play lightweight design: we optimize partial modules rather than redesign the backbone for sharp accuracy leaps, so steady indicator growth is reasonable. In addition, all tests adopted a single dataset split without k-fold division or external cross-dataset validation, as explained below.
Despite its satisfactory detection performance, the model has practical limitations. First, the experiments were conducted solely on our self-built Astragalus dataset, lacking cross-domain verification. Second, slice overlap and backlight shadows led to localization deviations of fractured edges. Third, early mold with slight color difference from normal tissues occasionally caused missed detections. Future work will adopt semi-supervised learning for hard sample augmentation, introduce public datasets to conduct generalization tests, and further optimize inference speed to facilitate industrial edge deployment.
5. Conclusions
This work presents a lightweight Astra-YOLO detection model based on YOLOv11n for accurate and efficient defect detection of Astragalus slices. Aiming at the complex texture interference, difficult fine-grained defect localization and high computational consumption existing in Astragalus slice detection tasks, three targeted optimizations are integrated into the baseline model. GhostConv lightweight convolution replaces partial standard convolutions to reduce model parameters and computational overhead. A parameter-free SimAM attention mechanism is embedded in the detection head to decouple the interference of natural “chrysanthemum heart” radial textures and enhance the feature focusing ability for subtle lesions. In addition, Wise-IoU v3 is utilized to refine bounding box regression and boost the localization accuracy of tiny defects, like insect damage and mold.
Systematic experiments verify that the optimized Astra-YOLO achieves balanced performance improvement and lightweight superiority. It obtains an mAP@0.5 of 92.7%, an mAP@0.5:0.95 of 73.8%, a precision of 92.4%, and a recall of 92.1%, with an ultra-light parameter count of 2.53 M and computational complexity of 6.20 GFLOPs, outperforming all comparative models in terms of lightweight level and comprehensive detection performance. Quantitative results demonstrate that the collaborative optimization of the three modules effectively avoids the fine-grained accuracy degradation caused by traditional attention mechanisms and conventional loss functions, improving the baseline mAP@0.5:0.95 by 1.7 percentage points. The head-only simAM embedding strategy also achieves optimal fine-grained detection performance, verifying the rationality of the structural design.
This study constructs a 3110-image Astragalus slice defect dataset covering fractures, insect damage, mold and normal physiological textures and develops a lightweight and high-precision detection method. The proposed model well meets the real-time requirements of industrial online detection, providing reliable technical support for the intelligent processing and automatic quality grading of Astragalus slices and offering a valuable reference for defect detection of agricultural and traditional Chinese medicine materials with complex textures.
Author Contributions
Methodology, J.Y., Z.L. and X.D.; Formal analysis, Q.S. and Y.J.; Resources, S.C.; Writing—original draft, J.Y.; Writing—review and editing, X.D. All authors have read and agreed to the published version of the manuscript.
Funding
This study was supported by Natural Science Foundation of Jiangsu Province, China (BK20241058).
Institutional Review Board Statement
Not applicable.
Informed Consent Statement
Not applicable.
Data Availability Statement
The original Astragalus slices image data, annotation files, and experimental results of the present study may be obtained from the corresponding author on reasonable request.
Conflicts of Interest
The authors declare no conflicts of interest.
References
- Xi, J.Y.; Su, Y.J.; Zhao, K.P.; Feng, J.L.; Yang, F.D. Research progress on the homology of medicine and food of Astragalus membranaceus. West China J. Pharm. Sci. 2023, 38, 718–724. [Google Scholar]
- Cheng, Y.-X.; Liu, Z.-Y.; Xu, B.; Song, P.-P.; Chao, Z.-M. Research status of insect infestation in Chinese medicinal materials during storage. China J. Chin. Mater. Med. 2023, 48, 5152–5161. [Google Scholar] [CrossRef] [Scilit]
- Du, X.; Qian, J.H.; Nie, W.N.; Wu, W.G.; Li, W.L. Research progress of modern image analysis methods in the field of Chinese medicinal materials identification. Chin. Pharm. J. 2025, 60, 1479–1485. [Google Scholar]
- Wang, F.; Zheng, J.; Tian, X.; Wang, J.; Niu, L.; Feng, W. An automatic sorting system for fresh white button mushrooms based on image processing. Comput. Electron. Agric. 2018, 151, 416–425. [Google Scholar] [CrossRef] [Scilit]
- Wang, Q.; Yu, C.; Zhang, H.; Chen, Y.; Liu, C. Design and experiment of online cottonseed quality sorting device. Comput. Electron. Agric. 2023, 210, 107870. [Google Scholar] [CrossRef] [Scilit]
- Lu, J.; Chen, W.; Lan, Y.; Qiu, X.; Huang, J.; Luo, H. Design of citrus peel defect and fruit morphology detection method based on machine vision. Comput. Electron. Agric. 2024, 219, 108721. [Google Scholar] [CrossRef] [Scilit]
- Wonggasem, K.; Chakranon, P.; Wongchaisuwat, P. Automated quality inspection of baby corn using image processing and deep learning. Artif. Intell. Agric. 2024, 11, 61–69. [Google Scholar] [CrossRef] [Scilit]
- Wang, B.; Hua, J.; Xia, L.; Lu, F.; Sun, X.; Guo, Y.; Su, D. A defect detection method for akidzuki pears based on computer vision and deep learning. Postharvest Biol. Technol. 2024, 218, 113157. [Google Scholar] [CrossRef] [Scilit]
- Xiang, W.; Wu, D.; Wang, J. Enhancing stem localization in precision agriculture: A two-stage approach combining YOLOv5 with EffiStemNet. Comput. Electron. Agric. 2025, 231, 109914. [Google Scholar] [CrossRef] [Scilit]
- Moya, V.; Guerra, M.; Pazmiño, K.; Abedrabbo, F.; Chicaiza, F.A.; Pozo-Espín, D. Tomato classification with YOLOv8: Enhancing automated sorting and quality assessment. Smart Agric. Technol. 2025, 12, 101221. [Google Scholar] [CrossRef] [Scilit]
- Gu, M.; Shen, H.; Ling, J.; Yu, Z.; Luo, W.; Wu, F.; Gu, F.; Hu, Z. Online detection of broken and impurity rates in half-feed peanut combine harvesters based on improved YOLOv8-Seg. Comput. Electron. Agric. 2025, 237, 110494. [Google Scholar] [CrossRef] [Scilit]
- Xue, S.; Li, Z.; Wang, D.; Zhu, T.; Zhang, B.; Ni, C. YOLO-ALDS: An instance segmentation framework for tomato defect segmentation and grading based on active learning and improved YOLO11. Comput. Electron. Agric. 2025, 238, 110820. [Google Scholar] [CrossRef] [Scilit]
- He, J.; Ren, Y.; Li, W.; Fu, W. YOLOv11-RCDWD: A new efficient model for detecting maize leaf diseases based on the improved YOLOv11. Appl. Sci. 2025, 15, 4535. [Google Scholar] [CrossRef] [Scilit]
- Fang, K.; Zhou, R.; Deng, N.; Li, C.; Zhu, X. RLDD-YOLOv11n: Research on rice leaf disease detection based on YOLOv11. Agronomy 2025, 15, 1266. [Google Scholar] [CrossRef] [Scilit]
- Luo, Y.; Wu, A.; Fu, Q. MAS-YOLOv11: An improved underwater object detection algorithm based on YOLOv11. Sensors 2025, 25, 3433. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Xia, C.; Chen, Q.; Shi, Y.; Wang, X.; Zhang, X.; Wu, Y.; Wang, Y. Improved lightweight YOLOv5n-based network for bruise detection and length classification of asparagus. Comput. Electron. Agric. 2025, 233, 110194. [Google Scholar] [CrossRef] [Scilit]
- He, W.; Wu, F.; Snyder, L.U.; Cheng, J.; Wilcox, E.; Xiang, L. Improved two-stage deep learning algorithm and lightweight YOLOv5n for classifying cottonseed damage. Comput. Electron. Agric. 2025, 232, 110042. [Google Scholar]
- Yu, S.; Liu, Z.; Zhang, L.; Zhang, X.; Wang, J. FasterNet-YOLO for real-time detection of steel surface defects algorithm. PLoS ONE 2025, 20, e0323248. [Google Scholar] [PubMed]
- Zhao, F.; Zhang, J.; Liu, Q.; Liang, C.; Zhang, S.; Li, M. Fast quality detection of astragalus slices using FA-SD-YOLO. Agriculture 2024, 14, 2194. [Google Scholar] [CrossRef] [Scilit]
- Huang, M.J.; Cai, W.Q.; Zhang, Z.J.; Fang, Z.Z.; Guo, W.L.; Long, Y.B.; Lan, Y.B.; Wang, J.H. Real-time and accurate recognition algorithm for litchi fruit varieties based on improved YOLO11. Trans. Chin. Soc. Agric. Eng. 2025, 41, 156–164. [Google Scholar]
- Tang, Y.S.; Jiang, X.H.; Yu, X.F.; Gao, J.L.; Hu, J.; Zhang, Z.H.; Zhai, C.J. Detection method of maize leaf diseases based on WPM-YOLO11. Jiangsu J. Agric. Sci. 2026, 42, 264–272. [Google Scholar]
- China Association of Chinese Medicine. Standard for the Classification and Grading of Chinese Herbal Medicines Part 4: Astragalus, T/CACM 1021.4-2018; China Association of Chinese Medicine: Beijing, China, 2018. [Google Scholar]
- Ma, S.; Liu, Y.; Zhang, Y. Fabric defect detection based on improved lightweight YOLOv8n. Appl. Sci. 2024, 14, 8000. [Google Scholar] [CrossRef] [Scilit]
- Li, H.W.; Gao, J.T.; Chen, J.S.; Yao, Y.; Wei, J.; Jin, Z.Z.; He, D.Q. Research on mango recognition method based on improved YOLO13n model and edge computing. Trans. Chin. Soc. Agric. Mach. 2026, 57, 159–166. [Google Scholar]
- Hu, D.D.; Zhang, Z.T.; Niu, G.C. Lane line detection fusing CBAM attention mechanism and deformable convolution. J. Beijing Univ. Aeronaut. Astronaut. 2024, 50, 2150–2160. [Google Scholar]
- Liao, J.; He, X.; Liang, Y.; Wang, H.; Zeng, H.; Luo, X.; Li, X.; Zhang, L.; Xing, H.; Zang, Y. A Lightweight Cotton Verticillium Wilt Hazard Level Real-Time Assessment System Based on an Improved YOLOv10n Model. Agriculture 2024, 14, 1617. [Google Scholar] [CrossRef] [Scilit]
- Che, Y.; Bai, H.; Sun, L.; Fang, Y.; Guo, X.; Yin, S. Real-Time Detection of Varieties and Defects in Moving Corn Seeds Based on YOLO-SBWL. Agriculture 2025, 15, 685. [Google Scholar] [CrossRef] [Scilit]
- Gao, S.; Zhou, Z.Q.; Zhong, S.Y.; Huang, X.Z. Research on intelligent identification model of Chinese herbal pieces based on improved YOLOv3. World Sci. Technol. Mod. Tradit. Chin. Med. 2025, 27, 364–374. [Google Scholar]
- Zhang, L.J.; You, H.H.; Li, Z.Y.; Wei, Z.C.; Jia, H.J.; Yu, Y.; Li, D.M. Accurate identification of ginseng appearance quality based on improved lightweight YOLOv8n. Trans. Chin. Soc. Agric. Eng. 2024, 40, 178–187. [Google Scholar]
- Zhang, L.; You, H.; Wei, Z.; Li, Z.; Jia, H.; Yu, S.; Zhao, C.; Lv, Y.; Li, D. DGS-YOLOv8: A Method for Ginseng Appearance Quality Detection. Agriculture 2024, 14, 1353. [Google Scholar] [CrossRef] [Scilit]
- Han, B.; Lu, Z.; Dong, L.; Zhang, J. Lightweight Non-Destructive Detection of Diseased Apples Based on Structural Re-Parameterization Technique. Appl. Sci. 2024, 14, 1907. [Google Scholar] [CrossRef] [Scilit]
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.











