# A New Image Oversampling Method Based on Influence Functions and Weights
## 3 The Proposed IFW-SMOTE
### Synthesis of New Image Samples  
In order to enable SMOTE to oversample the image, the core of our scheme is to preserve the spatial structure and visual features of the image while generating image samples with naturalness and consistency. The sample synthesis part is divided into three core modules: the feature extractor (ResNet-34), the feature interpolation module (SMOTE), and the image reduction module (DCGAN). The design focuses on local feature extraction for ResNet-34 while combining with SMOTE to generate new samples in the feature space and finally reducing to images.  
The structure of the image feature extractor is shown in Figure 2. We adjust the traditional pre-training model by deleting the pooling and fully connected layers because these layers are only used for classification, unsuitable for retaining local features, and do not contain parameters. The introduction of residual blocks prevents the loss of optimal local features from generating noise, and the residual fast design improves the feature quality of the samples to provide better feature representation for the SMOTE interpolation module later. Since SMOTE interpolation is performed in one-dimensional data, the last layer of the model is designed as a spreading layer, which spreads the received multi-dimensional output of the previous layer into one dimension for interpolation calculation.  
The visualization of the image features after spreading is shown in Figure 3. SMOTE selects a sample \(x_{i}\) from the few classes of sample features of the spreading and then calculates its nearest neighbor sample \(x_{k}\); in our method, the value of \(k\) is five, and we randomly select one of the five \(x_{k}\) (\(k=1,2,3,4,5\)) selected as the nearest neighbor sample and synthesize samples based on the two samples. The synthesized sample feature visualization is shown in Figure 4.  
Figure 3: Visualization of image features.  
Figure 2: Image feature extraction network architecture.  
The formula for synthesizing new samples is expressed in Equation (9). A new sample is synthesized using the following formula for each nearest neighbor sample \(x_{i}\):  
\[xs=\varpi x_{i}+(1-\varpi)x_{k} \tag{9}\]  
\(x_{k}\) is the nearest neighbor sample of a few category samples \(x_{i}\), \(\varpi(0\leq\varpi\leq 1)\) is a randomly generated weight, and \(xs\) controls the degree of interpolation to a synthetic new sample.  
The composite from SMOTE interpolation is not an actual image but a spreading feature of the image. The next step is to perform image restoration. The first step in image restoration is reshaping, which reshapes the synthesized one-dimensional image features into multi-dimensional spatial features. We choose to use the generator of DCGAN to restore the image for these features. We do not use the discriminator in our scheme because the discriminator evaluates the authenticity of the generated image to ensure that the quality of the generated image is similar to the original image, and excessive similarity will lead to overfitting of the model during the data training process. The structure of the DCGAN generator is shown in Figure 5.  
In DCGAN, the input to the general generator is a random noise Z. Our scheme replaces Z with a feature vector generated after SMOTE interpolation. Instead of random noise, the input is a feature vector extracted and spread by ResNet, and SMOTE interpolates this feature vector to generate a new feature vector. In addition, the dense layer needs to be adapted to the input of the SMOTE feature vector. Since the SMOTE generated feature vector already has a high dimension, the output dimension of the dense layer needs to be appropriately modified to match the feature size required for image restoration. After a series of convolution, pooling, and loss steps, a complete and clear image is finally output.