Intelligent egg sorting method and device based on light-weight detection and confidence fusion

By using a lightweight YOLOv8 architecture and a multi-feature confidence fusion strategy, the problem of data scarcity and cross-scenario adaptation in egg detection scenarios is solved, achieving stable detection with high recall and low false positive rate, and adapting to egg sorting needs in complex environments.

CN122156874APending Publication Date: 2026-06-05XICHANG COLLEGE

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
XICHANG COLLEGE
Filing Date
2026-02-11
Publication Date
2026-06-05

AI Technical Summary

Technical Problem

Egg detection scenarios face challenges such as data scarcity, cross-scenario adaptation difficulties, weakened target edge features, and image noise affecting the confidence fluctuation of detection results. Domain differences across multiple application scenarios lead to insufficient model generalization ability, and the scarcity of defective samples and uneven category distribution make it difficult to achieve practical implementation with high recall and low false positive rates.

Method used

It adopts a lightweight YOLOv8 architecture and a multi-feature confidence fusion strategy, combined with HSV+LAB color analysis, ellipse fitting shape verification, and DIoU-NMS deduplication, and forms a self-improving closed loop through iterative optimization to meet the needs of egg sorting production lines.

Benefits of technology

It achieves high recall and low false positives in complex scenarios, stable color recognition and shape verification against illumination fluctuations, improves the robustness and adaptability of the model, and supports a real-time deployable and easy-to-integrate egg sorting method.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122156874A_ABST
    Figure CN122156874A_ABST
Patent Text Reader

Abstract

The application discloses a kind of based on light detection and confidence fusion's egg intelligent sorting method and equipment, belong to egg sorting technical field.The method includes: S1.model training: generate the light YOLOv8 model of adaptation egg sorting scene;S2.real-time sorting: the model trained is deployed to production line, real-time processing egg image, output sorting result;S3.iterative optimization: form self-promotion closed loop, continuously expand data volume, so that model can continuously learn new knowledge, improve performance in specific scene.The application relies on light YOLOv8 architecture and multi-feature confidence fusion strategy, with high recall low false detection in complex scene, stable color recognition against light fluctuation, shape verification improves robustness, small sample cross-domain adaptation is strong, real-time deployable power friendly, engineering can be operated and maintained and output structured easy integration Advantage, can accurately adapt to egg sorting production line demand.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of egg sorting technology, specifically relating to an intelligent egg sorting method and equipment based on lightweight detection and confidence fusion. Background Technology

[0002] Currently, target detection technology has deeply empowered the entire egg production chain, undertaking real-time and stable core visual inspection functions in key scenarios such as automated sorting on production lines, product quality grading, accurate screening of broken products, and color consistency control. This provides solid technical support for the construction of downstream quality traceability systems, optimization of production process parameters, and improvement of product yield. Notably, with continuous breakthroughs in few-shot transfer learning and zero-shot domain adaptation technologies, the data scarcity and cross-scenario adaptation challenges in this scenario have been significantly alleviated, especially providing a feasible technical path for the rapid engineering implementation of heterogeneous detection equipment deployment and in complex environments (such as dynamic lighting changes, background texture interference, and target stacking occlusion). However, the inherent characteristics of the egg detection scenario still bring multiple technical challenges: 1. The appearance texture of eggs is highly similar to the background color, and the high gloss reflection on the eggshell surface can easily weaken the edge features of the target and result in insufficient contrast between the foreground and the background, which directly affects the accurate recognition rate of minor defects (such as fine cracks and micro-damage). 2. During the process of brightness adaptation and exposure parameter adjustment, image noise and artifact signals are easily amplified synchronously, causing fluctuations in the confidence of the detection results, which in turn interferes with the accuracy of subsequent quality level judgment; 3. Significant inter-domain differences in multiple application scenarios (such as differences in production line equipment models, different camera parameter configurations, reflective properties of tray materials, and surface contamination and water stains) and inconsistencies in color space distribution and lighting conditions pose core challenges to improving model generalization ability and controlling color consistency. 4. Defective samples are inherently scarce and have an uneven distribution of categories. In real-world scenarios, the cost of labeling defective samples is high. Furthermore, the dynamic changes in target occlusion and stacking patterns further increase the threshold for achieving the practical goal of "high recall and low false positive rate".

[0003] Against this backdrop, it is necessary to provide a new egg sorting method to solve the above problems. Summary of the Invention

[0004] The present invention aims to at least partially solve one of the technical problems in the aforementioned related technologies.

[0005] Therefore, the purpose of this invention is to provide an intelligent egg sorting method and equipment based on lightweight detection and confidence fusion. Relying on the lightweight YOLOv8 architecture and multi-feature confidence fusion strategy, it has the advantages of high recall and low false detection in complex scenarios, stable color recognition against light fluctuations, improved robustness through shape verification, strong cross-domain adaptation with small samples, real-time deployability and computing power friendliness, engineering operability and maintenance, and easy integration of structured output, which can accurately adapt to the needs of egg sorting production lines.

[0006] To solve the above-mentioned technical problems, the present invention is implemented as follows: This invention provides an intelligent egg sorting method based on lightweight detection and confidence fusion, the method comprising: S1. Model Training: Generate a lightweight YOLOv8 model adapted to the egg sorting scenario; S2. Real-time sorting: Deploy the trained model to the production line, process egg images in real time, and output sorting results; S3. Iterative optimization: Form a self-improving closed loop, continuously expand the amount of data, enable the model to continuously learn new knowledge, and improve performance in specific scenarios.

[0007] In addition, the intelligent egg sorting method based on lightweight detection and confidence fusion according to the present invention may also have the following additional technical features: In some of these implementations, HSV+LAB color analysis, ellipse fitting shape verification, and DIoU-NMS deduplication are used to improve detection and grading accuracy.

[0008] In some implementations, the model training steps include: S11. Training data collection and preprocessing; S12. Model Training and Optimization; The steps of real-time sorting include: S21. Image acquisition and preprocessing for images to be sorted; S22. Use the model trained in S12 to detect eggs; S23. Analysis of egg quality characteristics; S24. Results Fusion and Output; The steps of iterative optimization include: S31. Set a threshold to generate pseudo-labels; S32. Data Supplementation and Model Iteration.

[0009] In some implementations, step S11 includes: Collect egg image data: covering normal eggs, slightly damaged eggs, severely damaged eggs, eggs of different colors, stacked eggs, reflective eggs, and stained eggs; Data deduplication: Remove duplicate images to avoid redundancy; Labeling verification: Ensure that the egg detection frame accurately surrounds the eggshell, and ensure that the category labels, including color and damage, are consistent; Data augmentation: Simulate stacking with Mosaic stitching, simulate reflection with pixel perturbation, and simulate lighting changes with flipping and brightness adjustment to address the scarcity of defective egg samples; Format conversion: Convert the labeled data to the YOLO-specific format.

[0010] In some implementations, step S12 includes: Dataset partitioning: Divide the dataset into training set, validation set, and test set in a 7:2:1 ratio; Set hyperparameters: Set imgsz, epochs, lr, and batch to suit egg detection requirements; Model training: Based on a lightweight YOLOv8 architecture (CSP / C2f backbone network + FPN / PAN feature fusion), an egg detection and feature analysis model was trained. Validation and early stopping: Use mAP and F1 score as indicators to avoid overfitting; Model export: Convert the optimal model into TensorRT format to meet the real-time detection needs of the production line.

[0011] In some implementations, step S21 includes: The production line camera captures images of eggs in real time and decodes them into digital signals. Perform size alignment and normalization to reduce interference from lighting and equipment differences.

[0012] In some implementations, step S22 includes: YOLOv8 inference: Use a trained model to detect the location and type of eggs in an image, and output the detection confidence score; DIoU-NMS Deduplication: Removes overlapping detection boxes from stacked eggs, ensuring that each egg corresponds to a single detection result.

[0013] In some implementations, step S23 includes: ROI extraction: Extracting the region of interest from a single egg to eliminate background interference; Color analysis: HSV+LAB collaborative analysis, H channel resists light fluctuations, LAB space conforms to human visual perception, determines the color grade of eggs, and filters out stains and interference; Shape analysis: Canny edge detection → contour extraction → ellipse fitting, calculate the roundness, aspect ratio, and contour integrity of the egg, and identify minor damage.

[0014] In some implementations, step S24 includes: DIoU-NMS Deduplication: Removes overlapping detection boxes from stacked eggs, ensuring that each egg corresponds to a single detection result.

[0015] In some implementations, step S23 includes: ROI extraction: Extracting the region of interest from a single egg to eliminate background interference; Color analysis: HSV+LAB collaborative analysis, H channel resists light fluctuations, LAB space conforms to human visual perception, determines the color grade of eggs, and filters out stains and interference; Shape analysis: Canny edge detection → contour extraction → ellipse fitting, calculate the roundness, aspect ratio, and contour integrity of the egg, and identify minor damage.

[0016] In some implementations, step S24 includes: Manual spot checks and revisions: Correcting candidate box positions, adding missed eggs, and deleting false detection labels to ensure the quality of pseudo labels; Merge training sets: Merge the revised pseudo-labeled data with the original training set and re-optimize the training model; Model update: Replace the old model with the optimized model to continuously improve sorting accuracy.

[0017] The present invention also provides a computer device, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that the processor executes the computer program to implement the steps of the intelligent egg sorting method based on lightweight detection and confidence fusion as described in any of the preceding claims.

[0018] Additional aspects and advantages of the invention will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention. Attached Figure Description

[0019] Figure 1 This is a flowchart of target detection and multi-feature analysis processing disclosed in one embodiment of the present invention; Figure 2 This is a flowchart of the entire process management of dataset processing, model training, and few-shot self-improvement disclosed in one embodiment of the present invention. Detailed Implementation

[0020] 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, not all, of the embodiments of the present invention. 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.

[0021] The embodiments of the present invention will be described in detail below with reference to the accompanying drawings and specific examples and application scenarios.

[0022] This invention provides an intelligent egg sorting method based on lightweight detection and confidence fusion. This method employs an image processing approach oriented towards object detection and multi-feature analysis as the core front-end algorithm to implement the sorting process. It addresses the problem of transforming acquired egg images into the necessary "detection + quality grading results" (such as egg location, breakage status, color grade, and shape integrity) for sorting. An image processing-oriented data flow management method is used as the back-end data and model lifecycle management process to achieve data preparation, model training, and iterative model optimization, ensuring the core algorithm's accuracy and usability in egg sorting scenarios and solving problems related to data scarcity, scenario adaptation, and model generalization. The core output of the object detection and multi-feature analysis-oriented image processing method is the structured results of a single batch / single image (bounded boxes, color / shape features, confidence scores, and JSON data). The core output of the image processing-oriented data flow management method is a high-quality model adapted to the egg scenario (i.e., the iteratively optimized model), which is used as a tool in the front-end image processing method.

[0023] Example 1:

[0024] In some embodiments of the present invention, an image processing method oriented towards target detection and multi-feature analysis is provided, such as... Figure 1 As shown, the steps include: Step 1: Input Acquisition and Decoding The system acquires raw image data from various sources, including image files, real-time camera footage, and online video streams, and then decodes it to transform it into an initial data format that can be recognized by subsequent processes.

[0025] Step 2: Preprocessing (size / proportion alignment, normalization) The decoded image is resized or scaled to conform to a uniform standard, and normalization is performed to map the image pixel values ​​to a specific range, reducing the interference of data differences on subsequent algorithms and making the image more suitable for subsequent processing requirements.

[0026] Step 3: Object Detection (YOLO Inference) By using the YOLO (You Only Look Once) object detection algorithm, inference calculations are performed on the preprocessed image to quickly identify key information such as the location and category of various target objects in the image.

[0027] Step 4: NMS / DIoU-NMS / Soft-NMS Non-maximum suppression (including improved algorithms such as DIoU-NMS and Soft-NMS) is used to filter multiple candidate detection boxes obtained from target detection, remove duplicate or redundant detection boxes, and retain the detection results that best represent the target, thereby improving the accuracy of target detection.

[0028] Step 5: ROI Extraction and Standardization Based on the target region identified by object detection, regions of interest (ROIs) are extracted, and these regions are standardized to ensure consistency in size, format, and other aspects, so that subsequent feature analysis can be carried out uniformly.

[0029] Step 6: Color Feature Analysis (HSV / LAB / Brightness Score) For the extracted and standardized regions of interest, color features within the regions are analyzed using color space models such as HSV and LAB. At the same time, relevant indicators such as brightness are quantitatively scored to obtain color feature data.

[0030] Step 5: ROI Extraction and Standardization Based on the target region identified by object detection, regions of interest (ROIs) are extracted, and these regions are standardized to ensure consistency in size, format, and other aspects, so that subsequent feature analysis can be carried out uniformly.

[0031] Step 6: Color Feature Analysis (HSV / LAB / Brightness Score) For the extracted and standardized regions of interest, color features within the regions are analyzed using color space models such as HSV and LAB. At the same time, relevant indicators such as brightness are quantitatively scored to obtain color feature data.

[0032] Step 9: Result Filtering and Threshold Determination Based on a pre-set threshold, the comprehensive confidence results after multi-feature fusion are screened, and results with confidence levels below the threshold are filtered out to determine the final valid target detection results.

[0033] Step 10: Visual annotation and statistical export (image + JSON) The final target detection results are visualized and labeled on the original image. At the same time, relevant statistical information (such as the number of targets, the features of each target, etc.) is exported in JSON format for easy viewing and analysis later.

[0034] Example 2: This embodiment provides a data flow management method for image processing, aiming to construct a complete closed loop from data preparation to model self-improvement, such as... Figure 2 As shown, it includes the following steps: Step 1: Raw Data Collection and Deduplication Collect raw image data (such as on-site shooting or downloading from public datasets), remove duplicate data by comparing data features (such as pixel values ​​and file names), avoid redundant information occupying storage resources and affecting subsequent processing efficiency, and provide a clean initial data source for data processing.

[0035] This embodiment provides a data flow management method for image processing, aiming to construct a complete closed loop from data preparation to model self-improvement, such as... Figure 2 As shown, it includes the following steps: Step 1: Raw Data Collection and Deduplication Collect raw image data (such as on-site shooting or downloading from public datasets), remove duplicate data by comparing data features (such as pixel values ​​and file names), avoid redundant information occupying storage resources and affecting subsequent processing efficiency, and provide a clean initial data source for data processing.

[0036] Step 4: YOLO annotation format conversion The validated labeled data (such as XML or JSON format) is converted into the label format specific to the YOLO model (usually a txt file containing the target category, center point coordinates, and aspect ratio) to ensure that the labeled information can be correctly recognized by the YOLO training framework, thus achieving data and model format adaptation.

[0037] Step 5: Dataset split (train / val / test) The augmented dataset is split into a training set, a validation set, and a test set according to a preset ratio (e.g., 7:2:1): the training set is used for learning model parameters, the validation set is used to adjust hyperparameters and monitor model performance during training, and the test set is used to finally evaluate the model's true generalization ability. The three sets are independent and complementary.

[0038] Step 6: Set hyperparameters (epochs / batch / imgsz / lr) Configure the core hyperparameters for model training: set the number of training epochs to control the total training time, set the batch size to balance training speed and memory usage, set the input image size (imgsz) to standardize training data specifications, and set the learning rate (lr) to control the parameter update amplitude, providing a reasonable parameter basis for efficient training.

[0039] Step 7: Training (Forward Propagation / Backward Propagation / Optimization) The model training process begins as follows: First, the training set data is input into the model through forward propagation to calculate the prediction results; then, the parameter gradient is calculated based on the error between the prediction results and the actual labels (such as the loss function value) through backpropagation; finally, the model parameters are updated along the gradient descent direction using an optimizer (such as Adam or SGD), and the process is iterated until the preset training rounds are completed.

[0040] Step 8: Verification and Early Stop (mAP / F1) After each training round, the model performance is evaluated using the validation set. The mean average precision (mAP) is used to measure the accuracy of object detection, and the F1 score is used to balance precision and recall, generating a performance index curve. When the validation set performance does not improve for several consecutive rounds (e.g., 5 rounds), the early stopping mechanism is triggered to stop training and avoid the model from overfitting due to excessive learning of training set noise.

[0041] Step 9: Optimal Model Selection (best.pt / last.pt) Compare all model files saved during training: select the "best model" with the best performance on the validation set (e.g., the highest mAP) as the core model for subsequent applications; at the same time, retain the "last model" at the end of training as a backup to prevent the best model from becoming invalid due to special circumstances (e.g., abnormal validation set) and ensure the reliability of model selection.

[0042] Step 10: Model Export (ONNX / TensorRT) Convert the selected best model into a format suitable for the deployment scenario: export it to ONNX format to achieve cross-framework (such as PyTorch, TensorFlow) compatibility and intermediate representation, which facilitates multi-platform debugging; it can be further converted to TensorRT engine format, and the inference speed on the GPU can be improved through optimization methods such as CUDA acceleration, cuDNN optimization, GPU parallel computing, PyTorch Tensor optimization, and efficient model structure to meet the real-time detection requirements in industrial scenarios.

[0043] Step 11: Low-threshold inference to generate candidate boxes (pseudo-labeling and few-sample self-boosting process) This approach leverages a trained model to infer from unlabeled new data (small sample data), lowering the confidence threshold to generate a large number of candidate detection boxes containing potential targets. This covers more possible target regions, providing ample initial candidate objects for subsequent pseudo-labeling and addressing the problem of insufficient labeled data in small sample scenarios. Specifically, by setting a low confidence threshold (e.g., 0.1-0.3), the aim is to generate as many potential target candidate boxes as possible, even if some noise is included, to provide rich candidate targets for subsequent pseudo-labeling.

[0044] Step 12: Rule Filtering (Confidence / Shape) Automated screening of initially generated candidate boxes: Set a low confidence threshold (e.g., 0.1) for initial screening to remove candidate boxes with low confidence or obvious errors. Then, combine prior knowledge and filter candidate boxes that do not conform to the actual target shape by shape rules (e.g., target aspect ratio range, area size limit) to retain the most likely correct candidate boxes, reduce invalid annotations, and significantly reduce the workload of subsequent manual processing.

[0045] Step 13: Manual spot checks and revisions Professional staff conduct sampling checks and fine-tuning of the filtered candidate bounding boxes: checking the accuracy of the candidate box positions and the correctness of the category labels (correcting incorrect category labels), correcting boxes with positional misalignments, deleting false positive boxes, and supplementing target boxes missed by the model. This ensures the accuracy of the pseudo-labeled data and avoids erroneous labeling affecting the model's retraining performance. This step is crucial for ensuring the quality of the pseudo-labeled data and ensuring its effective use for iterative model enhancement.

[0046] Step 14: Merge into the training set (pseudo-labeling and few-shot self-boosting process) By merging the manually revised high-quality pseudo-labeled data with the original training set, the scale and diversity of the training data are expanded, and the scale of the training set data is updated. This forms a self-improving closed loop of "model training → pseudo-label generation → manual revision → data supplementation (expanding the training set) → model optimization training", continuously expanding the amount of data, enabling the model to continuously learn new knowledge, gradually improving its performance in specific scenarios, and effectively alleviating the problem of data scarcity in small sample scenarios.

[0047] Example 3: This invention proposes an egg detection and attribute recognition method that achieves stable detection and color / shape recognition in complex production environments (uneven lighting, occlusion stacking, reflection, and motion blur). It utilizes a lightweight YOLOv8 multi-scale feature extraction and decoupled detection head, supplemented by DIoU-NMS to suppress overlap and redundancy, improving the detection rate of small targets and occluded scenes. Within the ROI, HSV / LAB collaborative analysis is performed with added brightness consistency constraints to reduce the impact of lighting / white balance drift on color separation. Geometric verification using Canny-contour-ellipse fitting outputs indicators such as aspect ratio, roundness, and integrity to filter out non-target and abnormal samples. Multi-feature confidence fusion with α / β / γ weights mitigates decision fluctuations caused by single-channel distortion (such as color shift due to strong reflection). Even under degenerate conditions such as complex backgrounds, dense small targets, and similar colors, it achieves high recall and low false positive detection results, outputting visualized annotations and structured JSON data, providing accurate, reliable, and deployable algorithmic support for graded sorting and online quality inspection.

[0048] The method of this invention includes three main stages: Phase 1: Preparatory phase, using Example 2 to construct an egg-specific model.

[0049] Objective: To generate a high-quality, lightweight YOLOv8 model adapted to egg sorting scenarios (such as eggshell reflection, stacking, minor damage, and color grading).

[0050] The steps include: Step 1-1: Data Collection and Preprocessing (Steps 1-4 of Example 2): Collect egg image data: covering common production line scenarios such as normal eggs, slightly damaged eggs, severely damaged eggs, eggs of different colors (white eggs, brown eggs), stacked eggs, reflective eggs, and eggs with stains; Data deduplication: Remove duplicate images to avoid redundancy; Labeling and verification: Ensure that the egg inspection frame accurately surrounds the eggshell and that the color / damage category labeling is consistent (e.g., minor cracks are labeled uniformly to avoid confusing stains with damage). Data augmentation: Targeted simulation of egg production line scenarios—Mosaic stitching to simulate stacking, pixel perturbation to simulate reflection, and flipping / brightness adjustment to simulate lighting changes, solving the problem of scarce egg defect samples; Format conversion: Convert annotation data (XML / JSON) to YOLO's proprietary format (txt file).

[0051] The method of this invention includes three main stages: Phase 1: Preparatory phase, using Example 2 to construct an egg-specific model.

[0052] Objective: To generate a high-quality, lightweight YOLOv8 model adapted to egg sorting scenarios (such as eggshell reflection, stacking, minor damage, and color grading).

[0053] The steps include: Step 1-1: Data Collection and Preprocessing (Steps 1-4 of Example 2): Collect egg image data: covering common production line scenarios such as normal eggs, slightly damaged eggs, severely damaged eggs, eggs of different colors (white eggs, brown eggs), stacked eggs, reflective eggs, and eggs with stains; Data deduplication: Remove duplicate images to avoid redundancy; Labeling and verification: Ensure that the egg inspection frame accurately surrounds the eggshell and that the color / damage category labeling is consistent (e.g., minor cracks are labeled uniformly to avoid confusing stains with damage). Data augmentation: Targeted simulation of egg production line scenarios—Mosaic stitching to simulate stacking, pixel perturbation to simulate reflection, and flipping / brightness adjustment to simulate lighting changes, solving the problem of scarce egg defect samples; Format conversion: Convert annotation data (XML / JSON) to YOLO's proprietary format (txt file).

[0054] Phase Two: Real-time Sorting – Executing the Core Algorithm Using Example 1 Objective: To deploy the trained model to the production line, process egg images in real time, and output sorting results.

[0055] Step 2-1: Image Acquisition and Preprocessing (Steps 1-2 of Example 1) The production line camera captures images of eggs in real time and decodes them into digital signals. Size alignment (uniform to 640×640) and normalization (pixel values ​​mapped to [0,1]) reduce interference from lighting and device differences.

[0056] Phase Two: Real-time Sorting – Executing the Core Algorithm Using Example 1 Objective: To deploy the trained model to the production line, process egg images in real time, and output sorting results.

[0057] Step 2-1: Image Acquisition and Preprocessing (Steps 1-2 of Example 1) The production line camera captures images of eggs in real time and decodes them into digital signals. Size alignment (uniform to 640×640) and normalization (pixel values ​​mapped to [0,1]) reduce interference from lighting and device differences.

[0058] Steps 2-3: Egg quality characteristic analysis (Steps 5-6 of Example 1) ROI extraction: Extracting the region of interest (ROI) of a single egg (excluding background interference); Color Analysis: HSV+LAB Collaborative Analysis—H channel (hue) resists light fluctuations, LAB space conforms to human visual perception, determines the color grade of eggs (such as pure white, light brown, dark brown), and filters out stain interference. Shape analysis: Canny edge detection → contour extraction → ellipse fitting, calculate the roundness, aspect ratio, and contour integrity of the egg, and identify minor damage (such as cracks causing irregular contours or large ellipse fitting errors).

[0059] Steps 2-4: Result Fusion and Output (Steps 7-10 of Example 1) Multi-feature confidence fusion: Calculate the comprehensive confidence based on the weights α (detection confidence), β (color confidence), and γ (shape confidence) to avoid distortion caused by a single feature (such as color misjudgment due to reflection). Threshold filtering: Set a threshold to retain high-confidence results (such as normal white eggs and grade 1 damaged brown eggs). Sorting and landing: Output visual labels (egg location, category) and JSON structured data to control the production line sorting equipment (such as robotic arms) to sort eggs into corresponding areas (normal egg area, broken egg area, different color grade areas).

[0060] Phase 3: Iterative optimization – Improving accuracy by using pseudo-labeled loop closure from Example 2 (continuous adaptation) Objective: To address the decrease in model accuracy caused by new production line scenarios (such as novel eggshell stains and extreme lighting) and form a self-improving closed loop.

[0061] Step 3-1: Pseudo-label generation (Steps 11-12 of Example 2) Low-threshold inference: Using the currently deployed model, perform low-threshold (0.2) inference on newly added unlabeled egg images (such as extremely reflective eggs and new types of damaged eggs) on the production line to generate potential candidate boxes; Rule-based filtering: Based on egg shape (width-to-height ratio, roundness range) and low confidence threshold (0.1), obviously erroneous candidate boxes (such as impurities and debris) are filtered out.

[0062] Step 3-2: Data Supplementation and Model Iteration (Steps 13-14 of Example 2) Manual spot checks and revisions: Correcting candidate box positions, adding missed eggs, and deleting false detection labels to ensure the quality of pseudo labels; Merging training sets: The revised pseudo-labeled data is merged with the original training set to incrementally train the model; Model update: The optimized model is redeployed to the production line to replace the old model and continuously improve sorting accuracy.

[0063] The advantages of this invention include: Advantage 1: High recall and low false positives in complex scenarios Principle: A lightweight YOLOv8 architecture (CSP / C2f backbone network + FPN / PAN feature fusion + decoupled detection head) is adopted to perform target prediction on multi-scale feature maps, and NMS / DIoU-NMS algorithms are used to suppress overlapping redundant detection boxes. The FPN / PAN structure enhances the feature transfer efficiency of small targets and occluded targets, and the decoupled detection head reduces task conflicts by separating classification and regression branches, effectively improving the target detection capability in densely stacked and occluded scenes.

[0064] Results: Even under complex backgrounds such as target stacking and occlusion, ambient reflection, and dynamic blur, it can still stably output target candidate boxes, significantly reducing the false negative rate and the number of duplicate boxes, and ensuring the integrity and uniqueness of the detection results.

[0065] Advantage 2: Stable color recognition and resistant to light fluctuations Principle: An HSV+LAB collaborative analysis model is constructed within the region of interest (ROI). The H channel (hue) of the HSV color space is insensitive to changes in brightness, enabling stable threshold segmentation; the LAB color space conforms to the characteristics of human visual perception, suppressing interference from similar colors by calculating the Euclidean distance of color features or setting thresholds; simultaneously, a brightness consistency scoring mechanism is superimposed to constrain color feature distortion caused by exposure deviations and white balance drift.

[0066] Results: In scenarios with uneven lighting, changes in ambient color temperature, switching between different camera devices, or differences in production shifts, color classification confusion is significantly reduced, and the stability and consistency of color recognition results are greatly improved.

[0067] Advantage 3: Shape verification improves robustness and interpretability Principle: Through the process of "grayscale conversion → Canny edge detection → contour extraction → least squares ellipse fitting", the core geometric indicators such as the aspect ratio, roundness, and contour integrity of the target are output. Geometric features are naturally robust to background texture noise and color interference, and can be used as independent evidence streams to cross-validate with detection and color feature results, forming a multi-dimensional verification mechanism.

[0068] Results: Effectively filters out non-target objects (such as impurities and debris) and targets with abnormal shapes, significantly improving the reliability of the final results; at the same time, the output geometric indicators provide interpretable evidence for the detection results, facilitating problem tracing and algorithm iteration optimization.

[0069] Advantage 4: Multi-feature confidence fusion reduces fluctuations and biases. Principle: A normalized weighted fusion model is constructed, and the confidence scores of YOLO detection, color classification, and shape verification are calculated and fused according to preset weights (α / β / γ). By integrating evidence information from different noise sources, distortion of a single feature channel is suppressed (e.g., when strong reflection causes color features to fail, shape features and detection features provide the supporting results), achieving complementary fault tolerance.

[0070] Results: The stability of detection results is significantly improved under extreme conditions such as strong reflection, partial occlusion, and complex background texture, avoiding a sharp drop in accuracy caused by the failure of a single feature; the precision and recall of the overall detection task are optimized simultaneously, resulting in better overall performance.

[0071] Advantage 5: Strong small sample / cross-domain adaptation capability Principle: The system adopts a dual-drive strategy of "transfer learning + pseudo-labeling closed loop": Based on the pre-trained model, candidate labels for unlabeled data are generated through low-threshold inference. After rule filtering (such as confidence and geometric constraints) and manual sampling and revision, the labels are fed back into the training set for incremental training, gradually approaching the target application domain. At the same time, it supports hot updates of color / brightness thresholds and feature fusion weights, which can quickly adapt to changes in camera equipment, lighting conditions or production shifts without restarting the service.

[0072] Results: Significantly reduces reliance on target domain annotation data, resulting in a substantial decrease in annotation costs; reduces cross-camera deployment and new scene deployment cycles by more than 50%; and allows accuracy drops caused by domain offsets (such as equipment replacement or environmental changes) to be recovered within hours, significantly improving adaptability flexibility.

[0073] Advantage 6: Real-time deployment and computationally friendly Principle: Optimize computing efficiency across three layers: model, inference, and engineering. The model layer adopts the lightweight YOLOv8n architecture, combined with FP16 half-precision quantization and TensorRT acceleration, supporting multi-instance parallelism and batch inference. The inference layer switches multi-scale detection and TTA (test-time data augmentation) functions on demand to balance accuracy and speed. The engineering layer ensures efficient resource utilization through I / O data caching, post-processing vectorization, and server-side rate limiting and graceful degradation strategies (such as disabling TTA and reducing input resolution under high load).

[0074] Results: On mid-to-low-end GPUs (such as Tesla T4) or edge computing devices (such as Jetson AGX), single-frame inference latency can be controlled within 20ms, throughput meets the requirements of online sorting and real-time quality inspection, and industrial deployment can be achieved without high-performance computing hardware.

[0075] Results: Significantly reduces reliance on target domain annotation data, resulting in a substantial decrease in annotation costs; reduces cross-camera deployment and new scene deployment cycles by more than 50%; and allows accuracy drops caused by domain offsets (such as equipment replacement or environmental changes) to be recovered within hours, significantly improving adaptability flexibility.

[0076] Advantage 6: Real-time deployment and computationally friendly Principle: Optimize computing efficiency across three layers: model, inference, and engineering. The model layer adopts the lightweight YOLOv8n architecture, combined with FP16 half-precision quantization and TensorRT acceleration, supporting multi-instance parallelism and batch inference. The inference layer switches multi-scale detection and TTA (test-time data augmentation) functions on demand to balance accuracy and speed. The engineering layer ensures efficient resource utilization through I / O data caching, post-processing vectorization, and server-side rate limiting and graceful degradation strategies (such as disabling TTA and reducing input resolution under high load).

[0077] Results: On mid-to-low-end GPUs (such as Tesla T4) or edge computing devices (such as Jetson AGX), single-frame inference latency can be controlled within 20ms, throughput meets the requirements of online sorting and real-time quality inspection, and industrial deployment can be achieved without high-performance computing hardware.

[0078] Advantage 8: Structured output and easy integration Principle: Design a standardized output system: At the visual level, generate visual annotation results with target bounding boxes, categories, and confidence scores; at the data level, output structured data in JSON format, including fields such as target detection list (detections), color classification statistics (color_counts), and task summary information (summary); at the interface level, align with REST protocol, batch processing interface, and edge communication protocol to adapt to different integration scenario requirements.

[0079] Results: It can quickly connect to grading and sorting equipment, MES (Manufacturing Execution System) / ERP (Enterprise Resource Planning) systems or quality inspection reporting platforms, and can be integrated with the existing production system without secondary development, thus accelerating the technology implementation cycle.

[0080] Any part of this invention not described in detail can be referred to in the prior art or in the art known to those skilled in the art. This embodiment does not limit such part and will not describe it in detail here.

[0081] The embodiments of the present invention have been described above with reference to the accompanying drawings. However, the present invention is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of the present invention without departing from the spirit and scope of the claims, and all of these forms are within the protection scope of the present invention.

Claims

1. A smart egg sorting method based on lightweight detection and confidence fusion, characterized in that, The method includes: S1. Model Training: Generate a lightweight YOLOv8 model adapted to the egg sorting scenario; S2. Real-time sorting: Deploy the trained model to the production line, process egg images in real time, and output sorting results; S3. Iterative optimization: Form a self-improving closed loop, continuously expand the amount of data, enable the model to continuously learn new knowledge, and improve performance in specific scenarios.

2. The intelligent egg sorting method based on lightweight detection and confidence fusion according to claim 1, characterized in that, The accuracy of detection and grading is improved by using HSV+LAB color analysis, ellipse fitting shape verification, and DIoU-NMS deduplication.

3. The intelligent egg sorting method based on lightweight detection and confidence fusion according to claim 1, characterized in that, The steps of model training include: S11. Training data collection and preprocessing; S12. Model Training and Optimization; The steps of real-time sorting include: S21. Image acquisition and preprocessing for images to be sorted; S22. Use the model trained in S12 to detect eggs; S23. Analysis of egg quality characteristics; S24. Results Fusion and Output; The steps of iterative optimization include: S31. Set a threshold to generate pseudo-labels; S32. Data Supplementation and Model Iteration.

4. The intelligent egg sorting method based on lightweight detection and confidence fusion according to claim 3, characterized in that, Step S11 includes: Collect egg image data: covering normal eggs, slightly damaged eggs, severely damaged eggs, eggs of different colors, stacked eggs, reflective eggs, and stained eggs; Data deduplication: Remove duplicate images to avoid redundancy; Labeling verification: Ensure that the egg detection frame accurately surrounds the eggshell, and ensure that the category labels, including color and damage, are consistent; Data augmentation: Simulate stacking with Mosaic stitching, simulate reflection with pixel perturbation, and simulate lighting changes with flipping and brightness adjustment to address the scarcity of defective egg samples; Format conversion: Convert the labeled data to the YOLO-specific format.

5. The intelligent egg sorting method based on lightweight detection and confidence fusion according to claim 3, characterized in that, Step S12 includes: Dataset partitioning: Divide the dataset into training set, validation set, and test set in a 7:2:1 ratio; Set hyperparameters: Set imgsz, epochs, lr, and batch to suit egg detection requirements; Model training: Based on the lightweight YOLOv8 architecture, train an egg detection and feature analysis model; Validation and early stopping: Use mAP and F1 score as indicators to avoid overfitting; Model export: Convert the optimal model into TensorRT format to meet the real-time detection needs of the production line.

6. The intelligent egg sorting method based on lightweight detection and confidence fusion according to claim 3, characterized in that, Step S21 includes: The production line camera captures images of eggs in real time and decodes them into digital signals. Perform size alignment and normalization to reduce interference from lighting and equipment differences; Step S22 includes: YOLOv8 inference: Use a trained model to detect the location and type of eggs in an image, and output the detection confidence score; DIoU-NMS Deduplication: Removes overlapping detection boxes from stacked eggs, ensuring that each egg corresponds to a single detection result.

7. The intelligent egg sorting method based on lightweight detection and confidence fusion according to claim 3, characterized in that, Step S23 includes: ROI extraction: Extracting the region of interest from a single egg to eliminate background interference; Color analysis: HSV+LAB collaborative analysis, H channel resists light fluctuations, LAB space conforms to human visual perception, determines the color grade of eggs, and filters out stains and interference; Shape analysis: Canny edge detection → contour extraction → ellipse fitting, calculate the roundness, aspect ratio, and contour integrity of the egg, and identify minor damage.

8. The intelligent egg sorting method based on lightweight detection and confidence fusion according to claim 3, characterized in that, Step S24 includes: Multi-feature confidence fusion: Calculate the comprehensive confidence based on the detection confidence α, color confidence β, and shape confidence γ to avoid misjudgment caused by distortion of a single feature; Threshold filtering: Set a filtering threshold to retain high-confidence results; Sorting and Landing: Outputs visual labels and JSON structured data, including egg location and category, to control the production line sorting equipment to sort eggs into the corresponding areas.

9. The intelligent egg sorting method based on lightweight detection and confidence fusion according to claim 3, characterized in that, Step S31 includes: Low-threshold inference: Using the currently deployed model, perform low-threshold inference on newly added unlabeled egg images on the production line to generate potential candidate boxes; Rule-based filtering: Based on egg shape parameters including aspect ratio and roundness range, and a low confidence threshold, obviously erroneous candidate boxes are filtered out; Step S32 includes: Manual spot checks and revisions: Correcting candidate box positions, adding missed eggs, and deleting false detection labels to ensure the quality of pseudo labels; Merge training sets: Merge the revised pseudo-labeled data with the original training set and re-optimize the training model; Model update: Replace the old model with the optimized model to continuously improve sorting accuracy.

10. A computer device, comprising: A memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that the processor executes the computer program to implement the steps of the intelligent egg sorting method based on lightweight detection and confidence fusion as described in any one of claims 1-9.