Grape leaf segmentation and variety classification method based on edge enhancement
By introducing an edge enhancement feature channel attention module and a lightweight backbone network ShuffleNetV2 into the YOLOv11n-seg model, the grape leaf classification model was optimized, solving the problem of excessively large models or decreased accuracy in resource-constrained environments, and achieving efficient and accurate grape leaf segmentation and variety classification.
Patent Information
- Application Number
- CN202511412314.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-29
- Publication Date
- 2026-01-13
AI Technical Summary
In existing technologies, grape variety classification based on the YOLO model suffers from problems such as excessively large models or decreased accuracy after compression on resource-constrained agricultural platforms, making it difficult to achieve efficient and accurate grape leaf segmentation and variety classification in resource-constrained environments.
Using the YOLOv11n-seg model as the baseline, the original attention module was replaced by constructing an edge enhancement feature channel attention module (EFCAAttention), and combined with the lightweight backbone network ShuffleNetV2 to optimize the model to improve classification accuracy and reduce the number of parameters, thus constructing the GL-YOLO model.
While maintaining or improving classification accuracy, it significantly reduces the number of model parameters and computational overhead, making it suitable for resource-constrained agricultural environments and achieving efficient grape leaf segmentation and variety classification.
Smart Images

Figure CN121330355A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of smart agriculture technology, and in particular to a method for grape leaf segmentation and variety classification based on edge enhancement. Background Technology
[0002] Smart agriculture is increasingly relying on advanced computer vision technology, especially in plant phenotyping and trait identification. Among various plant organs, leaves are frequently used as research subjects due to their ease of acquisition, availability throughout the growing season, and non-destructive collection methods. These characteristics make leaves an ideal target for high-throughput phenotypic analysis, where morphological features can be efficiently extracted using machine learning algorithms for yield prediction, trait classification, and disease detection.
[0003] In recent years, deep learning, especially convolutional neural networks (CNNs), has made groundbreaking progress in plant image analysis. CNNs significantly outperform traditional methods in tasks such as variety identification, disease diagnosis, and target segmentation. In viticulture, accurate variety identification is crucial for quality control, product traceability, and vineyard management. However, traditional methods for grape variety identification, such as ampelography or molecular marker techniques, are often labor-intensive and time-consuming. Therefore, among existing technologies, CNN-based image classification methods are gradually becoming a promising alternative, capable of analyzing phenotypic features such as leaf shape, color, and veins under the influence of genetic and environmental factors. Existing research has shown that combining multiple visual features (such as shape, texture, and edge structure) can achieve high recognition accuracy, highlighting the rich discriminative power of leaf morphology. Nevertheless, a systematic method is still lacking to determine which visual features (edge shape, vein structure, and color) are most critical for variety identification under different lighting conditions.
[0004] While deep CNNs offer superior accuracy, practical agricultural applications often require lightweight models suitable for real-time inference on resource-constrained platforms. Single-stage object detectors like YOLO (You Only Look Once) are favored in such applications because they can predict both object location and class simultaneously in a single forward pass, enabling fast and efficient processing. Various variants of YOLO (such as YOLOv5 and YOLOv8) have demonstrated competitiveness on agricultural datasets: the improved YOLOv5 achieved 91.07% accuracy in tomato virus disease identification, and YOLOv8 achieved 97.63% accuracy in mango fruit detection. YOLO's compact structure, reduced parameter count, and smaller model size make it particularly suitable for mobile and embedded deployments. However, even the streamlined YOLO model can still be too large for ultra-low-power devices, and direct model compression often leads to a decrease in accuracy. Summary of the Invention
[0005] To address the problem that existing models in practical agricultural applications need to be simplified or compressed due to limited platform resources, resulting in insufficient accuracy in grape variety prediction and classification, this invention provides a grape leaf segmentation and variety classification method based on edge enhancement. This method improves classification accuracy while significantly reducing the number of parameters, and can be widely deployed in resource-constrained environments.
[0006] To achieve the above objectives, the present invention provides the following technical solution:
[0007] A method for grape leaf segmentation and variety classification based on edge enhancement includes: using the YOLO model as the baseline model for classification, optimizing the baseline model using a first optimization strategy and a second optimization strategy to obtain a GL-YOLO model as an improved model; the baseline model includes a convolutional backbone network, a spatial pyramid pooling module, a segmentation head, and an attention module; wherein, the first optimization strategy includes: constructing an edge-enhanced feature channel attention module and replacing the attention module in the baseline model; the second optimization strategy includes: replacing the convolutional backbone network with a lightweight backbone network; and using the improved model to segment and classify the grape leaves to be tested to obtain the variety category label of the tested grape leaves.
[0008] For the lightweight classification model, this invention provides a preferred option for the selection of a lightweight baseline model, specifically the YOLOv11n-seg model.
[0009] To ensure the enhancement of key features and further improve classification accuracy, this invention provides a preferred scheme for determining specific features in the feature enhancement of channel attention. Before constructing the edge enhancement feature channel attention module and replacing the attention module in the YOLO model, the method further includes: determining key classification indicators, specifically achieved through the following steps: obtaining the original dataset of grape leaf images and dividing it into an original training set and an original validation set; determining leaf veins, leaf edge contours, and leaf color as visual feature indicators affecting classification; processing the original training set to generate training sets that examine the three visual feature indicators respectively; independently training each processed training set using an object detection model and evaluating it on the original validation set; obtaining the leaf edge contour as the key indicator affecting classification performance among the three visual feature indicators, thereby constructing the edge enhancement feature channel attention module.
[0010] To ensure accurate assessment of the three visual feature indicators and to accurately obtain the key visual indicators affecting classification, this invention provides a preferred scheme for the training set for assessing the three visual feature indicators. The steps of processing the original training set to generate training sets for assessing the three visual feature indicators respectively include: grayscale conversion, converting all images in the original training set into single-channel grayscale images, suppressing color information, and preserving leaf edge contours and leaf vein patterns to obtain a first training set after removing color information; edge masking, applying a binary mask to the boundary regions in all images in the original training set to remove leaf edge contours to obtain a second training set after removing leaf edge contour information; and leaf vein suppression, replacing the pixels of leaf vein color in all images in the original training set with the color of the surrounding leaf mesophyll to eliminate leaf vein patterns to obtain a third training set after removing leaf vein information.
[0011] Regarding the specific implementation method of leaf vein suppression, the present invention provides a preferred solution. The leaf vein suppression eliminates the leaf vein pattern by replacing the pixels of leaf vein color in all images in the original training set with the color of the surrounding leaf mesophyll. The step of obtaining a third training set with leaf vein information removed is specifically implemented by k-means-based color clustering, wherein the cluster center representing the leaf vein is replaced with the cluster center of the leaf mesophyll.
[0012] For the construction of the edge enhancement feature channel attention module, the present invention provides a preferred scheme, wherein the edge enhancement feature channel attention module (EFCAAttention) is obtained by combining the depth separable edge extraction submodule (DWEdgeExtract) and the efficient channel attention submodule (ECA); wherein, the depth separable edge extraction submodule is used to enhance the network's sensitivity to leaf edge contours, while the efficient channel attention submodule is used to optimize channel-level feature weights under the condition of computational overhead limitations.
[0013] To further reduce the computational burden, this invention provides a preferred solution for the selection of a lightweight backbone network, wherein the lightweight backbone network adopts ShuffleNetV2.
[0014] Regarding the specific selection of a lightweight backbone network, this invention provides two other optional solutions, wherein the lightweight backbone network adopts MobileNetV3 or GhostNet.
[0015] Regarding the specific model selected for the training set, this invention provides a preferred solution, wherein the target detection model specifically adopts the YOLOv8n target detection model.
[0016] To enhance the interpretability and user accessibility of the model output, this invention provides a preferred solution, the method of which further includes: converting the obtained variety category labels of the measured grape leaves into text descriptions based on a large language model.
[0017] Compared with the prior art, the present invention has the following advantages:
[0018] This invention presents a method for grape leaf segmentation and variety classification based on edge enhancement. Using the YOLO model as the baseline model for classification, an improved model (GL-YOLO model) is obtained by constructing an edge enhancement feature channel attention module and replacing the attention module in the baseline model as the first optimization strategy, and by replacing the original convolutional backbone network of the baseline model with a lightweight backbone network as the second optimization strategy. This improved model is then used for grape leaf segmentation and variety classification. Simultaneously, the most discriminative feature, leaf edge contour, is introduced into the edge enhancement feature channel attention module and embedded in the model. This improves classification accuracy while significantly reducing the number of parameters, allowing for widespread deployment in resource-constrained environments such as mobile platforms or embedded agricultural systems. Attached Figure Description
[0019] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.
[0020] Figure 1 A flowchart illustrating a method for grape leaf segmentation and variety classification based on edge enhancement, provided in one embodiment of the present invention;
[0021] Figure 2 The original dataset is used in the model training of the grape leaf segmentation and variety classification method based on edge enhancement provided in one embodiment of the present invention;
[0022] Figure 3 This is an example of a dataset after different feature suppression in a grape leaf segmentation and variety classification method based on edge enhancement provided in one embodiment of the present invention;
[0023] Figure 4 The diagram shows the structure of the improved GL-YOLO model obtained in the edge-enhanced grape leaf segmentation and variety classification method provided in one embodiment of the present invention.
[0024] Figure 5 The diagram shows the structure of the EFCAAttention module in the edge-enhanced grape leaf segmentation and variety classification method provided in one embodiment of the present invention.
[0025] Figure 6 The edge-enhanced grape leaf segmentation and variety classification method provided in one embodiment of the present invention
[0026] ShuffleNetV2 architecture diagram;
[0027] Figure 7 A schematic diagram of the ablation experiment results regarding feature contribution in a grape leaf segmentation and variety classification method based on edge enhancement provided in one embodiment of the present invention;
[0028] Figure 8 Grad-CAM heatmap to reflect model popularity;
[0029] Figure 9 This invention provides a plugin for generating variety description text using the Poe API in a method for grape leaf segmentation and variety classification based on edge enhancement, as part of one embodiment of the present invention. Detailed Implementation
[0030] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0031] Considering that existing technologies, even with simplification of segmentation and classification models, may still result in excessively large ultra-low-power devices, while direct model compression often leads to a decrease in accuracy, this invention explores efficient backbone network alternatives and accuracy improvement schemes to address this issue, and provides the following specific implementation methods:
[0032] Please refer to Figure 1 In a preferred embodiment, a method for grape leaf segmentation and variety classification based on edge enhancement is provided, which is mainly implemented through the following steps:
[0033] S1. Using the YOLO model as the baseline model for classification, the baseline model is optimized using a first optimization strategy and a second optimization strategy to obtain the GL-YOLO model as the improved model. The baseline model includes a convolutional backbone network, a spatial pyramid pooling module, a segmentation head, and an attention module (C2PSA). The first optimization strategy includes: constructing an edge enhancement feature channel attention module and replacing the attention module (C2PSA) in the baseline model. The second optimization strategy includes: replacing the convolutional backbone network with a lightweight backbone network.
[0034] First, regarding the base model, in a preferred embodiment, the YOLOv11n-seg model is specifically chosen. This embodiment selects the YOLOv11n-seg model as the base model for subsequent development based on preliminary experiments. YOLOv11n-seg is a lightweight variant of the YOLOv11 series, with built-in segmentation capabilities, designed for high-speed inference on edge devices. This model includes a compact convolutional backbone network, a Spatial Pyramid Pooling Module (SPPF), and a segmentation head. It achieves a good balance between accuracy and efficiency, making it suitable for fine-grained classification and segmentation tasks in resource-constrained environments.
[0035] Secondly, regarding the improved model, to enhance the performance and efficiency of the base model, this embodiment employs two model optimization strategies from S2. The improved model is called GL-YOLO (Grape Leaves-YOLO). To ensure the enhancement of key features and further improve classification accuracy, this invention provides a preferred implementation method for determining the specific features in the feature enhancement of channel attention. In S2, before constructing the edge enhancement feature channel attention module and replacing the C2PSA attention module in the YOLO model, it is necessary to determine the key classification metrics. This is achieved through the following steps:
[0036] S12a. Obtain the original dataset of grape leaf images and divide it into an original training set and an original validation set. Specifically, this embodiment uses a publicly available grape leaf image dataset (original dataset), which comes from Kaggle (DOI:10.34740 / kaggle / ds / 1248678). This dataset contains a total of 1009 high-resolution grape leaf images, which were taken under natural lighting conditions at different times. Figure 2 As shown, the original dataset contains samples from 11 grape varieties: Auxerrois, Cabernet Franc, Cabernet Sauvignon, Chardonnay, Merlot, Müller Thurgau, Pinot Noir, Riesling, Sauvignon Blanc, Syrah, and Tempranillo. Grape leaves exhibit significant differences in shape (leaf margin outline), veins, and leaf color, making this dataset highly suitable for fine-grained variety classification and segmentation tasks. The grape leaf feature indicators and the corresponding dataset processing procedures are described below:
[0037] S12b. Leaf veins, leaf margin contour, and leaf color are identified as visual feature indicators affecting classification. The original training set is processed to generate training sets that examine each of the three visual feature indicators. To systematically study the influence of specific visual attributes on grape variety classification, this embodiment identifies three key feature indicators: leaf veins, leaf margin contour, and leaf color. To examine the contribution of each feature individually, this embodiment generates three improved versions (three training sets) based on the original dataset. In a preferred embodiment, this step is specifically implemented through the following steps, such as... Figure 3 As shown:
[0038] Grayscale conversion converts all RGB images in the original training set into single-channel grayscale images, suppressing color information while preserving leaf edge contours and vein patterns, thus obtaining the first training set after removing color information. Figure 3 In the image, row (a) is the original image and row (b) is the image after grayscale conversion.
[0039] Edge masking involves applying a binary mask to the boundary regions of all images in the original training set to remove leaf edge contours, resulting in a second training set with leaf edge contour information removed. Specifically, leaf edges are detected and covered with a neutral background, preserving only the internal texture (including veins) and color of the leaves. Figure 3 In the image, row (c) is the image after edge masking.
[0040] Vein suppression involves replacing the vein-colored pixels in all images of the original training set with the color of the surrounding leaf mesophyll to eliminate vein patterns, resulting in a third training set with vein information removed. Further, this step is implemented using k-means-based color clustering, where the cluster centers representing veins are replaced with the cluster centers representing leaf mesophyll. Figure 3 In the middle, row (d) is the image after leaf vein suppression.
[0041] S12c. Each processed training set is independently trained using an object detection model and evaluated on the original validation set. This allows for a quantitative assessment of the independent importance of each visual feature in the grape variety identification task. In a preferred embodiment, the object detection model specifically employs a YOLOv8n or YOLOv11n-seg object detection model.
[0042] S12d. The leaf edge contour is obtained as the key indicator affecting classification performance among the three visual feature indicators, and an edge enhancement feature channel attention module is constructed accordingly.
[0043] In S1, the improved model constructed is as follows: Figure 4 As shown.
[0044] In the first optimization strategy, a novel attention mechanism is proposed, such as... Figure 5As shown, an Edge Enhancement Feature Channel Attention (EFCA) module is constructed. In a preferred embodiment, this module is obtained by combining a Depth Separable Edge Extraction (DWEdgeExtract) submodule with an Efficient Channel Attention (ECA) submodule. The DWEdgeExtract submodule enhances the network's sensitivity to leaf edge contours, while the Efficient Channel Attention (ECA) submodule optimizes channel-level feature weights with minimal computational overhead. The EFCA Attention module replaces the C2PSA attention module in the original YOLOv11n-seg architecture.
[0045] In the second optimization strategy, a more lightweight backbone network was constructed, such as... Figure 6 As shown, to further reduce computational burden, the standard convolutional backbone network is partially replaced with ShuffleNetV2 modules. ShuffleNetV2 modules offer efficient channel operations and low latency, making them suitable for real-time applications on low-power hardware. This hybrid design achieves a good balance between accuracy and inference cost. In alternative implementations, the lightweight backbone network can also employ MobileNetV3 or...
[0046] GhostNet.
[0047] This embodiment integrates ShuffleNetV2—a lightweight network employing depthwise separable convolutions and channel shuffling—into YOLO, significantly reducing computational costs without substantially lowering accuracy. Furthermore, efficient models such as MobileNet and GhostNet can also be applied to tasks like detection, enabling real-time inference on edge devices.
[0048] Meanwhile, an attention mechanism is introduced to enhance feature discrimination capabilities. To this end, the EFCAAttention module is proposed, which combines depthwise convolution-based edge feature extraction with ECA channel attention and embeds it into the GL-YOLO model. This model aims to emphasize structural details, especially leaf edges (leaf margin contours) and vein features, and has been validated through ablation experiments, demonstrating that these features are highly discriminative for grape variety classification.
[0049] S2. By improving the model, the grape leaves to be tested are segmented and classified to obtain the variety category label of the tested grape leaves.
[0050] The following sections will cover model validation, experimental configuration, and evaluation metrics: All experiments were conducted on a personal workstation equipped with a 64-bit Windows 11 operating system, an AMD Ryzen 97940HX CPU, and an NVIDIA GeForce RTX 4060 laptop GPU (8GB VRAM). Model training and evaluation were performed using the PyTorch and Ultralytics YOLO frameworks.
[0051] The following metrics were used for performance evaluation:
[0052] mAP95(B): Average detection accuracy in the range of 0.50 to 0.95 IoU threshold.
[0053] mAP95(S): Average segmentation accuracy within the IoU threshold range of 0.50 to 0.95.
[0054] Precision(B): The accuracy of bounding box prediction.
[0055] Precision(S): Pixel-level precision of the segmentation mask.
[0056] Parameters: The total number of learnable parameters in the model, used as an indicator of model complexity.
[0057] FLOPs: The number of floating-point operations per second performed by the model, reflecting computational complexity.
[0058] (I) Ablation experiment on the contribution of different leaf characteristics to variety classification:
[0059] This experiment presents the results of examining three visual feature indicators, such as... Figure 7 As shown in the figure, the impact of removing leaf color, leaf margin outline, or leaf vein features on model performance is illustrated. It can be seen from the figure that removing the leaf margin outline leads to the most significant performance degradation, further verifying its importance in classification tasks.
[0060] A similar trend was observed across most varieties. YOLOv8n performed best when trained on unmodified original images, with an average precision (AP) of 0.923, a precision (P) of 0.865, and a recall (R) of 0.806. Performance slightly decreased when leaf color information was removed (grayscale conversion), with the AP dropping to 0.869, indicating that color plays a limited role in variety differentiation. However, removing leaf margin contour information led to a significant performance drop: precision decreased to 0.391, recall to 0.557, and the AP to only 0.535. This highlights the crucial role of leaf margin shape features in distinguishing grape varieties.
[0061] In contrast, suppressing leaf vein information had a moderate impact on performance, with AP decreasing to 0.571, higher than the case of leaf margin outline removal, but still significantly lower than the grayscale version. These results clearly demonstrate that leaf margin outline is the most important feature in grape variety classification, followed by leaf vein structure, while leaf color contributes the least.
[0062] This exploration process directly guided the subsequent model design of this embodiment, prompting the addition of feature enhancement for leaf edge contours to the attention mechanism in this embodiment, thus obtaining the above step S22d. The leaf edge contour is obtained as the key indicator affecting classification performance among the three visual feature indicators, thereby constructing the edge enhancement feature channel attention module.
[0063] (II) Comparative experiment between the Edge Enhancement Feature Channel Attention Module (EFCAAttention) and different attention mechanisms:
[0064] To verify the effectiveness of the proposed Edge Enhancement Feature Channel Attention (EFCAAttention) module, this embodiment compares it with several widely used attention mechanisms, including ECA, CBAM, and SwinTransformer, all integrated within the same YOLOv11n-seg framework. The verification results are shown in Table 1.
[0065] Table 1: Performance comparison of different attention mechanisms integrated into YOLOv11n-seg
[0066] Attention mechanism Paras mAP95(B) mAP95(S) Precision (B) Precision(S) EFCA 2,788,846 0.9790 0.9786 0.9560 0.9552 ECA 2,595,028 0.9680 0.9712 0.9406 0.9400 CBAM 2,603,315 0.9610 0.9816 0.9338 0.9338 SwinTransformer 2,926,293 0.9730 0.9738 0.9346 0.9330
[0067] ECA, as a lightweight channel-only attention module, can improve performance to some extent, but its lack of spatial modeling capabilities may limit its segmentation accuracy. CBAM, by applying channel attention and spatial attention sequentially, shows a slight improvement over ECA, but still lags behind EFCAAttention. Swin Transformer leverages global context modeling for its advantages, but its computational cost is high (2.93M parameters), and its accuracy does not surpass EFCAAttention. Experimental results show that EFCAAttention performs best overall, achieving an mAP95 of 0.979 in the detection task and 0.9786 in the segmentation task, while maintaining a competitive parameter count of 2.79M.
[0068] These results demonstrate that EFCAAttention achieves a better balance between accuracy and efficiency by combining leaf edge feature enhancement and efficient channel attention, making it particularly suitable for fine-grained grape leaf analysis in resource-constrained environments.
[0069] (III) Comparison of experimental results for lightweight backbone network improvement:
[0070] To explore the impact of different lightweight backbone networks on model performance and computational efficiency, this embodiment evaluates three common lightweight architectures—ShuffleNetV2, MobileNetV3, and GhostNet—within the YOLOv11n-seg framework. Each backbone network replaced the default C3k2 module in the original convolutional backbone network, and all models were trained and tested under the same conditions. The validation results are shown in Table 2.
[0071] Table 2: Performance comparison of different lightweight backbone network integrations in YOLO11n-seg
[0072]
[0073] MobileNetV3 boasts the fewest parameters (2.20M) and the lowest computational cost (1.098 GFLOPs), demonstrating strong potential for deployment on ultra-low-power devices. However, it sacrifices accuracy: the mAP95 for detection drops to 0.912, and the segmentation metric also declines, with both detection and segmentation precision being the lowest among all tested models. GhostNet performs best on almost all metrics, achieving an mAP95 of 0.97 for detection and 0.974 for segmentation, with a precision as high as 0.9475. However, it fails to meet the lightweight requirement, with the largest number of parameters (3.47M) and a high GFLOPs (4.188), limiting its practical application on real-time or edge devices. ShuffleNetV2 offers the best balance between accuracy and model complexity. With only 2.33M parameters and 4.043 GFLOPs, it maintains accuracy comparable to or even slightly better than the baseline YOLOv11n-seg, and outperforms MobileNetV3 in all metrics. Although GhostNet scored slightly higher, ShuffleNetV2 was chosen due to its combination of performance and resource efficiency, making it the optimal deployment solution in the lightweight architecture proposed in this invention. In the table, GFLOPs represents billions of items.
[0074] (iv) Overall comparison with the baseline model:
[0075] The comparison results of YOLOv11n-seg and YOLOv8n-seg as baseline models are shown in Table 3.
[0076] Table 3: Performance comparison between the improved GL-YOLO model and the baseline YOLO11n-seg model
[0077] Model Paras GFlops mAP95(B) mAP95(S) Precision (B) Precision(S) YOLO11n-seg 2,876,848 4.941 0.9696 0.9722 0.9354 0.9346 YOLOv8n-seg 3,409,968 6.037 0.9696 0.9668 0.9352 0.9344 GL-YOLO 2,278,520 3.992 0.9668 0.9722 0.9512 0.9504
[0078] The results in Table 3 show that GL-YOLO outperforms YOLOv11n-seg and YOLOv11n-seg in both accuracy and mAP.
[0079] YOLOv8n-seg uses fewer parameters and fewer GFLOPs.
[0080] To evaluate the effectiveness of the proposed lightweight and leaf margin-enhanced model (GL-YOLO), this embodiment compares its performance with two baseline models: YOLOv11n-seg and YOLOv8n-seg. GL-YOLO integrates...
[0081] The ShuffleNetV2 backbone network and EFCAAttention module are designed to achieve the best balance between accuracy and computational cost.
[0082] Experimental results show that GL-YOLO has the lowest number of parameters (2.28M) and the lowest GFLOPs (3.992), compared to
[0083] YOLOv11n-seg (2.88M parameters, 4.94 GFLOPs) and YOLOv8n-seg (3.41M parameters, 6.04 GFLOPs) significantly reduce model complexity. Despite the reduced computational complexity, GL-YOLO maintains comparable or even better performance across key metrics.
[0084] In terms of accuracy, GL-YOLO achieved an mAP95 of 0.9668 for detection and 0.9722 for segmentation, slightly higher than the YOLOv11n-seg baseline and comparable to YOLOv8n-seg. Notably, GL-YOLO surpassed both baseline models in precision, achieving a bounding box precision of 0.9512 and a segmentation precision of 0.9504, indicating more reliable and consistent predictions.
[0085] Therefore, the GL-YOLO proposed in this invention not only maintains strong detection and segmentation performance but also significantly reduces computational overhead. Its superior accuracy and compact design make it ideal for deployment in resource-constrained environments, such as mobile platforms or embedded agricultural systems.
[0086] (V) Model Ablation Experiment
[0087] To evaluate the independent effectiveness of the improvements in the GL-YOLO architecture, this embodiment conducted ablation experiments, introducing its core components—EFCAAttention and ShuffleNetV2—into the YOLOv11n-seg baseline model. This allows this embodiment to independently evaluate the contributions of attention enhancement and lightweight backbone to the final model performance. The experimental results are shown in Table 4.
[0088] Table 4: Ablation experiments verify the model benefits of each improved component
[0089]
[0090] As shown in Table 4, when only the ShuffleNetV2 backbone network is integrated, the number of YOLO11n-seg model parameters decreases from 2.88M to 2.33M, and the computational cost decreases from 4.941 GFLOPs to 4.043 GFLOPs. Despite the decrease in computational cost, the detection and segmentation accuracy remain stable (mAP95(B): 0.9592; mAP95(S): 0.9672), indicating that ShuffleNetV2 can effectively improve efficiency without sacrificing performance.
[0091] In contrast, introducing only the EFCAAttention module (EFCA in the table) significantly improved accuracy, achieving an mAP95(B) of 0.9790 for detection and 0.9786 for segmentation, while also maintaining high precision (0.9560 for detection and 0.9552 for segmentation). Although this version of the model is slightly larger than the final GL-YOLO, it demonstrates the crucial role of edge-enhanced attention mechanisms in improving representation capabilities.
[0092] The final GL-YOLO model combines the two, achieving a balance between them: performance is close, only introducing...
[0093] The version of the EFCAAttention module maintains a low number of parameters (2.28M) and minimal computational overhead (3.992 GFLOPs). This validates the effectiveness of the modular improvements and supports the design choice of combining a lightweight backbone with a feature-sensitive attention mechanism.
[0094] (vi) Grad-CAM analysis:
[0095] To better understand the model's internal attention behavior, this embodiment applies Grad-CAM (Gradient-Weighted Class Activation Mapping) to visualize the most influential regions in each model's predictions. This visualization experiment demonstrates three representative models: YOLOv11n-seg, YOLOv8n-seg, and the proposed GL-YOLO. The generated heatmap is shown below. Figure 8As shown in the heatmap, there are significant differences in attention distribution. GL-YOLO consistently focuses on the leaf contour and overall shape, which is consistent with the results obtained in step S22d of this embodiment—leaf margin contour plays a key role in grape variety classification. This indicates that the introduction of the EFCAAttention module effectively guides the model to focus on biologically relevant features, such as leaf margin contour.
[0096] These results visually validate the quantization performance improvements observed in the aforementioned experiments and highlight the advantages of the GL-YOLO architecture improvements. They also underscore the importance of incorporating domain-specific priors (such as edge sensitivity) into attention modeling, particularly in fine-grained plant classification tasks.
[0097] Accurate grape variety identification and leaf segmentation are crucial aspects of smart viticulture. The embodiments of this invention explored the influence of leaf shape, veins, and color on variety classification through ablation experiments, revealing that leaf margin contours are the most discriminative feature. Based on this, a novel attention module—EFCAAttention—is proposed, combining depthwise separable convolution for edge feature extraction and efficient channel attention (ECA) for efficient channel recalibration. By replacing the original C2PSA module in YOLOv11-seg and introducing a lightweight backbone network based on ShuffleNetV2, a lightweight model for grape leaf analysis, GL-YOLO, is constructed. Experimental results show that GL-YOLO improves mAP and accuracy while reducing the number of parameters by 19.61%, providing an efficient solution for real-time vineyard phenotyping.
[0098] In a more preferred embodiment, the grape leaf segmentation and variety classification method based on edge enhancement also includes the following step: S3. Converting the obtained variety category labels of the measured grape leaves into text descriptions based on a large language model.
[0099] In addition to technical optimization, to enhance the interpretability and user accessibility of the model output, this embodiment provides a specific approach: by constructing a lightweight natural language generation module, the predicted grape leaf labels are converted into text descriptions, such as... Figure 9As shown, this module, based on ChatGPT, connects the model's prediction results to the ChatGPT interface (GPT-4o backend) via a PoeAPI encapsulation interface for interaction, integrating a lightweight natural language interface. After the YOLO model infers from the input grape leaf image, it extracts the predicted category labels, which are then inserted into predefined prompt templates to form the ChatGPT input. The generated text response is streamed and saved as a .txt file corresponding to the input image. Therefore, after completing grape variety identification, the system returns a textual description of the corresponding variety, enriching the output and providing a user-friendly decision support interface. Although this module currently runs as a standalone script and a graphical front-end has not yet been developed, it demonstrates the feasibility of integrating descriptions generated by Large Language Models (LLMs) into the visual recognition process, bridging the gap between raw predictions and interpretable output. This vision-language hybrid approach has potential value in educational, research, or user-oriented agricultural applications. Moreover, this integration reflects the development trend of agricultural AI: combining visual reasoning with natural language generation to improve transparency, usability, and interpretability. This module runs after prediction and does not affect the core detection or segmentation process. Instead, it provides semantic feedback to the visual results, which may support downstream "human-computer interaction" decision-making.
[0100] Based on the above embodiments, this invention achieves the following beneficial technical effects: By proposing the lightweight and leaf-edge-sensitive GL-YOLO model, this invention solves key challenges in grape leaf segmentation and variety classification. Through ablation experiments, the contributions of three visual features (leaf edge contour, leaf veins, and leaf color) to variety classification were systematically evaluated, and the results showed that leaf edge contour plays the most crucial role in classification. Based on this result, this invention developed the EFCAttention module, a novel attention mechanism that combines edge enhancement with efficient channel attention. When this module is embedded together with the ShuffleNetV2 backbone network...
[0101] Following YOLOv11n-seg, the generated GL-YOLO model significantly reduces the number of parameters while maintaining improved accuracy. Visual inspection using Grad-CAM further confirms that GL-YOLO can focus on biologically relevant regions, especially leaf margins and leaf contours, consistent with the results of ablation experiments. Furthermore, this invention constructs a lightweight natural language generation module and introduces a ChatGPT-based tag-to-description module, demonstrating the application potential of vision-language integration in intelligent agricultural tools.
[0102] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The program can be stored in a computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. The storage medium can be a magnetic disk, optical disk, read-only memory (ROM), or random access memory (RAM), etc.
[0103] The technical features of the above embodiments can be combined arbitrarily. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as the combination of these technical features does not contradict each other, it should be considered within the scope of this specification. Furthermore, the above embodiments only illustrate several implementation methods of the present invention, and their descriptions are relatively specific and detailed, but they should not be construed as limiting the scope of the present invention. For those skilled in the art, several modifications and improvements can be made without departing from the concept of the present invention, and these all fall within the protection scope of the present invention.
Claims
1. A method for grape leaf segmentation and variety classification based on edge enhancement, characterized in that, include: Using the YOLO model as the baseline model for classification, a first optimization strategy and a second optimization strategy are applied to optimize the baseline model, resulting in the GL-YOLO model as an improved model. The baseline model includes a convolutional backbone network, a spatial pyramid pooling module, a segmentation head, and an attention module. The first optimization strategy includes constructing an edge enhancement feature channel attention module and replacing the attention module in the baseline model. The second optimization strategy includes replacing the convolutional backbone network with a lightweight backbone network. By improving the model, the grape leaves to be tested are segmented and classified for detection, and the variety category label of the tested grape leaves is obtained.
2. The method for grape leaf segmentation and variety classification based on edge enhancement according to claim 1, characterized in that, The YOLO model specifically adopts YOLOv11n-seg.
3. The method for grape leaf segmentation and variety classification based on edge enhancement according to claim 1, characterized in that, Before constructing the edge enhancement feature channel attention module and replacing the attention module in the YOLO model, the process also includes: determining the key classification metrics, which is achieved through the following steps: Obtain the original dataset of grape leaf images and divide it into the original training set and the original validation set; Leaf veins, leaf margin outline, and leaf color were identified as visual feature indicators that affect classification. The original training set was processed to generate training sets that examine the three visual feature indicators respectively. Each processed training set is trained independently using an object detection model and evaluated on the original validation set; Leaf edge contour is identified as a key indicator among the three visual feature metrics that affect classification performance, and an edge enhancement feature channel attention module is constructed based on this.
4. The method for grape leaf segmentation and variety classification based on edge enhancement according to claim 3, characterized in that, The step of processing the original training set to generate training sets that examine the three visual feature metrics specifically includes: Grayscale conversion converts all images in the original training set into single-channel grayscale images, suppressing color information while preserving leaf edge contours and vein patterns, thus obtaining the first training set after removing color information. Edge masking: Apply a binary mask to the boundary regions of all images in the original training set to remove the leaf edge contours, and obtain a second training set with leaf edge contour information removed. Vein suppression involves replacing the vein-colored pixels in all images of the original training set with the color of the surrounding leaf mesophyll to eliminate the vein pattern, thus obtaining a third training set with vein information removed.
5. The method for grape leaf segmentation and variety classification based on edge enhancement according to claim 4, characterized in that, The leaf vein suppression method involves replacing the pixels with the leaf vein color in all images of the original training set with the color of the surrounding leaf mesophyll to eliminate the leaf vein pattern. The step of obtaining a third training set with leaf vein information removed is specifically implemented using k-means-based color clustering, where the cluster center representing the leaf vein is replaced with the cluster center of the leaf mesophyll.
6. The method for grape leaf segmentation and variety classification based on edge enhancement according to claim 1, characterized in that, The edge enhancement feature channel attention module is obtained by combining a depth-separable edge extraction submodule and an efficient channel attention submodule; wherein, the depth-separable edge extraction submodule is used to enhance the network’s sensitivity to leaf edge contours, while the efficient channel attention submodule is used to optimize channel-level feature weights under computational overhead constraints.
7. The method for grape leaf segmentation and variety classification based on edge enhancement according to claim 1, characterized in that, The lightweight backbone network uses ShuffleNetV2.
8. The method for grape leaf segmentation and variety classification based on edge enhancement according to claim 1, characterized in that, The lightweight backbone network adopts MobileNetV3 or GhostNet.
9. The method for grape leaf segmentation and variety classification based on edge enhancement according to claim 3, characterized in that, The target detection model specifically adopts the YOLOv8n target detection model.
10. The method for grape leaf segmentation and variety classification based on edge enhancement according to claim 1, characterized in that, Also includes: The variety category labels of the measured grape leaves are converted into text descriptions based on a large language model.