## 2 Methodology
### Data Augmentation
#### 2.2.2 Defect-Containing Images Generation Based on FastGAN  
Training a GAN from scratch on a small number of samples can often lead to overfitting or mode collapse [38]. Therefore, we needed to train a generator that could learn quickly and a discriminator that could provide useful information continuously to train the generator. We designed a channel excitation module that can use low-scale activations to correct channel responses on high-scale feature maps. This allowed for a more robust gradient flow throughout the model weights and sped up training. We proposed a self-supervised discriminator, trained as a feature encoder and equipped with an additional decoder. This allowed the discriminator to learn more descriptive feature maps covering more regions from the input image, thus producing more comprehensive signals to train the generator. (1) Skip-layer excitation (SLE) module  
The SLE module draws inspiration from the skip-connection of the Resnet block (Figure 4) and the feature recalibration design of the Squeeze-and-Excite module (Figure 5). Thus, SLE not only has the advantage of channel-level feature recalibration but also enhances the gradient flow throughout the entire model. The Resnet block implements the skip-connection as an element-wise addition between outputs from different convolutional layers, requiring the spatial dimensions of the activations to be the same. The SLE module multiplies the outputs between channels, eliminating the heavy computation of convolution and enabling skip connections between different resolutions. Figure 4: Resnet block. Figure 3: Example of geometric enhancements. We define the skip-layer excitation module as:  
\[y=\mathcal{F}(x_{low},\{W_{i}\})x_{high} \tag{1}\]  
where \(x\) and \(y\) are the input and output feature maps of the SLE module, the function \(\mathcal{F}\) contains operations on \(x_{low}\), and \(W_{i}\) denotes the module weights to be learned. Figure 6 shows an actual SLE module, where \(x_{low}\) and \(x_{high}\) are feature maps \(8\times 8\) and \(128\times 128\) in size. The operations in module F are adaptive average pooling, convolution, LeakyReLU, convolution, and sigmoid activation. The output is multiplied along the channel dimension with \(x_{high}\) to obtain y (with the same shape as \(x_{high}\)). Self-supervised discriminator  
We trained D as an encoder with a small decoder, D extracts the image features, and the decoder reconstructs the image. The decoder and D were trained on real samples only, and the optimized loss function is:  
\[\mathcal{L}_{recons}=\mathbb{E}_{f\sim D_{module}(x),x\sim I_{med}}[\| \mathcal{G}(f)-\mathcal{T}(x)\|] \tag{2}\]  
where \(f\) is the intermediate feature map from D. The function \(\mathcal{G}\) contains the processing of f and the decoder, and the function \(\mathcal{T}\) represents the processing of the sample \(x\) from the real image \(I_{real}\). Our self-supervised D is shown in Figure 7, where the decoder consists of four convolutional layers and generates a \(128\times 128\) feature map. We used the decoder on feature maps \(16^{2}\) and \(8^{2}\), randomly cropping \(1/8\) of the height and width of \(16^{2}\), and then cropping the same part from the real image to obtain \(I_{part}\). We resized the real image to obtain I, and the decoder generated \(I^{\prime}_{part}\) from the cropped \(16^{2}\) and \(I^{\prime}\) from \(8^{2}\). D and the decoder were trained together to minimize the loss in Equation (2). This reconstruction training ensured that D extracted more comprehensive representations from the input images, including both global features (from \(8^{2}\)) and fine texture details (from \(16^{2}\)). Figure 6: The structure of the skip-layer excitation module. Finally, we adopted the hinge version of the adversarial loss [39, 40] to iteratively train our D and G.  
\[\mathcal{L}_{D}= -\mathbb{E}_{x\sim l_{real}}[min(0,-1+D(X))]\] \[-\mathbb{E}_{y\sim G(z)}[min(0,-1-D(\hat{x}))] \tag{3}\] \[+\mathcal{L}_{recons}\] \[\mathcal{L}_{G}=-\mathbb{E}_{z\sim\mathcal{N}}[D(G(z))] \tag{4}\]