Abstract:Objective To propose an intelligent defect detection method based on an improved YOLO v7 model for the challenges of strong polymorphism in peanut surface defects and insufficient accuracy of traditional visual inspection methods.Methods A cross-channel attention mechanism is integrated to enhance local feature response. Then, a bidirectional feature pyramid is constructed to improve multi-scale defect fusion. Additionally, an angle constraint loss function is introduced to optimize irregular object localization. Furthermore, the model is optimized using an industrial-grade sample library combined with data augmentation strategies.Results The improved model achieves a precision of 0.917, a recall of 0.903, Pt@0.5 of 0.948, and Pt@[0.5:0.95] of 0.705 on the test set, with an inference speed of 74.166 frames per second, significantly outperforming other models. Ablation experiments indicate that the MSAM module contributes most to fine-grained feature recognition.Conclusion The proposed method balances detection accuracy and real-time performance, effectively overcoming challenges such as complex surface textures and significant defect scale variation. The proposed method provides an efficient solution for intelligent defect inspection on peanut surfaces.