# FAS-Res2 net: An Improved Res2 net-Based Script Identification Method for Natural Scenes
## 3 Methods
### Adaptive Multi-Layer Feature Fusion Module  
The module for fusing features from text images adopts the Feature Pyramid Network (FPN) architecture [28]. Different text instances are mapped onto feature maps with different resolutions. While key feature details are extracted in one layer, other layers are considered as regions with background noise. Any incorrect evaluation can hinder the gradient propagation during backpropagation. The feature information of each layer in the pyramid structure has its unique use, and its information weight may hinder the gradient transfer and affect the identification results.  
Figure 4 illustrates the feature fusion process. Initially, the feature information of each layer enters the pyramid, and the p1 feature map undergoes 1 \(\times\) 1 convolution and upsampling. The fusion feature information is obtained by adding Ci of the same size to p1, p2, p3, and p4, and the resulting feature map sizes are 1/4, 1/8, 1/16, and 1/32 of the original image, respectively. Next, the Adaptive Spatial Feature Fusion (ASFF) algorithm [29] was applied to adjust the size and weight fusion of feature information. Feature information resizing involves downsampling by pooling and convolution and upsampling using interpolation. Adjust the feature map resolution in each layer to match the scale size of the specified layer. When upsampling, 1 \(\times\) 1 convolution modifies the feature information channel size, and nearest neighbor interpolation adjusts the spatial size ratio. During downsampling, feature maps can be compressed to half their original size using 3 \(\times\) 3 convolutions with a stride of 2, and the channels resized. For example, when downsampling by 1/4 to reduce resolution, pooling is performed first, followed by 3 \(\times\) 3 convolution with stride 2. After resizing, perform adaptive blending is based on size. The fusion calculation formula is shown in formula (1):  
\[S_{mn}^{i}=a_{mn}^{i}v_{mn}^{1\to i}+b_{mn}^{i}v_{mn}^{2\to i}+c_{mn}^{i}v_{mn}^{3 \to i}+d_{mn}^{i}v_{mn}^{4\to i} \tag{1}\]  
where \(v_{mn}^{x\to i}\) represents the feature vector at \((i,j)\) in the feature map adjusted from layer \(x\) to layer \(i\). \(v_{mn}^{1\to i}\), \(v_{mn}^{2\to i}\), \(v_{mn}^{3\to i}\), \(v_{mn}^{4\to i}\) represent the scaled feature maps of layers 1, 2, 3, and 4, respectively, \(a\), \(b\), \(c\), and \(d\) are the weight parameters of the four layers. The resized feature map enters the convolution calculation to obtain each weight parameter, and after concat, softmax, and normalization, the weight ratio between 0 and 1 is obtained, and the total weight sum is 1. The normalized calculation formula is as follows (2):  
\[a_{mn}^{i}=\frac{e^{i_{mn}^{i}}}{e^{i_{mn}^{i}}+e^{i_{mn}^{i}}+e^{i_{mn}^{i}} +e^{i_{mn}^{i}}} \tag{2}\]  
where \(l_{a_{mn}}^{i}\), \(l_{b_{mn}}^{i}\), \(l_{c_{mn}}^{i}\), \(l_{d_{mn}}^{i}\) is the core parameter. Adaptive aggregation of features at each layer was achieved by computing the weights of each layer at each scale. This adaptive multi-layer feature fusion strategy can effectively eliminate the influence of background noise, accurately identify positive samples, and retain aggregated effective information, enhancing the scale invariance of features. Finally, adjust the weight-fused p1_fu, p2_fu, p3_fu, and p4_fu feature information so that the dimensions, width, and height are all equal, and then perform concat parallel connection to obtain the best local feature information extracted by the entire CNN part.  
Figure 4: Adaptive multi-layer feature fusion module diagram.