Abstract:Objective To address the issues of weak generalization, insufficient accuracy, and poor anti-interference ability in existing intelligent detection methods for food packaging defects.Methods On the basis of the intelligent sorting system for food packaging defects, a method for intelligent detection of food packaging defects is proposed, which combines machine vision and an improved U-Net model. By introducing a multi-scale residual convolution module into the convolution module, the method reduces the computational complexity of the model and improves the training effect. By integrating channel attention, spatial attention, and multi-scale attention, a lightweight hybrid attention module is constructed to achieve the synergistic effect of different dimensions of attention, strengthen the model's feature extraction and anti-interference abilities for food packaging defects, and suppress complex background noise. Replacing the max pooling layer in U-Net with soft pooling reduces feature information loss and preserves more defect feature details and edge information. Model training and comparative experiments are conducted by building an experimental platform.Results The proposed method has excellent generalization ability in multiple types of food packaging defect detection tasks, with an average detection accuracy of 97.50%, which is 10.3% higher than that of the traditional U-Net model. The detection time for a single image is only 20 ms. The model parameter size is 12.8 M. The missed detection rate is 1.1%, and the false detection rate is 0.5%.Conclusion This method effectively addresses the core pain points of existing detection methods, achieving an optimized balance among multi-scale defect detection accuracy, model lightweighting, and real-time performance. It can quickly and accurately identify and locate food packaging defects.