Attention Guided Convolutional Neural Networks for Accurate Egg Defect Detection in Food Quality Assessment
摘要
Egg defect detection is essential for ensuring food safety and quality in the egg production industry. This study introduces a novel approach for egg defect detection by integrating a multi-head self-attention (MHSA) mechanism into the AlexNet convolutional neural network (CNN) to overcome the limitations of traditional CNNs in capturing long-range dependencies and global context. A machine vision system equipped with a constant-speed rotating mechanism was developed to capture multi-view images of each egg’s surface. Each egg was imaged from six angles, generating a dataset of 2400 images categorized into four classes: bloodstained, cracked, dirty, and intact. The collected images were pre-processed through segmentation and cropping before being fed into the MHSA-AlexNet architecture. The extracted feature maps were flattened and passed through an MHSA layer with eight attention heads, followed by a fully connected layer and Softmax classifier. The proposed MHSA-AlexNet model achieved an average accuracy of 0.9847, outperforming the baseline AlexNet and surpassing other state-of-the-art CNNs. The model also surpassed conventional machine learning models, including Naïve Bayes, Random Forest, and Support Vector Machine, by 36.35–66.81%. Comparison with prior studies demonstrated that MHSA-AlexNet achieved superior accuracy, emphasizing the effectiveness of integrating self-attention mechanisms for egg defect detection.