内容简介:In the original paper, he first used the VGG19 model to achieve this result. VGG19 is a popular neural network for image recognition, but we’re mainly going to focus on how it extracts features from a photograph. The feature extraction is done through a nu
In the original paper, he first used the VGG19 model to achieve this result. VGG19 is a popular neural network for image recognition, but we’re mainly going to focus on how it extracts features from a photograph. The feature extraction is done through a number of sequential layers that can detect small patterns . The features it initially picks up are very simple, but gets more complex as more feature layers are added. we can then use these features, to recreate our original image!
Content Loss
In this step, we want to try to recreate, more or less the essence of our content image. To achieve this, we’ll first start off by creating an image full of random noise. We’ll then shape this image to look like our content image, using the extracted features from our network as a guide. The distance between the random image features and the content features is called our “content loss”. To get the best stylized image, we want to minimize this loss function through back-propagation. We’ll finally loop through this whole thing and optimize on each step to get a pretty good recreation of our image.
for i in range(1,epochs+1):target_features = model_activations(target,model)content_loss = torch.mean((content_features['conv4_2']-target_features['conv4_2'])**2)
Style Loss
For this step, we’ll want to recreate the core artistic direction of our style image. Gatsy solves this in an interesting way! Instead of comparing our style features to another image, we’ll compare each feature map to itself. We’ll first transform the style features into a gram matrix, which is basically the inner product of a matrix. The “style loss” was is basically the sum of losses for all feature maps in the model network. We’ll do a similar looping process and optimize on each step.
style_loss = 0for layer in style_wt_meas:style_gram = style_grams[layer]target_gram = target_features[layer]_,d,w,h = target_gram.shapetarget_gram = gram_matrix(target_gram)style_loss += (style_wt_meas[layer]*torch.mean((target_gram-style_gram)**2))/d*w*h
Our final step in this process is to calculate our final loss as the weighted sum of our content loss and style loss. we’ll also optimize this loss at each step of our training loop.
total_loss = content_wt*content_loss + style_wt*style_loss
Problems and Future Work
Gatsy Method for Style Transfer was the first of it’s kind, but it did have some problems. The major problem is that it’s very slow. This is because Since the optimization is done every cycle in the training loop, the algorithm takes some time produce anything. Secondly, sometimes changing the weights will greatly destabilize the photo. There is a fix by adding a total loss variation which aligns the mean and variance of the content and style images. From my research, it looks like Neural Style Transfer is still a hot topic, with applications being applied to video processing, simulations, and designs.
I used Ayush Chaurasia: Artistic Neural Style Transfer From Scratch on Youtube to create the code. Like I mentioned in the beginning of this article, there are plenty of great resources you can find online. If you wanted to get started with computer vision problems, I think that building neural style transfer application can be very fun and exciting! So I hoped this helped and I wish you luck if you try to pursue this!
Thanks for Reading!
Here are some cool results that I’ve taken, I can’t wait to see what you’ll create!
以上所述就是小编给大家介绍的《Lets Get Artsy! Creating Custom Snapchat Filters With Neural Networks!》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!
猜你喜欢:本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
新媒体运营实战技能
张向南 勾俊伟 / 人民邮电出版社 / 2017-5 / 39.80元
《新媒体运营实战技能》共7章。第1章重点介绍了新媒体图片的创意思路及制作技巧,包括微信公众号封面图、信息长图、icon图标、九宫图、gif图片的具体实战操作;第2章重点介绍了创意云文字、微信排版、滑动看图等新媒体文字的排版方法与处理技巧;第3章是新媒体表单,引导读者对表单结构、设计场景及具体应用全面了解;第4章关于H5的创意思路及制作方法,解析了引发H5传播的心理因素,并重点介绍H5的制作工具与具......一起来看看 《新媒体运营实战技能》 这本书的介绍吧!