Cherry maturity and surface defect detection method and related device

By constructing a lightweight SEDDP-YOLO model, the problems of low model complexity and inference efficiency of the YOLO algorithm in cherry recognition are solved, achieving efficient and accurate detection of cherry maturity and surface defects, which is suitable for real-time detection of edge devices.

CN121033840AInactive Publication Date: 2025-11-28SHAANXI UNIV OF SCI & TECH
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202511138269.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-08-14
Publication Date
2025-11-28
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

In existing technologies, the YOLO algorithm for cherry recognition suffers from problems such as complex model structure, low inference efficiency, poor recognition of small targets, and difficulty in deploying edge devices, making it difficult to meet the real-time detection requirements of automatic fruit and vegetable sorting lines, mobile detection terminals, and agricultural machinery harvesting devices.

Method used

Based on the YOLOv8 model, a benchmark target detection model, Cherry-YOLO, was constructed. Through response-structure dual-guided pruning and structure-aware cross-layer distillation mechanism, a lightweight SEDDP-YOLO model was optimized. Combining the pruning strategy of multi-dimensional channel importance scoring and the cross-layer structure-aware distillation mechanism, a lightweight SEDDP-YOLO cherry detection model was constructed.

Benefits of technology

It significantly reduces model size and computational load, improves inference speed, is suitable for edge device deployment, and achieves efficient and accurate detection of cherry ripeness and surface defects, meeting the real-time detection needs of orchards and sorting lines.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121033840A_ABST
    Figure CN121033840A_ABST
Patent Text Reader

Abstract

The invention discloses a cherry maturity and surface defect detection method and a related device, and the method comprises the steps: collecting and preprocessing cherry image data, and constructing a cherry image data set; constructing a reference target detection model Cherry-YOLO, performing response-structure double-guide pruning operation on the reference target detection model Cherry-YOLO, introducing a structure perception cross-layer distillation mechanism to obtain an SEDDP-YOLO model, and performing training by using a cherry image data set to obtain a lightweight optimized cherry detection model; and the maturity and surface defects of the cherries are detected by using the lightweight optimized cherry detection model, so that automatic detection and grading tasks of the cherries are completed. According to the method, efficient and accurate detection of the maturity and the surface defects of the cherries is realized, the real-time deployment requirements on orchard sites, sorting assembly lines and low-power-consumption equipment are met, and the method can be widely applied to the field of small target identification and grading detection of other agricultural products.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the interdisciplinary field of artificial intelligence, computer vision and agricultural intelligent equipment, and relates to a method and related device for detecting the ripeness and surface defects of cherries. Background Technology

[0002] Cherries, as a high-value fresh fruit, are beloved by consumers for their small size, vibrant color, and crisp, sweet taste. Their ripeness and surface integrity directly affect not only the product grade but also significantly influence market prices and consumer purchasing decisions. Therefore, accurate ripeness classification and surface defect detection of cherries before they enter the market are crucial for ensuring product quality and achieving standardized grading. Currently, cherry quality sorting still relies heavily on manual labor. While manual sorting offers some flexibility in certain situations, its overall efficiency is low, making it difficult to meet the demands of the modern fruit and vegetable industry's large-scale, high-turnover supply and demand. Furthermore, human judgment is often heavily influenced by experience and fatigue, easily leading to errors and inconsistent grading standards and unstable accuracy. In addition, with rising labor costs year after year, traditional manual sorting methods face serious challenges in terms of economic viability and sustainability.

[0003] To improve sorting efficiency and consistency, machine vision technology has been widely introduced into fruit and vegetable inspection scenarios in recent years, especially deep learning-based target detection algorithms, which have provided effective support for automated recognition. Among them, the YOLO (You Only Look Once) series of algorithms has become an important tool in fruit and vegetable appearance recognition research due to its end-to-end detection structure, high-speed inference capabilities, and excellent recognition accuracy. With the continuous evolution of multiple versions such as YOLOv3, YOLOv5, YOLOv8 to YOLOv10, this series of algorithms has made continuous breakthroughs in detection accuracy and real-time performance, and has been successfully applied to quality inspection tasks of various fruits such as apples, oranges, and tomatoes.

[0004] However, directly applying the YOLO algorithm to cherry recognition still faces several technical bottlenecks. First, due to the small size of cherries and their low proportion in images, they are easily confused with their surroundings in complex backgrounds, making it difficult for the model to accurately extract effective features. Second, occlusion or overlap between fruits, such as stem or leaf cover, further increases the detection difficulty. Furthermore, natural harvesting environments often involve uneven lighting, reflections, and background interference, placing higher demands on the model's robustness. More importantly, although newer versions of the YOLO series have improved accuracy, their large model structure, high parameter count, and computational complexity make them difficult to deploy directly in resource-constrained scenarios such as mobile terminals, embedded systems, or fruit and vegetable sorting lines, limiting their practical application and widespread use.

[0005] To address this, researchers have proposed various model compression and acceleration techniques, including pruning, knowledge distillation, quantization, and structural reconstruction. Pruning removes redundant channels and structures from the network, reducing model size; distillation utilizes the teacher network to guide the student network in learning key features, thus maintaining accuracy while reducing parameters; and quantization and structural optimization further improve the model's execution efficiency at the operator and network architecture levels. These methods have, to some extent, promoted the lightweighting of detection algorithms. However, these methods still have significant shortcomings in small object detection tasks such as cherry detection. On the one hand, if pruning strategies lack a global assessment of structural importance, key perceptual paths can be mistakenly deleted, severely impacting accuracy. On the other hand, conventional distillation methods are mostly based on overall features or classification outputs, making it difficult to provide fine-grained guidance for regions with blurred boundaries, small object regions, or occluded regions. Furthermore, while some lightweight networks have compact structures, they inherently lack features in extraction, spatial modeling, and inter-layer interactions, making them unsuitable for fine-grained agricultural vision tasks.

[0006] In summary, there is an urgent need for a novel object detection method that effectively integrates network structure compression and local structure transfer mechanisms. This method should significantly reduce model size and inference latency while maintaining detection accuracy, and enhance the model's ability to perceive and represent complex small targets. The method should possess good deployability and stability, and be directly applicable to automated fruit and vegetable sorting lines, mobile detection terminals, unmanned vending systems, and agricultural harvesting devices to achieve efficient and intelligent detection of fruits such as cherries. Summary of the Invention

[0007] The purpose of this invention is to provide a method and related apparatus for detecting the ripeness and surface defects of cherries, solving the problems of complex model structure, low inference efficiency, poor small target recognition effect and difficulty in deploying edge devices in the prior art.

[0008] To achieve the above objectives, the present invention employs the following technical solution:

[0009] A method for detecting cherry ripeness and surface defects, comprising:

[0010] Collect cherry image data, preprocess the cherry image data, and construct a cherry image dataset;

[0011] Based on the YOLOv8 model, a benchmark target detection model Cherry-YOLO was constructed. The Cherry-YOLO benchmark target detection model was subjected to response-structure dual-guided pruning operation, and a structure-aware cross-layer distillation mechanism was introduced to obtain the SEDDP-YOLO model.

[0012] The SEDDP-YOLO model was trained using a cherry image dataset to obtain a lightweight optimized cherry detection model;

[0013] A lightweight optimized cherry detection model was used to detect cherry ripeness and surface defects, completing the automatic cherry detection and grading task.

[0014] Further preprocessing of cherry image data includes:

[0015] The cherry images were cleaned and enhanced. The ripeness and surface defect categories of cherries in the images were labeled manually. The cherry image data were divided into training set, validation set and test set according to a preset ratio.

[0016] Furthermore, the backbone network of the benchmark target detection model Cherry-YOLO is a FasterNet-RepMixer structure, the neck network is a DySlimNeck structure, the detection head is a Detect-FRM structure, and the loss function is AGF-CIoU.

[0017] Furthermore, the execution process of the response-structure dual-guided pruning operation includes:

[0018] Before pruning, the gradient sensitivity, activation response intensity, attention allocation weight and edge response capability of each benchmark target detection model channel are calculated. Differentiated weight factors are set based on the function of each benchmark target detection model channel, and the channel importance score is obtained by combining the results.

[0019] During the pruning process, channels are grouped according to the module-aware weight strategy, and the output weight of low-scoring channels is controlled by a hierarchical pruning + soft masking mechanism. Invalid channels are gradually shrunk during the training phase, and physical pruning is completed after training stabilizes to obtain a compressed lightweight model structure.

[0020] Furthermore, the structure pruning method using layered pruning + soft masking mechanism is as follows:

[0021] Each layer of the passageway is divided into several groups, and each group contains a fixed number of passageways.

[0022] Sort the channel groups according to the scoring function and retain the high-scoring channel groups;

[0023] A soft mask is introduced for the low-scoring group channel, and its feature output is multiplied by a dynamic decay coefficient during training.

[0024] After training convergence, all channel groups with dynamic soft mask coefficients less than a set threshold are physically deleted to complete the structure pruning.

[0025] Furthermore, the structure-aware cross-layer distillation mechanism includes feature alignment distillation, attention distillation, salient region distillation, and Logit output distillation.

[0026] Furthermore, the training method for the SEDDP-YOLO model is as follows:

[0027] The SEDDP-YOLO model was trained end-to-end using the training set in the cherry image dataset. The performance metrics of mAP@0.5, mAP@0.5:0.95, and F1 score were evaluated on the validation set in the cherry image dataset. The training of the SEDDP-YOLO model was completed when the performance metrics reached the preset standards.

[0028] A system for detecting cherry ripeness and surface defects, comprising:

[0029] The acquisition module is used to acquire cherry image data, preprocess the cherry image data, and construct a cherry image dataset;

[0030] The modeling module is used to build the benchmark target detection model Cherry-YOLO based on the YOLOv8 model, perform response-structure dual-guided pruning operation on the benchmark target detection model Cherry-YOLO, and introduce a structure-aware cross-layer distillation mechanism to obtain the SEDDP-YOLO model.

[0031] The training module is used to train the SEDDP-YOLO model using a cherry image dataset to obtain a lightweight optimized cherry detection model.

[0032] The detection module is used to detect the ripeness and surface defects of cherries using a lightweight optimized cherry detection model, and complete the automatic detection and grading of cherries.

[0033] A terminal device includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the method.

[0034] A computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the method.

[0035] Compared with the prior art, the present invention has the following beneficial effects:

[0036] This invention provides a method for detecting cherry maturity and surface defects. Based on the YOLOv8 model, a baseline target detection model, Cherry-YOLO, is constructed for structural compression and feature reconstruction. A pruning strategy based on multi-dimensional channel importance scoring and a cross-layer structure-aware distillation mechanism are jointly introduced to build a lightweight SEDDP-YOLO cherry detection model. The pruning strategy integrates gradient, activation, attention, and edge response features, preserving key channel structures. The distillation mechanism integrates feature alignment, salient region guidance, and logit matching to improve the recognition ability of small targets and blurred boundaries. While maintaining high detection accuracy and robustness, the method significantly compresses the size and computational cost of the baseline target detection model, achieving a compression rate of over 60% and increasing the inference speed to 177 FPS. It is suitable for deployment on edge devices such as Jetson and Raspberry Pi, meeting the real-time detection needs of orchards and sorting lines. This invention achieves efficient and accurate detection of cherry maturity and surface defects, meeting the real-time deployment requirements of orchards, sorting lines, and low-power devices. It is not only suitable for detecting the ripeness and surface defects of cherries, but can also be widely applied to the identification and grading of small targets in other agricultural products (such as grapes, blueberries, loquats, etc.), and has good engineering practicality and industrial promotion value. Attached Figure Description

[0037] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present invention and should not be regarded as a limitation on the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.

[0038] Figure 1 This is a flowchart of the cherry ripeness and surface defect detection method of the present invention.

[0039] Figure 2 This is a network structure diagram of Cherry-YOLO, the benchmark target detection model of this invention.

[0040] Figure 3 This is an example diagram of the cherry dataset annotation for this invention.

[0041] Figure 4 This is an example image of a cherry after data enhancement according to the present invention.

[0042] Figure 5 This is a normalized radar chart of the multidimensional performance indicators of the benchmark target detection model under different pruning rates according to the present invention.

[0043] Figure 6 This is a schematic diagram of the structure-aware translayer distillation mechanism of the present invention.

[0044] Figure 7 This is a comparison chart of the detection performance of the benchmark target detection model before and after pruning and distillation according to the present invention.

[0045] Figure 8 is a multi-dimensional performance comparison chart of the present invention with other target detection models, where (a) is a comparison chart of model accuracy indicators, (b) is a comparison chart of model computational complexity, (c) is a comparison chart of model parameter quantity, (d) is a comparison chart of model inference speed, (e) is a scatter plot of model efficiency, and (f) is a radar chart of model comprehensive performance.

[0046] Figure 9 shows the SEDDP-YOLO model detection diagram of the present invention, wherein (a) is an example diagram of SEDDP-YOLO model detection, and (b) is a heat map of SEDDP-YOLO model detection.

[0047] Figure 10 This is a schematic diagram of a cherry ripeness and surface defect detection system according to a preferred embodiment of the present invention.

[0048] Figure 11 This is a schematic diagram of the electronic device structure according to a preferred embodiment of the present invention. Detailed Implementation

[0049] The following description, in conjunction with the accompanying drawings, illustrates exemplary embodiments of this application, including various details to aid understanding. These should be considered merely exemplary. Therefore, those skilled in the art will recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of this application. Similarly, for clarity and brevity, descriptions of well-known functions and structures are omitted in the following description.

[0050] Obviously, the described embodiments are only some, not all, of the embodiments in this application. All other embodiments obtained by those skilled in the art based on the embodiments in this application without inventive effort are within the scope of protection of this application.

[0051] It should be noted that the terminals involved in the embodiments of this application may include, but are not limited to, mobile phones, personal digital assistants (PDAs), wireless handheld devices, tablet computers, personal computers (PCs), MP3 players, MP4 players, wearable devices (e.g., smart glasses, smartwatches, smart bracelets, etc.), smart home devices, and other smart devices.

[0052] Furthermore, the term "and / or" in this article is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, or B existing alone. Additionally, the character " / " in this article generally indicates that the preceding and following related objects have an "or" relationship.

[0053] The present invention will now be described in further detail with reference to the accompanying drawings:

[0054] See Figure 1 This invention provides a method for detecting the ripeness and surface defects of cherries, specifically including the following steps:

[0055] S1. To improve the detection accuracy, feature extraction capability, and deployment efficiency of YOLOv8 in cherry ripeness and surface defect detection tasks, this invention optimizes and improves the original structure of YOLOv8 in several ways, constructing a higher-performance and lighter-structured baseline detection model, Cherry-YOLO. See [link to relevant documentation]. Figure 2 The improvements include backbone network replacement, neck network reconstruction, detector head optimization, and loss function improvement.

[0056] A baseline target detection model, Cherry-YOLO, is constructed based on YOLOv8. This model employs a FasterNet-RepMixer structure in the backbone network, enabling more efficient local feature modeling and channel compression. A DySlimNeck module is introduced in the neck network, achieving efficient transfer and compression of semantic information between upper and lower layers through multi-scale channel fusion and lightweight residual design. A Detect-FRM structure is introduced in the detection head, combined with the DFL distributed bounding box regression mechanism, significantly improving the recognition ability for targets with blurred boundaries and irregular sizes. Simultaneously, the AGF-CIoU loss function is adopted to enhance the fitting ability and regression accuracy of target contours.

[0057] S2. Collect and construct a cherry image dataset, specifically including: collecting cherry images from different angles, distances, and lighting conditions under natural growing environments and experimental conditions; performing data cleaning and enhancement on the images; and manually labeling the cherry maturity and surface defect categories in the images, including three maturity states (ripe, semi-ripe, and unripe) and various surface defects such as cracks, spots, and corrosion. The image dataset is then divided into training, validation, and test sets according to a preset ratio, and robustness and generalization ability are improved through data enhancement strategies such as rotation, scaling, and brightness adjustment.

[0058] S3. Perform response-structure dual-guided pruning on the benchmark Cherry-YOLO model. This includes: calculating the gradient sensitivity, activation response strength, attention allocation weight, and edge response capability of each channel before pruning; setting differentiated weight factors based on the channel's function in different modules (Backbone, Neck, Head); and comprehensively deriving a channel importance score. During pruning, channels are grouped according to a module-aware weighting strategy, and a hierarchical pruning + soft masking mechanism is used to control the output weight of low-scoring channels. After training stabilizes, physical pruning is completed to obtain a compressed, lightweight model structure. This pruning scheme can significantly reduce the number of parameters and computational complexity of the benchmark object detection model while preserving as many high-response, high-contribution effective channels as possible, enabling student models to have approximate feature representation capabilities.

[0059] The structure pruning method using layered pruning and soft masking is as follows:

[0060] Each layer of the passageway is divided into several groups, and each group contains a fixed number of passageways.

[0061] Sort the channel groups according to the scoring function and retain the high-scoring channel groups;

[0062] A soft mask is introduced for the low-scoring group channel, and its feature output is multiplied by a dynamic decay coefficient during training.

[0063] After training convergence, all channel groups with dynamic soft mask coefficients less than a set threshold are physically deleted to complete the structure pruning.

[0064] S4. A structure-aware cross-layer distillation mechanism is introduced into the pruned lightweight model to achieve more refined and semantically consistent guided optimization of the student model. This distillation mechanism includes cross-layer feature alignment distillation between the teacher and student models, DFL-guided attention distillation, and Grad-CAM-guided salient region distillation. A joint distillation loss function is used to train the student model, improving its expressive ability in key regions and overall detection accuracy. In feature alignment distillation, bilinear interpolation and channel mapping are used to align the features of each layer of the teacher model with the corresponding layers of the student model in terms of scale and semantic distribution. In attention distillation, the attention weights of the DFL module in the teacher model guide the student model to focus on key boundary regions. In salient region distillation, the Grad-CAM method is used to extract the key response regions of the teacher model, and cosine similarity loss is applied to guide the student model to focus on effective target boundaries. In Logit distillation, the KL divergence function is introduced to optimize the output probability distribution of the student model to be consistent with that of the teacher model, thereby improving the overall classification confidence and recognition accuracy. The aforementioned multi-level perceptual distillation mechanism collectively enhances the student model's ability to detect small targets, identify blurred boundaries, and discriminate against complex backgrounds.

[0065] After joint training and optimization using the above pruning and distillation strategies, a lightweight SEDDP-YOLO model is finally formed.

[0066] S5. The SEDDP-YOLO model optimized by pruning and distillation is trained end-to-end on the training set of the cherry image dataset. Performance metrics (including mAP@0.5, mAP@0.5:0.95, F1 score, etc.) are evaluated on the validation set. When the performance metrics reach the preset standard, the training of the SEDDP-YOLO model in the cherry image dataset is completed, and the final lightweight optimized cherry detection model is obtained.

[0067] S6. Deploy the final lightweight optimized cherry detection model to the edge or actual detection system, obtain the cherry images to be detected and input them into the lightweight optimized cherry detection model, output the detection results, including cherry maturity classification information and surface defect recognition results, and complete the automatic cherry detection and grading task.

[0068] The present invention will be further described in detail below through specific embodiments:

[0069] Example 1:

[0070] This embodiment discloses a method for detecting cherry maturity and surface defects based on structure-aware distillation and pruning, specifically including the following steps:

[0071] Step 1: Construct the baseline target detection model Cherry-YOLO

[0072] The backbone network of the benchmark object detection model Cherry-YOLO is based on the FasterNet architecture. FasterNet effectively reduces redundant computation by introducing partial convolution (PConv) and pointwise convolution (PWConv) mechanisms, while maintaining sensitivity to object edges and structural features, thus enhancing its ability to detect small objects such as cherries. This architecture utilizes a partial channel computation strategy, significantly reducing the computational complexity and the number of parameters of the benchmark object detection model while extracting key features, making it particularly suitable for deployment on resource-constrained edge devices.

[0073] Furthermore, a RepMixer module is embedded in the backbone network to enhance nonlinear expressive power. Channel mixing operations and lightweight residual connections further improve the transmission efficiency and stability of deep features, effectively mitigating the gradient vanishing problem. While maintaining the same spatial resolution, this module enables efficient information exchange, improving the recognition ability of small targets in complex backgrounds.

[0074] To further enhance the multi-scale perception capability and robustness of the benchmark object detection model, the neck structure is a DySlimNeck structure. This structure integrates a lightweight convolutional module (GSConv), a dynamic activation function (DyReLU), and a cross-scale dynamic fusion module (CSDF). GSConv can efficiently aggregate multi-scale feature maps while significantly reducing computational cost, DyReLU can enhance the benchmark object detection model's ability to adaptively adjust the feature response amplitude, and CSDF can adaptively fuse feature information of different scales and semantic depths.

[0075] A high-resolution detection layer (P2) was added to the DySlimNeck structure. This layer is mainly used to capture small cherry targets with high resolution requirements, significantly improving the benchmark target detection model's ability to identify maturity and minor surface defects. On the actual sorting line, even with occlusion between fruits or complex backgrounds, the benchmark target detection model still maintains good feature representation and detection robustness.

[0076] The detection head is the Detect-FRM detection head, which consists of three parts:

[0077] 1. PCRC (Pooling-Convolution Refinement Component): Extracts region features through a combination of pooling and convolution operations, enhancing target saliency;

[0078] 2. FRM (Feature Refinement Module): Further filters and reconstructs the fused features to improve the accuracy of boundary fitting;

[0079] 3. DFL (Distribution Focal Loss) mechanism: The bounding box regression adopts a distributed regression method to achieve finer-grained positioning accuracy.

[0080] Detect-FRM can effectively improve the localization performance of benchmark target detection models under different scales and densities, and is especially suitable for boundary modeling in complex occlusion scenes. It also optimizes the adaptability to changes in the shape, size and distribution of cherry fruits.

[0081] Furthermore, considering the significant size variations, pose differences, and occlusion issues of cherries in their natural environment, traditional IoU-based loss functions struggle to accurately fit these deformable targets. Therefore, AGF-CIoU (Adaptive Gaussian Focus Complete IoU) is introduced as the bounding box regression loss function. This loss function comprises the following three parts:

[0082] 1. IoU weighting term: Apply adaptive weighting to the center offset error between the predicted box and the ground truth box to increase the penalty for misalignment in the center region;

[0083] 2. Gaussian mask term: A two-dimensional Gaussian weighted template is embedded in the boundary regression loss to guide the benchmark target detection model to focus on the central key region;

[0084] 3. Semantic comparison: By comparing and learning the feature differences between student and teacher models, the structural expression and feature consistency of the benchmark target detection model are enhanced.

[0085] Step 2: Collect cherry image data and preprocess it to construct a cherry image dataset.

[0086] To ensure that the optimized benchmark target detection model Cherry-YOLO has a good training foundation and generalization ability, a high-quality cherry image dataset was constructed based on the actual orchard environment and laboratory control conditions. The images were manually labeled and enhanced to form training, validation and test sets, providing complete data support for the training of the benchmark target detection model.

[0087] Regarding image acquisition, cherry images were primarily obtained through two methods. The first was natural orchard scene acquisition, using a standardized cherry planting base in Tongchuan City, Shaanxi Province, China as the shooting location. The acquisition time covered the immature, semi-ripe, and fully ripe stages of the cherry fruit. The acquisition device was a Huawei Mate 40 Pro smartphone, with an image resolution of 8192×6144 pixels. Shooting angles included common perspectives such as horizontal, overhead, and low-angle views, with shooting distances ranging from 10 to 100 cm, comprehensively covering the morphological characteristics of cherries at different scales and angles. To control variations in lighting conditions, images were collected in the morning, noon, and afternoon to ensure the samples covered various natural lighting scenarios. The second method involved supplementary laboratory acquisition. To improve data diversity and image quality, a Hikvision MV-CS200-10GC industrial camera (resolution 5472×3648, frame rate 5.9fps) was used to acquire high-resolution images of various cherry varieties under standard light source control conditions. By standardizing pose control and background settings, cherry image samples in standard poses were obtained, enhancing the generalization ability of the benchmark target detection model across varieties and environmental scenarios. Finally, the two types of acquisition results were merged to obtain a total of 2000 high-quality RGB image samples, covering multiple maturity stages and typical appearance defect features.

[0088] See Figure 3For image annotation, the open-source image annotation tool LabelImg was used to manually annotate each image one by one. All cherry targets were annotated with bounding boxes to ensure accuracy and consistency in localization. The annotation categories included four types: Category 0 for ripe cherries, Category 1 for semi-ripe cherries, Category 2 for unripe cherries, and Category 3 for cherries with surface defects (such as spots, cracks, insect damage, etc.). The annotation results were saved as YOLO format text files, with one annotation file corresponding to each image. Each line of data included the category number, the coordinates of the bounding box center point, and the normalized values ​​of width and height. After annotation, the images and annotation files were divided into training, validation, and test sets in an 8:1:1 ratio, containing 1600, 200, and 200 image samples respectively, ensuring the scientific rigor and data independence of the training and evaluation process.

[0089] See Figure 4 In terms of data augmentation, various image augmentation strategies were employed to improve the robustness and generalization ability of the benchmark target detection model in complex scenes. Geometric augmentation included random image rotation (angle range ±30°), scaling (0.8–1.2 times), cropping, translation, and horizontal flipping to simulate different shooting angles and target pose changes. Color augmentation included brightness adjustment, tone perturbation, Gaussian noise superposition, and Gamma transformation to enhance the benchmark target detection model's adaptability to changes in illumination and image quality. Furthermore, synthetic augmentation operations were introduced, such as simulating foliage occlusion, shadow projection, and background replacement, to further expand the benchmark target detection model's ability to recognize occlusion and complex backgrounds. All augmentation operations were implemented using OpenCV and custom scripts, with corresponding annotation files adjusted synchronously to ensure data consistency. After augmentation, the total number of images increased from the original 2000 to 7904, with the training set containing 6336 images, the validation set containing 787 images, and the test set containing 781 images. The total number of labeled bounding boxes exceeded 68,000.

[0090] The constructed dataset has the following characteristics: (1) It fully covers all stages of cherry maturity, which makes it easier for the benchmark target detection model to learn the evolution characteristics of color, gloss and size with the growth cycle; (2) It contains a variety of defect types, including common surface anomalies such as spots, broken skin and wormholes, which improves the ability of the benchmark target detection model to identify defects; (3) It has diverse shooting angles and complex background environments, including a variety of natural occlusions and lighting interferences, which fits the actual application scenarios; (4) It has high image resolution and accurate annotation, which ensures that the benchmark target detection model can fully learn boundary information and detailed features.

[0091] Step 3: Perform response-structure dual-guided pruning on the baseline target detection model Cherry-YOLO.

[0092] To compress the structure of benchmark target detection models, reduce computational overhead, and improve inference speed while maintaining detection accuracy, a response-structure dual-guided pruning strategy is proposed based on the optimized benchmark target detection model Cherry-YOLO. This strategy, grounded in multi-dimensional channel importance assessment and incorporating differences in module structure, achieves lightweight processing of the benchmark target detection model through refined pruning, thereby obtaining a student model with higher deployment efficiency.

[0093] First, to scientifically evaluate the impact of each channel on target detection, this invention constructs a channel scoring function that integrates four features: gradient, activation, attention, and edge response. Let the score of the c-th channel be S. c Its definition is as follows:

[0094] Score c =α1·G c +α2·A c +α3·W c +α4·E c

[0095] Among them, G c This represents the gradient sensitivity of channel c, reflecting its contribution to the loss function; A c W represents the mean activation value of channel c. c E represents the weights assigned to channel c in the attention mechanism (such as the attention coefficients generated by the SE or CBAM modules); c The edge response intensity of channel c is represented by the Sobel operator in the Backbone and Neck, and by the DFL boundary heatmap in the Head; α1, α2, α3 and α4 represent hyperparameters, with relative weights set according to different structural modules.

[0096] Next, based on the structure of the benchmark target detection model, this invention divides the entire network into three modules: Backbone, Neck, and Head. Differentiated pruning strategies are set for the characteristics of different modules; for example, edge information preservation is emphasized in the Backbone, channel fusion complementarity is stressed in the Neck, and localization and classification accuracy are highlighted in the Head. This "module-aware pruning strategy" can prevent the accidental pruning of key structures, ensuring that the pruned benchmark target detection model has complete functional expressive capabilities.

[0097] To ensure the stability of the baseline target detection model training and the final compression effect, a "group pruning + soft masking" mechanism is proposed for pruning. The specific steps are as follows:

[0098] 1. Divide each floor's channels into several groups (Group Pruning), with each group containing a fixed number of channels;

[0099] 2. Based on the aforementioned scoring function S c Sort the channel groups and retain the top K% of the highest-scoring channel groups;

[0100] 3. Introduce a Soft Mask for the low-scoring group channels. During training, its feature output is multiplied by a dynamic decay coefficient β∈(0,1), for example:

[0101]

[0102] in For the final feature output at position (i,j) on channel c, β c Let β be the dynamic soft mask coefficient for channel c. c It decays linearly or decreases stepwise as the training progresses.

[0103] 4. After training converges, all β c Channel groups smaller than a set threshold will be physically deleted, thus simplifying the structure.

[0104] This mechanism gradually weakens the impact of redundant channels without disrupting the network training process, and ultimately solidifies the channel compression, avoiding gradient oscillations caused by sudden pruning.

[0105] See Figure 5 This embodiment also conducts multiple comparative experiments on the pruning rate to verify the performance change trend of the benchmark target detection model under different compression ratios. The results show that when the pruning rate reaches 50%, the performance loss is minimal and the efficiency improvement is optimal, representing the best balance between lightweight design and practicality. In the actual experiment, the pruning rate of the full benchmark target detection model was set to 50%, meaning that the number of channels retained per layer was approximately half that of the original benchmark target detection model. The performance indicators of the benchmark target detection model after pruning are as follows: the number of parameters decreased from the original 12.93M to 4.87M; the computational complexity (FLOPs) decreased from 9.1GFLOPs to 3.7GFLOPs; and the inference speed increased by more than 100%, facilitating real-time deployment at the edge.

[0106] Meanwhile, the P2 high-resolution detection branch, the CSDF structure in the Neck, and the DFL boundary prediction module were preserved during the pruning process, effectively ensuring the small target detection and boundary localization capabilities.

[0107] Step 4: Perform structure-aware cross-layer distillation on the pruning baseline target detection model.

[0108] See Figure 6To effectively restore the detection accuracy of the benchmark object detection model and improve its boundary representation ability after pruning and compression, a structure-aware cross-layer distillation mechanism is introduced during the student model training phase. This mechanism uses the original, unpruned benchmark object detection model, Cherry-YOLO, as the teacher model, providing multi-scale, structure-aligned, and saliency-guided knowledge transfer to the pruned lightweight student model. This ensures that the benchmark object detection model maintains a lightweight structure while achieving detection performance close to or even exceeding that of the original benchmark object detection model.

[0109] The structure-aware distillation mechanism consists of the following four parts:

[0110] 1. Cross-scale feature-aligned distillation

[0111] In the distillation process, to enable the student model to have intermediate layer expressive capabilities similar to the teacher model, this invention selects multiple feature layers from the teacher model. Feature layer corresponding to the student model Alignment distillation is performed. After adjusting the feature maps to the same size using bilinear interpolation, the L2 distance between each pair of feature maps is calculated as the loss term.

[0112]

[0113] Norm(·) represents the feature map normalization operation to eliminate the influence of scale differences on the distillation effect.

[0114] 2. Boundary-guided attention distillation

[0115] To enhance the ability of the baseline target detection model to represent cherry boundary regions, especially in densely distributed and occluded scenarios, a boundary heatmap generated by the DFL branch is introduced as a salient region guidance mechanism. Specifically, the boundary heatmap A generated by the DFL branch of the teacher model in the output head is used as the reference. T The student model corresponds to response A. S Perform KL divergence distillation:

[0116]

[0117] Among them, D KL (·) represents the Kullback-Leibler divergence, which measures the difference in responses between teachers and students in key boundary regions. This module guides students to learn more accurate predictive features near the boundaries.

[0118] 3. Grad-CAM significant region distillation

[0119] To guide the student model to focus on the same key regions of interest as the teacher model, a saliency heatmap is generated based on Grad-CAM technology to align the student feature map. Feature layer F is selected.l The Grad-CAM activation map is G T (Teacher) and G S (Student), construct the angle cosine similarity loss function:

[0120]

[0121] Here, <·,·> represents the inner product, and ||·||2 is the L2 norm. This loss term enhances the consistency of the student model's representation of the target region's feature orientation.

[0122] 4. Output layer soft label distillation

[0123] This invention retains the classic KL divergence distillation method in the Logits layer, guiding the student model to maintain an output distribution consistent with the teacher model in the final class prediction stage. The loss term is expressed as follows:

[0124]

[0125] Among them, T logits Represents the original output Logits, S of the teacher model. logits Let represent the original output Logits of the student model, σ(·) represent the softmax function, and τ represent the temperature coefficient used to smooth the probability distribution. Through soft label transfer, the student model can better learn inter-class boundaries.

[0126] 5. Overall distillation loss function

[0127] This invention combines the above four distillation strategies into a joint loss function to guide student models in performing multidimensional structure alignment and knowledge transfer during the distillation training phase:

[0128]

[0129] Where λ1, λ2, λ3, and λ4 represent the weights of the loss terms, which are adjusted based on the performance of the validation set. Commonly used settings are (1.0, 1.0, 0.5, 0.5).

[0130] See Figure 7 After applying the above structure-aware distillation mechanism to the student model with a pruning rate of 50%, the detection accuracy of the benchmark target detection model on the cherry test set was significantly improved, with mAP@0.5 reaching 90.9% and mAP@0.5:0.95 increasing to 63.5%, which is basically on par with the performance of the unpruned benchmark target detection model, while having lower computational overhead and higher inference speed.

[0131] Step 5: Training and Validating the Performance of the Optimized SEDDP-YOLO Model

[0132] After completing pruning and distillation optimization, in order to obtain a lightweight cherry detection model with high accuracy and efficiency, the distilled student model was trained end-to-end, and its performance was evaluated on the validation and test sets to ensure that the SEDDP-YOLO model meets the actual deployment requirements.

[0133] For training configuration, the SEDDP-YOLO model was trained using the PyTorch framework. The training hardware environment included an Intel i5-9300H CPU, an NVIDIA RTX 4090 GPU, and 64GB of RAM. The operating system was Windows 10, Python version 3.12.3, and the deep learning framework version was PyTorch 2.3.0 + CUDA 12.1. The training parameters were set as follows: 200 epochs, a batch size of 16, an initial learning rate of 0.01, and the SGD momentum optimizer with a momentum factor of 0.937 and a weight decay coefficient of 0.0005. The image input resolution was uniformly set to 640×640.

[0134] During training, the standardized dataset constructed in step two is used as input. The training set is used for SEDDP-YOLO model fitting, the validation set is used for hyperparameter tuning and performance monitoring, and the test set is used for final performance evaluation. In each training round, key performance metrics, including mAP (mean Average Precision), Precision, Recall, and F1-score, are recorded on the validation set. Simultaneously, the number of SEDDP-YOLO model parameters, computational complexity (GFLOPs), and inference frame rate (FPS) are recorded to evaluate the efficiency of the SEDDP-YOLO model.

[0135] After pruning and structure-aware distillation, the SEDDP-YOLO model performed as follows on the test set: mAP@0.5: 0.909; mAP@0.5: 0.95: 0.635; Precision: 0.918; Recall: 0.912; F1-score: 0.915; Inference speed: 177 FPS; Number of parameters in the SEDDP-YOLO model: 4.87M; Computational complexity: 3.7 GFLOPs.

[0136] Referring to Figure 8, to comprehensively evaluate the superiority of the SEDDP-YOLO model, typical lightweight object detection algorithms such as YOLOv3-Tiny, YOLOv5s, YOLOv8n, YOLOv10n, and RT-DETR-l were selected as comparison objects, and all were trained and tested on the same training and test sets. Experimental results show that the SEDDP-YOLO model, while maintaining a small model size and low computational load, outperforms the comparison models in the cherry detection task in terms of detection accuracy, especially showing significant improvements in mAP@0.5 and F1-score.

[0137] Step Six: Deployment and Application

[0138] After completing the training and validation of the optimized SEDDP-YOLO model, the final lightweight cherry detection model was deployed in a real-world application environment to verify its detection accuracy, response speed, and stability in real sorting tasks, further demonstrating its engineering feasibility and promotional value.

[0139] The SEDDP-YOLO model boasts excellent inference efficiency and platform compatibility, enabling deployment on various edge computing devices, including but not limited to NVIDIA Jetson AGX Xavier, Jetson Nano, Raspberry Pi with NPU acceleration modules, RK3588 edge terminals, and industrial camera embedded platforms. SEDDP-YOLO model files exported in ONNX format can be loaded using inference acceleration frameworks such as TensorRT, NCNN, or OpenVINO, achieving efficient, low-latency real-time detection.

[0140] Referring to Figure 9, during the deployment process, images of cherries on the conveyor belt are continuously acquired. A lightweight, optimized cherry detection model uses these images as input to automatically identify the cherry's maturity level (unripe, semi-ripe, ripe) and the presence of surface defects (such as cracks, spots, wormholes, etc.), and outputs the target category and location bounding box coordinates in real time. The detection results can be used to guide robotic arms, pneumatic devices, or sorting chutes in automatically sorting and classifying different types of cherries.

[0141] The present invention presents a systematic end-to-end detection process, encompassing key stages such as image acquisition, data annotation, model building, pruning and distillation training, performance evaluation, and deployment. The overall process design aims to achieve efficient and accurate identification of cherry ripeness and surface defects, while also possessing excellent lightweight deployment capabilities.

[0142] First, high-resolution image acquisition equipment was used to acquire cherry images from multiple angles, under varying lighting conditions, and with different ripeness and defect types in actual orchards and laboratory environments, constructing a representative and diverse original image set. The location, ripeness, and surface defect types of the cherries were then meticulously annotated using manual annotation tools, and the images were divided into training, validation, and test sets according to a standard ratio. Simultaneously, to enhance the generalization ability and robustness of the baseline target detection model, various data augmentation operations were implemented on the image samples, including rotation, scaling, brightness adjustment, and occlusion simulation.

[0143] After data preparation, an improved benchmark object detection model, Cherry-YOLO, was built based on the YOLOv8 architecture. The original modules were replaced with a FasterNet backbone and a DySlimNeck neck structure to improve the lightweight nature and small object detection capability of the benchmark model. The Detect-FRM detection head was introduced to enhance the accuracy of object boundary representation, and an improved AGF-CIoU loss function was used to optimize regression performance. This benchmark object detection model design significantly reduces computation and parameter count while maintaining detection accuracy, providing a foundation for subsequent compression and deployment.

[0144] To further reduce redundancy in benchmark target detection models, this invention designs a response-structure dual-guided pruning strategy. A multi-factor channel scoring function is constructed based on indicators such as channel gradient, activation, attention, and edge response. Combined with a module-aware mechanism, differentiated pruning is applied to different network regions. While preserving key detection paths, the channel retention ratio of the entire benchmark target detection model is controlled, effectively compressing the model size and improving inference efficiency.

[0145] To mitigate accuracy loss after pruning, this invention introduces a structure-aware distillation mechanism. The original, unpruned benchmark target detection model serves as the teacher model, guiding the student model through cross-layer distillation at four levels: feature alignment, boundary response, semantically salient regions, and the output layer. This restores the model's structural expressiveness and detection performance. Ultimately, the benchmark target detection model achieves a significant reduction in parameters and computational complexity while maintaining high accuracy, resulting in a good balance between structural compression and detection accuracy.

[0146] After training, the performance of the SEDDP-YOLO model was comprehensively evaluated on the test set. The results show that the SEDDP-YOLO model of this invention outperforms mainstream lightweight detection models in key metrics such as mAP, precision, and recall, demonstrating good stability and applicability. The final SEDDP-YOLO model is exported in ONNX format, supporting deployment on edge devices such as Jetson Xavier, Nano, and RK3588. Combined with inference acceleration frameworks such as TensorRT and NCNN, it can achieve high frame rate and low latency real-time cherry ripeness and surface defect detection. The overall process is not only applicable to the scenario described in this invention but can also be transferred to detection tasks for other fruits such as grapes, blueberries, and tomatoes, demonstrating strong scalability and industrial application value.

[0147] This invention constructs a fruit inspection method integrating image processing, model optimization, and intelligent analysis. Its significant advancement lies in achieving fully automated processing of cherries, from image acquisition and maturity / surface defect identification to intelligent grading output. By introducing a structure-aware pruning strategy and a multi-level distillation mechanism, combined with a FasterNet lightweight backbone, a Slim-Neck fusion structure, and a Detect-FRM detection head, this invention not only significantly reduces the parameters and computational overhead of the baseline target detection model but also maintains high detection accuracy in scenarios with complex backgrounds and densely distributed small targets. Simultaneously, the optimized loss function and multi-scale perception module significantly improve the boundary recognition capability and robustness of the baseline target detection model, providing reliable support for the real-time application of fruit sorting systems. In summary, the advancements of this invention are reflected in its precise model design, efficient lightweight strategy, and excellent practical deployment performance, demonstrating good engineering feasibility and promising prospects for industrial promotion.

[0148] Example 2:

[0149] This invention also provides a system for detecting the ripeness and surface defects of cherries, such as... Figure 10 As shown, the system includes an acquisition module, a modeling module, a training module, and a detection module. This system enables a closed-loop operation of the entire process of cherry image acquisition, annotation, modeling, training, and real-time detection. It is suitable for cherry ripeness and defect detection tasks in agricultural production sites, fruit and vegetable sorting workshops, and mobile harvesting equipment.

[0150] The acquisition module is used to acquire cherry image data, preprocess the cherry image data, and construct a cherry image dataset;

[0151] The modeling module is used to build the benchmark target detection model Cherry-YOLO based on the YOLOv8 model, perform response-structure dual-guided pruning operation on the benchmark target detection model Cherry-YOLO, and introduce a structure-aware cross-layer distillation mechanism to obtain the SEDDP-YOLO model.

[0152] The training module is used to train the SEDDP-YOLO model using a cherry image dataset to obtain a lightweight optimized cherry detection model.

[0153] The detection module is used to detect the ripeness and surface defects of cherries using a lightweight optimized cherry detection model, and complete the automatic detection and grading of cherries.

[0154] It is understood that the cherry ripeness and surface defect detection system provided by the present invention corresponds to the cherry ripeness and surface defect detection methods provided in the foregoing embodiments. The relevant technical features of the cherry ripeness and surface defect detection system can be referred to the relevant technical features of the cherry ripeness and surface defect detection methods, and will not be repeated here.

[0155] Another object of the present invention is to provide an electronic device, such as... Figure 11 As shown, it includes a memory, a processor, and a computer program stored in the memory and executable on the processor, the processor performing the steps of the cherry ripeness and surface defect detection method.

[0156] The method for detecting cherry ripeness and surface defects includes the following steps:

[0157] Collect cherry image data, preprocess the cherry image data, and construct a cherry image dataset;

[0158] Based on the YOLOv8 model, a benchmark target detection model Cherry-YOLO was constructed. The Cherry-YOLO benchmark target detection model was subjected to response-structure dual-guided pruning operation, and a structure-aware cross-layer distillation mechanism was introduced to obtain the SEDDP-YOLO model.

[0159] The SEDDP-YOLO model was trained using a cherry image dataset to obtain a lightweight optimized cherry detection model;

[0160] A lightweight optimized cherry detection model was used to detect cherry ripeness and surface defects, completing the automatic cherry detection and grading task.

[0161] A fourth objective of this invention is to provide a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the method for detecting cherry ripeness and surface defects.

[0162] The method for detecting cherry ripeness and surface defects includes the following steps:

[0163] Collect cherry image data, preprocess the cherry image data, and construct a cherry image dataset;

[0164] Based on the YOLOv8 model, a benchmark target detection model Cherry-YOLO was constructed. The Cherry-YOLO benchmark target detection model was subjected to response-structure dual-guided pruning operation, and a structure-aware cross-layer distillation mechanism was introduced to obtain the SEDDP-YOLO model.

[0165] The SEDDP-YOLO model was trained using a cherry image dataset to obtain a lightweight optimized cherry detection model;

[0166] A lightweight optimized cherry detection model was used to detect cherry ripeness and surface defects, completing the automatic cherry detection and grading task.

[0167] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0168] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0169] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0170] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0171] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and not to limit it. Although the present invention has been described in detail with reference to the above embodiments, those skilled in the art should understand that modifications or equivalent substitutions can still be made to the specific implementation of the present invention. Any modifications or equivalent substitutions that do not depart from the spirit and scope of the present invention should be covered within the scope of protection of the claims of the present invention.

Claims

1. A method for detecting the ripeness and surface defects of cherries, characterized in that, include: Collect cherry image data, preprocess the cherry image data, and construct a cherry image dataset; Based on the YOLOv8 model, a benchmark target detection model Cherry-YOLO was constructed. The Cherry-YOLO benchmark target detection model was subjected to response-structure dual-guided pruning operation, and a structure-aware cross-layer distillation mechanism was introduced to obtain the SEDDP-YOLO model. The SEDDP-YOLO model was trained using a cherry image dataset to obtain a lightweight optimized cherry detection model; A lightweight optimized cherry detection model was used to detect cherry ripeness and surface defects, completing the automatic cherry detection and grading task.

2. The method for detecting cherry ripeness and surface defects according to claim 1, characterized in that, Preprocessing of cherry image data includes: The cherry images were cleaned and enhanced. The ripeness and surface defect categories of cherries in the images were labeled manually. The cherry image data were divided into training set, validation set and test set according to a preset ratio.

3. The method for detecting cherry ripeness and surface defects according to claim 1, characterized in that, The backbone network of the benchmark target detection model Cherry-YOLO is a FasterNet-RepMixer structure, the neck network is a DySlimNeck structure, the detection head is a Detect-FRM structure, and the loss function is AGF-CIoU.

4. The method for detecting cherry ripeness and surface defects according to claim 1, characterized in that, The execution process of the response-structure dual-guided pruning operation includes: Before pruning, the gradient sensitivity, activation response intensity, attention allocation weight and edge response capability of each benchmark target detection model channel are calculated. Differentiated weight factors are set based on the function of each benchmark target detection model channel, and the channel importance score is obtained by combining the results. During the pruning process, channels are grouped according to the module-aware weight strategy, and the output weight of low-scoring channels is controlled by a hierarchical pruning + soft masking mechanism. Invalid channels are gradually shrunk during the training phase, and physical pruning is completed after training stabilizes to obtain a compressed lightweight model structure.

5. The method for detecting cherry ripeness and surface defects according to claim 4, characterized in that, The structure pruning method using layered pruning and soft masking is as follows: Each layer of the passageway is divided into several groups, and each group contains a fixed number of passageways. Sort the channel groups according to the scoring function and retain the high-scoring channel groups; A soft mask is introduced for the low-scoring group channel, and its feature output is multiplied by a dynamic decay coefficient during training. After training convergence, all channel groups with dynamic soft mask coefficients less than a set threshold are physically deleted to complete the structure pruning.

6. The method for detecting cherry ripeness and surface defects according to claim 1, characterized in that, Structure-aware cross-layer distillation mechanisms include feature alignment distillation, attention distillation, salient region distillation, and Logit output distillation.

7. The method for detecting cherry ripeness and surface defects according to claim 1, characterized in that, The training method for the SEDDP-YOLO model is as follows: The SEDDP-YOLO model was trained end-to-end using the training set in the cherry image dataset. The performance metrics of mAP@0.5, mAP@0.5:0.95, and F1 score were evaluated on the validation set in the cherry image dataset. The training of the SEDDP-YOLO model was completed when the performance metrics reached the preset standards.

8. A system for detecting cherry ripeness and surface defects, characterized in that, include: The acquisition module is used to acquire cherry image data, preprocess the cherry image data, and construct a cherry image dataset; The modeling module is used to build the benchmark target detection model Cherry-YOLO based on the YOLOv8 model, perform response-structure dual-guided pruning operation on the benchmark target detection model Cherry-YOLO, and introduce a structure-aware cross-layer distillation mechanism to obtain the SEDDP-YOLO model. The training module is used to train the SEDDP-YOLO model using a cherry image dataset to obtain a lightweight optimized cherry detection model. The detection module is used to detect the ripeness and surface defects of cherries using a lightweight optimized cherry detection model, and complete the automatic detection and grading of cherries.

9. A terminal device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 7.

10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 7.

Citation Information

Cited By

  • Multi-stage screening and quality detection method for peaches

    CN121354095A