PCB Defect Detection Algorithm Based on Improved YOLOv7
Achieving enhanced detection accuracy is a challenging task in the field of PCB defect detection.To address this problem,this study proposes a series of improvement methods based on PCB defect detection.First,a novel attention mechanism,referred to as BiFormer,is introduced.This mechanism uses dual-layer routing to achieve dynamic sparse attention,thereby reducing the amount of computation required.Second,an innovative upsampling operator called CARAFE is employed.This operator combines semantic and content information for upsampling,thereby making the upsampling process more comprehensive and efficient.Finally,a new loss function based on the MPDIoU metric,referred to as the LMPDIoU loss function,is adopted.This loss function effectively addresses unbalanced categories,small targets,and denseness problems,thereby further improving image detection performance.The experimental results reveal that the model achieves a significant improvement in mean Average Precision(mAP)with a score of 93.91%,13.12 percentage points higher than that of the original model.In terms of recognition accuracy,the new model reached a score of 90.55%,representing an improvement of 8.74 percentage points.These results show that the introduction of the BiFormer attention mechanism,CARAFE upsampling operator,and LMPDIoU loss function effectively improves the accuracy and efficiency of PCB defect detection.Thus,the proposed methods provide valuable references for research in industrial inspection,laying the foundation for future research and applications.
PCB defectBiFormer attention mechanismMPDIoU loss functionupsampling operator CARAFEtarget detection