原理
结构示意图:


总损失=内容损失+风格损失
将图a的style loss 和 图p的content loss 组合起来,最小化total loss function求得x
L t o t a l ( p → , a → , x → ) = α L c o n t e n t ( p → , x → ) + β L s t y l e ( a → , x → ) {L_{total}}(\overrightarrow {\rm{p}} \;,\overrightarrow a \;,\overrightarrow x \;) = \alpha {L_{content}}(\overrightarrow p ,\overrightarrow x ) + \beta {L_{style}}(\overrightarrow {a\;} ,\overrightarrow x ) Ltotal(p,a,x)=αLcontent(p,x)+βLstyle(a,x)
其中, α, β对应两个loss的权重,调节它们会得到不同的效果。
内容损失函数:
Lcontent采用平方损失函数,为每个像素的损失和
L c o n t e n t ( p → , x → , l ) = 1 2 ∑ i j ( F i j l − P i j l ) 2 {L_{content}}(\overrightarrow {\rm{p}} \;,\overrightarrow x \;,l) = \frac{1}{2}\sum\limits_{ij} {(F_{ij}^l - P_{ij}^l)2} Lcontent(p,x,l)=2<

本文介绍了一种基于深度学习的图像风格迁移方法,通过调整内容损失和风格损失的权重,实现了从内容图像到风格图像的有效迁移。文章详细展示了使用VGG19网络搭建神经网络模型的过程,并提供了完整的Python代码实现。
最低0.47元/天 解锁文章
7720





