In industrial inspection, printed circuit board (PCB) defects are numerous and complex, small size, difficult to detect. The traditional inspection methods are prone to the shortcomings of leakage and misdetection. To address the above problems, this paper proposes an improved PCB bare board defect detection algorithm based on YOLOv5s, which strengthens the fusion of deep abstract specialization semantic information and shallow fine-grained pixel structure information by adding BiFPN module to reconstruct the feature fusion network; introduces Biformer attention mechanism in the backbone network and feature fusion part to make full use of shallow features while The Biformer attention mechanism is introduced in the backbone network and feature fusion part to enhance the global information capture capability of the model while making full use of the shallow features; the small target detection head is added to make the feature map with higher resolution, reduce the loss of localization accuracy and edge region information during feature fusion, and enhance the small target detection capability, while the dynamic convolution ODConv replaces the conventional convolution module in the network to further improve the network performance. The test shows that the improved model mAP@0.5 can reach 96.0%, an increase of 0.76%, which meets the needs of industrial non-destructive testing.