1. Introduction
The peach is a widely popular fruit, rich in vitamins, minerals, and dietary fiber. Research has confirmed its health-promoting effects, including improving digestion and enhancing the body’s antioxidant capacity [
1]. In China, peaches serve not only as a major fruit for consumption but also as a pillar industry underpinning the agricultural economy in many regions. According to statistics from the Ministry of Agriculture and Rural Affairs, China ranks among the global leaders in both peach cultivation area and yield. The peach industry constitutes a primary source of income for numerous farming households. Therefore, ensuring peach quality and optimal harvest timing is crucial for enhancing industrial efficiency.
Currently, in most orchards and sorting processes, the determination of peach ripeness still relies predominantly on manual methods. Sorting personnel make subjective judgments based on characteristics such as fruit color, size, firmness, and aroma. This approach is not only labor-intensive and inefficient but also prone to inconsistent evaluation standards due to individual differences [
2]. This is particularly problematic in large-scale plantations, where manual sorting struggles to rapidly and accurately grade large volumes of peaches. Consequently, fruits may be harvested outside their optimal ripeness window, leading to over-ripening, spoilage, or premature picking, which in turn causes economic losses and resource wastage. Consequently, traditional ripeness identification methods have become one of the bottlenecks constraining the enhancement of quality, efficiency, and sustainable development in the peach industry.
In recent years, with the rapid advancement of artificial intelligence and computer vision technologies, deep learning-based detection methods have provided new solutions for fruit recognition and grading in agriculture. Traditional methods rely on manually designed features, which exhibit poor adaptability to complex environments (e.g., lighting variations, occlusion) and demand extensive expertise. In contrast, deep learning can automatically extract high-level features from images, thereby significantly improving recognition robustness and efficiency [
3]. Related technologies [
4] have demonstrated broad application potential in quality detection for various fruits and vegetables and have laid a technical foundation for achieving intelligent, non-destructive detection of peach ripeness.
In the field of peach ripeness detection, several scholars have conducted research related to deep learning. Among them, Zeng et al. proposed an improved YOLOv5s-based model named YOLO-Faster, which incorporates the lightweight FasterNet backbone and the CBAM attention mechanism to achieve rapid detection of peach ripeness in natural environments, significantly improving detection speed while maintaining high accuracy. Zhao et al. achieved peach ripeness classification using a novel single-stage instance segmentation model, demonstrating good segmentation and recognition performance in complex scenes [
5]. Li et al. proposed the PeachYOLO lightweight algorithm, optimizing the accuracy and real-time performance of peach detection in complex orchard environments [
6]. Other studies have achieved efficient recognition of winter peach fruits by improving the ResNet network and multi-scale feature fusion techniques [
7], as well as peach ripeness grading methods based on an improved MobileNet V3 network, further promoting the application of lightweight technologies in this field [
8]. Furthermore, improved versions of the YOLO series algorithms have been applied to peach detection tasks. For instance, the YOLOv7-Peach algorithm was specifically optimized for detecting immature small yellow peaches in complex natural environments, enhancing small target recognition capability [
9].
Simultaneously, lightweight deep learning technologies have accumulated substantial research results in ripeness detection for other fruits and vegetables, providing important references for research in the peach domain. For example, for fruits such as citrus and apples, researchers have improved models in the YOLOv4, YOLOv7, and YOLOv11 series by incorporating lightweight techniques such as depthwise separable convolutions, channel pruning, and Ghost convolutions, achieving a 50–80% reduction in model parameters while maintaining high detection accuracy [
10,
11,
12]. In the detection of crops such as tomato, citrus, and kiwifruit, researchers have developed mobile-adapted models, enabling real-time ripeness grading based on smartphones or embedded devices [
13,
14,
15]. For fruits and vegetables like fragrant pears, grapes, and strawberries, the application of lightweight YOLO models has also validated the technical feasibility of balancing real-time performance and accuracy in complex agricultural environments [
16,
17,
18].
Despite significant progress in fruit and vegetable ripeness detection using deep learning, lightweight intelligent grading of peach ripeness still faces numerous challenges. First, the wide variety of peach cultivars (e.g., winter peach, small yellow peach) leads to substantial differences in their color and morphology. Additionally, the color transition during ripening is complex; for instance, the ripening color mechanisms differ significantly between red-fleshed and yellow-fleshed varieties [
5]. These variations challenge the feature extraction capabilities of existing lightweight models, limiting their adaptability to such diversity [
19]. Second, issues such as lighting variations, occlusion by leaves and branches, and fruit overlap in natural orchard environments impose higher demands on the robustness of lightweight models. Existing studies often focus on detection in single environments or for specific cultivars, leaving room for improvement in generalization capability [
20,
21]. Third, existing lightweight models commonly face the trade-off between “accuracy and complexity.” While complex models can ensure high detection accuracy, their substantial parameter counts and computational costs hinder deployment on mobile or embedded devices in orchards. Conversely, overly simplified lightweight models often suffer from insufficient feature extraction, which compromises ripeness grading accuracy [
22,
23]. Additionally, lthough efficient architectures like ConvNeXt have shown promising results and lightweight potential in generic fruit ripeness identification [
24], their application in the specific context of peach ripeness detection remains underexplored.
To address the aforementioned issues, this paper proposes an improved lightweight ConvNeXt architecture, LightConvNeXt-FCS, based on lightweight modeling principles. To achieve an optimal balance between model complexity and detection accuracy, we introduce a lightweight core module (LightBlock) that significantly reduces parameters and computational cost. This design is further enhanced by incorporating attention mechanisms, cross-stage connections, and multi-scale fusion via auxiliary structures, which collectively preserve the model’s representational capacity. Experimental results show that the improved model requires only 2.75 M parameters and 624.23 M FLOPs, representing a 90.1% reduction in parameters and an 86.0% decrease in computational cost compared to ConvNeXt-Tiny, with the model size compressed to 9.9% of the original. In the three-class peach ripeness classification task, the model demonstrates improved classification performance, achieving an accuracy of 94.62%, slightly outperforming the original model. By substantially reducing resource consumption, this model effectively resolves the typical dilemma of traditional models—high accuracy requiring high complexity, or lightweight design sacrificing accuracy. This study presents a lightweight deployment solution for the rapid and intelligent grading of peach ripeness. This approach offers a practical means to promote cost-effective and intelligent quality detection of agricultural products, thereby enhancing overall industry quality and efficiency.
2. Materials and Methods
2.1. Main Dataset: NinePeach
The public dataset utilized in this study is named NinePeach, which is designed to replicate real-field environments and is specifically intended for peach instance segmentation and ripeness classification tasks. This dataset encompasses various critical factors that affect the accuracy of peach detection, including complex scenarios such as variations in natural illumination, adhesion of multiple fruits, and occlusion by stems and leaves. As of June 2022, NinePeach is, to our knowledge, the largest and most diverse publicly available peach dataset. It provides essential support for research in this field.
Data collection was conducted from May to June 2022 in the experimental orchard of Huazhong Agricultural University in Wuhan, China, covering nine peach varieties, including Dahongpao, Qingfeng, Chunmei, Chunmi, Chunxue, Songsen, Maotao, Youtaopan, and Xiahui. The images were captured using a smartphone (specifications in
Table 1). The device operated on Android 11, featured an octa-core CPU, and was equipped with a main camera sensor (Sony IMX598, 1/2 inch; manufacturer: Sony Group Corporation, Tokyo, Japan) with a focal length of 4.7 mm. Original images were stored in JPEG format with a resolution of 4000 × 3000 pixels. During acquisition, the distance between the camera and the peaches was maintained within 30–50 cm. Images were taken from multiple angles under natural illumination in authentic orchard conditions, which preserves the realism of the dataset. The collected peach samples exhibited diverse morphologies, including isolated peaches, closely adjacent peaches, peaches partially occluded by leaves or stems, and peaches under backlighting, comprehensively reflecting actual field situations. Sample images from the dataset are displayed in
Figure 1.
The dataset categorizes peaches into three ripeness stages: unripe, semi-ripe, and ripe. For the ripeness classification task, each peach was cropped using its annotation boundaries. Any fruit whose bounding box had a side shorter than 224 pixels was discarded to maintain adequate resolution after cropping and resizing. Finally, all image sizes were uniformly resized to 224 × 224 pixels. The dataset was partitioned into training, validation, and test sets in a ratio of 7:1.5:1.5 to ensure the rationality of model evaluation.
To address the issue of intra- and inter-variety sample imbalance within the dataset, we defined categories with fewer than 400 original training samples for a specific variety-ripeness combination as small-sample categories, and the others as large-sample categories. Different data augmentation strategies were applied to each category. For small-sample categories, the augmentation strategy included geometric transformations (such as random scaling between 90 and 110% inbetween 90–110% in the x and y directions, random translation within ±10%, random rotation of ±15 degrees, random shearing of ±5 degrees, and horizontal flipping with a 50% probability), the addition of Gaussian noise with a 30% probability, and random brightness adjustment and contrast variation between 80 and 120%. Forbetween 80–120%. For large-sample categories, a more conservative augmentation approach was adopted, including geometric transformations (such as random scaling between 95 and 105% inbetween 95–105% in the x and y directions, random translation within ±5%, random rotation of ±10 degrees, random shearing of ±3 degrees, and horizontal flipping with a 30% probability), and random brightness adjustment and contrast variation between 90 and 110%. Thesebetween 90–110%. These augmentations improved data diversity and model generalization. The specific numbers of images before and after data augmentation are detailed in
Table 1.
2.2. Generalization Validation Dataset: Peach Ripeness Dataset
To validate the generalization capability of the proposed LightConvNeXt-FCS model, this study additionally introduces a publicly available peach ripeness classification dataset, the Peach ripeness Dataset. This dataset specifically focuses on hairy peaches and was constructed in a real orchard environment. Images of hairy peaches at different growth stages were captured using a smartphone, with an original resolution of 3024 × 4032 pixels. The dataset includes three ripeness stages: hard-mature, semi-ripe, and ripe. It covers variations in shooting distance, lighting conditions, and fruit growth states. It comprises a total of 1245 images. In this study, all images were uniformly cropped and resized to 224 × 224 pixels, and categorized into three maturity classes: immature, semi-ripe, and mature. The dataset was split into training, validation, and test sets in an approximate ratio of 7:1.5:1.5. Data augmentation strategies similar to those used for the NinePeach dataset were employed to maintain consistency. This dataset is used solely for model generalization validation and does not participate in the structural design, parameter tuning, or training process of LightConvNeXt-FCS. Sample images from the dataset are shown in
Figure 2, and the data statistics before and after augmentation are presented in
Table 2.
2.3. ConvNeXt-Tiny
In recent years, Swin Transformer has demonstrated superior performance to traditional Convolutional Neural Networks (CNNs) in image classification tasks, owing to its strong feature modeling capability. This advancement has established a new paradigm for visual architecture design [
25]. As an important extension of this paradigm, ConvNeXt (Liu et al., 2022) [
24] is a pure CNN architecture that innovatively incorporates design principles from Swin Transformer. By introducing core components such as depthwise convolutions and inverted bottleneck design, ConvNeXt significantly enhances feature representation while maintaining the inherent simplicity and computational efficiency of CNNs, and effectively controls parameter scale [
26]. Research shows that ConvNeXt has achieved performance and scalability comparable to Transformer architectures, and even outperforms Swin Transformer in complex vision tasks such as ADE20K semantic segmentation and COCO object detection [
27].
These studies not only validate the continuing value of CNN architectures in modern vision tasks but also demonstrate the effectiveness of the “CNN optimization path integrating Transformer design principles” in improving task performance while considering deployment efficiency. Peach ripeness classification is a key task in agricultural product quality inspection, demanding high feature discrimination capability to distinguish subtle visual changes due to ripeness differences, as well as high computational efficiency to support deployment in real production scenarios. Given ConvNeXt’s outstanding performance in complex vision tasks, its compact parameter size, and efficient inference characteristics, this paper selects ConvNeXt as the baseline network to investigate effective techniques for peach ripeness classification.
2.4. LightConvNeXt-FCS
To address the core contradiction of “difficulty in balancing accuracy and lightweight design” in the traditional ConvNeXt-Tiny model for peach ripeness classification, this paper proposes the LightConvNeXt-FCS lightweight architecture. The design revolves around a coherent pipeline where a re-engineered lightweight core, attention-augmented feature refinement, hierarchical feature propagation, and multi-scale representation integration interact synergistically. The overall architecture is illustrated in
Figure 3.
LightConvNeXt-FCS follows an end-to-end pipeline of “feature encoding—enhancement—fusion—classification.” Its structural design is explicitly tailored to meet the core demands of peach ripeness classification. The Stem layer converts the input RGB image (default size 224 × 224) into a low-resolution high-dimensional feature map through a 4 × 4 stride convolution, increasing the number of channels from 3 to 64, thereby completing preliminary feature encoding and laying the foundation for subsequent feature extraction. The four-stage feature extraction modules (Stage 1–4) sequentially expand the receptive field through 2 × 2 downsampling, with channel numbers configured as 64, 128, 256, and 384, respectively. Each stage is composed of stacked improved LightBlocks, and after the stage output, an SGE attention module is incorporated to integrate feature extraction and enhancement, ensuring hierarchical progression of features while filtering key information through the attention mechanism. Cross-stage skip connection modules are introduced in Stages 2–4 to organically integrate fine-grained features from preceding stages with semantic features from the current stage, effectively mitigating inter-level information loss and promoting complementarity among features at different levels. The multi-scale feature fusion module (Feature-Fusion) performs scale unification and attention-weighted fusion on the normalized features from the four stages, integrating semantic information and detail features from different levels to enhance the completeness and discriminative power of the features. Finally, the fused features are transformed into a one-dimensional vector via global average pooling (GAP) and fed into a fully connected layer to accomplish the three-class classification of peach ripeness (unripe, semi-ripe, ripe). Compared with the original ConvNeXt-Tiny, LightConvNeXt-FCS achieves lightweight design by “reducing the number of channels, decreasing the stack count of Blocks, and simplifying internal computational structures” while maintaining the integrity of the feature extraction hierarchy. Simultaneously, it compensates for the feature representation loss caused by lightweight design through attention mechanisms and feature fusion strategies, forming a closed-loop feature processing flow characterized by “efficient extraction—precise selection—full fusion”.
2.4.1. LightBlock
For the fine-grained task of peach ripeness classification, the original ConvNeXt Block exhibits limitations in cross-channel feature interaction and attention modeling. Its depthwise convolution hinders inter-channel fusion, while its simplistic attention mechanism fails to adequately capture localized color and texture variations critical to ripeness assessment. Additionally, the fixed MLP expansion ratio reduces parameter efficiency, complicating mobile deployment. To address these issues, this study introduces LightBlock, an optimized lightweight module that integrates: a channel shuffle mechanism [
28] to enhance cross-channel information exchange; a lightweight hybrid attention design inspired by CBAM [
29] and SGE [
30] to strengthen spatial and channel-wise feature refinement; and a grouped convolution-based structure [
31] to improve computational efficiency. These modifications maintain the architectural rationality of ConvNeXt [
24] while adapting it to fine-grained classification demands.
The input features first undergo dynamic grouped depthwise convolution processing. This design incorporates dual optimizations: firstly, dynamically selecting the convolution kernel size based on network depth—small 3 × 3 kernels for shallow layers to precisely capture texture details on the peach surface, medium 5 × 5 kernels for middle layers to balance local features and contextual information, and large 7 × 7 kernels for deep layers to cover the overall color distribution and morphological characteristics of the peach [
32]; secondly, introducing a grouped convolution strategy, where input channels are divided into several groups according to a grouping ratio coefficient. This reduces redundant computations between channels through grouped depthwise convolution while ensuring independent feature learning within each group, further improving computational efficiency [
33]. To ensure channel dimension consistency, an adaptive channel adjustment mechanism is designed, using 1 × 1 convolution or identity mapping to correct potential channel mismatches caused by grouped convolution.
Subsequently, a channel shuffle operation is introduced. The number of groups is adaptively determined based on the input channel count (dynamically set as the ceiling of the input channel number divided by 8, and no less than 1). Through the operation flow of “dimension reshaping → channel transposition → dimension restoration,” the independence limitation imposed by channel grouping is broken, promoting cross-fusion of features such as peach color and texture across different groups, thereby enhancing inter-channel information interaction [
34].
After the normalization layer, the MLP part adopts a hierarchical expansion ratio strategy: using 1.2 as the base expansion ratio. Shallow networks apply a dynamic adjustment coefficient of 0.7 times (actual expansion ratio 0.84), focusing on extracting basic color and texture features; middle layers maintain a coefficient of 1.0 times (actual expansion ratio 1.2), balancing feature representation capability and computational efficiency; deep layers employ a coefficient of 1.1 times (actual expansion ratio 1.32), enhancing the learning capacity for complex ripeness patterns (such as multi-region color transitions and mixed textures) [
35]. The MLP structure supports two implementation methods: linear layers or 1 × 1 convolutions. Both complete channel dimension transformation through the process of “feature compression → activation mapping → feature restoration.” The intermediate channel number is adaptively determined by the dynamically adjusted expansion ratio, ensuring optimal feature transformation under limited computational resources.
A lightweight CBAM attention module [
29] is specifically introduced to strengthen feature extraction capability. This module contains dual branches for channel attention and spatial attention working collaboratively: The channel attention branch aggregates spatial dimension information through global average pooling, combined with two-level 1 × 1 convolutions to achieve compression and restoration in the channel dimension, generating a channel weight vector. This enables the model to adaptively focus on color channels strongly related to peach ripeness (e.g., feature channels corresponding to yellow and red). The spatial attention branch concatenates the results of average pooling and max pooling along the channel dimension to capture extreme value information in the spatial dimension, then extracts a spatial weight map through a 3 × 3 convolution, precisely locating key ripeness-indicating regions on the peach surface (such as color transition zones, texture variation areas, and spot distribution areas). The element-wise multiplication of the dual-branch attention weights with the original features achieves dual feature enhancement in both channel and spatial dimensions, effectively improving the discriminative ability for fine-grained features.
Finally, the features are adaptively scaled by learnable layer scaling parameters, combined with DropPath stochastic depth technology to prevent model overfitting. The processed features are then connected with the original input via a residual connection, ensuring the integrity of feature propagation and the smoothness of gradient flow [
36].
In terms of computational efficiency, LightConvNeXtBlock achieves a significant reduction in computational complexity through the synergistic optimization of dynamic grouped depthwise convolution, hierarchical MLP strategy, lightweight attention mechanism, and channel shuffle technology. Specifically: The FLOPs of dynamic grouped depthwise convolution are N × H × W × C × K2 (where N is batch size, H and W are feature map dimensions, C is input channel count, g is number of groups, K is kernel size). Although the grouping strategy does not change the theoretical order of FLOPs, it improves actual computation speed through hardware cache optimization. The channel shuffle operation only involves tensor dimension transformations, and its computational overhead is negligible. The FLOPs of the MLP part are 2 × N × H × W × C × M (where M is the dynamically adjusted intermediate channel count). The hierarchical expansion ratio strategy ensures M maintains optimal values at different network depths. The FLOPs of the lightweight CBAM attention module are 2 × N × + 3 × N × H × W (where r is the channel compression ratio).
Ultimately, the designed Light lightweight model reduces the parameter count dramatically from 27.82 M of ConvNeXt-Tiny to 2.48 M (a reduction of 91.09%). FLOPs are optimized from 4454.77 M (4.45 G) to 399.37 M (0.40 G) (a reduction of 91.04%). The model storage size is also compressed from 106.13 MB to 9.46 MB (a reduction of 91.08%). Under the premise of achieving extreme compression exceeding 91% in parameters, computational load, and storage overhead, the model still maintains excellent classification performance: classification accuracy reaches 89.45%, Precision is 87.80%, Recall is 88.63%, and the F1-score is 88.11%. Experimental results indicate that this model achieves a good balance between extreme lightweight design and classification performance, making it more suitable for practical application scenarios with strictly limited resources, such as on-site orchard collection and mobile terminal deployment. Its overall architecture is shown in
Figure 4.
2.4.2. SGE
In traditional Convolutional Neural Networks (CNNs), all regions of the input image are treated equally during feature extraction, which may lead to insufficient focus on critical features. For fine-grained peach ripeness grading, where subtle local differences in texture and color are key, SGE’s spatial focus on “where” is more suitable than channel-only attention (e.g., SE), which focuses on “what.” This allows the model to pinpoint the most informative local patches, essential for distinguishing closely related maturity stages.
The SGE [
30] module divides the feature map into groups along the channel dimension and independently learns spatial weights within each group. It captures global contextual information for each group through global average pooling—a simple and efficient operation that provides a stable statistical prior. Then, a lightweight sub-network establishes intra-group spatial importance weights. This group-wise structure preserves channel independence, allowing diversified feature representations.
In LightConvNeXt-FCS, the SGE module is applied after downsampling at each stage, before the LightBlock stack. This creates synergy with the feature fusion mechanism. Applying SGE before multi-stage fusion ensures that features flowing into subsequent cross-stage connectors and the final Feature-Fusion module are already spatially refined. This order is optimal because it prioritizes enhancing discriminative power at the native resolution first, allowing fusion to integrate purified information rather than raw features. The pipeline—extraction, spatial refinement, then fusion—forms an effective flow.
Compared with conventional attention mechanisms, SGE employs a group-wise modeling strategy which substantially reduces parameter count while preserving representational capacity. The design rationale is threefold. First, the group configuration achieves an effective balance between modeling flexibility and parameter efficiency. Second, the use of global average pooling is justified by its operational simplicity and proven effectiveness in aggregating spatial context. Finally, the deliberately lightweight construction of the sub-network ensures minimal computational overhead, which is critical for practical deployment on resource-constrained devices. By integrating the SGE module, the model attains enhanced feature discrimination without incurring significant computational cost, thereby facilitating its application in real-world scenarios. The structure of the SGE module is depicted in
Figure 5.
2.4.3. Cross-Stage Skip Connection Mechanism
To mitigate the progressive loss of fine-grained details through the network’s stages, we introduce a cross-stage skip connection mechanism. Inspired by DenseNet [
37] and the Feature Pyramid Network (FPN) [
38], we introduce a cross-stage skip connection mechanism named Cross-Stage. DenseNet achieves feature reuse through dense connections, effectively alleviating the vanishing gradient problem, while FPN constructs a multi-scale feature pyramid through top-down and lateral connections, significantly enhancing object detection performance. Drawing on these ideas, we design a cross-stage feature transmission mechanism based on the ConvNeXt architecture, whose core lies in establishing direct connections between shallow and deep features.
Specifically, for the i-th stage (i ≥ 1), we collect the feature outputs from all preceding stages 0 to i − 1 and fuse them via a cross-stage connector. The mathematical expression of this connector is as follows:
Let the feature set of the first i stages be {F
0, F
1, …, F
i−1}, and the target output channel number be C. The operation of the connector can be expressed as:
where ϕⱼ(·) denotes the transformation function for the j-th feature, consisting of two steps: bilinear interpolation upsampling and a 1 × 1 convolution, ensuring all feature maps attain a unified spatial size and channel dimension. Concat[·] represents the concatenation operation along the channel dimension.
The advantages of this design are reflected in three aspects: first, by preserving shallow detailed features, the model’s perception of subtle textural changes on the peach surface is enhanced; second, the fusion of multi-scale features provides a richer representation space, facilitating the capture of ripeness characteristics from local to global; third, the cross-layer connections improve gradient flow, making network training more stable. Experimental results show that this mechanism significantly improves the model’s accuracy in the peach ripeness classification task with a negligible increase in computational complexity.
The network structure diagram is shown in
Figure 6.
2.4.4. Multi-Scale Feature Fusion Mechanism (Feature-Fusion)
ConvNeXt’s hierarchical progressive structure suffers from insufficient cross-stage feature interaction. This limitation leads to the dilution of spatial details from shallow layers and a loss of semantic information in deep layers during classification. To address this issue, we introduce a novel feature fusion mechanism. Inspired by the effectiveness of the Feature Pyramid Network (FPN) [
38] in multi-scale feature fusion for object detection, we design a Feature Fusion Module. This module integrates the multi-scale features refined by the preceding SGE modules and cross-stage connections. It thereby enhances the model’s capacity to jointly leverage detailed spatial information and high-level semantics, which improves discriminative feature capture and boosts overall performance.
The core design of the feature fusion module consists of three key steps: channel unification, adaptive weighting, and feature refinement. First, for the set of feature maps from different stages {F
1, F
2, …, Fₙ}, the channel dimensions are unified via 1 × 1 convolutional layers, mapping them into the same feature space. This process can be formally expressed as:
where Fᵢ′ denotes the adjusted feature map of the i-th stage. Subsequently, all adjusted feature maps are upsampled to the spatial size of the shallowest feature map to maintain spatial alignment.
During the feature weighting stage, the module employs an attention mechanism to adaptively learn the contribution weights of each feature map. Specifically, the concatenated feature maps are compressed in the spatial dimension through global average pooling, followed by a 1 × 1 convolution and a Softmax activation function to generate a normalized weight vector:
where W = [w
1, w
2, …, wₙ] represents the attention weights for each feature map. The final fused feature is obtained through weighted summation:
To optimize the expressive power of the fused features, the module further employs depthwise separable convolution for post-processing, consisting of a 3 × 3 depthwise convolution and a 1 × 1 pointwise convolution, supplemented by layer normalization operations:
This design ensures sufficient fusion of multi-scale features while controlling computational complexity through lightweight operations. Experimental results demonstrate that the feature fusion module effectively enhances the model’s ability to integrate cross-level features, significantly improving classification accuracy, particularly excelling in visual tasks requiring fine-grained discrimination. Its network structure diagram is shown in
Figure 7.
2.5. Experimental Environment
The configuration environment for peach ripeness classification includes: CPU: AMD EPYC 9754 128-Core Processor (18 vCPU), GPU: Nvidia RTX 4090D (24 GB), operating system: Ubuntu 20.04, memory: 60 GB, system disk: 30 GB, and data disk: 50 GB. The model was trained using PyTorch 1.11.0, which is based on Python 3.8, with CUDA 11.3 to support GPU acceleration. The input image size was set to 224 × 224, a common and reasonable setting for convolutional neural network training in image classification tasks. Considering the sufficient GPU memory, the training batch size was set to 32, ensuring both training efficiency and avoidance of memory overflow. To ensure the model fully learns the data features and reaches a stable state, the total number of training epochs was set to 200, along with an early stopping mechanism (patience value: 20, minimum improvement: 0.01) to prevent overfitting and terminate ineffective training in a timely manner. The optimizer selected was AdamW, with an initial learning rate set to 1 × 10−4, combined with a weight decay of 0.1 to suppress overfitting. Its betas parameters were set to (0.9, 0.999). The learning rate scheduler employed CosineAnnealingLrUpdater, along with a warm-up mechanism (warm-up ratio: 0.1, warm-up iterations: 10, warm-up by epoch) to achieve more stable convergence. The loss function selected was CrossEntropyLoss, suitable for measuring the discrepancy between predicted probabilities and true labels in the three-class peach ripeness classification task (ripe, semi-ripe, unripe). During training, automatic mixed precision training (AMP) and gradient accumulation (accumulation steps: 2) were enabled, with a gradient clipping threshold of 0.5 to stabilize the training process. Label smoothing (0.1) was also applied to further enhance model generalization capability. Evaluation metrics included accuracy, precision, recall, and f1_score, comprehensively assessing the classification performance of the model.
2.6. Evaluation Indicators
This study employs several metrics (accuracy, precision, recall, and F1-score) to accurately and effectively evaluate the performance demonstrated by the proposed model. These metrics provide a comprehensive assessment of the LightConvNeXt-FCS model’s performance. The formulas for these metrics are as follows:
In this context, the number of correctly identified positive samples is referred to as TP (True Positive), and the number of correctly identified negative samples is referred to as TN (True Negative). False Positive (FP) denotes cases where negative samples are incorrectly identified as positive, while False Negative (FN) refers to cases where positive samples fail to be identified and are classified as negative. These metrics form the basis for calculating all other evaluation indicators in our assessment.
3. Experiments and Results Analysis
3.1. Parameter Optimization Experiment of LightBlock
To further optimize the balance between performance and efficiency of the lightweight convolution block (LightBlock), this study systematically conducted ablation experiments on two key parameters: the group convolution ratio and the MLP expansion ratio. Regarding the design of parameter values, the group convolution ratio was set to three gradients: 2, 4, and 6, corresponding to moderate, high, and extremely high degrees of grouping, respectively. This setup effectively evaluates the impact of different parameter-sharing intensities on model performance. The MLP expansion ratio was set to three levels: 0.8, 1.2, and 1.4, covering configurations from compression to moderate expansion, aiming to explore the optimal balance point between feature transformation capability and computational complexity. The experimental results are presented in
Table 3.
From the overall trend of the experimental results, different parameter combinations exhibit a clear trade-off relationship between model complexity and performance. In terms of the group convolution ratio, configurations with a ratio of 2 generally achieve a better balance between efficiency and accuracy. Among these, the gr2_mlp1.2 configuration attains the highest accuracy of 94.62%, with only 2.75 M parameters, 624.23 M FLOPs, and a model size of 10.50 MB. This represents an excellent performance-efficiency profile, outperforming other combinations under similar parametric constraints.
Regarding the impact of the MLP expansion ratio, the results indicate that an expansion ratio of 1.2 yields the best performance across nearly all grouping settings. For instance, with a group convolution ratio of 2, increasing the MLP expansion ratio from 0.8 to 1.2 improves accuracy by 2.29 percentage points, while the parameter count only rises from 2.23 M to 2.75 M, and FLOPs increase from 531.63 M to 624.23 M. Further raising the expansion ratio to 1.4 leads to a slight drop in accuracy to 94.18%, while parameters and FLOPs grow to 3.02 M and 671.17 M, respectively. This suggests that an MLP expansion ratio of 1.2 lies within an optimal range that enhances representational capacity without incurring excessive computational overhead.
Compared to configurations with higher group convolution ratios, gr2_mlp1.2 demonstrates clear advantages. For example, gr4_mlp1.2 achieves 93.56% accuracy with 2.94 M parameters and 664.85 M FLOPs, while gr6_mlp1.2 attains 93.74% accuracy but with higher complexity (3.25 M parameters, 742.40 M FLOPs). Thus, the gr2_mlp1.2 configuration not only reaches the highest accuracy but also maintains lower computational costs and a compact model size.
In summary, the experimental results confirm that the optimal parameter configuration for LightBlock is a group convolution ratio of 2 combined with an MLP expansion ratio of 1.2. This setup achieves the best balance among model size (10.50 MB), computational cost (624.23 M FLOPs), parameter count (2.75 M), and classification performance (94.62% accuracy). These findings provide a valuable reference for parameter selection in lightweight network design and validate that moderate—rather than extreme—parameter compression can yield superior overall efficiency and effectiveness.
3.2. Attention Mechanism Comparison Experiment
To systematically evaluate the effectiveness of different attention modules in the peach ripeness grading task, a comparative experiment on five mainstream attention mechanisms was conducted under the unified LightConvNeXt-FCS framework. These mechanisms include the mixed channel and spatial attention CBAM [
29], the efficient channel attention ECA [
39], the normalization-based attention NAM [
40], the parameter-free attention SimAM [
41], and the spatial group enhancement attention SGE [
30]. All experiments were performed using the same training dataset and hyperparameter settings to ensure fair and comparable results, as shown in
Table 4.
As shown in
Table 4, in terms of lightweight performance, ECA and SimAM achieved the optimal indicators (Params: ~2.74 M, Size: 10.45 MB, FLOPs: 624.23 M and 623.85 M, respectively), while SGE was slightly higher (Params: 2.75 M, FLOPs: 624.23 M, Size: 10.50 MB) and maintained excellent lightweight characteristics. NAM performed the worst in lightweight (Params: 2.80 M, FLOPs: 636.77 M). In terms of classification performance, SGE achieved the highest accuracy of 94.62%, with Precision, Recall and F1-Score all around 94.6% (94.60%, 94.59%, 94.59%, respectively), significantly outperforming other mechanisms. ECA followed with an accuracy of 94.18%, while SimAM and NAM had relatively low accuracy (93.21% and 93.03%, respectively) despite their lightweight advantages or disadvantages.
The confusion matrix of the five attention mechanisms is shown in
Figure 8 (Attention Mechanism Comparison for Peach ripeness Grading), which reflects the detailed classification performance of each model on three ripeness levels (ripe, semi-ripe, unripe). It can be seen that SGE achieved the best classification results in all categories: 327 correct predictions for ripe peaches, 415 for semi-ripe, and 325 for unripe, with the least misclassifications. ECA and CBAM had slightly more misclassifications in semi-ripe and unripe categories, while NAM and SimAM showed more obvious misclassifications in semi-ripe peaches.
Comprehensively considering lightweight performance and classification accuracy, SGE is the optimal attention module for this task. It enhances feature representation without increasing complexity significantly, and is highly compatible with the lightweight design of LightBlock. Thus, SGE was adopted as the core attention module between stages in subsequent model construction.
3.3. Ablation Study
To systematically validate the effectiveness of each module within the proposed LightConvNeXt-FCS architecture, we conducted rigorous ablation experiments on the three-class peach ripeness dataset. Using the original ConvNeXt-Tiny model as the baseline, we sequentially introduced the lightweight core module (LightBlock), the Spatial Group Enhancement attention (SGE), the Cross-Stage skip connections, and the multi-scale feature fusion mechanism (Feature-Fusion). The contributions of each module were quantitatively evaluated from the dimensions of parameter count, computational complexity, and classification accuracy. The results of the ablation study are presented in
Table 5.
The experimental results show that the original ConvNeXt-Tiny model achieves an accuracy of 94.00%, with 27.82 M parameters, 4.45 G FLOPs, and a model size of 106.13 MB, making it computationally heavy for lightweight deployment. Introducing only the LightBlock module drastically reduces the parameters to 2.48 M (a reduction of 91.1%), FLOPs to 0.40 G (a reduction of 91.0%), and model size to 9.46 MB. However, accuracy drops to 89.45%, indicating that aggressive lightweighting compromises representational capacity.
The auxiliary modules effectively recover accuracy while preserving lightweight characteristics. Adding the feature fusion mechanism (Light_fusion) increases parameters to 2.68 M and FLOPs to 0.59 G, while improving accuracy to 90.83% (+1.38 percentage points), demonstrating its ability to restore lost information with minimal overhead. The cross-stage skip connection (Light_CS) raises accuracy to 90.65% (+1.20 points) with only a slight increase in parameters (2.54 M) and FLOPs (0.43 G), showing high parameter efficiency. The SGE attention module (Light_SGE) achieves 91.98% accuracy (+2.53 points) with nearly no increase in parameters (2.49 M) or FLOPs (0.40 G), confirming its efficient feature selection capability.
Analysis of module combinations reveals meaningful design trade-offs. The Light_SGE configuration maintains low computation (0.40 G FLOPs) while reaching 91.98% accuracy, suitable for computation-sensitive scenarios. The three-module combination Light_fusion_SGE achieves 94.18% accuracy at 0.59 G FLOPs, even surpassing the baseline accuracy by 0.18 points, striking an excellent complexity–accuracy balance. The full LightConvNeXt-FCS model integrates all four modules, resulting in 2.75 M parameters and 0.62 G FLOPs—only 9.9% and 14.0% of the baseline, respectively—while attaining the highest accuracy of 94.62% and an F1-score of 94.59%, outperforming the original model across all key metrics.
The ablation study confirms that the four proposed modules, through careful combination, achieve synergistic optimization in parameter efficiency, computational cost, and classification performance. LightBlock provides the lightweight foundation; SGA enhances feature selection efficiently; cross-stage connections improve information flow; and feature fusion integrates multi-scale semantics. Their integration successfully resolves the typical lightweight dilemma where high accuracy often requires high complexity, whereas extreme lightweighting sacrifices accuracy.
3.4. Comparative Experiments
To rigorously validate the effectiveness of the proposed LightConvNeXt-FCS model and address potential concerns regarding randomness, we conducted extensive comparative experiments on the three-category peach ripeness classification task. Each compared model, including Swin Transformer Tiny [
25], DeiT Tiny [
42], EdgeNeXt Small [
27], EfficientNetV2 B0 [
43], MobileNetV2 [
26], MobileNetV3 Small [
44], ShuffleNet V2 [
28], and ConvNeXt Tiny [
24], was independently trained three times under identical dataset and training settings. The performance metrics reported are the mean and standard deviation calculated from these three independent runs. Evaluation metrics included the number of parameters (Params), floating-point operations (FLOPs), model size (Size), accuracy (Acc), precision (Prec), recall (Rec), and F1 score (F1). The detailed results (covering parameter count, computational cost, and multi-dimensional evaluation metrics) are presented in
Table 6, while the intuitive correlation between model parameter quantities and accuracy performance is visualized in
Figure 9 (Comparison of different model parameters and accuracy results). Furthermore, the training stability of all models is visualized in
Figure 10 (Curves of accuracy values of the validation set) and
Figure 11 (Curves of loss values of the validation set), which demonstrate the convergence behavior of each model across multiple runs.
Figure 9 intuitively presents the parameter count (denoted by blue bars) and accuracy (denoted by the red line) of each comparative model: most models exhibit an unfavorable trade-off—for instance, Model a (Swin Transformer Tiny) and Model h (ConvNeXt Tiny) deliver relatively high accuracy, yet this performance is accompanied by a substantial parameter count (surpassing 27 M). In contrast, some lightweight models (e.g., Model g (ShuffleNet V2)) have a small parameter footprint but only yield relatively low accuracy. By comparison, our proposed LightConvNeXt-FCS (corresponding to Model i) maintains a lightweight parameter count of merely 2.75 M, while its accuracy ranks among the top tier across all models. This visualization directly underscores the notable lightweight advantage and performance superiority of LightConvNeXt-FCS.
As shown in
Table 6, the proposed LightConvNeXt-FCS model achieves a mean accuracy of 94.62%, a mean precision of 94.60%, a mean recall of 94.59%, and a mean F1-score of 94.59% with only 2.75 M parameters and 0.62 G FLOPs. This performance surpasses all compared models with similar or larger parameter counts. Compared to the original ConvNeXt-Tiny [
24], LightConvNeXt-FCS reduces the number of parameters by 90.1% (from 27.82 M to 2.75 M) and the computational cost by 86.0% (from 4.45 G FLOPs to 0.62 G FLOPs), while the model size is compressed to 10.50 MB (approximately 9.9% of the original). Moreover, the mean classification accuracy is improved from 94.00% to 94.62%, with other evaluation metrics also showing enhancement. Critically, LightConvNeXt-FCS achieves the smallest standard deviation in accuracy among all models, which, combined with its superior mean accuracy, strongly suggests that its performance improvement is statistically significant and not attributable to random initialization variance.
In comparisons with other lightweight models, LightConvNeXt-FCS also exhibits excellent and stable performance. For instance, while MobileNetV2 [
26] (2.23 M parameters) and MobileNetV3 Small [
44] (1.52 M parameters) have comparable or fewer parameters, their mean accuracies (93.62% and 92.56%, respectively) and F1-scores (93.39% and 92.05%, respectively) are lower, and their performance shows notably higher variance, with accuracy standard deviations of ±0.31% and ±1.42%, respectively). Similarly, ShuffleNet V2 [
28] (1.26 M parameters) achieves a lower mean accuracy of 91.50% with higher variability (±0.94%). This highlights the advantage of the proposed model in maintaining high and stable classification performance under a strict parameter budget. For models with larger parameter counts, such as Swin Transformer Tiny [
25] (27.52 M parameters) and DeiT Tiny [
42] (5.52 M parameters), their mean accuracies (93.68% and 92.83%) are lower than that of LightConvNeXt-FCS, and their computational costs and model sizes are substantially higher.
For
Figure 10 (curves of validation set accuracy values), the accuracy curve of LightConvNeXt-FCS exhibits a steady upward trend throughout the training process and quickly converges to a high accuracy level. In contrast, the accuracy curves of some comparative models either show obvious fluctuations (indicating unstable training) or achieve a relatively low final accuracy. For
Figure 11 (curves of validation set loss values), the loss of LightConvNeXt-FCS decreases rapidly in the early training stage and then stabilizes at a low level. This not only demonstrates the model’s ability to efficiently learn effective feature representations but also further verifies the superior training stability of LightConvNeXt-FCS.
Overall, the experimental results, supported by multiple independent runs and analysis of variance, indicate that LightConvNeXt-FCS achieves the best performance-efficiency trade-off in the peach ripeness classification task. It not only substantially reduces computational resource requirements but also delivers improved and highly stable classification accuracy. This effectively addresses the common trade-off between model complexity and robust feature extraction capability, providing a more feasible and reliable solution for rapid and accurate grading of fruit ripeness.
3.5. Generalization Verification Experiment
To systematically evaluate the robustness and adaptability of the proposed LightConvNeXt-FCS model in practical applications, a generalization verification experiment was conducted on an independent public dataset, the Peach ripeness Dataset (PMD). It should be acknowledged that the peach varieties in PMD are included in the primary training set (NinePeach), while the acquisition environment and imaging equipment differ. This setup effectively tests the model’s classification stability under varying data collection conditions, preventing overfitting to a single dataset’s characteristics and providing a more objective assessment of real-world deployment performance. The compared models include: the original baseline ConvNeXt-Tiny, a simplified version with only the lightweight core module LightBlock (referred to as Light), and the complete LightConvNeXt-FCS model proposed in this study. All models directly used the final weights converged on the NinePeach dataset without retraining, fine-tuning, or parameter updates on PMD. Consistent preprocessing and augmentation strategies from the main experiment were applied to ensure fair evaluation. Models performed forward inference on the PMD test set, with accuracy (Acc), precision (Prec), recall (Rec), and F1 score (F1) as evaluation metrics. The results are shown in
Table 7.
From the experimental data, the ConvNeXt-Tiny baseline model demonstrates stable classification capability on PMD, achieving an accuracy of 94.12%, with precision, recall, and F1 score of 90.53%, 91.09%, and 90.76%, respectively, establishing a solid generalization baseline. However, its high resource consumption—27.82 M parameters, 4454.77 M FLOPs, and 106.13 MB model size—limits its applicability in low-cost deployment scenarios.
The Light model, which replaces only the core module with LightBlock, fully demonstrates the advantages of lightweight design in generalization verification: it requires only 2.48 M parameters, 399.37 M FLOPs, and 9.46 MB model size, representing a 91.1% reduction in parameters, a 91.0% reduction in FLOPs, and a compression to 8.9% of the original model size compared to ConvNeXt-Tiny. The lightweight improvement remains stable on the out-of-distribution dataset. In classification performance, this model achieves an accuracy of 93.38%, only 0.74 percentage points lower than the baseline, while precision, recall, and F1 score remain stable around 90.71%, with performance gaps controlled within 1%. These results indicate that LightBlock effectively preserves the ability to extract and recognize key features of peach ripeness from different sources while drastically reducing resource consumption, without causing significant degradation in generalization performance. This provides a reliable lightweight foundation for further optimization.
The proposed LightConvNeXt-FCS model maintains the ultimate lightweight advantage with 2.75 M parameters, 624.23 M FLOPs, and 10.50 MB model size—still achieving a 90.1% parameter reduction, 86.0% FLOPs reduction, and 9.9% model size compression compared to ConvNeXt-Tiny—while further improving generalization classification performance. Experimental data show its accuracy reaches 95.34%, which is 1.22 percentage points higher than ConvNeXt-Tiny and 1.96 percentage points higher than the Light model. Its precision, recall, and F1 score reach 90.86%, 91.91%, and 91.04%, respectively, outperforming both comparative models. These results demonstrate that LightConvNeXt-FCS, while inheriting the lightweight advantages of LightBlock, achieves enhanced generalization capability through structural optimization. It better adapts to scene differences in out-of-distribution datasets, effectively alleviating the tension between “lightweight design” and “generalizability.”
4. Discussion
This study proposes the LightConvNeXt-FCS model to address the dilemma between model complexity and classification accuracy in peach ripeness grading, and the discussion below focuses on its practical applicability, implications for real-time agriculture, existing limitations, and future improvement directions.
In terms of practical applicability, the lightweight design of LightConvNeXt-FCS endows it with significant advantages in deployment scenarios. By optimizing the core module and integrating efficient auxiliary structures, the model achieves a substantial reduction in parameters and computational cost while maintaining high classification accuracy. This characteristic is particularly important for agricultural applications that rely on edge computing devices, including smartphones and embedded terminals. Specifically, the model’s small parameter count and low computational footprint make it highly suitable for deployment on mobile devices (e.g., smartphones and tablets) for in-field inspection by farmers, as well as on embedded systems integrated into orchard sorting lines or harvest-assist robots for real-time, on-site grading. Unlike large-scale deep learning models that depend on high-performance computing resources, LightConvNeXt-FCS operates stably on low-cost, low-power devices, thus enabling rapid on-site ripeness detection of peaches. This reduces reliance on professional testing equipment and personnel, lowers the barrier to adopting intelligent grading technology in agricultural production, and increases its feasibility for small and medium-sized orchards as well as individual farmers.
The model plays a positive role in promoting the development of real-time agriculture. Accurate and real-time peach ripeness grading is an important link in the entire agricultural production chain, involving harvest timing, storage and preservation, and market circulation. The rapid detection capability of LightConvNeXt-FCS allows farmers to grasp the ripeness status of peaches in a timely manner, thereby determining the optimal harvest period. This can effectively avoid losses caused by premature or delayed harvest—premature harvest affects fruit quality, while delayed harvest reduces storage time and market value. In addition, real-time grading results can provide data support for the subsequent storage and preservation links, helping to formulate targeted preservation strategies based on different ripeness levels and improve the utilization rate of storage resources. From the perspective of the agricultural industry chain, adopting this technology helps shift peach production from an experience-driven to a data-driven approach, thereby accelerating agricultural intelligence and modernization.
Despite the above achievements, this study still has certain limitations. The most notable one is the insufficient comprehensiveness of the generalization verification. Since the peach varieties in the generalization validation set are also present in the main training set, the current evaluation of generalization performance is limited to scenarios with the same varieties under different acquisition environments. This cannot fully verify the adaptability of the model to new peach varieties that have not been involved in training. In actual agricultural production, there are numerous peach varieties with obvious differences in appearance characteristics, which may lead to a decline in the classification accuracy of the model when facing new varieties. In addition, the model’s performance under extreme environmental conditions (such as strong backlight, heavy fog, and rainy days) has not been fully verified. Although the main dataset covers some complex illumination conditions, extreme weather scenarios that may occur in actual production are not fully considered, which may affect the stability of the model in practical applications.
In view of the existing limitations, future research can be carried out in the following directions. First, the dataset scope should be expanded. A more diverse dataset needs to be collected and constructed, incorporating additional peach varieties beyond those currently used, as well as images captured under extreme environmental conditions. This can further improve the generalization ability of the model and enhance its adaptability to complex and diverse actual production environments. Second, optimize the model structure. On the basis of the existing lightweight design, further explore more efficient feature extraction and fusion mechanisms, and balance the relationship between model lightweight and robustness. For example, introducing dynamic adjustment mechanisms that can adapt to different environmental conditions to improve the model’s performance under extreme weather. Third, enrich the application scenarios. Combine the model with other agricultural technologies, such as unmanned aerial vehicles (UAVs) and Internet of Things (IoT) sensors, to realize large-scale, non-contact peach ripeness detection in orchards. This can further improve the efficiency of ripeness grading and provide more comprehensive data support for the refined management of orchards. Finally, deeper research should be conducted on integrating the model into the agricultural production chain—for example, by linking grading results with storage and transportation systems to establish a closed-loop intelligent management framework and maximize the technology’s practical value.