Automatic detection method and system for egg latent crack based on view AI perception multi-instance learning
By employing multi-instance learning and view AI perception methods, combined with a frozen backbone network and a single-layer gated attention module, the problems of incomplete observation and low recognition rate in the detection of hidden cracks in poultry eggs are solved, achieving high-precision automated detection of hidden cracks in poultry eggs.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- ZHEJIANG UNIV
- Filing Date
- 2026-04-14
- Publication Date
- 2026-07-10
Smart Images

Figure CN122367965A_ABST
Abstract
Description
Technical Field
[0002] This application belongs to the field of nondestructive testing technology for hidden cracks in poultry eggs, and particularly relates to an automated detection method and system for hidden cracks in poultry eggs based on view AI perception and multi-example learning. Background Technology
[0003] Eggshell crack detection is a crucial step in the automated grading process for poultry eggs, vital for ensuring food safety and improving industry efficiency. Machine vision methods, with their advantages of high detection speed, low equipment cost, and non-contact, non-destructive operation, have become the mainstream technology for automated eggshell quality inspection. Egg cracks are classified into complete cracks and blind cracks. Blind cracks are those where the outermost protective membrane of the shell is intact, but the bony layer contains fine, hidden cracks. These cracks are difficult to detect with the naked eye, but may leak egg liquid or allow bacteria to enter during transportation or storage due to vibration or pressure. According to the USDA's definition, blind cracks ("blind checks") refer to the most common and difficult-to-identify type of crack or defect during egg candling. These problems are often only visible when the egg is passed through a specific angle under a candling lamp, or can be assessed by tapping the egg and listening to the sound. During production, completely cracked eggs are usually discarded, but blind cracks, due to their minute size, are often difficult to detect with the naked eye and therefore frequently go undetected.
[0004] Currently, the main non-destructive testing methods for egg cracks both domestically and internationally include machine vision and acoustic technologies. Acoustic methods are susceptible to noise interference from industrial environments, while traditional machine vision methods exhibit limited robustness and decreased reliability under complex real-world conditions. When applying convolutional neural networks to multi-view eggshell crack detection using machine vision technology, if the images acquired from multiple perspectives only have egg-level labels, directly training by treating all perspective images of cracked eggs as positive samples will forcibly assign positive labels to images without cracks, generating contradictory training signals and causing a mismatch between egg-level labels and training samples. Furthermore, existing methods have low recognition rates for latent cracks and incomplete observation of high-curvature end regions. Therefore, there is an urgent need to design an automated detection method and system for latent cracks in poultry eggs to solve the aforementioned technical problems, hence this invention. Summary of the Invention
[0005] This application provides an automated detection method and system for hidden cracks in poultry eggs based on view AI perception and multi-instance learning, in order to solve the problems of incomplete observation of high-curvature end regions and low detection and recognition rate of hidden cracks in traditional machine vision methods in the prior art.
[0006] In a first aspect, embodiments of this application provide an automated detection method for latent cracks in poultry eggs based on view AI perception multi-instance learning, the method comprising the following steps: (S1) Data acquisition steps: Use image acquisition equipment to acquire multi-view, multi-site images of each poultry egg, and assign egg-level binary classification labels to each poultry egg to form training and validation datasets; (S2) Model construction steps: Using the training and validation datasets as input, the frozen backbone network is used to extract image-level representations, and then the whole image-level representations are adaptively weighted and aggregated through a single-layer gated attention module to obtain egg-level representations. Using egg-level binary classification labels as supervision signals, the standard cross-entropy loss function is used for end-to-end training to complete the construction of the automated detection model for hidden cracks in poultry eggs. (S3) Product inspection steps: Import the image of the egg to be inspected into the trained automated detection model for hidden cracks in eggs, and obtain the detection result of whether the egg to be inspected has hidden cracks through model inference.
[0007] Secondly, embodiments of this application provide a computer-readable storage medium storing a computer program that, when executed by a processor, implements the aforementioned automated detection method for hidden cracks in poultry eggs.
[0008] Thirdly, embodiments of this application provide a computer device, including: Memory, used to store instructions; A processor is configured to execute the instructions to enable the device to implement the automated detection method for hidden cracks in poultry eggs as described above.
[0009] Fourthly, embodiments of this application provide an automated detection system for latent cracks in poultry eggs based on view AI perception and multi-instance learning, the system comprising: The aforementioned computer equipment; and, A multi-view, multi-site image acquisition device is used to acquire complete image data of each individual egg in the system under multi-view, multi-site conditions.
[0010] This invention provides an automated method for detecting latent cracks in poultry eggs based on view AI perception and multi-instance learning. This method uses a multi-instance learning framework to organize effective images of a single egg from multiple perspectives and sites into a multi-instance package structure. A frozen, self-supervised visual foundation model is used as the backbone network for feature extraction. A single-layer gated attention module mechanism automatically aggregates perspectives containing key crack information to form an egg-level representation. End-to-end training is only required for egg-level binary classification labels. This invention also provides an automated system for detecting latent cracks in poultry eggs. Utilizing multi-view, multi-site image acquisition equipment for online imaging, it can clearly image the entire eggshell surface, including high-curvature areas. On a dataset containing 28,305 images of 1,887 eggs, the method of this invention achieves an accuracy of 98.66 ± 0.78%. Under the same labeling budget of approximately three hours, the model built based on the multi-instance learning framework of this invention, with its weak supervision and view AI perception characteristics, achieves an accuracy 4.43% higher than the strongly supervised benchmark model YOLO26s. Therefore, the model of this invention combines the advantages of clear imaging of the entire surface, low annotation requirements and high classification accuracy, and can provide an efficient weak supervision scheme for high-throughput online detection of hidden cracks in eggshells. Attached Figure Description
[0011] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments of this application will be briefly introduced below. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0012] Figure 1 This is a flowchart illustrating the automated detection method for latent cracks in poultry eggs based on view AI perception multi-instance learning, according to an embodiment of this application. Figure 2 This is a schematic diagram of the structure of a poultry egg according to an embodiment of this application; Figure 3 This is a schematic diagram of the imaging layout of poultry eggs in an embodiment of this application, viewed from the left, center, and right angles of the image acquisition device and aided by the egg-canning light source. Figure 4 This is a flowchart illustrating the specific construction method of the automated detection model for hidden cracks in poultry eggs according to an embodiment of this application. Figure 5 This is a flowchart illustrating the method for obtaining the final attention by the gating attention module during the construction of the automated detection model for hidden cracks in poultry eggs, as described in this application embodiment. Figure 6 This is a schematic diagram of the automated detection method for latent cracks according to an embodiment of this application; Figure 7 These are representative examples of the appearance of white-shelled and brown-shelled eggs under candling light (rows 1 and 3) and diffuse reflected light (rows 2 and 4) in the embodiments of this application. Figure 8 This is a schematic diagram of the sequential image acquisition process in which five stations are arranged sequentially along the rolling direction of the poultry egg, and imaging is performed from three different perspectives in sequence, according to an embodiment of this application; A, B, C, D, and E are the five stations; Figure 9 This is a performance evaluation result of the automated detection model for hidden cracks in poultry eggs based on view AI perception multi-instance learning, as described in the embodiments of this application. Figure 10 The following are representative egg samples from embodiments of this application, along with corresponding single-layer attention weight diagrams; where (a) represents a hidden cracked egg, and (b) represents an intact egg; Figure 10 In (a) and (b), the red box indicates a hidden crack, and the yellow box indicates a water ripple. Figure 11 This is a comparison and confusion matrix between the automated detection model for hidden cracks in poultry eggs based on view AI perception multi-instance learning in this application embodiment and a benchmark model. Detailed Implementation
[0014] The features and exemplary embodiments of various aspects of this application will be described in detail below. To make the objectives, technical solutions, and advantages of this application clearer, the application will be further described in detail below with reference to the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described herein are only intended to explain this application and not to limit it. For those skilled in the art, this application can be implemented without some of these specific details. The following description of the embodiments is merely to provide a better understanding of this application by illustrating examples.
[0015] In existing technologies, online detection methods for egg cracks, especially machine vision methods, suffer from limitations in the recognition rate and reliability of hidden cracks due to mismatched multi-view image supervision information and incomplete observation of high-curvature areas of the eggshell. For example... Figure 1 As shown in the figure, this invention provides an automated detection method for latent cracks in poultry eggs based on multi-instance learning. The method includes the following steps: (S1) Data acquisition steps: Use image acquisition equipment to acquire multi-view, multi-site images of each poultry egg, and assign egg-level binary classification labels to each poultry egg to form training and validation datasets; (S2) Model construction steps: Using the training and validation datasets as input, the frozen backbone network is used to extract image-level representations, and then the whole image-level representations are adaptively weighted and aggregated through a single-layer gated attention module to obtain egg-level representations. Using egg-level binary classification labels as supervision signals, the standard cross-entropy loss function is used for end-to-end supervised training to complete the construction of the automated detection model for hidden cracks in poultry eggs. (S3) Product Inspection Steps: The image of the egg to be inspected is imported into the trained automated detection model for hidden cracks in eggs. The model inferences to obtain the detection result of whether there are hidden cracks in the egg. This method is based on the multiple instance learning (MIL) framework and constructs an automated detection model for hidden cracks in eggs. It features weak supervision and view AI perception, and only requires egg-level binary classification labels to learn features from multi-view egg images. The model combines a frozen backbone network with a single-layer gated attention module to aggregate crack-related information from different viewpoints and stations. This method achieves end-focused imaging through multi-view, multi-station image acquisition equipment, enabling clear imaging of the entire surface of the eggshell and solving the problem of blind spots caused by existing machine vision focusing only on the equatorial position of the egg.
[0016] The automated detection method for hidden cracks in poultry eggs of the present invention can be applied to the detection of common poultry eggs. These poultry eggs are a general term for eggs of poultry and edible birds, specifically chicken eggs, duck eggs, and goose eggs.
[0017] like Figure 2 As shown, a common poultry egg has a pointed end A and an air cell end B. Assuming that the major axis of egg 2 is in the x-axis direction, the minor axis of egg 2 is in the y-axis direction, its major axis radius is a, its minor axis radius is b, and its egg shape angle is θ, then the outer contour curve of egg 2 can be described on a two-dimensional plane by the following deformed ellipse equation: .
[0018] In the preferred technical solution of the present invention, such as Figure 3 As shown, in the method, when the image acquisition device 1 acquires the test image of the egg from multiple perspectives, the multiple perspectives include at least a central perspective (M), a left perspective (L), and a right perspective (R). The central perspective (M) is the perspective when the image acquisition device faces the equatorial region of the egg 2 and is directly facing the equatorial region of the egg. The image acquired by the image acquisition device from multiple perspectives and multiple stations of each egg is the egg image of the equatorial region of the egg. The left perspective (L) is the perspective when the image acquisition device faces the air cell end region of the egg. The image acquired by the image acquisition device from multiple perspectives and multiple stations of each egg is the egg image of the air cell end of the egg. The right perspective (R) is the perspective when the image acquisition device faces the tip region of the egg. The image acquired by the image acquisition device from multiple perspectives and multiple stations of each egg is the egg image of the tip region of the egg.
[0019] like Figure 3 and combined Figure 2As shown, structurally, a poultry egg has a clearly defined major axis (a) and minor axis (b), and can be considered centrally symmetrical along the major axis. When the image acquisition device acquires images from multiple stations, the rolling angle of each egg along the minor axis tangent at adjacent stations is 360° / n, where n represents the number of stations and is a natural number greater than or equal to 1. For example, when the image acquisition device acquires images from 5 stations, the rolling angle of each egg along the minor axis tangent at adjacent stations is 72°. The fully automatic monitoring system of this invention is equipped with a multi-station, multi-view image acquisition device, which can continuously acquire images of a single egg from different perspectives and stations, thereby obtaining complete image data of a single egg and realizing the detection of hidden cracks on the overall surface of the egg. In the comparative example of this invention, the model using only intermediate view images is insufficient to fully observe the high curvature region at the end of the egg, thus limiting the detection performance. More specifically, the detection performance of the Stitching-MobileNetV3 intermediate-view multi-image classification model based on image stitching and the BiLSTM-DenseNet-201 intermediate-view multi-image classification model based on temporal input is lower than that of the method of this invention. At the same time, when the ablation experiment uses only the intermediate view (M) as input, the accuracy of the model decreases. Therefore, multi-view observation plays an important role in the detection of hidden cracks on the whole surface.
[0020] In the preferred technical solution of the present invention, such as Figure 3 As shown, the method uses image acquisition device 1 to acquire multi-view, multi-site images of each egg under the illumination of candling light source 3. The exposure time of the candling light source is set to 500 microseconds. The illumination area 31 of the candling light source 3 is positioned relative to the photosensitive area 11 of the image acquisition device 1 under multi-view conditions. Preferably, the candling light source is positioned relative to the image acquisition device acquiring the intermediate view (M) during illumination. Setting the exposure time to 500 microseconds under 12-watt red LED candling light source illumination reduces motion blur in the images acquired by the image acquisition device. The image acquisition under the candling light source primarily uses monochrome features to avoid color channel interference with the detection results.
[0021] like Figure 4 and Figure 6 As shown, in a preferred embodiment of the present invention, step (S2) of the method, which constructs an automated detection model for hidden cracks in poultry eggs, specifically includes the following steps: (S21) Based on all valid images of each poultry egg from multiple sites and multiple perspectives, construct a structured multi-example package corresponding to the poultry egg; (S22) A frozen self-supervised visual base model is used to independently extract image-level representations for each image in the multi-example package; (S23) Image-level representations are weighted and aggregated into egg-level representations through a single-layer gated attention module; (S24) Using egg-level binary classification labels as supervision signals, end-to-end training is performed on the single-layer gated attention module and the classification head through the standard cross-entropy loss function.
[0022] The automated detection model for latent cracks in poultry eggs of this invention employs a frozen backbone network to extract image-level representations, which are then aggregated into egg-level representations. Weakly supervised binary classification can be completed using only egg-level binary classification labels. Based on a multi-instance learning framework and using a single-layer gated attention module, this model exhibits the characteristics of view-based AI perception. On the test set, it achieved an accuracy of 98.66±0.78%, an F1 score of 98.57±0.83%, a precision of 98.74±0.79%, and a recall of 98.45±0.97%. Therefore, the model of this invention can achieve high-precision acquisition of egg-level representations, and all cracked eggs are correctly identified.
[0023] In a specific implementation, all valid images of a single egg are compiled into a multi-example package. In step (S2) of the method, the image acquisition device constructs images from three perspectives and five stations. Therefore, in step (S21), assuming s is the number of the five stations {A,B,C,D,E} and v is the number of the three perspectives {L,M,R}, the egg images acquired by station s and perspective v are denoted as... Then the complete image data set of each egg is organized into a structured multi-instance package. for: Where H is the height of the image; W is the width of the image; Represents the space of real numbers; The multi-example package B retains the actual multi-view acquisition structure and preserves the complete site-view image data structure for each egg, which facilitates aggregation by the subsequent single-layer gating attention module.
[0024] In a specific implementation, step (S22) involves processing each image. The frozen DINOv2 backbone network was used to encode it as a classification (CLS) token representation. : The 15 feature vectors of each egg are organized into a feature tensor X: This invention preferably employs a frozen self-supervised visual foundation model to extract features from image data at each site and from each viewpoint. When labeled data is limited, freezing the backbone network prevents overfitting. The self-supervised visual foundation model preferably uses DINOv2, which achieves strong generalization representations through large-scale self-supervised pre-training. During training, the backbone network parameters remain frozen, and only the multi-instance learning head parameters are updated. This design helps reduce overfitting under conditions of limited labeled data and also facilitates fair comparisons between different experimental configurations.
[0025] Step (S23) uses a single-layer gated attention module for aggregation; the design of this invention is inspired by the manual egg-candling process. In actual testing, the inspector first observes the light transmission angle of the egg from different directions at a fixed rotation position, then rotates the egg to the next position, and finally integrates the observation results from all positions to make a judgment. This is similar to the aggregation process of the multi-example package in this invention, in which the image-level representations of all perspectives of a single egg are adaptively weighted and aggregated. Unlike the scaling dot product attention used in Transformer, this mechanism assigns scalar weights to example features through a learnable scoring function, without the need for query-key-value mapping.
[0026] like Figure 5 As shown, in a preferred embodiment of the present invention, the aggregation step of the single-layer gating attention module includes: (S231) For a set of N input feature vectors, calculate the nonnormalized score e for the k-th example. k : Among them, V U It is a learnable weight matrix, w It is a learnable weight vector, where ⊙ represents element-wise multiplication. denoted as the hidden layer dimension of the single-layer gated attention module; the tanh function is the hyperbolic tangent function, used to capture discriminative feature responses, while the σ function is the sigmoid function, used to suppress or amplify feature dimensions through a learning gate; (S232) The final attention weight a is obtained by normalization through the softmax operation. k : The preferred technical solution of this invention employs a σ function to reduce the interference of irrelevant features. Through this single-layer gated attention module mechanism, feature dimensions can be differentially weighted before example aggregation. Ultimately, positive samples receive higher attention scores, negative examples are given lower weights, and uncertain examples are assigned moderate importance.
[0027] In a preferred embodiment of the present invention, the single-layer gated attention module described in step (S23) is aggregated to obtain the egg-level characterization Z. egg : ; in This represents the attention weight assigned to viewpoint v under site s; under example package-level supervision, this module learns the relative importance of different image observations within the example package. Therefore, image observations containing more evidence related to latent cracks are likely to receive higher attention weights and have greater weight in the final egg-level representation. For example, when valid information related to latent cracks appears near the end of the egg, the corresponding side viewpoint (L or R) may receive higher attention weights.
[0028] In a preferred embodiment of the present invention, step (S24) includes the following steps: (S241) The obtained egg-level representation is first regularized by the Dropout layer, and then mapped to a two-dimensional logit vector by a linear classifier. : ; in It is the learnable weight matrix of the linear layer. is the bias vector of the linear layer, and p is the Dropout probability; within the single-layer gated attention module, Dropout with a probability of 0.1~0.3 is applied for regularization. Since the backbone network used in the frozen self-supervised visual base model can already provide strong feature representations, a relatively shallow classification head is sufficient and also helps to alleviate the overfitting problem under weak supervision.
[0029] (S242) When using the multi-instance learning model framework for training, the output logit is trained under supervision using the standard cross-entropy loss function for binary classification tasks to construct an automated detection model for hidden cracks in poultry eggs.
[0030] In the model building step of the method (S2), an image preprocessing step (S20) can be added to the poultry egg images in the training set acquired by the image acquisition device. The image preprocessing step (S20) is selected from one or more combinations of random rotation, random scaling, random translation, random horizontal flipping and random vertical flipping operations on the image data; preferably, when performing random rotation, the rotation angle is controlled within ±30°; when performing random scaling, the scaling factor is controlled within 0.8-1.2 times; when performing random translation, the translation distance is controlled within ±10% of the image size.
[0031] In a preferred embodiment of the present invention, the hidden layer dimension of the single-layer gated attention module is... The value is 128~512; preferably, the hidden layer dimension of the single-layer gated attention module is... The value is 256. In a preferred embodiment of the present invention, the dropout probability is 0.1 to 0.5; more preferably, the dropout probability is 0.1 to 0.3.
[0032] In a preferred embodiment of the present invention, the image input resolution is controlled within the range of 224×224 to 518×518; preferably, the image input resolution is 448×448.
[0033] The computer device provided by this invention includes: a memory for storing instructions; and a processor for executing the instructions to enable the computer device to implement the aforementioned automated detection method for hidden cracks in poultry eggs. The computer device provided by this invention can be an electronic device such as a personal computer (PC), server device, mobile device, and embedded device. This electronic device models a model based on information provided by other components in the system. The electronic device may include a processor, RAM, neural network chip, memory, sensors, and communication modules, and may also include input / output modules, security modules, power control devices, etc. The processor can control the overall operation of the electronic device. The processor may include one processor core (single-core) or multiple processor cores (multi-core). The processor can process or execute programs and / or data stored in the memory. In some example embodiments, the processor can control the function of the neural network chip by executing programs stored in the memory. The processor can be implemented as a CPU, GPU, AP, etc. In the computer device of this invention, the CPU can be a microcontroller based on an ARM architecture.
[0034] Memory can include random access memory (RAM), such as dynamic random access memory (DRAM) and static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), CD-ROM, Blu-ray or other optical disc storage devices, hard disk drive (HDD), solid-state drive (SSD), or flash memory. Memory is a storage location for storing data and can store operating systems (OS), various programs, and various types of data. A specific technical solution of this invention also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the aforementioned automated detection method for hidden cracks in poultry eggs. The computer-readable storage medium can be used as one implementation of memory.
[0035] According to the aforementioned computer device, the specific technical solution of this invention also provides an automated detection system for latent cracks in poultry eggs based on view AI perception and multi-example learning. The system includes: the aforementioned computer device; and a multi-view, multi-site image acquisition device for acquiring complete images of each poultry egg under multi-view, multi-site conditions. The computer device in this application embodiment may include a computer-readable storage medium storing a computer program. When the computer program is executed by a processor, it implements the aforementioned automated detection method for latent cracks in poultry eggs. The computer program instructions can be formed into a program file and stored in the aforementioned computer-readable storage medium in the form of a software product, enabling a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods in the various embodiments of this application. The aforementioned computer-readable storage medium includes various media capable of storing program code, such as USB flash drives, mobile hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks, or terminal devices such as computers, servers, mobile phones, and tablets. Therefore, the present invention can provide an automated detection method for hidden cracks in poultry eggs, which can be applied to the non-destructive testing of hidden cracks in poultry eggs. Example
[0036] 1. Dataset Construction Egg samples were collected in January 2026 from a commercial poultry farm in Hangtou Town, Jiande City, Zhejiang Province, China (29.07°N, 119.17°E). All eggs were laid on the same day and imaged the following day without any intermediate processing. The dataset includes two categories: white-shelled eggs (Hy-Line White) and brown-shelled eggs (Hy-Line Brown). The dataset contains 354 clean white-shelled eggs, 359 white-shelled eggs with watermarks, 252 white-shelled eggs with hidden cracks, 355 clean brown-shelled eggs, 110 brown-shelled eggs with watermarks, and 457 brown-shelled eggs with hidden cracks. For the binary crack detection task, clean eggs and watermarked eggs were classified as intact, and eggs with hidden cracks were classified as cracked, resulting in 1178 intact eggs and 709 cracked eggs. Figure 7 Representative examples of white-shelled and brown-shelled eggs' shell appearance under candling light (rows 1 and 3) and diffuse light (rows 2 and 4) are shown. (a) shows a hidden crack (red box), (b) shows watermarks (yellow box), and (c) shows a typical sample of a clean eggshell. Eggs with watermarks are difficult to distinguish as negative samples because the local visual pattern of watermarks under candling light is similar to that of hidden cracks. With a fixed acquisition size, images were cropped using preset regions of interest, resulting in image samples for each egg containing 15 viewpoints. The final dataset contains 28,305 qualified images.
[0037] 2. Model Training and Benchmark Comparison The training and validation datasets used images of both white-shelled and brown-shelled eggs. The datasets were divided into a training set (1321 eggs), a validation set (372 eggs), and a test set (194 eggs) at the egg level, in a 7:2:1 ratio. This division avoided cross-set data leakage while maintaining the same category and eggshell color distribution ratios as the original dataset in each subset. Under weak supervision, each egg only needed to be labeled with a binary positive or negative label to indicate the presence of hidden cracks in the eggshell.
[0038] like Figure 8 As shown, five stations (AEs) are arranged sequentially along the rolling direction of the eggs. The eggs rotate approximately 72° between adjacent stations (AEs), and the five stations provide complete 360° coverage. The image acquisition device uses an industrial camera to image each station using two side views (L, R) and one center view (M).
[0039] The model of this invention is implemented based on the PyTorch framework. The performance of the model is evaluated using three benchmark models as comparisons. The three benchmark models are as follows: (1) a single image classifier, which classifies each viewpoint separately, with Adaptive-MobileNetV2 as the comparison; (2) two multi-image classifiers that only use intermediate views, namely Stitching-MobileNetV3, which aggregates observations through image stitching, and BiLSTM-DenseNet-201, which aggregates observations through sequence modeling; (3) a target detector that requires bounding boxes to be labeled for the crack region of each image, with YOLO26 series as an example. The three benchmark models and the model of this invention are all trained under the same settings to ensure fair comparison. In the binary classification task, a decision threshold of 0.5 is applied to the softmax probability of positive samples to determine the predicted category.
[0040] To ensure fairness in comparisons under limited annotation resources, all benchmark models and the model of this invention were evaluated on the same test set. Under the annotation cost-aware comparison protocol, for the strongly supervised benchmark model YOLO26, its bounding box annotation time budget was limited to approximately three hours, under which approximately 1000 images could be annotated; under the same annotation time budget, the accuracy of the method of this invention is 4.43% higher than that of the YOLO26 object detector.
[0041] The automated detection model for hidden cracks in poultry eggs of this invention uses four standard classification metrics to evaluate model performance: accuracy, F1 score, precision, and recall. The definitions of each metric are as follows: TP, TN, FP, and FN represent the number of true positives, true negatives, false positives, and false negatives, respectively. F1 score, precision, and recall are calculated using macro-averages to avoid bias caused by an imbalance in the number of intact and flawed samples. Specifically, the F1 score, precision, and recall are first calculated for each category according to equations (A.1) to (A.4), and then the average is calculated for both categories with equal weights according to the definitions in equations (A.5) to (A.7). The results are shown in Table 1.
[0042] Table 1. Performance comparison of the model of this invention with different benchmark models Model category accuracy F1 score Accuracy Recall rate DenseNet-201 Single Image Classifier 93.20±1.87% 93.00±1.89% 92.49±1.85% 94.50±1.51% Stitching-MobileNetV3 Multi-image classifier 93.61±0.41% 93.11±0.40% 94.08±1.05% 92.45±0.37% BiLSTM-DenseNet Multi-image classifier 91.96±0.76% 91.38±0.83% 91.91±0.79% 90.96±0.93% YOLO26s Target detector 94.23±0.85% 93.95±0.87% 93.58±0.96% 94.45±0.80% YOLO26m Target detector 93.51±0.86% 93.17±0.91% 92.91±0.88% 93.56±1.01% YOLO26l Target detector 93.51±1.81% 93.23±1.85% 92.76±1.90% 93.97±1.71% This invention model Multi-image classifier 98.66±0.78% 98.57±0.83% 98.74±0.79% 98.45±0.97% The results show that the model of this invention achieved an accuracy of 98.66±0.78%, an F1 score of 98.57±0.83%, a precision of 98.74±0.79%, and a recall of 98.45±0.97% on the test set. Therefore, the model of this invention can achieve high-precision egg-level characterization, and almost all cracked eggs were correctly identified. The AP value obtained from the PR curve is 1.0000 ( Figure 9 a) indicates that on this test set, the crack category is classifiable at all thresholds, and the confusion matrix shows that the false negatives on the test set are zero. Figure 9 (b) demonstrates strong and stable latent crack identification performance. Figure 9 Performance evaluation of the automated detection model for latent cracks in poultry eggs based on view AI perception multi-instance learning of the present invention: (a) PR curve; (b) test set confusion matrix.
[0043] Figure 10 The attention weights for five sites and three viewpoints of a typical poultry egg sample, along with their corresponding multi-view images, are shown. (a) shows a typical egg with a hidden crack, with the corresponding multi-view image showing the opacity adjusted according to the attention weights; (b) shows the attention weights for a typical intact egg and its multi-view image. Figure 10 As seen in (a), images with crack-related features are assigned relatively high weights (high opacity), while images mainly composed of water ripple features are assigned lower weights (high opacity). Therefore, the attention distribution of the model in this invention tends to assign higher weights to crack-related images, while not assigning high weights to visually similar water ripple appearances. In contrast, in (b), the attention weights assigned to various viewpoints and sites of a typical intact egg are relatively uniform and low.
[0044] Figure 11This document presents a comparative evaluation of the automated detection model for latent cracks in poultry eggs according to embodiments of this application, compared to benchmark models. The two multi-image classifiers can only utilize intermediate viewpoint information, limiting their ability to detect latent cracks in the egg's end region. In contrast, the single-image classifier can handle all views, but relies on strict rejection rules rather than effective multi-view aggregation, thus achieving a recall of 94.50±1.51%, but with relatively low precision. Under the same annotation workload, the YOLO26 series target detector exhibits the strongest overall performance, achieving an accuracy of 94.23±0.85%. The model of this invention performs best among all benchmark models, improving accuracy by 4.43% compared to the strongest benchmark model. Therefore, effective latent crack classification depends not only on acquiring complete multi-view and multi-site observation data but also on effectively aggregating information from different views and sites. Confusion matrices for some benchmark models are attached. Figure 11 The figure illustrates the general performance trends of different benchmark models.
[0045] 3. Ablation test This experiment designed ablation experiments from three angles: (1) Gated attention mechanism: The single-layer gated attention was replaced with an average pooling strategy to evaluate the effect of learnable example-specific weighting compared to uniform averaging. (2) Multi-view coverage: Two side views (L, R) were removed, and only the middle view (M) of each station was retained, approximating the traditional imaging scheme that only retains the middle view (M). All other components remained unchanged, and the contribution of the three-view imaging configuration to the detection performance was evaluated. (3) Backbone network: The frozen self-supervised vision base model was replaced with frozen ImageNet pre-trained ResNet-50 and ViT-B / 14 respectively to evaluate the contribution of self-supervised pre-training compared to supervised pre-training. The results are shown in Table 2.
[0046] Table 2. Ablation experiment evaluation results of this model Configuration accuracy F1 score Accuracy Recall rate This invention model 98.66±0.78% 98.57±0.83% 98.74±0.79% 98.45±0.97% Average pooling 98.35±0.67% 98.24±0.73% 98.54±0.38% 97.99±1.01% Only retain the middle view 94.85±0.96% 94.54±0.99% 94.60±1.23% 94.54±0.86% ResNet-50 93.40±1.73% 92.80±1.96% 94.44±1.31% 91.82±2.35% ViT-B / 14 92.68±1.91% 92.06±2.00% 93.60±2.56% 91.18±1.95% To evaluate the contribution of key components in the model of this invention, four ablation experiments were compared with the complete model, and the results are summarized in Table 2. Replacing the gated attention module with an average pooling layer module leads to a performance decrease, indicating that learnable example-specific weighted aggregation is superior to uniform averaging. When only the intermediate view is retained, the accuracy drops to 94.85%. This setting is similar to the traditional imaging scheme with only the intermediate view (M), and the significant performance drop highlights the importance of multi-view coverage for reliable full-surface latent crack detection. When only the intermediate view is retained, the high curvature region of the egg image becomes blurred. Replacing the frozen DINOv2 backbone network with frozen ImageNet pre-trained ResNet-50 and ViT-B / 14, respectively, resulted in a significant decrease in accuracy. Therefore, the performance of the model of this invention comes from the synergistic effect of the gated attention module, multi-view input, and backbone network selection, rather than the effect of a single module.
[0047] Table 3 shows the accuracy evaluation results compared to existing commercial grading detection systems. Commercial grading detection systems typically focus on mature system integration and extremely high throughput, while the model of this invention aims to reduce annotation requirements and achieve reliable extraction of egg-level representations based on multi-view visual observation data. This invention only requires a binary classification label of "cracked / no crack" for one egg to complete training, without needing to annotate each image or the location and boundaries of the crack, significantly reducing annotation costs compared to strongly supervised methods. Traditional, well-known strongly supervised methods require annotating crack bounding boxes or pixel-level masks for each image, resulting in extremely high annotation costs and costs; while traditional single-image classification models in benchmark comparison models require removing crack-free views from the collected multi-view cracked egg dataset before training. From the perspective of annotation costs and supervised learning, the model of this invention provides a feasible and efficient weakly supervised solution for high-throughput online eggshell hidden crack detection.
[0048] Table 3 Performance Comparison with Commercial Egg Sorting Equipment 4. Model optimization experiment The model optimization experiment of this invention used adjustments to the model configuration for optimization. The model configuration adjustment and evaluation results are shown in Table 4.
[0049] Table 4 Evaluation Results of Model Configuration Adjustment for the Invention As shown in Table 4, regarding model configuration adjustments, reducing the input resolution from 448×448 to 224×224 resulted in a 3.09% decrease in accuracy, while increasing the resolution to 518×518 did not provide further gains, indicating that 448×448 represents a suitable trade-off between performance and computational cost. Within the test range, the gating attention hyperparameter had only a moderate impact on performance. A possible reason is that the current dataset only includes brown and white eggs, which limits the evaluation of broader generalization capabilities. The frozen DINOv2 backbone network improved feature quality but may limit the model's deployment on resource-constrained hardware.
[0050] In summary, the automated detection model for latent cracks in poultry eggs of this invention features view-based AI perception. It utilizes image acquisition equipment for multi-view, multi-site egg candling imaging. Under weak supervision using only egg-level binary classification labels, it aggregates 15 multi-view observations for each egg based on a multi-instance learning framework combined with a frozen DINOv2 backbone network and a single-layer gated attention module. On a dataset containing 1887 eggs and 28305 images, an egg-level accuracy of 98.66 ± 0.78% was achieved. With a total annotation time of approximately three hours, the accuracy of this model is 4.43% higher than the strongly supervised YOLO26s benchmark, highlighting the practical value of weakly supervised learning under limited annotation conditions. Ablation experiments and attention visualization further validate the effectiveness of the multi-view hardware design and the aggregation of the single-layer gated attention module. Therefore, this invention provides a feasible and highly efficient weakly supervised solution for high-throughput online detection of latent cracks in eggshells.
[0051] In the various embodiments of this invention, the functional units can be integrated into a processing module, or each unit can exist physically separately, or two or more units can be integrated into a module. The integrated module can be implemented in hardware or as a software functional module. If the integrated module is implemented as a software functional module and sold or used as an independent product, it can be stored in a computer-readable storage medium.
[0052] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented, in whole or in part, as a computer program product. A computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the flow or function according to the embodiments of this application is 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 or transmitted through a computer-readable storage medium. The computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. 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 (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid-state disk (SSD)).
[0053] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
Claims
1. An automated detection method for latent cracks in poultry eggs based on view AI perception and multi-instance learning, characterized in that, The method includes the following steps: (S1) Data acquisition steps: Use image acquisition equipment to acquire multi-view, multi-site images of each poultry egg, and assign egg-level binary classification labels to each poultry egg to form training and validation datasets; (S2) Model construction steps: Using the training and validation datasets as input, the frozen backbone network is used to extract image-level representations, and then the whole image-level representations are adaptively weighted and aggregated through a single-layer gated attention module to obtain egg-level representations. Using egg-level binary classification labels as supervision signals, the standard cross-entropy loss function is used for end-to-end training to complete the construction of the automated detection model for hidden cracks in poultry eggs. (S3) Product inspection steps: Import the image of the egg to be inspected into the trained automated detection model for hidden cracks in eggs, and obtain the detection result of whether the egg to be inspected has hidden cracks through model inference.
2. The automated detection method for hidden cracks in poultry eggs according to claim 1, characterized in that, In the method described above, when the image acquisition device acquires the test image of the poultry egg from multiple perspectives, the image acquisition device acquires the image from at least a central perspective (M), a left perspective (L), and a right perspective (R). The central perspective (M) is the perspective when the image acquisition device faces the equatorial region of the poultry egg and is directly facing the equatorial region of the poultry egg, and the image acquired is of the equatorial region of the poultry egg. The left perspective (L) is the perspective when the image acquisition device faces the air cell end region of the egg, and the image acquired is of the air cell end region of the poultry egg. The right view (R) is the viewpoint when the image acquisition device is facing the pointed area of the egg, and the image acquired is of the pointed area of the egg. Preferably, when the image acquisition device acquires images of the test from multiple stations, the rolling angle of each egg in the minor axis tangential direction at adjacent stations where the image acquisition device acquires images is 360° / n, where n represents the number of stations and is a natural number greater than or equal to 1; Preferably, when the image acquisition device acquires images to be tested at 5 stations, the rolling angle of each egg in the minor axis tangential direction is 72° at the adjacent stations where the image acquisition device acquires images.
3. The automated detection method for hidden cracks in poultry eggs according to claim 1, characterized in that, The method uses an image acquisition device to acquire multi-view, multi-site images of each egg under the condition of being illuminated by a candling light source, the exposure time of which is set to 500 microseconds; the illumination area of the candling light source and the photosensitive area of the image acquisition device under multi-view conditions are set in relative positions; preferably, the candling light source is set in relative positions to the image acquisition device for acquiring the intermediate view (M) when it is illuminating. Preferably, the egg images in the training and validation datasets include both white-shelled egg images and brown-shelled egg images.
4. The automated detection method for hidden cracks in poultry eggs according to claim 1, characterized in that, The method includes step (S2) of constructing an automated detection model for hidden cracks in poultry eggs, which specifically includes the following steps: (S21) Based on all valid images of each poultry egg from multiple sites and multiple perspectives, construct a structured multi-example package corresponding to the poultry egg; (S22) A frozen self-supervised visual base model is used to independently extract image-level representations for each image in the multi-example package; (S23) Image-level representations are weighted and aggregated into egg-level representations through a single-layer gated attention module; (S24) Using egg-level binary classification labels as supervision signals, end-to-end training is performed on the single-layer gated attention module and the classification head through the standard cross-entropy loss function.
5. The automated detection method for hidden cracks in poultry eggs according to claim 4, characterized in that, In the method described, step (S2) is constructed using a three-view, five-station image acquisition device. Therefore, in step (S21), assuming s is the number of the five stations {A, B, C, D, E}, and v is the number of the three viewpoints, the image of the poultry egg acquired by the image acquisition device at station s and viewpoint v is denoted as... Then, the complete and valid image of each egg is organized into a structured multi-instance package. for: Where H is the height of the image; W is the width of the image; Represents the space of real numbers; Preferably, in step (S22), each image of a poultry egg is denoted as... The DINOv2 backbone network was frozen and encoded as a classification (CLS) token representation. : The 15 feature vectors of each egg are organized into a feature tensor X: (S23) The step of weighted aggregation of the single-layer gated attention module includes: (S231) For a set of N input feature vectors, calculate the nonnormalized score e for the k-th example. k : ; Among them, V U Both are learnable weight matrices, w It is a learnable weight vector, where ⊙ represents element-wise multiplication. denoted as the hidden layer dimension of the single-layer gated attention module; the tanh function is the hyperbolic tangent function, used to capture discriminative feature responses, while the σ function is the sigmoid function, used to suppress or amplify feature dimensions through a learning gate; (S232) The final attention weight a is obtained by normalization through the softmax operation. k : Preferably, in step (S23), the single-layer gated attention module is aggregated to obtain the egg-level representation Z. egg : ; in This represents the attention weight assigned to site s when viewing v; Preferably, in step (S24), the specific steps for end-to-end training of the single-layer gated attention module and the classification head using the egg-level binary classification label as the supervision signal and the standard cross-entropy loss function include: (S241) The obtained egg-level representation is first regularized by the Dropout layer, and then mapped to a two-dimensional logit vector by a linear classifier. : ; in It is the learnable weight matrix of the linear layer. is the bias vector of the linear layer, and p is the Dropout probability; (S242) When learning and training using the multi-instance learning model framework, the output logit vector is... Supervised training was conducted using the standard cross-entropy loss function for binary classification tasks to obtain an automated detection model for hidden cracks in poultry eggs.
6. The automated detection method for hidden cracks in poultry eggs according to claim 5, characterized in that, In the model construction step of the method (S2), the poultry egg images in the training set acquired by the image acquisition device are subjected to the image preprocessing step (S20); The image preprocessing step (S20) is selected from one or more combinations of random rotation, random scaling, random translation, random horizontal flipping and random vertical flipping operations on the image data; preferably, when performing random rotation, the rotation angle is controlled within ±30°; when performing random scaling, the scaling factor is controlled within 0.8-1.2 times; when performing random translation, the translation distance is controlled within ±10% of the image size.
7. The automated detection method for hidden cracks in poultry eggs according to claim 5, characterized in that, The hidden layer dimension of the single-layer gated attention module The value is 128~512; preferably, the hidden layer dimension of the single-layer gated attention module is... It is 256; The image-level representation input resolution is in the range of 224×224 to 518×518; preferably, the image-level representation input resolution is 448×448.
8. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it implements the automated detection method for hidden cracks in poultry eggs as described in any one of claims 1 to 7.
9. A computer device, comprising: Memory, used to store instructions; A processor is configured to execute the instructions to enable the device to implement the automated detection method for hidden cracks in poultry eggs as described in any one of claims 1 to 7.
10. An automated detection system for latent cracks in poultry eggs based on view AI perception and multi-instance learning, characterized in that, The system includes: The computer device of claim 9; and, A multi-view, multi-site image acquisition device is used to acquire complete image data of each individual egg in the system under multi-view, multi-site conditions.