## 3 Methodology
### Shape-IoU Loss Function  
YOLOv11 utilizes the CIoU loss function for localization, which improves upon GIoU by minimizing the normalized distance between bounding box centroids, rather than merely maximizing the overlap area. CIoU also contains an aspect ratio penalty term to improve detection accuracy [29]. However, it only focuses on the relative positional and shape relationships between boxes, ignoring intrinsic geometric properties like absolute size and shape, which are crucial for small-target detection [37]. In PCB defect analysis, where targets are often minute, this can lead to small features being suppressed within overlap regions. To address this, the Shape-IoU loss function was adopted [32], which explicitly incorporates target frame geometry into IoU calculations. This enables the geometric awareness of bounding boxes and stabilizing bounding box regression. Consequently, by introducing a geometry-sensitive loss computation mechanism, the model achieves heightened sensitivity to absolute physical size deviations. This effectively addresses the core issue of minuscule defect sizes being neglected during training, making Shape-IoU particularly suitable for PCB defect detection and other scenarios involving minute object recognition. Shape-IoU is calculated in the following section.  
First, the calculation of the intersection over union (\(IoU\)) is calculated as follows:  
\[IoU=\frac{\left|B\cap B^{st}\right|}{\left|B\cup B^{st}\right|}, \tag{8}\]  
where \(IoU\) measures the overlap between the predicted box (\(B\)) and the ground truth box (\(B^{st}\)) as the ratio of their intersection area to their union area.  
The weight coefficients in the horizontal (\(ww\)) and vertical (\(hh\)) directions are defined, respectively, as follows:  
\[ww=\frac{2\times\left(w^{gt}\right)^{scale}}{\left(w^{gt}\right)^{scale}+\left( h^{gt}\right)^{scale}}, \tag{9}\]  
\[hh=\frac{2\times\left(h^{gt}\right)^{scale}}{\left(w^{gt}\right)^{scale}+ \left(h^{gt}\right)^{scale}}, \tag{10}\]  
where \(h^{gt}\) and \(w^{gt}\) represent the height and width of the ground truth box, respectively. \(scale\) is the scale factor, which is related to the scale of the target in the dataset. The calculation of shape distance is defined as  
\[distance^{shape}=hh\times\frac{\left(x_{c}-x_{c}^{gt}\right)^{2}}{c^{2}}+ww \times\frac{\left(y_{c}-y_{c}^{gt}\right)^{2}}{c^{2}}, \tag{11}\]  
where (\(x_{c},\ y_{c}\)) and (\(x_{c}\)\({}^{gt},\ y_{c}\)\({}^{gt}\)) represent the center coordinates of the predicted box and the ground truth box, respectively. By accumulating weighted differences in width and height, the shape consistency term is calculated as follows:  
\[\Omega^{shape}=\sum\
olimits_{t=w,h}\left(1-e^{-\omega t}\right)^{\theta}, \theta=4 \tag{12}\]  
The proportions of weighted differences in width (\(\omega_{w}\)) and height (\(\omega_{h}\)) are, respectively, defined as  
\[\begin{cases}\omega_{w}=hh\times\frac{\left|w-w^{gt}\right|}{\max\left(w,w^{ gt}\right)},\\ \omega_{h}=ww\times\frac{\left|h-h^{gt}\right|}{\max\left(h,h^{gt}\right)}, \end{cases} \tag{13}\]where \(w\) and \(h\) represent the height and width of the predicted box, respectively. Shape-IoU is defined as  
\[L=1-IoU+distance^{shape}+0.5\times\Omega^{shape} \tag{14}\]  
The diagram of the Shape-IoU prediction frame and real frame is displayed in Figure 5.