Inner-MPDIoU Loss for PCB Defect Detection
- The paper introduces Inner-MPDIoU Loss as an innovative boundary-based loss that enhances tiny object localization by focusing on an adjustable inner region and penalizing corner drift.
- It modifies IoU loss by computing the overlap on a scaled auxiliary ground-truth box, thereby improving performance in high-density, small-object detection tasks.
- Empirical results on the PKU-Market-PCB dataset show improved recall (+0.41 pp) and mAP0.5:0.95 (+2.83 pp), validating the method's precision in defect detection.
Inner-MPDIoU Loss is a boundary-based loss function developed to improve the localization accuracy of tiny objects in object detection tasks, particularly in printed circuit board (PCB) defect detection. It modifies traditional IoU-based losses by focusing the overlap computation on a scale-adjustable inner region of the ground-truth bounding box and incorporating penalties for drift in both box center and corner alignment, normalized for scale invariance. The method is introduced and evaluated in “Multi-Scale PCB Defect Detection with YOLOv8 Network Improved via Pruning and Lightweight Network” (Pingzhen et al., 23 Jul 2025) to address challenges in high-density, small-object detection scenarios.
1. Mathematical Formulation
The Inner-MPDIoU loss is constructed through several key steps, utilizing both the predicted bounding box and the ground-truth box represented by their edges. It introduces an auxiliary ground-truth box , generated by scaling about its center by ratio . The steps are:
- Auxiliary Box Construction:
Here, is the center, and are width and height.
- Intersection Area:
- Area Calculations:
- Union:
- Corner-Point Drift Penalty:
These terms measure discrepancies at the top-left and bottom-right corners.
- Image-Scale Normalization:
- Inner-MPDIoU Metric:
- Loss Function:
This formulation encourages not only overlap, but also precise matching in box location and aspect under a scale-invariant normalization.
2. Intuitive Rationale and Components
Each component of Inner-MPDIoU serves a specific purpose for robust performance on tiny and dense targets:
- The auxiliary box focuses the metric on a controllable region of the ground-truth box via , allowing finer control over localization emphasis. For , the loss prioritizes the core; for , it relaxes localization to a larger region, compensating for slight labeling uncertainty or missing center alignment.
- The intersection-over-union between and directs optimization to achieve high overlap specifically in the scaled region.
- The corner distance penalties () penalize misalignments in both position and aspect, targeting failures that standard IoU or DIoU loss cannot fully capture.
- Normalization by renders penalty strength consistent regardless of image scale.
A plausible implication is that this construction is more sensitive to the kinds of small misalignments that are critical for defect detection in high-resolution, high-density PCB imagery.
3. Comparison with Related IoU-based Losses
Inner-MPDIoU is distinct from several established IoU-family losses:
| Loss | Overlap Term | Drift/Aspect Penalty |
|---|---|---|
| IoU | Yes (IoU) | None |
| GIoU | Yes | Enclosing box area |
| DIoU | Yes | Center-point distance |
| CIoU | Yes | Center + aspect penalty |
| MPDIoU | Yes | Multiple key-point drifts |
| Inner-MPDIoU | Yes (aux. IoU) | Two corners, img normalized |
Standard IoU focuses solely on area. GIoU, DIoU, and CIoU incrementally introduce penalties for enclosure, center, and aspect, but do not control for error concentration within a specific region of the box. MPDIoU generalizes center drift to multiple corners, but still lacks tunable focus. Inner-MPDIoU uniquely concentrates the overlap metric on an adjustable inner (or slightly expanded) region, and applies a pair of corner penalties tailored for high-density, tiny-object contexts (Pingzhen et al., 23 Jul 2025).
4. Hyperparameters and Control
The primary hyperparameter of Inner-MPDIoU is the inner-region ratio :
- Valid range:
- leaves the auxiliary box the same as ground-truth.
- restricts the focus, exerting greater pressure on core alignment—effective for remedying box overshoot.
- introduces tolerance, helpful if predicted boxes are systematically off-center.
In the referenced work, no additional term weighting is introduced; implicit equal contribution is made by IoU and the corner-penalty components. Tuning is typically performed on a small validation subset. No explicit balance hyperparameter is required between the loss' two terms.
5. Implementation Considerations
Integrating Inner-MPDIoU into object detection frameworks such as YOLOv8 involves minimal modification to the bounding box regression loss:
- Replace CIoU or similar loss with the Inner-MPDIoU loss function.
- For each forward pass and for each positive sample, compute auxiliary box coordinates, overlap and union areas, the two corner distances, normalization by , and form the final loss.
- The computational overhead is negligible—element-wise min/max and squared distance operations account for <1% increase in FLOPs.
A PyTorch-style function is provided in the primary reference:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
def inner_mpdiou_loss(pred_boxes, gt_boxes, img_wh, ratio): # pred_boxes, gt_boxes: (N,4) in (l, t, r, b) format W_img, H_img = img_wh rho2 = W_img*W_img + H_img*H_img # 1) auxiliary inner GT box x_gt = (gt_boxes[:,0]+gt_boxes[:,2]) * 0.5 y_gt = (gt_boxes[:,1]+gt_boxes[:,3]) * 0.5 W_gt = gt_boxes[:,2] - gt_boxes[:,0] H_gt = gt_boxes[:,3] - gt_boxes[:,1] lt = torch.stack([x_gt - W_gt*ratio, y_gt - H_gt*ratio], dim=1) rb = torch.stack([x_gt + W_gt*ratio, y_gt + H_gt*ratio], dim=1) # 2) intersection with pred_boxes lt_min = torch.max(pred_boxes[:,:2], lt) rb_min = torch.min(pred_boxes[:,2:], rb) wh_int = (rb_min - lt_min).clamp(min=0) I = wh_int[:,0] * wh_int[:,1] # 3) areas A_pred = (pred_boxes[:,2]-pred_boxes[:,0]) * (pred_boxes[:,3]-pred_boxes[:,1]) A_aux = (rb[:,0]-lt[:,0]) * (rb[:,1]-lt[:,1]) U = A_pred + A_aux - I + 1e-7 # 4) corner‐point distances d1 = (lt[:,0] - pred_boxes[:,0])**2 + (lt[:,1] - pred_boxes[:,1])**2 d2 = (rb[:,0] - pred_boxes[:,2])**2 + (rb[:,1] - pred_boxes[:,3])**2 # 5) Inner-MPDIoU metric inner_mpdiou = (I / U) - ((d1 + d2) / rho2) # 6) loss loss = 1.0 - inner_mpdiou.clamp(min=-1.0, max=1.0) return loss.mean() |
No modifications are needed elsewhere in the network pipeline. The additional cost is compatible with real-time requirements in industrial applications.
6. Empirical Performance and Impact
In ablation studies on the PKU-Market-PCB dataset, Inner-MPDIoU yields superior localization metrics, especially for small targets:
| Stage | P (%) | R (%) | mAP₀.₅ (%) | mAP₀.₅:₀.₉₅ (%) |
|---|---|---|---|---|
| A+B+C (no loss) | 98.25 | 98.85 | 99.06 | 63.51 |
| +Inner-MPDIoU | 98.39 | 99.26 | 99.20 | 66.34 |
A net gain of +0.41 pp in recall and +2.83 pp mAP₀.₅:₀.₉₅ (over 4% relative) is achieved (Pingzhen et al., 23 Jul 2025). Qualitatively, on challenging backgrounds or for very small defect regions (e.g., 1–2 px missing-hole/spur), Inner-MPDIoU facilitates tighter bounding, mitigates overextension, and reduces missed tiny objects. Application within a YOLOv8-based detector demonstrates improvements without requiring additional model complexity or computational resources.
7. Application Scope and Limitations
Inner-MPDIoU is especially well-suited for domains where precise delineation of small, high-density, or high-value regions is central, such as PCB defect detection. The tunable focus via provides flexibility across data regimes, allowing calibration for varying levels of annotation confidence or object granularity.
A plausible implication is that while Inner-MPDIoU demonstrates improvements in PCB defect benchmarks, the utility of the inner-region penalty may depend on the degree of annotation quality, object density, and specific small-object localization challenges present in other domains. Since only two corner-points are penalized (rather than all four as in some variants), certain forms of skew or rotational error may not be fully penalized unless is appropriately chosen.
Overall, Inner-MPDIoU characterized by its scale-controlled overlap focus and multi-point corner penalties, provides an effective and low-overhead approach for improving tiny-object localization in contemporary object detection frameworks (Pingzhen et al., 23 Jul 2025).
Sponsored by Paperpile, the PDF & BibTeX manager trusted by top AI labs.
Get 30 days free