Abstract:With the aim to address the issues of low efficiency and high labor costs in crack detection and sorting of preserved eggs, a method for online crack detection based on an improved version of YOLO v5 was proposed. The backbone feature extraction network was replaced with the EfficientViT network, and the network was trained by using transfer learning, resulting in two models: YOLO v5n_EfficientViTb0 and YOLO v5s_EfficientViTb1. YOLO v5n_EfficientViTb0 served as a lightweight model, reducing the parameter size by 148% and the floating point operations by 268% compared with that of the original model. YOLO v5s_EfficientViTb1, on the other hand, was a high-precision detection model with an average precision mean of 878%. Through the utilization of GradCAM++ for model visualization and analysis, it was discovered that the improved model demonstrated a decreased focus on the background region. This finding served as evidence supporting the effectiveness of the enhancements implemented in the model. Moreover, a target box matching algorithm was designed for video frames to enable object tracking of preserved eggs in videos. Based on the detection sequence of preserved eggs, the algorithm achieved localization of the eggs and discrimination between cracked and intact ones. The lightweight model achieved a discrimination accuracy of 92.0%, while the high-precision model achieved an accuracy of 94.3%. These research findings indicated that the improved lightweight model provided a solution for preserved egg crack detection equipment with lower computational capabilities, while the improved high-precision model offered technical support for preserved egg crack detection equipment with higher production requirements.