# Transmission Lines Insulator State Detection Method Based on Deep Learning
## 2 Materials and Methods
### Content-Aware Feature Reassembly Operator  
The original YOLOv7 employs a relatively simplistic nearest neighbor interpolation method for up-sampling, which fails to effectively preserve crucial features of the insulator. Moreover, it can introduce aliasing artifacts, causing feature distortion. To address this issue, this paper replaces nearest neighbor interpolation with a content-aware feature reassembly up-sampling operator [25]. This operator introduces minimal additional parameters and combines context information from a large receptive field to perform feature up-sampling,thereby preserving the fine-grained details of the insulator as much as possible. Due to its content-aware nature, this up-sampling operator can utilize adaptive and optimized reassembly kernels at different locations. Comprising prediction modules for reassembly kernels and content-aware reassembly modules, the up-sampling operator's overall structure is depicted in Figure 4.  
The content-aware feature reassembly operator consists of two steps. The first step is to predict a reassembly kernel for each target location according to its content, and the second step is to reassemble the features with predicted kernels. Assuming a 2D input feature map \(X\in\mathbb{R}^{H\times W\times C}\) and an up-sample ratio \(\sigma\) (supposing \(\sigma\) is an integer), then the operator will produce a new feature map \(X^{\prime}\in\mathbb{R}^{\sigma H\times\sigma W\times C}\). For any location \(l^{\prime}=(x^{\prime},y^{\prime})\) in output \(X^{\prime}\), there is a source location \(l=(x,y)\) in input \(X\), where \(x=\frac{x^{\prime}}{\sigma^{\prime}}\), \(y=\frac{y^{\prime}}{\sigma^{\prime}}\). In the first step, the kernel prediction module \(\psi\) predicts a location-wise kernel \(W_{l^{\prime}}\) for each location \(l^{\prime}\) based on the neighbor of \(X_{l}\), as shown in Equation (6):  
\[W_{l^{\prime}}=\psi(N(X_{l},\ k_{encoder})) \tag{6}\]  
where \(N(X_{l},\ k_{encoder})\) is denoted as the \(k_{encoder}\times k_{encoder}\) sub-region of \(X\) centered at the location \(l\), i.e., the neighbor of \(X_{l}\). \[X^{\prime}_{l^{\prime}}=\phi(N(X_{l},\ k_{up}),\ W_{l^{\prime}}) \tag{7}\]  
where \(\phi\) is the content-aware reassembly module that reassembles the neighbor of \(X_{l}\) with the kernel \(W_{l^{\prime}}\). The details of \(\psi\) and \(\phi\) are as follows. The kernel prediction module generates reassembly kernels in a content-aware manner. Each source location on \(X\) corresponds to \(\sigma^{2}\) target locations on \(X^{\prime}\). Each target location requires a reassembly kernel of size \(k_{up}\times k_{up}\), where \(k_{up}\) is the size of the reassembly kernel, so this module outputs a reassembly kernel of size \(H\times W\times C_{up}\), where \(C_{up}=\sigma^{2}k_{up}^{2}\). The kernel prediction module is composed of two submodules, i.e., channel compressor and content encoder. Channel compressor compresses the input feature channels from \(C\) to \(C_{m}\) using a convolutional layer of \(1\times 1\). Reducing the channels of the input feature map reduces the parameter and computational cost. And content encoder generates a reassembly kernel based on the content of the input features with a convolutional layer with a kernel size of \(k_{encoder}\). The parameters of the encoder are \(k_{encoder}\times k_{encoder}\times C_{m}\times C_{up}\). For each reassembly kernel \(W_{l^{\prime}}\) in the content-aware reassembly module, the content-aware reassembly module will reassemble the features in a neighborhood via function \(\phi\). We use a simple \(\phi\) which is just a weighted sum operator. For the target location \(l^{\prime}\) and the  
Figure 4: Module structure of content-aware feature reassembly operator. corresponding square region \(N(X_{l},k_{up})\) centered on \(l=(x,y)\), the reassembly is shown in Equation (8):  
\[\mathbf{X}_{l^{\prime}}^{\prime}=\sum_{n=-r}^{r}\sum_{m=-r}^{r}\mathbf{W}_{l^{\prime}(n, m)}\cdot\mathbf{X}_{(x+n,y+m)} \tag{8}\]  
where \(r=\frac{k_{up}}{2}\).