Abstract:With the development of electronic products in the direction of high performance and miniaturization, printed circuit boards (PCBs), as the core carrier of electronic systems, are becoming more and more complex in design and manufacturing, with more closely arranged components and a finer structure, which puts forward higher requirements for component detection and defect detection. Although the target detection models based on convolutional neural networks represented by YOLO have received a lot of research, these models are only designed for a single defect or component detection scenario, and have a limited effect on the detection of small targets and dense scenarios. The emergence of RT-DETR has enabled Transformer-based end-to-end detection models to perform excellently in real-time detection. Therefore, based on the RT-DETR model, this article proposes an end-to-end real-time target detection model MFSF-DETR, based on a Transformer for PCB scenarios. Firstly, the Faster-CGLU Block is used to replace the Block layer in the backbone network, the channel attention mechanism is refined, and the entanglement transformer block (ETB) is introduced to integrate the frequency domain with the spatial domain to enrich the deep semantics. Then, the rep adaptive weighted cross-scale feature fusion (RAWCFF) is designed to replace the CNN-based cross-scale feature fusion and form a new feature fusion encoder with the cross-scale feature shift fusion (CFSF)to realize the deep interaction between neighboring and non-neighboring features. Finally, the proposed model is evaluated using the PCB defect dataset DsPCBSD+, the PKU-Market-PCB dataset, the PCB component dataset PCB_WACV, and the PCB and drone dataset VisDrone2019 to assess its detection performance and generalization ability in PCB scenarios. The experimental results show that the MFSF-DETR model achieved the highest accuracy of 85.6%, 98.1%, and 89.9% in defect and component detection, respectively, which is 3.1%, 1.0%, and 3.8% higher than the baseline model. Meanwhile, the FPS indicators also reached 120.2, 57.1, and 71.8, respectively, achieving efficient and high-precision detection in the PCB background.