# Lightweight Crack Automatic Detection Algorithm Based on TF-MobileNet
## 3 Crack Detection Method Based on TF-MobileNet
### Feature Fusion Network of TF-MobileNet  
In the feature fusion stage, we used a fusion strategy that combines feature pyramids (FPN) as well as path aggregation networks (PAN). The FPN (Feature Pyramid Network) adopts a top-down architecture that combines high-level semantic information with low-level detailed information. It achieves this by propagating features from high-resolution feature maps downward, merging them with lower-resolution feature maps at each level, forming a pyramid structure. FPN is effective at capturing features across different scales, improving the model's performance in detecting both small and large objects. By enhancing the semantic information of lower-level feature maps, it increases detection accuracy.  
PANet (Path Aggregation Network) builds on FPN by adding a bottom-up path aggregation module. This module combines bottom-up feature maps with top-down feature maps, further strengthening the feature information. PANet not only improves the fusion of multi-scale features but also introduces global contextual information, enhancing object segmentation capabilities. It is particularly well-suited for object detection and segmentation tasks in complex scenarios.  
In FPN, because of the process of feature maps from large to small and then from small to large, the feature information at the shallow level was significantly lost after passing through multiple layers. Therefore, a bottom-up path aggregation network (PAN) was after the FPN, and the (i)th feature map of the PAN fuses the (i + 1)th feature map of the FPN to get the new fused feature map. Figure 3 below illustrates the detailed fusion process. This approach enhanced the characterization capability of the features.  
This study combines FPN and PANet to leverage the strengths of both. FPN provides rich multi-scale features for detection, while PANet further enhances the feature representation, improving the model's accuracy in object localization and classification. This fusion contributes to better detection performance across various scenarios, particularly in cases with complex backgrounds and the presence of multi-scale objects.  
Next, we inserted the parameter-free attention mechanism, SimAM, into the Neck network. After conducting ablation experiments, we confirmed that this module enhances feature fusion. Additionally, we added a Transformer structure to the Neck network to upgrade the PANet, and the inclusion of a multi-headed self-attentive mechanism further enhanced the feature fusion effect. Finally, the fused feature maps were passed into  
Figure 2: The network structure of Bneck.  
the prediction side to generate many candidate anchor boxes. We applied non-maximal suppression (NMS) [36] to remove superfluous predictor boxes. By setting the threshold to 0.5, NMS selected the predictor box with the highest score and removed those that significantly overlapped with it. The score values were measured by IoU as shown in Figure 4.  
The marker box is represented by the yellow box and the predictor box is represented by the green box. If the proportion of the overlap of the areas of the two boxes to the concatenation surpassed the designated threshold, we considered this prediction box to be true and valid, and we can use Equation (3) to calculate each _IoU_ value. Finally, we used CIoU for localization loss and BCELoss for classification loss estimation.  
\[IoU=\frac{S_{g}\cap S_{p}}{S_{g}\cup S_{p}} \tag{3}\]  
There are various methods for non-maximum suppression (NMS). This study tested the non-maximum suppression technique described in YOLO during crack image prediction and found that CIoU (Complete Intersection over Union) was more effective. CIoU takes into account the distance between the object and the anchor box, overlap ratio, scale, and a penalty term, making the object box regression more stable and preventing failures during training. Therefore, this study utilized CIoU for localization loss and BCELoss (Binary Cross Entropy Loss) for classification loss estimation.