# Research on Defect Detection Method for Composite Materials Based on Deep Learning Networks
## 3 ECA Ghost CNN Method
### Efficient Channel Attention Module  
In this paper, the global pooling operation in the ECA mechanism has been improved, and the model has been optimized using the improved ECA mechanism. The ECA block replaces the attention computation module based on the SE block. It requires fewer parameter computations and better aligns with the requirements of lightweight model design.  
The attention mechanism module in SE is used to optimize the CNN. The convolution operation in the CNN enables the integration of spatial and channel information within the local receptive field of each layer. This process leads to the generation of meaningful features.  
In the ECA block, the structure performs pooling of feature maps within each channel. Average pooling is commonly used to preserve the background information in the image on a global scale. Max pooling is used to capture extreme values and preserve texture information in the image since the background in the image of the composite material contains more semantic information, while the defects are visible in the texture information of the components. Therefore, in this paper, the global pooling operation in ECA is improved by using a pooling method that combines average pooling and maximum pooling. The specific principle is shown in Figure 3. Compared to the original ECA block, the addition of the influence of feature values from both average pooling and max pooling helps to prevent the omission of finer-grained features.  
In the improved ECA module, the feature maps undergo both mean pooling and max pooling separately. This process extracts information from each channel of the feature map, resulting in data of size \(1\times 1\times C\). The two results are then added channel-wise while maintaining the original size. Subsequently, the obtained data undergo one-dimensional convolution, and the sigmoid activation function is applied to obtain attention weights for each channel. During the one-dimensional convolution process, the ECA block focuses more on the relationships between adjacent channels in the feature map. A one-dimensional convolution with a kernel size of k is applied between adjacent channels to facilitate cross-channel interactions, thus avoiding dimension reduction operations, as observed in the SE block. ECA employs a frequency band matrix, \(\rm W_{k}\), to facilitate the exchange of information between channels, thereby ensuring efficient and effective information extraction. The frequency band matrix is illustrated below.  
\[\begin{bmatrix}w^{1,1}&\cdots&w^{1,k}&0&0&\cdots&\cdots&0\\ 0&w^{2,2}&\cdots&w^{2,k+1}&0&\cdots&\cdots&0\\ \vdots&\vdots&\vdots&\vdots&\ddots&\vdots&\vdots&\vdots\\ 0&\cdots&0&0&\cdots&w^{C,C-k+1}&\cdots&w^{C,C}\end{bmatrix} \tag{2}\]  
Each row in the matrix contains \(k\) values of the non-constant number 0, which represents the \(k\) channels surrounding each channel involved in the relational operation. \(C\) represents the number of channels. In general, \(C\) is an integer that is a power of 2. The entire matrix involves a total of \(k\times C\) parameters. When participating in the computation, each channel only operates with its \(k\) adjacent channel neighbors. The operation can be achieved by using a one-dimensional convolution with a kernel size of \(1\times k\). It is possible to share the learning parameters among the channels, thereby improving performance. This approach is known as ECA-NS.  
The ECA block can be obtained by replacing the FC of the MLP structure in the SE block with the one-dimensional convolution of the ECA-NS method. It can be directly attached to the feature extraction component of the model to enhance its performance. Meanwhile, compared to the SE block, the ECA block has fewer parameters, which can improve the model's running speed.  
Figure 3: ECA block structure (**left**) and improved ECA block structure (**right**).