{"id":293,"date":"2016-03-31T15:06:54","date_gmt":"2016-03-31T15:06:54","guid":{"rendered":"http:\/\/liipetti.net\/erratic\/?p=293"},"modified":"2018-05-06T09:41:38","modified_gmt":"2018-05-06T09:41:38","slug":"i-have-seen-a-neural-mirage","status":"publish","type":"post","link":"http:\/\/liipetti.net\/erratic\/2016\/03\/31\/i-have-seen-a-neural-mirage\/","title":{"rendered":"I have seen a neural mirage"},"content":{"rendered":"<p>In my previous post, <a href=\"http:\/\/liipetti.net\/erratic\/2016\/03\/28\/controlling-image-content-with-fc-layers\/\" target=\"_blank\">Controlling image content with FC layers<\/a>, I described how I had modified neural-style to optimize content based on the classifications obtained from the top-most, fully connected layers (which neural-style does not use). \u00a0I had found that the modified program produced visually quite interesting results, but I was not fully sure whether this was due to the use of FC layers or merely from the use of one and same image for both content and style.<\/p>\n<p>I have since then confirmed that the modified program, which I have given the name Neural Mirage, actually optimized contents according to classifications while the\u00a0details are obtained through the style of the original photo. The result is a totally new image, in which the spatial arrangement of the original is totally absent. The image has been deconstructed and then reconstructed, sometimes looking like a map, sometimes like a puzzle in which the pieces have been reordered, even repainted from different perspectives,\u00a0while\u00a0they still appear to fit together seamlessly. Like in the view from Munich below.<\/p>\n<p><a href=\"http:\/\/liipetti.net\/erratic\/wp-content\/uploads\/2016\/03\/12928353_10154184379158729_6766375259441867285_n.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-295\" src=\"http:\/\/liipetti.net\/erratic\/wp-content\/uploads\/2016\/03\/12928353_10154184379158729_6766375259441867285_n-300x225.jpg\" alt=\"12928353_10154184379158729_6766375259441867285_n\" width=\"300\" height=\"225\" srcset=\"http:\/\/liipetti.net\/erratic\/wp-content\/uploads\/2016\/03\/12928353_10154184379158729_6766375259441867285_n-300x225.jpg 300w, http:\/\/liipetti.net\/erratic\/wp-content\/uploads\/2016\/03\/12928353_10154184379158729_6766375259441867285_n-200x150.jpg 200w, http:\/\/liipetti.net\/erratic\/wp-content\/uploads\/2016\/03\/12928353_10154184379158729_6766375259441867285_n-150x113.jpg 150w, http:\/\/liipetti.net\/erratic\/wp-content\/uploads\/2016\/03\/12928353_10154184379158729_6766375259441867285_n.jpg 960w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a>\u00a0 \u00a0<a href=\"http:\/\/liipetti.net\/erratic\/wp-content\/uploads\/2016\/03\/12936698_10154180913498729_2347588058552307576_n.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-294\" src=\"http:\/\/liipetti.net\/erratic\/wp-content\/uploads\/2016\/03\/12936698_10154180913498729_2347588058552307576_n-300x225.jpg\" alt=\"12936698_10154180913498729_2347588058552307576_n\" width=\"300\" height=\"225\" srcset=\"http:\/\/liipetti.net\/erratic\/wp-content\/uploads\/2016\/03\/12936698_10154180913498729_2347588058552307576_n-300x225.jpg 300w, http:\/\/liipetti.net\/erratic\/wp-content\/uploads\/2016\/03\/12936698_10154180913498729_2347588058552307576_n-200x150.jpg 200w, http:\/\/liipetti.net\/erratic\/wp-content\/uploads\/2016\/03\/12936698_10154180913498729_2347588058552307576_n-150x113.jpg 150w, http:\/\/liipetti.net\/erratic\/wp-content\/uploads\/2016\/03\/12936698_10154180913498729_2347588058552307576_n.jpg 512w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>Or in the view of the Helsinki harbor seen from the sea:<\/p>\n<p><a href=\"http:\/\/liipetti.net\/erratic\/wp-content\/uploads\/2016\/03\/xpl4vgg16-helsinki03-fc8-cw1e3sw10000-800_350.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-296\" src=\"http:\/\/liipetti.net\/erratic\/wp-content\/uploads\/2016\/03\/sthlm0006-300x225.jpg\" alt=\"sthlm0006\" width=\"300\" height=\"225\" srcset=\"http:\/\/liipetti.net\/erratic\/wp-content\/uploads\/2016\/03\/sthlm0006-300x225.jpg 300w, http:\/\/liipetti.net\/erratic\/wp-content\/uploads\/2016\/03\/sthlm0006-1024x768.jpg 1024w, http:\/\/liipetti.net\/erratic\/wp-content\/uploads\/2016\/03\/sthlm0006-200x150.jpg 200w, http:\/\/liipetti.net\/erratic\/wp-content\/uploads\/2016\/03\/sthlm0006-150x113.jpg 150w, http:\/\/liipetti.net\/erratic\/wp-content\/uploads\/2016\/03\/sthlm0006.jpg 2048w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/>\u00a0 \u00a0\u00a0<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-297\" src=\"http:\/\/liipetti.net\/erratic\/wp-content\/uploads\/2016\/03\/xpl4vgg16-helsinki03-fc8-cw1e3sw10000-800_350-300x225.png\" alt=\"xpl4vgg16-helsinki03-fc8-cw1e3sw10000-800_350\" width=\"300\" height=\"225\" srcset=\"http:\/\/liipetti.net\/erratic\/wp-content\/uploads\/2016\/03\/xpl4vgg16-helsinki03-fc8-cw1e3sw10000-800_350-300x225.png 300w, http:\/\/liipetti.net\/erratic\/wp-content\/uploads\/2016\/03\/xpl4vgg16-helsinki03-fc8-cw1e3sw10000-800_350-200x150.png 200w, http:\/\/liipetti.net\/erratic\/wp-content\/uploads\/2016\/03\/xpl4vgg16-helsinki03-fc8-cw1e3sw10000-800_350-150x113.png 150w, http:\/\/liipetti.net\/erratic\/wp-content\/uploads\/2016\/03\/xpl4vgg16-helsinki03-fc8-cw1e3sw10000-800_350.png 800w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>Up to this point, I had used the original VGG16 net in these tests, modified as described in the previous post.<\/p>\n<p>I then wanted to monitor what classes the program is seeing in the target image, and how it manages to work towards the correct classes. I was able to see that the content losses from FC8-layer were diminishing properly, but I also wanted to see which specific classes were seen present in the target image as well as in each of the intermediate results.<\/p>\n<p>Making sure that there was a Softmax layer on top of the upmost FC layer, I got an array of probabilities for each of the 1000 classes in VGG16. I did not have a list of names for the classes, though, and my attempt to reconstruct one produced such improbable results that I had find something else. At this point I found a VGG16 trained for places in\u00a0<a href=\"http:\/\/places.csail.mit.edu\/downloadCNN.html\" target=\"_blank\">http:\/\/places.csail.mit.edu\/downloadCNN.html<\/a>\u00a0together with a list of 205 classes like &#8220;alley&#8221;, &#8220;river&#8221;, &#8220;desert sand&#8221;. \u00a0My Mirage could now display, at the beginning, which features it is seeing in the content image, like for the Helsinki harbor:<\/p>\n<pre>----------- seeing the features -------------- \r\n0.4539 \/b\/basilica 21 \r\n0.0939 \/c\/cathedral\/outdoor 61 \r\n0.0704 \/c\/church\/outdoor 62 \r\n0.0832 \/h\/harbor 90 \r\n0.0673 \/p\/palace 133<\/pre>\n<p>The first iterations, starting with an image of random noise, usually see not much else than desert sand:<\/p>\n<pre> Iteration 10 \/ 1000 \r\n Content 1 loss: 10157.208443 \r\n Style 1 loss: 29152.839661 \r\n Style 2 loss: 7147411.132812 \r\n Style 3 loss: 10749539.062500 \r\n Style 4 loss: 164257.827759 \r\n Style 5 loss: 438.794106 \r\n Total loss: 18100956.865281 \r\n0.3538 \/d\/desert\/sand 68 \r\n0.0625 \/m\/marsh 116<\/pre>\n<p>Usually the content classes emerge quite early, and from there the optimization mainly continues to refine the style. Sometimes the optimization fails to find the correct classes, and if this persists for an image, then it usually helps to increase the content weight.<\/p>\n<pre>Iteration 70 \/ 1000 \r\n Content 1 loss: 495.897047 \r\n Style 1 loss: 27438.602448 \r\n Style 2 loss: 233755.386353 \r\n Style 3 loss: 186934.814453 \r\n Style 4 loss: 14508.877754 \r\n Style 5 loss: 177.618906 \r\n Total loss: 463311.196961 \r\n0.4232 \/b\/basilica 21 \r\n0.0789 \/c\/cathedral\/outdoor 61 \r\n0.0668 \/c\/church\/outdoor 62 \r\n0.1070 \/h\/harbor 90 \r\n0.0911 \/p\/palace 133<\/pre>\n<p>The VGG Places net is fun to work with, now that one can monitor what it is really seeing in the images. Otherwise, it might be that the images it produces are a little less detailed than those in which the default VGG19 was used. But not enough tests have been conducted to be sure.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In my previous post, Controlling image content with FC layers, I described how I had modified neural-style to optimize content based on the classifications obtained from the top-most, fully connected layers (which neural-style does not use). \u00a0I had found that the modified program produced visually quite interesting results, but I \u2026<\/p>\n<p class=\"continue-reading-button\"> <a class=\"continue-reading-link\" href=\"http:\/\/liipetti.net\/erratic\/2016\/03\/31\/i-have-seen-a-neural-mirage\/\">Continue reading<i class=\"crycon-right-dir\"><\/i><\/a><\/p>\n","protected":false},"author":1,"featured_media":297,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,3],"tags":[],"class_list":["post-293","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-art","category-neural-networks"],"_links":{"self":[{"href":"http:\/\/liipetti.net\/erratic\/wp-json\/wp\/v2\/posts\/293","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/liipetti.net\/erratic\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/liipetti.net\/erratic\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/liipetti.net\/erratic\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/liipetti.net\/erratic\/wp-json\/wp\/v2\/comments?post=293"}],"version-history":[{"count":2,"href":"http:\/\/liipetti.net\/erratic\/wp-json\/wp\/v2\/posts\/293\/revisions"}],"predecessor-version":[{"id":299,"href":"http:\/\/liipetti.net\/erratic\/wp-json\/wp\/v2\/posts\/293\/revisions\/299"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/liipetti.net\/erratic\/wp-json\/wp\/v2\/media\/297"}],"wp:attachment":[{"href":"http:\/\/liipetti.net\/erratic\/wp-json\/wp\/v2\/media?parent=293"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/liipetti.net\/erratic\/wp-json\/wp\/v2\/categories?post=293"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/liipetti.net\/erratic\/wp-json\/wp\/v2\/tags?post=293"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}