# CPAM: Cross Patch Attention Module for Complex Texture Tile Block Defect Detection
## 2 Related Work
### Attention Mechanism for Tile Block Defect Detection  
To help models better focus on defective regions, many scholars have enhanced the visual perception capabilities of models by adding attention mechanisms. For instance, \begin{table}
\begin{tabular}{c c c c c} \hline \hline \multirow{2}{*}{**Method**} & \multirow{2}{*}{**Application Object**} & **Calculation** & \multirow{2}{*}{**Performance**} & \multicolumn{2}{c}{**The Connection between**} \\  & & **Time** & & **Regional Features** \\ \hline First-order derivative edge detector & Solid-colored tiles & Low & Good & Bad \\ Histograms & Solid-colored tiles & Low & Good & Bad \\ Neural networks & Solid-colored tiles & High & Good & Not good \\ Morphological techniques & Solid-colored tiles & Low & Good & Bad \\ Gabor filters & Solid-colored tiles & Low & Bad & Bad \\ Wavelet transforms & Solid-colored tiles & High & Good & Bad \\ Multi-class support vector machine and & & & & \\ rotation invariant local variance metric & Solid-colored tiles & High & Good & Bad \\ (RIMLV) operator & & & & \\ Traditional deep learning models & Solid-colored tiles & High & Good & Not good \\ \hline \hline \end{tabular}
\end{table} 
Table 1: The characteristics of different methods in tile block defect detection. [PERSON] et al. [15] create a Multiscale Residual Attention Unit (MRAU) and apply it to micro-motor armature surface defect detection, [PERSON] et al. [16] present DE-block for metal surface defect detection, and [PERSON] et al. [4] utilize CBAM for bamboo surface sliver defects detection. In the field of tile block defect detection, [PERSON] et al. [9] use CBAM to help the model to further improve the focus on the defect region. CBAM helps the model to perform better by changing the importance of different locations in each space and thus highlighting the defective parts. However, since the importance of each location is not the same, the importance of each location in the defective area is also different, which may have an imbalance in importance. Therefore, CBAM does not help the model to focus on larger size defects, and CBAM cannot establish the connection between different regions to better distinguish defective regions from non-defective regions. To address the balance problem of highlighting the tile block defect region importance, inspired by [10; 14; 17; 18; 19; 20], this study attempts to solve the information imbalance within regions from the regionalization idea. [PERSON] et al. [10] segment the input image into nine patches and randomize two of them to construct a CNN architecture suitable for skin damage classification to combine local and global information. In addition, from the idea of processing the patch information [20], [PERSON] et al. [19] segment into multiple patches of fixed size and linearly embed them in the corresponding positions, and then fed the resulting vector sequence into a standard Transformer encoder to efficiently implement the image classification task. [PERSON] et al. [21] continue the idea of patch processing by randomly arranging and linking patches and then using a simple MLP for information extraction to achieve good image classification results. Inspired by the above approach and the existing excellent attention mechanisms [10; 14; 17], this study applies the processing idea of the patch to the attention mechanism, not for image input, but based on feature information. In this study, the feature information is viewed as a combination of multiple patches, and the defective patches are highlighted by distinguishing the importance of different patches, and thus, CPAM is proposed. Considering the correlation and irrelevance of information in the spatial direction, in order to enhance the relevance of information, CPAM only adopts a linear arrangement of spatial information adjacent to each other. In addition, to make CPAM more efficient, CPAM uses 1D convolution to efficiently establish the connection between different patches [17], so as to obtain weights that can effectively distinguish the importance of different patches.