# A Review of Image Inpainting Methods Based on Deep Learning
## 4 Deep-Learning-Based Image Inpainting Algorithm
### Attention Mechanism  
#### 4.3.1 Attention  
The attention mechanism [64] assigns higher weights to important information in images and lower weights to less critical information, allowing models to focus more on the essential details for efficient resource allocation in image information processing. In the field of image inpainting, the attention mechanism is used for feature matching between the area to be repaired and the background. In traditional methods, block matching methods based on texture synthesis in image repair methods are often used for feature matching between the area to be repaired and the background, but they lack an understanding of image semantics and global structure. Early block matching image repair algorithms attempted to use deep neural networks for block matching. The authors of [65; 66; 67] introduced block matching concepts to the image feature space to repair high-frequency detail textures. [PERSON] et al. [65] used the VGG19 classification network [68] to extract similar feature blocks from known areas in the intermediate feature layer for image completion. [PERSON] et al. [67] introduced Shift-Net to the U-Net architecture [61], moving feature information from known areas in the image encoding layer into the corresponding decoding layer to guide the repair of features in the missing area of the decoding space. Due to the limited receptive field of convolution, traditional CNN-based image repair networks often cannot effectively establish connections between missing areas and distant known areas, often leading to structural distortions, texture blurring, and incoherence on the repaired area boundaries. The attention mechanism can focus on the entire image globally and can effectively address the local limitations of traditional CNN-based image repair models. [PERSON] et al. [69] introduced a two-stage repair method. The second stage innovatively introduces a contextual attention layer, as shown in Figure 6, which can extract features from distant areas that approximate the area to be repaired without spatial constraints. \begin{table}
\begin{tabular}{c c c c c c c c} \hline \hline
**Dataset** & **Reference** & **PSNR\(\uparrow\)** & **SSIM\(\uparrow\)** & **FID\(\downarrow\)** & **L1\(\downarrow\)/\%** & **Image Resolution** & **Mask Type** \\ \hline \multirow{2}{*}{Paris Street View} & [9] & 17.59 & - & - & 10.33 & 128 \(\times\) 128 & Central area regular mask (25\%) \\  & [19] & 25.25 & 0.7790 & - & 1.88 & 512 \(\times\) 512 & Irregular mask (20–30\%) \\ \hline \multirow{2}{*}{Places2} & [18] & 23.36 & 0.8462 & 2.908 & 2.63 & 256 \(\times\) 256 & Central area regular mask (25\%) \\  & [24] & 26.03 & 0.890 & 1.57 & 2.11 & 512 \(\times\) 512 & Irregular mask (20–30\%) \\ \hline \hline \end{tabular} Note: The arrows (\(\uparrow\) and \(\downarrow\)) next to metrics like peak signal-to-noise ratio (PSNR), structural similarity index (SSIM), Fréchet inception distance (FID), and L1 norm indicate whether a higher or lower value is preferable, respectively. The absence of data in the table signifies that the original literature did not provide the respective metric value.  
\end{table} 
Table 2: Quantitative evaluations of convolutional operation improvement methods. Figure 6: Contextual attention layer. The image to be repaired is divided into areas to be repaired and background areas. The background area is extracted into small image blocks and treated as a convolution kernel for normalized convolution operations on the area to be repaired.