Light-weight appearance detection system based on deep learning and optimized YOLO algorithm
By improving the YOLOv11 model and introducing CARAFE, C2f_ContextGuided, and Slim-Neck modules, the problems of detection accuracy and real-time performance in fruit appearance detection were solved, achieving efficient and accurate cherry ripeness detection, which is suitable for embedded devices.
Patent Information
- Application Number
- CN202511746815.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-26
- Publication Date
- 2026-01-06
AI Technical Summary
Existing fruit appearance inspection technologies lack accuracy and adaptability when dealing with complex backgrounds, lighting changes, and diverse fruit shapes. Furthermore, the high computational complexity of deep learning models makes it difficult to meet real-time requirements, resulting in high costs and low efficiency for manual inspection.
A lightweight appearance detection system based on deep learning and optimized YOLO algorithm is adopted. By introducing CARAFE, C2f_ContextGuided and Slim-Neck modules to improve the YOLOv11 model, the number of parameters is reduced and the detection accuracy and efficiency are improved. It is suitable for cherry ripeness detection.
It enables efficient and accurate real-time detection in diverse fruit appearance inspection tasks, significantly improving detection accuracy and efficiency, reducing computational costs, and is suitable for deployment on embedded devices.
Smart Images

Figure CN121280418A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of appearance inspection technology, specifically, it relates to a lightweight appearance inspection system based on deep learning and optimized YOLO algorithm. Background Technology
[0002] In modern agricultural production, the appearance quality of fruit is a crucial factor determining its market value. Fruit appearance inspection, including color, shape, size, and surface defects, is typically performed manually. However, manual inspection is inefficient and susceptible to subjective factors, leading to inconsistent and inaccurate results. This is especially true in large-scale fruit production, where the cost and time required for manual inspection increase significantly. Furthermore, fruit has a short shelf life after harvest; failure to grade and process it promptly can lead to a decline in quality and economic losses. While some automated inspection systems based on traditional machine vision have been applied to fruit appearance inspection, these systems still suffer from insufficient accuracy and adaptability when dealing with complex backgrounds, varying lighting conditions, and diverse fruit morphologies. Moreover, while existing deep learning models can improve detection accuracy, their high complexity and computational cost make them unsuitable for the real-time inspection needs of large-scale orchards.
[0003] In existing fruit appearance inspection technologies, the most commonly used solutions are inspection systems based on traditional machine vision and deep learning algorithms. These systems mainly acquire images of the fruit's appearance through cameras and use image processing techniques or convolutional neural networks (CNNs) to extract features to identify appearance features such as the fruit's color, shape, and surface defects. Traditional machine vision techniques analyze fruit color, shape, and size using fixed image processing algorithms (such as edge detection and morphological processing). While these methods can achieve basic fruit appearance detection to a certain extent, they suffer from poor adaptability to complex environments. For example, when the fruit has a complex background, significant lighting variations, or subtle surface defects, traditional algorithms are easily affected, leading to decreased detection accuracy. Furthermore, traditional machine vision methods lack sufficient intelligence and flexibility, making them ineffective for handling non-standardized and highly heterogeneous fruit appearance detection tasks.
[0004] Convolutional neural networks have seen significant development in fruit appearance detection, but their high computational complexity, especially when processing high-resolution images or large-scale datasets, leads to increased computational and storage resource requirements, increasing the cost of detection equipment and making it difficult to meet real-time requirements. Furthermore, existing deep learning models, such as YOLO and Faster R-CNN, while improving detection accuracy, have large parameter counts and model sizes, making them difficult to run efficiently on embedded devices or in resource-constrained environments, thus limiting the widespread application of this technology. Poor real-time performance: Due to the high model complexity, existing deep learning-based fruit detection systems are slow when processing large numbers of images, making efficient real-time detection difficult, especially in rapid harvesting and production lines, where this latency impacts production efficiency. Summary of the Invention
[0005] To address the shortcomings of existing fruit appearance inspection technologies, this invention proposes a lightweight appearance inspection system based on deep learning and an optimized YOLO algorithm. It improves upon YOLOv11 to better suit cherry ripeness detection. The improved model, named GCS-YOLOv11, achieves efficient and accurate real-time detection in diverse fruit appearance inspection tasks by introducing a lightweight neural network structure and optimized detection algorithm. This solves the efficiency, cost, and accuracy problems of existing technologies in fruit inspection, promoting the development of smart agriculture.
[0006] This invention is achieved through the following technical solution: A lightweight appearance detection method based on deep learning and optimized YOLO algorithm: The method specifically includes the following steps: Step 1: Collect fruit image data under different lighting conditions using high-resolution cameras deployed in orchards or production lines, and preprocess the data to obtain an labeled dataset. Step 2: Perform image enhancement operations on the image marked in Step 1; Step 3: Improve the YOLOv11n model and train it using the data from Step 2: Step 4: Deploy the trained model to the testing environment and design evaluation metrics to assess the model's generalization ability. Step 5: Deploy the model onto an embedded device; capture fruit images through a camera connected to the embedded device, perform appearance inspection and grading operations on the fruit, and achieve lightweight appearance inspection.
[0007] Furthermore, in step one, each image is manually annotated to mark in detail the appearance defects, color, and shape information of the fruit, thereby generating a standard inspection label.
[0008] Furthermore, in step two, the image enhancement includes adjusting the image brightness and contrast, and performing random rotation, random flipping, random brightness adjustment, and mosaic processing on the image to generate diverse training samples. Furthermore, in step three, the improved YOLOv11n model specifically refers to: In step three, the improved YOLOv11n model specifically refers to: In the backbone section, the CARAFE module is used to replace the traditional upsampling operation; Introducing the C2f_ContextGuided module to replace the traditional C3 module; In the Neck section, the Slim-Neck module is introduced to optimize the feature fusion process: GSConv is used to replace regular convolution; and the VoVGSCSP module is used to replace the C2F module.
[0009] Furthermore, in step three, the improved YOLOv11n model is trained using the preprocessed and labeled dataset from step one. During training, the learning rate, batch size, and number of training epochs are adjusted and optimized. Cross-validation is used to ensure that the model achieves optimal performance.
[0010] Furthermore, in step four, the model is tested using a test set of images containing fruits of different types, colors, and growing environments. The evaluation focuses on the model's real-time performance, accuracy, and stability in fruit appearance detection tasks, with particular emphasis on its generalization ability, i.e., its effectiveness in detecting fruit under various conditions.
[0011] Furthermore, in step five, the detection model is run in real time on the embedded device to perform appearance inspection and grading operations on the fruit. Based on the model tested in step four, the appearance features of the fruit are identified by real-time detection of the input image, and the fruit is automatically graded according to color, shape and surface defects; the fruit is divided into different grades by setting thresholds.
[0012] A lightweight appearance detection system based on deep learning and optimized YOLO algorithm: The detection system includes a preprocessing module, a lightweight improvement module, a testing module, and an application module. The preprocessing module acquires fruit image data under different lighting conditions through high-resolution cameras deployed in orchards or production lines, and performs preprocessing to obtain an labeled dataset; and performs image enhancement operations on the labeled images. The lightweight improvement module is used to improve the YOLOv11n model and train it using the processed data: The testing module deploys the trained model to the testing environment and designs evaluation metrics to assess the model's generalization ability. The application module deploys the model onto an embedded device; it captures fruit images through a camera connected to the embedded device, performs appearance inspection and grading operations on the fruit, and achieves lightweight appearance inspection.
[0013] An electronic device includes a memory and a processor, the memory storing a computer program, the processor executing the computer program to implement the steps of the above method.
[0014] A computer-readable storage medium for storing computer instructions that, when executed by a processor, implement the steps of the above-described method.
[0015] Beneficial effects of the invention This invention improves the YOLOv11n model to obtain the GCS-YOLOv11 model, which can perform cherry ripeness detection tasks for cherry images from different angles and under different environments, providing a theoretical basis for subsequent intelligent harvesting work. (1) In the backbone network of YOLOv11, the ADown module (downsampling convolution) and the Cnotext Guided Block module with contextual feature extraction are introduced to replace the original C2F. In the Neck part, the VoVGSCSP module and GSConv are used to replace the original structure. The improved GCS-YOLOv11 model has a significantly reduced number of parameters and improved detection accuracy, effectively improving the accuracy and efficiency of image detection. (2) After comparing and evaluating the experimental results of YOLOv3-tiny, YOLOv5n, YOLOv6, YOLOv11n and the proposed model (Ours), the GCS-YOLOv11 model achieved a precision of 92.94%, a recall of 90.66%, and a MAP50 of 96.57%. Compared with the YOLOv5n model, the precision improved by 9.75 percentage points, the recall improved by 7.92 percentage points, and the MAP50 improved by 7.69 percentage points; compared with the original YOLOv11n model, the precision improved by 2.62 percentage points, the recall improved by 1.57 percentage points, and the MAP50 improved by 2.08 percentage points. This indicates that the GCS-YOLOv11 model has made significant progress in reducing false negatives and false positives, and has greatly improved the model's recognition performance. In terms of model parameter count, the GCS-YOLOv11 model has only 2.05M parameters and a model size of just 4.25MB, making it the model with the fewest parameters among the compared models, demonstrating better lightweight performance compared to other models. Furthermore, the GCS-YOLOv11 model has a GFLOPS of 5.4, significantly lower than other models, indicating its faster inference speed. In conclusion, the GCS-YOLOv11 model exhibits significant advantages in accuracy, speed, and lightweight design, demonstrating excellent performance.
[0016] (3) Through detection tests on cherry ripeness images from different angles and in different environments, the results show that the GCS-YOLOv11 model performs best in terms of recognition confidence and has a significant advantage in cherry ripeness detection tasks. It can be seen that the GCS-YOLOv11 model not only significantly improves recognition accuracy, but also provides an important reference for cherry ripeness assessment and intelligent harvesting technology. Attached Figure Description
[0017] Figure 1 The examples show various real growth postures of cherries in the embodiments of the present invention, including (a) single, (b) bright light, (c) dark light, (d) multiple, (e) shading, and (f) overlapping.
[0018] Figure 2 Cherries are classified as (a) ripe cherries, (b) unripe cherries and (c) semi-ripe cherries.
[0019] Figure 3 The image shows a cherry image after offline data enhancement according to the present invention, wherein (a) is the original image, (b) is a random brightness, (c) is a random rotation, (d) is the original image, (e) is rotated 90°, and (f) is a mosaic.
[0020] Figure 4 This is the original YOLOv11 model.
[0021] Figure 5 This is a diagram of the GCS-YOLOv11 network structure of the present invention.
[0022] Figure 6 This is a structural diagram of CARAFE.
[0023] Figure 7 This is a structural diagram of the Cnotext Guided Block module.
[0024] Figure 8 This is a structural diagram of the GSConv module.
[0025] Figure 9 The module structure is VoVGSCSP and GSbottleneck.
[0026] Figure 10 The graphs show the mAP and Precision results of the ablation experiment of this invention.
[0027] Figure 11 The graph shows the parameter results of the ablation experiment.
[0028] Figure 12 This is a diagram showing the comparative experimental results of this invention and other YOLO models.
[0029] Figure 13 This is a comparison chart of the recognition results of the original image, the original YOLOv11 model, and the GCS-YOLOv11 model of this 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] Unless otherwise specified, the experimental methods used in the following examples are conventional methods. Unless otherwise specified, the materials, reagents, methods, and instruments used are all conventional materials, reagents, methods, and instruments in the art, and can be obtained commercially by those skilled in the art.
[0032] A lightweight appearance detection method based on deep learning and optimized YOLO algorithm: The method specifically includes the following steps: Step 1: Collect fruit image data under different lighting conditions using high-resolution cameras deployed in orchards or production lines, and preprocess the data to obtain an labeled dataset; manually annotate each image to mark detailed information such as the appearance defects, color, and shape of the fruit, thereby generating a standard inspection label.
[0033] In this embodiment, the cherry ripeness dataset used was collected from May 1st to May 20th, 2024, within a cherry orchard in Wujing Town, Linqu County, Weifang City, Shandong Province, China. Images were captured using an iPhone 11 phone between 09:00 and 18:00 daily, at a distance of approximately 10-50 cm. To mitigate the risk of overfitting the network model due to limited diversity in the training samples, images were captured from left, right, and front angles. These images also encompassed various realistic cherry growth postures, including overlapping and adherent fruit. A total of 1681 cherry images were collected and saved in JPEG format with a resolution of 3024 × 4034 pixels. The collected images underwent data cleaning and filtering to remove low-quality images, such as those that were excessively blurry, severely overexposed, severely occluded, or irrelevant. This process resulted in a cherry ripeness dataset consisting of 1201 images. Figure 1 As shown.
[0034] To annotate the cherry images, rectangular regions were manually marked using MakeSense image annotation software. During annotation, the annotation boxes were placed as close to the targets as possible to minimize background pixel interference. After annotation, a series of TXT files were generated, with each image name corresponding to a specific TXT file name, and each line in the TXT file corresponding to one of the targets in the image. The target cherries were categorized into three types: ripe cherries, unripe cherries, and semi-ripe cherries, as shown below. Figure 2 As shown.
[0035] Step 2: Perform image enhancement operations on the acquired images. Image enhancement includes, but is not limited to, adjusting image brightness and contrast, and performing image rotation, flipping, cropping, and other processing to generate diverse training samples. In this embodiment, the deep learning network relies on a large amount of labeled data during feature extraction and learning. Noise and errors in the dataset can have a significant negative impact on model performance.
[0036] When a dataset contains a large amount of mislabeled or inaccurate data, the model may fail to learn patterns effectively. With a limited dataset, overfitting can occur, causing the network to overemphasize noise and interference in the images, thus reducing test accuracy.
[0037] To address this issue, an offline data augmentation program was employed, using techniques such as random rotation, random brightness, and mosaic to enhance the model's generalization ability and robustness, thereby mitigating the effects of overfitting. Data augmentation was performed on 1201 labeled images, generating 6416 augmented images. The dataset was then divided into training, validation, and test sets, containing 4997, 714, and 705 images respectively. Figure 3 As shown.
[0038] Step 3: Improve the YOLOv11n model and train it using the data from Step 2: In step three, the improved YOLOv11n model specifically refers to: In the backbone section, the CARAFE module is used to replace the traditional upsampling operation; A content-aware reconstructed feature module, CARAFE, is introduced to improve feature reconstruction quality by dynamically generating adaptive convolutional kernels, significantly enhancing the detection accuracy of small targets and scenes with blurred edges. The CARAFE module consists of a kernel prediction module and a feature reconstruction module, reducing computational burden while avoiding artifacts and mesh effects.
[0039] Introducing the C2f_ContextGuided module to replace the traditional C3 module: By fusing multi-scale features through a context-guided mechanism, the model's ability to perceive complex backgrounds and target shapes is enhanced. This module optimizes the collaborative relationship between deep and shallow features, improving detection robustness while reducing the number of parameters by 31%.
[0040] In the Neck section, the Slim-Neck module is introduced to optimize the feature fusion process: GSConv is used to replace regular convolution: the implicit connectivity of channels is preserved, redundant computation is reduced, and real-time performance is significantly improved; the VoVGSCSP module is used to replace the C2F module: the combination of GSConv and standard convolution forms a residual bottleneck structure, which promotes gradient flow and avoids information loss.
[0041] YOLO (You Only Look Once) is a high-efficiency and accurate single-stage object detection algorithm. This model divides the entire image into multiple grids, predicts the confidence level of whether an object exists in each grid, generates corresponding bounding boxes, and finally outputs the detection results using non-maximum suppression (NMS). Due to its balance of speed and accuracy, the YOLO series has been widely used in the field of object detection.
[0042] YOLOv11 is a further improvement on the YOLO series, designed to enhance detection accuracy for small targets and targets in complex backgrounds while maintaining detection speed. The model continues the lightweight design philosophy of YOLOv8 in its overall architecture and introduces a Content-Aware Reconstructed Feature Module (CARAFE) in the feature fusion stage to replace traditional upsampling operations.
[0043] The CARAFE module generates adaptive upsampling convolutional kernels for each location through a kernel prediction mechanism and combines this with content reconstruction to achieve high-quality upsampling of the feature map, thereby effectively improving the accuracy and spatial resolution of feature recovery. Compared with the bilinear interpolation or transposed convolution methods commonly used in YOLOv8, CARAFE demonstrates superior performance in small object detection tasks, and is particularly suitable for scenarios with large differences in target size and blurred edges.
[0044] Structurally, YOLOv11 continues to use the C2F module to enhance feature extraction capabilities, while retaining the decoupled head structure and anchorless detection mechanism. At the same time, it optimizes the weight allocation of the loss function, enabling the model to further improve its ability to detect edge and occluded targets while ensuring inference speed.
[0045] In practical applications, lightweight models can significantly reduce computational costs and improve detection efficiency. Therefore, in step three, YOLOv11 is improved to better suit cherry ripeness detection. The improved model is named GCS-YOLOv11. Its optimization points mainly include the following aspects: First, in the backbone network, the CARAFE module is used to replace the traditional upsampling operation, and the C2f_ContextGuided module is introduced to enhance feature extraction capabilities.
[0046] Secondly, in the Neck section, the GSConv module replaces the conventional convolution operation to further improve computational efficiency.
[0047] Furthermore, the C2F module was improved to a VoVGSCSP module. These optimizations significantly improved detection performance while maintaining the model's lightweight design. Figure 4 The original network structure of YOLOv11 is shown, and Figure 5 This is the improved Yolov11 network structure, with the key improvements highlighted in red.
[0048] Specifically, CARAFE consists of two main modules: the upsampling kernel prediction module and the feature recombination module.
[0049] (1) The content-aware reconstructed feature module CARAFE is introduced to replace traditional upsampling methods such as nearest neighbor interpolation, bilinear interpolation, or transposed convolution. CARAFE is a lightweight upsampling method based on a content-aware mechanism that can adaptively generate dynamic convolution kernels based on the local content of the input feature map, thereby achieving higher quality feature reconstruction. Compared with conventional upsampling methods, CARAFE has the following significant advantages: First, its core feature is dynamic perception. CARAFE analyzes the content of the feature map through the kernel prediction submodule and generates adaptive convolution kernel weights for each position, enabling the upsampling process to better adapt to the target shape and edge features, thereby effectively improving the model's ability to detect small targets and complex structures. This perception capability is particularly suitable for high-density, occluded, and target size differences.
[0050] Secondly, the CARAFE module maintains high feature representation capability while improving spatial resolution. Traditional upsampling methods often lead to blurred or distorted details due to fixed interpolation strategies, while CARAFE significantly improves the accuracy of reconstructed feature maps through content-based feature reconstruction, helping to maintain the integrity of target edge and texture information, thereby enhancing detection robustness and accuracy. Finally, the CARAFE module has a simple structure and small number of parameters, making it easy to integrate into the backbone network with almost no additional computational burden. Compared with complex transposed convolutions, CARAFE effectively avoids artifacts and mesh effects while maintaining efficient inference, providing a good foundation for the deployment of the model on edge computing devices. Therefore, the introduction of the CARAFE module not only optimizes the model's feature fusion process but also significantly improves detection accuracy and the model's generalization ability while maintaining a lightweight structure, making the model perform better in multi-scene, multi-scale target detection tasks.
[0051] (2) To further enhance the model's feature extraction and context information integration capabilities, the C2f_ContextGuided module was introduced to replace the traditional C3 module. This module aims to optimize feature capture and fusion through deeper contextual guidance, thereby improving the model's target detection performance in complex scenarios. First, the C2f_ContextGuided module incorporates a contextual guidance mechanism during feature extraction, effectively improving the model's comprehensive understanding of local and global features. The traditional C3 module primarily focuses on local feature extraction, while the C2f_ContextGuided module, by introducing contextual information, enables the model to capture target features more comprehensively at different scales, thus improving sensitivity to target location, size, and shape. This improvement is particularly suitable for scenarios with complex backgrounds or variable target locations, helping to improve the accuracy of target detection.
[0052] Secondly, the C2f_ContextGuided module enhances the collaborative relationship between multi-scale features by fusing deep and shallow features. This module not only captures richer feature information through hierarchical convolution but also optimizes the fusion of multi-layer features through context guidance, thereby improving the model's generalization ability at different scales. Especially when detecting objects of varying sizes, the C2f_ContextGuided module ensures high detection accuracy for different target sizes. Furthermore, the introduction of the C2f_ContextGuided module further optimizes computational complexity while achieving efficient feature fusion. Through the rational use of contextual information, the model can maintain high detection accuracy while reducing computational load, achieving a balance between performance and efficiency. This lightweight design is of great significance for real-time detection in practical applications, especially under conditions of limited computing resources. Therefore, the C2f_ContextGuided module effectively improves the model's detection accuracy and generalization ability through context guidance and multi-scale feature fusion, while optimizing computational efficiency to ensure the model maintains high detection performance in complex environments.
[0053] (3) A Slim-Neck module was introduced, which consists of two parts: GSConv and VoVGSCSP. Specifically, GSConv is integrated into the Neck part, and some C2F modules are replaced with VoV-GSCSP modules.
[0054] GSConv accelerates prediction computation because image processing in convolutional neural networks (CNNs) typically involves a gradual transformation from spatial information to channel information. Traditional dense convolutions preserve hidden connections to maintain information transfer as much as possible, while sparse convolutions may sever these connections. GSConv significantly reduces the impact of model depth on computational efficiency while preserving connections, especially when processing elongated feature maps in the Neck stage, eliminating the need for information compression.
[0055] Therefore, GSConv is particularly suitable for the Neck part because the feature maps no longer require further compression, and GSConv can reduce redundant information while maintaining information transmission. This characteristic allows GSConv to improve the efficiency of feature processing while reducing computational complexity, making it especially suitable for applications such as real-time monitoring. To make the oyster mushroom grading model more lightweight, a lightweight convolutional structure is adopted in the Neck part, in which GSConv becomes the optimal choice, significantly reducing the model's computational cost while ensuring efficient prediction.
[0056] (3.1) GSConv provides an effective strategy that significantly reduces model complexity while maintaining model accuracy, achieving a better balance between accuracy and speed. Furthermore, GSConv introduces the Slim-Neck design paradigm, significantly improving the computational efficiency and cost-effectiveness of the detector. In the embodiment, the VoVGSCSP module replaces the C2F module in the Neck section, further improving the model's computational efficiency and overall performance. Figure 8 As shown.
[0057] (3.2) In GSbottleneck, two GSConv operations and one standard convolution operation are defined and applied. The standard convolution operation helps to promote gradient flow and avoid gradient vanishing. This structure is similar to residual connections, encouraging the network to learn the residual between the input and output, thereby improving training efficiency and performance. The final output is summed rather than simply concatenated to form the bottleneck structure for residual learning. Figure 9 As shown.
[0058] Finally, the improved YOLOv11n lightweight model was trained using a preprocessed and labeled dataset. During training, hyperparameters such as learning rate, batch size, and number of training epochs were adjusted and optimized. Cross-validation was used to ensure that the model achieved optimal performance.
[0059] Step 4: Deploy the trained model to the testing environment to evaluate its generalization ability; In this embodiment, the hardware environment of the cherry dataset training and testing experimental platform designed in this invention is as follows: CPU is a 12th generation Intel Core i5-12490F@3.00 GHz, GPU is an NVIDIA GeForce® RTX 4060 (8 gigabytes of video memory), RAM is 32 gigabytes (32 MHz), operating system is 64-bit Windows 10, CUDA version 12.1, PyCharm 2022 1.1, PyTorch 2.1.0, and Python version 3.8. All comparative experiments in this invention were conducted in the same environment. The training configuration was: learning rate 0.01, momentum 0.937, weight decay 0.0005, batch size 16, a total of 300 iterations, and image size 640 × 640 pixels. Table 1 shows the configuration information of the experimental environment.
[0060] Table 1. Experimental Environment Configuration
[0061] In step four, the model is tested using a test set of images containing fruits of different types, colors, and growing environments. The evaluation focuses on the model's real-time performance, accuracy, and stability in fruit appearance detection tasks, with particular emphasis on its generalization ability, i.e., its effectiveness in detecting fruit under various conditions.
[0062] In step four, the evaluation indicators are as follows: The performance of YOLOv11 and improved models is evaluated using a combined metric of recall, precision, AP, mAP, and F1 score. TP (True Positive) represents the number of cherry tomatoes accurately identified by the YOLOv11 network model. FP (False Positive) represents the number of cherry tomatoes incorrectly identified by the YOLOv11 network model. FN (False Negative) is the number of actual cherry tomatoes the model failed to identify. Recall (R) represents how many actual cherry tomato samples were correctly identified. The ratio of true positive (TP) detections to the sum of true positives and false negatives (FN) reflects the model's ability to identify all relevant instances. Precision (P) represents how many optimistically predicted cherry tomato samples were correct. It is the ratio of accurate positive detections to the sum of true positives and false positives (FP). AP (mean precision) for a specific class is calculated as the ratio of true positives to the adjusted sum of true positives and false negatives divided by the number of instances (N). This measures precision at different recall levels. The average AP values across multiple classes are mAP (mean mean precision), with higher values indicating higher average precision for each class. The F1 score is the harmonic mean of Precision and Recall, providing a single metric that balances both. This is advantageous when the class distribution is uneven.
[0063]
[0064]
[0065]
[0066]
[0067]
[0068] Step 5: Deploy the model onto an embedded device (such as Raspberry Pi, NVIDIA Jetson, etc.); capture fruit images through a camera connected to the embedded device, perform appearance inspection and grading operations on the fruit, and achieve lightweight appearance inspection.
[0069] In step five, the detection model is run in real time on the embedded device to perform appearance inspection and grading of the fruit. Based on the model tested in step four, the appearance features of the fruit are identified by real-time detection of the input image, and the fruit is automatically graded according to color, shape and surface defects. By setting reasonable thresholds, the fruit is divided into different grades to meet market demand.
[0070] The test results can be displayed in real time, and can be combined with subsequent processing equipment such as automatic sorting machines to grade the fruits according to their appearance quality.
[0071] After being designed to be lightweight, the system can be deployed on embedded or mobile devices, supporting real-time detection in orchards or on mobile platforms, effectively reducing hardware costs and energy consumption.
[0072] Meanwhile, the test data can be transmitted to a central server via the network for further data analysis, production forecasting, and market decision-making.
[0073] By introducing the CARAFE module (Content-Aware Reconstruction Feature Module) and the Cnotext Guided Block module with contextual feature extraction into the YOLOv11 backbone network to replace the original C2F, and using the VoVGSCSP module and GSConv to replace the original structure in the Neck part, the improved GCS-YOLOv11 model has significantly reduced parameters, improved detection accuracy, and effectively enhanced image detection accuracy and efficiency.
[0074] After comparing and evaluating the experimental results of YOLOv3-tiny, YOLOv5n, YOLOv6, YOLOv8n, YOLOv11, and our proposed model (Ours), the model achieved a precision of 92.94%, a recall of 90.66%, and a MAP50 of 96.57%. Compared to the YOLOv5n model, the precision improved by 9.75 percentage points, the recall by 7.92 percentage points, and the MAP50 by 7.69 percentage points; compared to the original YOLOv8n model, the precision improved by 2.62 percentage points, the recall by 1.57 percentage points, and the MAP50 by 2.08 percentage points. This demonstrates that the GCS-YOLOv11 model has made significant progress in reducing false negatives and false positives, greatly improving the model's recognition performance. In terms of model parameter count, the GCS-YOLOv11 model has only 2.05M parameters and a model size of just 4.25MB, making it the model with the fewest parameters among the compared models, demonstrating better lightweight performance compared to other models. Furthermore, the GCS-YOLOv11 model has a GFLOPS of 5.4, significantly lower than other models, indicating its faster inference speed. In conclusion, the GCS-YOLOv11 model exhibits significant advantages in accuracy, speed, and lightweight design, demonstrating excellent performance.
[0075] Overall, the improved model has significantly improved detection performance and is more lightweight (see the comparison of ablation experiment results in Table 2), making the YOLOv11 network more suitable for target detection tasks on the cherry ripeness dataset.
[0076] Table 2 presents the ablation experiment results. (Based on Table 2 and...) Figure 10 This will demonstrate the accuracy and recall of the improved model of the present invention in cherry ripeness detection.
[0077] Table 2 Comparison of Fusion Experiment Results
[0078] Figure 10 The increase in mAP50 and accuracy value for each module is explained one by one. Figure 11 illustrates the change in the number of model parameters after replacing each module.
[0079] exist Figure 10 In the diagram, S indicates that GSConv replaces the regular convolutions in the Neck section, and VoVGSCSP replaces some regular C2F modules in the Neck section; C indicates that CARAFE replaces some regular convolutions in the Backbone section; and C indicates that C2F modules in the backbone network are replaced.
[0080] Figure 11 In the figure, model A represents the number of parameters of the original YOLOv11 model, model B represents the number of parameters with the CARAFE module added, model C represents the number of parameters using both CARAFE and Slim-Neck modules, and model D represents the number of parameters of our improved GCS-YOLOv11 model. As can be clearly seen from the figure, the improved GCS-YOLOv11 model has the fewest parameters among all models, with a 32% reduction in parameters compared to the original YOLOv11 model.
[0081] By comparing with mainstream models such as YOLOv3-tiny (Darknet-19), YOLOv5 (CSPDarknet53), YOLOv6 (EfficientRep), and YOLOv8n (Darknet53), we verified that the detection performance of our improved model is superior to other models. Furthermore, the improved model has significantly lower parameter count, model size, and GFLOPS computational cost compared to other models. YOLOv3-tiny was chosen as the comparison model because YOLOv8n is a lightweight model, while the original version of YOLOv3 is quite large; therefore, we selected its lightweight version for comparison with YOLOv11. Table 3 shows the experimental results comparison of different models.
[0082] Table 3 Comparison of GCS-YOLOv11 and other YOLO models
[0083] Experimental results show that the GCS-YOLOv11 model achieved an mAP50 of 96.57% on the validation set, a 2.08% improvement compared to the YOLOv11 model's 94.49%. Simultaneously, the number of parameters and computational cost of Ours are 68.08% and 66.67% of the YOLOv11 model, respectively. Compared to YOLOv3-tiny, GCS-YOLOv11 improved accuracy by 5.92%, while reducing the number of parameters and computational cost by 83.07% and 71.43%, respectively. Compared to models such as YOLOv5n and YOLOv6, GCS-YOLOv11 has a significant advantage in accuracy while maintaining lower computational and parameter costs. Through these improvements, GCS-YOLOv11 achieves a good balance between accuracy and efficiency, making it suitable for deployment in edge computing environments. Figure 13 The comparison of mAP50 values during the training process of the YOLO series models shows that the improved model is more effective.
[0084] By testing cherry ripeness images from different angles and in different environments, the results show that the GCS-YOLOv11 model performs best in terms of recognition confidence, demonstrating a significant advantage in cherry ripeness detection. Therefore, the GCS-YOLOv11 model not only significantly improves recognition accuracy but also provides important reference for cherry ripeness assessment and intelligent harvesting technology.
[0085] Figure 13 The graph shows a comparison of model parameters. As can be seen from the graph, the number of parameters in this improved model has decreased, and the accuracy has also improved. It is very helpful for cherry ripeness detection and is an effective detection model.
[0086] A lightweight appearance detection system based on deep learning and optimized YOLO algorithm: The detection system includes a preprocessing module, a lightweight improvement module, a testing module, and an application module. The preprocessing module acquires fruit image data under different lighting conditions through high-resolution cameras deployed in orchards or production lines, and performs preprocessing to obtain an labeled dataset; and performs image enhancement operations on the labeled images. The lightweight improvement module is used to improve the YOLOv11n model and train it using the processed data: The testing module deploys the trained model to the testing environment and designs evaluation metrics to assess the model's generalization ability. The application module deploys the model onto an embedded device; it captures fruit images through a camera connected to the embedded device, performs appearance inspection and grading operations on the fruit, and achieves lightweight appearance inspection.
[0087] An electronic device includes a memory and a processor, the memory storing a computer program, the processor executing the computer program to implement the steps of the above method.
[0088] A computer-readable storage medium for storing computer instructions that, when executed by a processor, implement the steps of the above-described method.
[0089] The memory in the embodiments of this application can be volatile memory or non-volatile memory, or may include both volatile and non-volatile memory. Non-volatile memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. Volatile memory can be random access memory (RAM), which is used as an external cache. By way of example, but not limitation, many forms of RAM are available, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate synchronous DRAM (DDR SDRAM), enhanced synchronous DRAM (ESDRAM), synchronous linked DRAM (SLDRAM), and direct rambus RAM (DR RAM). It should be noted that the memory of the methods described in this invention is intended to include, but is not limited to, these and any other suitable types of memory.
[0090] In the above embodiments, implementation can be achieved entirely or partially through software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented entirely or partially in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired means such as coaxial cable, optical fiber, digital subscriber line, DSL, or wireless means such as infrared, wireless, microwave, etc. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium such as a floppy disk, hard disk, magnetic tape; an optical medium such as a high-density digital video disc, DVD; or a semiconductor medium such as a solid-state disk, SSD, etc.
[0091] In implementation, each step of the above method can be completed by integrated logic circuits in the processor's hardware or by instructions in software. The steps of the method disclosed in the embodiments of this application can be directly implemented by a hardware processor, or by a combination of hardware and software modules in the processor. The software modules can reside in random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, or other mature storage media in the art. This storage medium is located in memory, and the processor reads information from the memory and, in conjunction with its hardware, completes the steps of the above method. To avoid repetition, detailed descriptions are omitted here.
[0092] It should be noted that the processor in the embodiments of this application can be an integrated circuit chip with signal processing capabilities. During implementation, each step of the above method embodiments can be completed by the integrated logic circuits in the processor's hardware or by instructions in software form. The processor can be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of this application can be directly embodied as execution by a hardware decoding processor, or as execution by a combination of hardware and software modules in the decoding processor. The software modules can be located in random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, or other mature storage media in the art. This storage medium is located in memory; the processor reads information from the memory and, in conjunction with its hardware, completes the steps of the above methods.
[0093] The foregoing has provided a detailed description of the lightweight appearance detection system based on deep learning and optimized YOLO algorithm proposed in this invention, and has elucidated the principles and implementation methods of this invention. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of this invention. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this invention. Therefore, the content of this specification should not be construed as a limitation of this invention.
Claims
1. A lightweight appearance detection method based on deep learning and optimized YOLO algorithm, characterized in that: the method comprises the following steps: Step one: collect fruit image data under different light conditions by deploying high-resolution cameras in orchards or production lines, and pre-process to obtain labeled data sets; Step two: perform image enhancement operations on the labeled images of step one; Step three: improve the YOLOv11n model and train it with the data from step two; Step four: deploy the trained model to the test environment and design evaluation indicators to evaluate the generalization ability of the model; Step five: deploy the model to an embedded device; collect fruit pictures through the camera connected to the embedded device, and perform appearance detection and grading operations on the fruit to achieve lightweight appearance detection.
2. The method of claim 1, wherein: In step one, each image is manually labeled, with detailed labeling of fruit appearance defects, color and shape information, to generate standard detection labels.
3. The method of claim 2, wherein: In step two, the image enhancement includes adjusting image brightness and contrast, randomly rotating, flipping, adjusting brightness and mosaic processing to generate diverse training samples.
4. The method of claim 3, wherein: In step three, the improved YOLOv11n model is as follows: In the Backbone part, replace the traditional upsampling operation with the CARAFE module; Introduce C2f_ContextGuided module to replace the traditional C3 module; In the Neck part, introduce Slim-Neck module to optimize the feature fusion process: use GSConv instead of regular convolution; use VoVGSCSP module to replace C2F module.
5. The method of claim 4, wherein: In step three, use the pre-processed and labeled data set of step one to train the improved YOLOv11n model, and adjust and optimize the learning rate, batch size and training rounds during training; use cross-validation method to ensure the model reaches optimal performance.
6. The method of claim 5, wherein: In step four, use the test set pictures containing fruits of different types, different colors and different growing environments to test the model; Evaluate the performance of YOLOv11 and the improved model using the following evaluation indicators; the evaluation indicators include: TP represents the number of cherry tomatoes accurately identified by the YOLOv11 network model; FP represents the number of cherry tomatoes incorrectly identified by the YOLOv11 network model; FN is the number of actual cherry tomatoes that the model cannot identify; recall rate represents how many actual cherry tomato samples are correctly identified; The ratio of true positive detection to the sum of true positive and false negative reflects the ability of the model to identify all relevant instances; Precision represents how many optimistically predicted cherry tomato samples are correct, which is the ratio of accurate positive detection to the sum of true positive and false positive. The AP of a specific class is calculated as the ratio of true positives to the adjusted sum of true positives and false negatives divided by the number of instances, which measures the precision at different recall levels; The average of the AP values of multiple classes is mAP, and the higher the value, the higher the average precision of the model for detecting each class; The F1 score is the harmonic mean of Precision and Recall, providing a single indicator that balances the two.
7. The method of claim 6, wherein: In step five, the detection model is run in real time on the embedded device to perform appearance detection and grading of the fruit, Based on the tested model in step four, the input image is detected in real time to identify the appearance characteristics of the fruit, and the fruit is automatically graded according to color, shape, and surface defects; by setting a threshold, the fruit is divided into different grades.
8. A detection system for performing the lightweight appearance detection method based on deep learning and optimized YOLO algorithm according to any one of claims 1 to 7, wherein: The detection system comprises a preprocessing module, a lightweight improvement module, a testing module, and an application module: The preprocessing module collects fruit image data under different lighting conditions through a high-resolution camera deployed in an orchard or production line, and performs preprocessing to obtain a labeled dataset; and performs image enhancement operations on the labeled images; The lightweight improvement module is used to improve the YOLOv11n model and train it through the processed data: The testing module deploys the trained model to a testing environment and designs evaluation indicators to evaluate the generalization ability of the model; The application module deploys the model to an embedded device; Through the camera connected to the embedded device, fruit pictures are collected to perform appearance detection and grading of the fruit, achieving lightweight appearance detection. 9.An electronic device comprising a memory and a processor, the memory storing a computer program, wherein, The processor executes the computer program to implement the steps of the method of any one of claims 1 to 7.
10. A computer readable storage medium for storing computer instructions, characterized in that, The computer instructions are executed by the processor to implement the steps of the method of any one of claims 1 to 7.