# CPAM: Cross Patch Attention Module for Complex Texture Tile Block Defect Detection
## 4 Experiments and Results
### Analysis of the Proposed Method
#### 4.4.2 Analysis of CPAM  
CPAM can be embedded into the model, experiments are conducted to embed CPAM into YOLOv7 in this paper, the structure of YOLOv7 is shown in Figure 4. Preserving the model backbone network integrity, this study conducts embedding location experiments, adding CPAM in front of the Yolo head, and conducting comparison experiments in three locations. The experimental results are shown in Table 4, where CPAM is embedded in front of P3 (Yolo head1), P4 (Yolo head2) and P5 (Yolo head3). From the results, it can be observed that CPAM can effectively improve the performance of the model regardless of the embedding position, with the highest map effect achieved when CPAM is embedded in front of P5. Moreover, it is also known from the results that adding multiple locations does not further improve the performance of the model. Therefore, the subsequent experiments in this study only added CPAM in front of P5. \begin{table}
\begin{tabular}{c c c c c} \hline
**Model** & **Precision** & **Recall** & **F1-Score** & **mAP** \\ \hline SSD-VGG16 & 96.4 & 39.8 & 0.45 & 86.0 \\ SSD-MobileNetv2 & 100 & 44.0 & 0.51 & 84.0 \\ YOLOv4 & 93.6 & 83.9 & 0.87 & 88.7 \\ YOLOv4-MobileNetv2 & 93.7 & 82.7 & 0.87 & 82.6 \\ YOLOv5-s & 93.9 & 63.7 & 0.69 & 90.0 \\ YOLOv5-m & 89.5 & 70.4 & 0.77 & 90.5 \\ YOLOX-tiny & 88.8 & 82.6 & 0.84 & 83.0 \\ YOLOX-s & 89.1 & 80.5 & 0.85 & 83.0 \\ YOLOX-m & 90.4 & 84.1 & 0.86 & 83.5 \\ YOLOv7 & 93.3 & 76.4 & 0.82 & 91.9 \\ \hline \end{tabular}
\end{table} 
Table 2: The results of different object detection algorithms. Figure 4: The structure of YOLOv7. \begin{table}
\begin{tabular}{c c c c c} \hline
**Model** & **AP\({}_{\text{Dirty}}\)** & **AP\({}_{\text{Impurity}}\)** & **AP\({}_{\text{Pour gaze bad}}\)** & **AP\({}_{\text{White dot}}\)** & **mAP** \\ \hline SSD-VGG16 & 65.4 & 81.4 & 100 & 97.1 & 86.0 \\ YOLOv4 & 71.0 & 84.7 & 100 & 98.9 & 88.7 \\ YOLOv5-m & 76.7 & 89.0 & 100 & 96.1 & 90.5 \\ YOLOX-m & 67.8 & 79.0 & 94.6 & 92.7 & 83.5 \\ YOLOv7 & 87.0 & 97.3 & 83.5 & 99.9 & 91.9 \\ \hline \end{tabular}
\end{table} 
Table 3: The specific AP values for different categories of defects. In this study, the arrangement of patches in the spatial direction is considered in the design of CPAM, so the comparison experiments regarding different arrangements in the spatial direction are conducted. The experimental results are shown in Table 5, and it can be learned that the performance of the model in terms of overall performance decreases when only one spatial orientation arrangement is considered. The overall performance of the model is more stable when both horizontal and vertical spatial directions are considered. As a result, CPAM considers the alignment of patches in both spatial directions at the same time. In addition, the comparison experiments of convolutional kernel size and patch size in CPAM are also given in Tables 6 and 7. Changing the size of the 1D convolutional kernel causes little influence on the outcome, and the overall performance is stable at certain values, i.e., 93.8-94.8% for mAP, 0.90-0.92 for F1, 90.9-94.6% for P, and 88.0-90.0 for R. When k is 3, the model performs better than the other cases. Changing the patch size is less effective for tile defect detection, and as observed in Table 6, the overall performance fluctuation is small. The overall performance fluctuates because the defect size varies in the selected tile defect dataset, and some patch sizes will work better for defects of matching size, so the performance will fluctuate. However, the change in defect size is not too large, so changing the patch size has a small impact on the model in this defect detection task. It is known from the ablation experiments of CPAM that CPAM has a significant gain for tile block defect detection; moreover, this study conducted comparison experiments with other commonly used attention mechanisms in industry, such as SE [29], CBAM [14]