Li Xingyou, Xue Sheng, Li Zhenye, Fang Xiaodong, Zhu Tingting, Ni Chao
College of Mechanical and Electronic Engineering, Nanjing Forestry University, Nanjing 210037, China.
Foods. 2024 Oct 21;13(20):3343. doi: 10.3390/foods13203343.
Quality management in the candy industry is a vital part of food quality management. Defective candies significantly affect subsequent packaging and consumption, impacting the efficiency of candy manufacturers and the consumer experience. However, challenges exist in candy defect detection on food production lines due to the small size of the targets and defects, as well as the difficulty of batch sampling defects from automated production lines. A high-precision candy defect detection method based on deep learning is proposed in this paper. Initially, pseudo-defective candy images are generated based on Style Generative Adversarial Network-v2 (StyleGAN2), thereby enhancing the authenticity of these synthetic defect images. Following the separation of the background based on the color characteristics of the defective candies on the conveyor belt, a GAN is utilized for negative sample data enhancement. This effectively reduces the impact of data imbalance between complete and defective candies on the model's detection performance. Secondly, considering the challenges brought by the small size and random shape of candy defects to target detection, the efficient target detection method YOLOv7 is improved. The Spatial Pyramid Pooling Fast Cross Stage Partial Connection (SPPFCSPC) module, the C3C2 module, and the global attention mechanism are introduced to enhance feature extraction precision. The improved model achieves a 3.0% increase in recognition accuracy and a 3.7% increase in recall rate while supporting real-time recognition scenery. This method not only enhances the efficiency of food quality management but also promotes the application of computer vision and deep learning in industrial production.
糖果行业的质量管理是食品质量管理的重要组成部分。有缺陷的糖果会显著影响后续的包装和消费,影响糖果制造商的生产效率和消费者体验。然而,由于目标和缺陷尺寸小,以及从自动化生产线批量采样缺陷困难,食品生产线上的糖果缺陷检测存在挑战。本文提出了一种基于深度学习的高精度糖果缺陷检测方法。首先,基于风格生成对抗网络v2(StyleGAN2)生成伪缺陷糖果图像,从而提高这些合成缺陷图像的真实性。根据传送带上有缺陷糖果的颜色特征分离背景后,利用生成对抗网络进行负样本数据增强。这有效地减少了完整糖果和有缺陷糖果之间的数据不平衡对模型检测性能的影响。其次,考虑到糖果缺陷的小尺寸和随机形状给目标检测带来的挑战,对高效目标检测方法YOLOv7进行了改进。引入了空间金字塔池化快速跨阶段部分连接(SPPFCSPC)模块、C3C2模块和全局注意力机制,以提高特征提取精度。改进后的模型在支持实时识别场景的同时,识别准确率提高了3.0%,召回率提高了3.7%。该方法不仅提高了食品质量管理的效率,还促进了计算机视觉和深度学习在工业生产中的应用。