当前位置:网站首页>Learning to Incorporate Structure Knowledge for Image Inpainting
Learning to Incorporate Structure Knowledge for Image Inpainting
2022-07-22 09:21:00 【yijun009】
Learning to Incorporate Structure Knowledge for Image Inpainting
原文链接: link.
Motivation
图像修复旨在用合理且充满细节的内容填充损坏的图像区域或者不想要的图像的区域。现存的方法可以粗略分为传统的和基于深度学习的方法。传统方法使用低级的特征(比如颜色和纹理描述符),并利用先验(如平滑度和图像统计)或辅助数据(如外部图像数据库),来手工修复。
如果没有对图像内容和结构的高层次理解,传统的方法通常难以生成语义上有意义的内容,特别是当图像的很大一部分丢失或损坏时。
基于深度学习的方法可以通过自动捕获图像内在的层次表示来理解图像内容,并生成高级语义特征来合成缺失的内容,在图像修复任务中优于传统方法。
Context Encoder( Pathak et al.(2016))是第一个利用Encoder-Decoder结构,并使用对抗策略训练网络的图像修复深度学习方法。其结果语义上内容合理,但缺乏细节以及有视觉上不能忽视的伪影。17、18年有多人基于其做了很多改进。
最近, Nazeri et al.(2019)提出利用显示的图像结构知识来做图像修复。他们提出了一个两阶段模型,将一个边generator和一个图像generator串联。Xiong et al.(2019)提出一个相似的模型,不在使用边generator而是使用轮廓generator(在更显著对目标场景下更适用)。效果都还不错。
以上两个模型显示了结构知识(比如边和轮廓)在生成合理又细节丰富的图像任务中很重要。然而,两阶段策略可能会有几个限制:1)由于使用两个generator,需要更多的参数;2)很容易受到负面影响的不合理的结构先决条件推理期间由于使用series-coupled架构(这句话的英文意思是如果第一阶段的结构不好,那么第二阶段更容易不好):3)没有一个明确的结构指导作为损失函数,,它可能不能够合成足够的结构信息,因为他们可能会因为网络太深或比较稀疏而被削弱或被遗忘。
基于这些见解,我们建议使用多任务框架,以更好地结合结构知识。我们利用一个共享的generator同步生成完整的图像和相应的结构知识。此外,Nazeri等人(2019)和Xiong等人(2019)有证明了结构先验有利于图像补全; 另一方面,相对于损坏的图像,它也更有可能从一个相对完整的图像中找出完整的结构。
We summarize the main contributions as follows:
- 我们提出了一个多任务学习框架来整合图像结构知识来辅助图像修复。
- 提出了一种结构知识嵌入方案,可以明确地为图像修复提供结构preconditions,并利用注意机制,利用图像中的相似块来细化生成的结构和内容。
- 针对结构学习和嵌入问题,提出了一种新的金字塔结构损失函数。已经进行了大量的实验来评估我们的方法的性能。
Methods
结构知识指的是:用Sobel算子算出来的三个通道两个方向,共6张梯度图;以及canny算子计算的轮廓图。
多任务框架指的是:以前利用结构知识的方案都是两阶段任务,本文提出的方案将结构知识与图像同时生成,并相互辅助。
注意机制指的是:注意机制不是我们一般的注意机制,是结合了non-local的注意力机制,利用图像中的相似块来细化生成的结构和内容。
金字塔结构损失函数:在本文中有两个scale的梯度图。
以上为本文主要内容,先来看看消融实验,来看看哪一块用处最大。
框架:
输入输出:
( I pred , C pred ( s ) ) = G ( I ^ , C ^ , E ^ , M ) \left(\mathbf{I}_{\text {pred}}, \mathbf{C}_{\text {pred}}^{(s)}\right)=G(\hat{\mathbf{I}}, \hat{\mathbf{C}}, \hat{\mathbf{E}}, \mathbf{M}) (Ipred,Cpred(s))=G(I^,C^,E^,M)
以上5个字母从左到右分别表示:输出图像,输出不同尺度s上的梯度图,网络,带有mask的输入图像,带有mask的梯度图像,带有mask的轮廓图像,以及mask。(既有规则的mask,又有不规则的mask)
总体采用GAN,生成器是Encoder-Decoder结构,鉴别器是PatchGAN鉴别器。
Encoder是 Nazeri et al.(2019)的下采样两倍之后,接8个reidual denseblock。梯度图与输出图像此时共享一个编码器,反正是提取特征。
Decoder中有新设计的注意力机制与结构嵌入模块,它们互相辅助。
右下虚线框内是灰色梯度图是生成的两个尺度,分别求loss。右上将经过注意力机制网络与不同尺度的梯度图concatenate到一起生成输出图像。下面具体讲讲:attention模块和structure embedding模块。
Attention Layer
对输入的feature map分成patch然后进行衡量相似性:
Given an input feature map, we first extract the feature patches and calculate the cosine similarity s i , j s_{i, j} si,j of each pair of the patches:
s i , j = * p i ∥ p i ∥ 2 , p j ∥ p j ∥ 2 * s_{i, j}=\left\langle\frac{p_{i}}{\left\|p_{i}\right\|_{2}}, \frac{p_{j}}{\left\|p_{j}\right\|_{2}}\right\rangle si,j=*∥pi∥2pi,∥pj∥2pj*
where p i p_{i} pi and p j p_{j} pj are the i i i -th and j j j -th patch of the input feature map x respectively.
然后用softmax获得相似性得分:
s ^ i , j = e s i , j ∑ j = 1 m e s i , j \hat{s}_{i, j}=\frac{e^{s_{i, j}}}{\sum_{j=1}^{m} e^{s_{i, j}}} s^i,j=∑j=1mesi,jesi,j
然后用得分乘以feature map原来的值,获得响应:
Supposing a total of m m m patches are extracted, the response of a position o i o_{i} oi in the output feature map is calculated as the weighted sum of the patch features:
o i = ∑ j = 1 m s ^ i , j p j o_{i}=\sum_{j=1}^{m} \hat{s}_{i, j} p_{j} oi=j=1∑ms^i,jpj
最后,用残差的形式加起来:
In particular, as shown in Figure 4 , 4, 4, we formulate all the operations into convolution forms, and make it a residual block which thus can be seamlessly embedded into our architecture:
y = x + γ o \mathbf{y}=\mathbf{x}+\gamma \mathbf{o} y=x+γo
where y \mathbf{y} y is the residual output, γ \gamma γ is a learnable scale parameter.
γ \gamma γ没说是咋学习的,待会儿看代码就知道了。
哎呀,又仔细看了一下文章,弄明白了non-local注意力是如何完成局部迁移的了。注意看公式中字母下标。
Structure Embedding Layer
是一个标准的residual denseblock。
Pyramid Structure Loss
除了用L1loss,这里加了个正则项。
L structure = ∑ s n s [ ∥ C pred ( s ) − C ( s ) ∥ 1 + β L edge ( s ) ] \mathcal{L}_{\text {structure}}=\sum_{s}^{n_{s}}\left[\left\|\mathbf{C}_{\text {pred}}^{(s)}-\mathbf{C}^{(s)}\right\|_{1}+\beta \mathcal{L}_{\text {edge}}^{(s)}\right] Lstructure=s∑ns[∥∥∥Cpred(s)−C(s)∥∥∥1+βLedge(s)]
where L edge ( s ) \mathcal{L}_{\text {edge}}^{(s)} Ledge(s) denotes the regularization term, β \beta β corresponding coefficient and n s n_{s} ns the number of total scales. To implement the regularization on the edge structure, we first use a Gaussian filter g g g to convolve the binary ground truth edge map E ( s ) \operatorname{map} \mathbf{E}^{(s)} mapE(s) to create a weighted edge mask as:
M E ( s ) = g ∗ E ( s ) \mathbf{M}_{E}^{(s)}=g * \mathbf{E}^{(\mathbf{s})} ME(s)=g∗E(s)
Then, we computes the edge regularization loss as:
L edge ( s ) = ∥ C pred ( s ) − C ( s ) ∥ 1 ⊙ M E ( s ) \mathcal{L}_{\text {edge}}^{(s)}=\left\|\mathbf{C}_{\text {pred}}^{(s)}-\mathbf{C}^{(s)}\right\|_{1} \odot \mathbf{M}_{E}^{(s)} Ledge(s)=∥∥∥Cpred(s)−C(s)∥∥∥1⊙ME(s)
where the weighted edge mask is used to extract the edge information from the gradient map. Using such an edge mask not only considers the positions of the binary edges but also exert constraints on their nearby locations, thus to highlight and intensify the edge structure. In our implementation, a Gaussian filter with size 10 × 10 10 \times 10 10×10 and standard deviation 1 is used.
这里对轮廓进行了一个高斯模糊,我觉得可能是作者觉得轮廓太细了。
Experiment
实验是常规的主观评估(图)、客观量化评估(表)、和消融实验。先把要比较的方法介绍一遍这个写法很好。
reference
[1] Yang J, Qi Z, Shi Y. Learning to Incorporate Structure Knowledge for Image Inpainting[C]//AAAI. 2020: 12605-12612.
写在最后:
我读文章不够深入,有意见或者建议请告诉我!要觉得好,也可以一键三连~
边栏推荐
- 1.QTimer::singleShot如何传参、2.QMetaObject::invokeMethod如何用函数传值
- Unity:素材下载
- PTA 基础题7-28猴子选大王(简单方法)
- LeetCode: 1179. 重新格式化部门表
- 预算dll要达到的效果,Qt将第三方窗口嵌入程序内,excel操作,数据库外键,判断程序是否启动
- LeetCode: 596. 超过5名学生的课
- Stm32+esp8266+mqtt protocol connects onenet IOT platform
- Sprintf rewriting of QT; The content under QT is scaled according to the scaling of the interface (without changing the font size)
- Pat class B 1010 univariate polynomial derivation (problem meaning understanding)
- App mobile End test [6] application (APK) package Management and Activity
猜你喜欢
NRF24L01无线模块设置发射接受模式方法
LeetCode: 184. 部门工资最高的员工
PTA basic questions 7-28 monkeys choose the king (simple method)
Six dimensional space
六度空间
Stm32+esp8266+mqtt protocol connects onenet IOT platform
数据存储分区--范围分区,哈希分区,列表分区,性能调优必不可缺少的部分
App移動端測試【6】應用程序(apk)包管理與activity
PTA 基础题7-28猴子选大王(简单方法)
递归求简单交错幂级数的部分和 (15分)
随机推荐
1.QTableWidget插入按钮,灵活删除本行,一列显示行号
Summary 20215 (Kruskal and PRIM)
LeetCode: 620. 有趣的电影
The detailed analysis of the divide () method in BigDecimal takes you into the world of source code
Go language learning: go language journey (4)
MySQL statement execution order
Flink学习笔记(六)Flink的时间和窗口
PTA 6-11 find the median of self-determined type element sequence (25 points)
App移動端測試【6】應用程序(apk)包管理與activity
win10sp1升到最新版本;QT5.9.6静态编译(network有效)
LeetCode: 184. 部门工资最高的员工
Upgrade win10sp1 to the latest version; Qt5.9.6 static compilation (network is valid)
MySQL的语句执行顺序
连接mysql8.0出现caching-sha2-password问题
LeetCode: 596. 超过5名学生的课
Leetcode 116. fill in the next right node pointer of each node
Stm32+esp8266+mqtt protocol connects onenet IOT platform
Summary of various technical data -mysql
在各類數據庫中隨機查詢n條數據
PTA 6-11 求自定类型元素序列的中位数 (25 分)