1. Introduction
In 2023, China’s poultry egg production and consumption reached approximately 34.5 million tons. Poultry eggs are rich in nutrients and have a significant positive impact on human health and development. The poultry egg industry plays a crucial role in driving national economic growth, promoting agricultural development, and ensuring food safety. However, during production, storage, and distribution, poultry eggs are prone to defects such as cracks, damage, and contamination [
1], which typically require manual inspection and sorting. Microcracks, in particular, severely affect egg quality but are often overlooked during inspection [
2]. Eggshell damage is a critical issue in egg production and a major source of economic loss for the industry [
3]. As a result, researchers both domestically and internationally are increasingly focused on developing high-speed, high-precision poultry egg crack detection technologies. Current research primarily centers on acoustic, optical, and electrical analysis, as well as deep learning methods, achieving notable advancements in these fields.
The acoustic-based eggshell crack detection method leverages the physical properties of sound to analyze the vibration signals generated by striking an eggshell, offering a novel research approach. Eggshell cracks can affect the structural strength and damping coefficient of eggs, which are reflected in the frequency and intensity of vibration signals. Chia-Chun Lai et al. [
4] used cross-correlation analysis and Bayesian classification to classify and detect acoustic response signals generated by eggshell cracks, achieving a detection rate of 97%. Li Sun et al. [
5] employed acoustic resonance analysis to detect eggshell cracks by impacting eggshells and collecting their response signals. They calculated Pearson correlation coefficients (PCCs) as feature parameters to compare the signal similarity between intact and cracked eggs at various sampling points. Based on these feature parameters, they established a general linear discriminant function to distinguish between intact and cracked eggs. In their experiment, a mixed sample of 100 chicken eggs and 100 duck eggs was used, and the crack detection rate reached 95.5%. However, these methods are susceptible to environmental conditions, egg shapes, crack locations and impact angles, leading to insufficient detection stability. Moreover, excessive impact force may further damage the eggshell structure. Additionally, since microcracks smaller than 5 mm have minimal impacts on the structural rigidity and resonance characteristics of eggs, acoustic techniques achieve lower accuracy in detecting microcracks [
6].
Shi Chenbo et al. [
7] proposed a non-destructive detection method for eggshell cracks based on a model of the electrical characteristics of eggs. This method involves establishing an electric field on the eggshell surface and analyzing the subtle current changes caused by cracks in the eggshell. The detection hardware system is designed based on electrical characteristic analysis. Additionally, Shi Chenbo et al. [
8] developed a wavelet-scattering convolutional network algorithm utilizing 1D-CNN, LSTM, BiLSTM, and GRU networks for the non-destructive detection of microcracks in eggshells from electrical signals. While this method achieves high accuracy, it has limitations in detection coverage, failing to comprehensively identify all microcracks. Additionally, air humidity can affect conductivity, introducing instability to this method. The detection performance of this method may also be suboptimal for hidden cracks that have not fully penetrated the eggshell or for dry, fine cracks.
Compared to acoustic and electrically based methods, optically based egg crack detection methods offer the advantages of being non-destructive and stable. This technique captures images of the eggshell surface using image acquisition devices and processes and analyzes the image data. Therefore, machine vision-based eggshell crack detection methods are widely used in practical applications and have developed relatively mature technologies [
9]. Guanjun Bao et al. [
10] addressed irregular dark spots and invisible microcracks on the eggshell surface by using a negative LOG (Laplacian of Gaussian) operator to enhance cracks. They then employed a hysteresis threshold algorithm to eliminate irrelevant dark spots in the binary image, ensuring crack continuity. Finally, they used an improved Local Fitting Image (LFI) indicator to distinguish between cracks and false markings, achieving a crack detection rate of 92.5%. Kunshan Yao et al. [
11] proposed methods such as crack enhancement and dual-threshold segmentation to extract the geometric features of cracks. Using the XGBoost classification model, they classified cracked eggs and achieved a recognition accuracy of 93.33%.
Traditional machine vision methods can effectively detect eggshell cracks; however, they often suffer from algorithmic complexity and slow processing speeds. With the recent advancements in deep learning in the field of computer vision, deep learning-based approaches have demonstrated superior performance in crack detection. Currently, the primary research achievements in eggshell crack detection focus on image classification tasks. Bhavya Botta et al. [
12] created an eggshell crack dataset containing 468 images, with crack widths ranging from 20 to 40
m and an average length of 30 mm. By employing convolutional neural networks (CNNs), they achieved a detection accuracy of 95.38%. Wenquan Tang [
13] proposed the MobileNetV3_egg model, based on MobileNetV3_large, for real-time detection of damaged preserved eggs, achieving an accuracy of 96.3% and detecting 300 images in 4.267 s. Amin Nasiri et al. [
14] collected images of intact, broken, and blood-stained eggs and used a CNN classification algorithm based on the VGG16 architecture, achieving an accuracy of 94.85%. With the introduction of segmentation networks such as U-Net, DeepLab-V3, and PSPNet, improved semantic segmentation models have also been applied to detection tasks. Xiuying Xu et al. [
15] developed a semantic segmentation model based on an improved U-Net for the segmentation of corn stalks in fields with complex backgrounds, achieving an accuracy of 93.87%, outperforming U-Net, SegNet, and ResNet models. Chengqi Liu et al. [
16] proposed a DeepLab V3+-based deep learning method for pig image segmentation in small sample sizes. They optimized the fusion of high- and low-frequency features using a recursive cascading approach to extract latent semantic information, resulting in a single-label model MIoU of 76.31%. However, these models are complex, with a large number of parameters and high training costs; therefore, they may not be suitable for the detection of narrow microcracks with few pixels in the images.
In the context of microcrack detection in poultry eggs for industrial applications, it is essential to address the model’s scale and efficiency. Given the constraints of computational power, a pressing research issue is how to reduce the parameters of semantic segmentation models to make them more lightweight and accelerate inference without compromising detection accuracy. In 2022, Zhuang Liu et al. [
17] redesigned a purely convolutional neural network model based on the standard ResNet and named it ConvNeXt. This model outperformed the Swin Transformer in the field of computer vision, with lower computational costs. Zhimeng Han et al. [
18] proposed an effective model combining U-Net and ConvNeXt for medical image segmentation, achieving leading results with fewer parameters. Inspired by ConvNeXt, our model introduces improvements such as large convolution kernels and depthwise separable convolutions to reduce the number of model parameters.
In microcrack detection, challenges arise due to the narrow width of cracks and the similarity in contrast between the crack ends and the background texture. This paper addresses these challenges through the following two approaches: by enhancing detailed features and fully aggregating feature information for segmentation. In segmentation tasks, cracks can be divided into edge and internal regions [
19]. In the field of object detection, some researchers [
20] have demonstrated that utilizing and integrating edge features can improve the model’s perception accuracy. Crack edge features help the model distinguish and locate crack defects. In digital image processing, edge detection effectively extracts object edge information by identifying pixels with significant brightness changes. Common detection algorithms include the Sobel, Prewitt, and Canny algorithms. Rasha Alshawi et al. [
21] proposed using Sobel and Canny filters for edge detection to extract engineering features and manually integrate them into the network model to guide segmentation. This feature enhancement method provides a robust solution for segmentation tasks on limited and skewed datasets. Inspired by data augmentation, this paper’s model incorporates a strategy of injecting image edge features into the encoder design to expand the detail feature space, thereby enhancing the model’s ability to detect microcracks.
Additionally, Hengshuang Zhao et al. [
22] proposed the Pyramid Scene Parsing Network (PSPNet) for pixel-level prediction tasks, providing an excellent framework by aggregating context from different regions. Building on this, Guosheng Lin et al. [
23] proposed a multi-stage refinement network (RefineNet) that effectively integrates missing information from downsampling, producing high-resolution predictive images. It is evident that multi-scale feature fusion is beneficial for improving segmentation accuracy. Therefore, our model aggregates multi-scale features in the decoder to obtain fused features. Ablation experiments demonstrate that this approach significantly enhances accuracy compared to single upsampling of high-resolution feature maps for prediction.
In microcrack image segmentation, addressing class imbalance is a critical challenge due to the uneven distribution of foreground and background in the images. The positive–negative cross-entropy loss function is commonly used for most semantic segmentation tasks. However, when foreground pixels are significantly fewer than background pixels, the background elements dominate the loss function calculation. This dominance causes the model to become overly biased toward the background, adversely affecting training and prediction outcomes. The Dice coefficient-based loss function proposed by Fausto Milletari et al. [
24] has been widely adopted to mitigate the negative impact of imbalanced foreground and background areas on model performance. The Dice loss function places more emphasis on capturing the foreground regions, ensuring a lower false-negative rate. However, it suffers from the issue of loss saturation and is typically used in conjunction with the cross-entropy loss function. Michael Yeung et al. [
25] proposed a unified focal loss that combines cross-entropy loss and Dice loss to address class imbalance. Experimental results indicate that this loss function exhibits robust performance in handling class imbalance.
In summary, this paper proposes a lightweight and highly real-time algorithm for the detection of microcracks in poultry eggs. The main innovations of this study are summarized as follows:
This paper proposes a Real-time ConvNext-Based U-Net architecture with Feature Infusion for egg microcrack detection (CBU-FI Net). This architecture leverages the strengths of both U-Net and ConvNeXt, using ConvNeXt’s fundamental modules as the backbone network. This approach significantly reduces the model’s parameter count and computational complexity.
To address the challenges in microcrack detection tasks, this paper introduces a feature infusion module within the encoder and employs multi-scale feature aggregation in the decoder for segmentation. By incorporating edge information, this strategy expands the spatial representation of crack features and enhances the extraction of both local details and global semantic information. This approach significantly improves microcrack segmentation accuracy, even with limited training data.
To tackle the challenge of positive and negative sample imbalance in microcrack images for practical industrial applications, this paper introduces a hybrid loss function that combines cross-entropy loss and Dice loss. This approach significantly improves segmentation performance on microcrack images.
4. Discussion
This study addresses the low efficiency and high cost of traditional poultry egg microcrack detection by proposing a real-time U-Net architecture based on feature infusion (CBU-FI Net). Using U-Net as the baseline model, we improved it to address the issues of large model parameters and slow image processing speed. The proposed model combines U-Net and ConvNeXt, enhancing the extraction of local detail information and global semantic information by injecting image edge features into the encoder and aggregating multi-scale features in the decoder. Additionally, a hybrid loss function based on cross-entropy loss and Dice loss was designed to further improve the segmentation performance of microcrack images, achieving real-time, high-precision, pixel-level microcrack detection. Compared to the original U-Net model, the improved model reduces the number of parameters and accelerates image processing speed while optimizing the model’s focus on microcracks. This enhances the proportion of crack edge features within the overall semantic information, strengthening the model’s ability to extract crack features.
The proposed real-time poultry egg microcrack detection model based on feature infusion achieves a real-time detection speed of 21 ms for input images with a resolution of 1024 × 1024. When detecting microcracks smaller than 20
m, the model achieved an MIoU of 82.47%. On the benchmark CrackSeg9k dataset, it achieved an inference speed of 4 ms per image with a resolution of 400 × 400 and an MIoU of 81.38%, with a model parameter count of 7.696 M. Compared to state-of-the-art segmentation models, it achieves leading accuracy with fewer parameters. Using industrial microscopic measurement, the smallest detectable crack size is 3
m. According to the visualization results presented in
Section 3.3, although microcrack segmentation is relatively complete, there are still small parts of microcrack ends that are not fully detected. This may be due to the microcrack width being less than 3
m or insufficient image resolution, resulting in the cracks occupying fewer pixels in the image and making it difficult for the algorithm to accurately segment the complete outline of the cracks.
The high-efficiency microcrack detection system we propose can help to improve production efficiency on poultry egg production lines, reduce economic losses caused by defective eggs, and enhance agricultural production efficiency. It can positively impact the upgrading and development of the entire poultry egg industry.
5. Conclusions
This study proposes a real-time ConvNext-based U-Net with feature infusion for egg microcrack detection (CBU-FI Net). This model integrates the advantages of ConvNeXt’s large convolution kernels and depthwise separable convolutions, addressing the issues of large parameter size and slow inference speed in the U-Net model. To tackle challenges in microcrack detection, such as narrow crack width and low contrast between crack ends and the background texture, the model infuses image edge features in the encoder and aggregates multi-scale features in the decoder, enhancing the extraction of both local detail information and global semantic information. Additionally, a composite loss function is constructed to address the imbalance between positive and negative samples. Using a single-point backlight source collection device, over 3400 graded poultry egg microcrack image patches were created for model training and validation.
Experimental results demonstrate that CBU-FI Net’s parameter size is only one-third of that of the original U-Net, and the inference speed is 21 ms per image (1 million pixels). This model exhibits strong robustness and generalization ability, adapting to different types of cracks and complex background environments. On the public benchmark CrackSeg9k dataset, CBU-FI Net achieved an inference speed of 4 ms per 400 × 400 image and an MIoU of 81.38%. Additionally, on the poultry egg microcrack defect dataset, the model’s Crack-IoU for microcracks (less than 20 m) was 65.51%; for smaller cracks (less than 5 m), the detection results show a Crack-IoU and MIoU of 60.76% and 80.22%, respectively, achieving real-time, high-precision real-microcrack detection. These results are superior to those achieved by the traditional U-Net model and other advanced semantic segmentation models, laying a foundation for online microcrack detection in poultry eggs based on semantic segmentation.
The proposed method for detecting microcracks in poultry eggs can significantly enhance production efficiency on egg processing lines, reducing economic losses associated with undetected defects. By improving the accuracy and reliability of crack detection, this method contributes to higher standards of food safety and quality control. Additionally, the method can be extended to other industries requiring precise defect detection, such as materials science, automotive manufacturing, and aerospace. As the technology continues to develop, it may find broader applications, driving innovation and efficiency across various sectors and supporting sustainable growth and advancement in these industries. In the future, we will explore the integration of discharge methods with imaging techniques to develop a multi-sensor fusion approach for the detection of microcracks in poultry eggs. By combining discharge signals with image data, we aim to enhance detection accuracy and robustness, thereby further improving the effectiveness of microcrack detection.