{"id":190,"date":"2016-02-14T12:43:45","date_gmt":"2016-02-14T12:43:45","guid":{"rendered":"http:\/\/liipetti.net\/erratic\/?p=190"},"modified":"2018-05-07T11:48:02","modified_gmt":"2018-05-07T11:48:02","slug":"switching-to-a-smaller-net","status":"publish","type":"post","link":"http:\/\/liipetti.net\/erratic\/2016\/02\/14\/switching-to-a-smaller-net\/","title":{"rendered":"Working with a smaller net"},"content":{"rendered":"<p>The core of neural-style is the pre-trained neural network. Pre-trained means that the net has been trained using a large number of images, usually with the goal that the net be able to recognize objects and features in images. The default neural network for neural-style, VGG-19 is very effective for such purposes. In addition, when used with neural-style, it is relatively easy to produce high-quality images. The only drawback is that it consumes a lot of memory. With 8 GB of memory \u00a0one cannot get resolutions beyond 800 pixels.<\/p>\n<p>It is now possible to switch to using another neural network in neural-style. I have tried nin-imagenet-conv, and found that I can get 1280px without running over 4 GB. The drawback is that with the default settings, the results might not be what you would expect having used VGG-19. I almost gave up myself, but then suddenly started making progress with nin-imagenet-conv. It is different, but not inferior. It may not be the best choice for copying someone&#8217;s style, but it is a great creative tool when you are looking for your own style.<\/p>\n<p>In this image, I have used neural-style together with nin-imagenet-conv to convert a webcam view from Helsinki using style from a painting by Lionel Feininger.<\/p>\n<p><a href=\"http:\/\/liipetti.net\/erratic\/wp-content\/uploads\/2016\/02\/kauppatori-nin-feininger.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-191\" src=\"http:\/\/liipetti.net\/erratic\/wp-content\/uploads\/2016\/02\/kauppatori-nin-feininger-300x160.png\" alt=\"kauppatori-nin-feininger\" width=\"456\" height=\"243\" srcset=\"http:\/\/liipetti.net\/erratic\/wp-content\/uploads\/2016\/02\/kauppatori-nin-feininger-300x160.png 300w, http:\/\/liipetti.net\/erratic\/wp-content\/uploads\/2016\/02\/kauppatori-nin-feininger-1024x545.png 1024w, http:\/\/liipetti.net\/erratic\/wp-content\/uploads\/2016\/02\/kauppatori-nin-feininger-250x133.png 250w, http:\/\/liipetti.net\/erratic\/wp-content\/uploads\/2016\/02\/kauppatori-nin-feininger-150x80.png 150w, http:\/\/liipetti.net\/erratic\/wp-content\/uploads\/2016\/02\/kauppatori-nin-feininger.png 1274w\" sizes=\"auto, (max-width: 456px) 100vw, 456px\" \/><\/a><\/p>\n<p>As always, I am not merely interested in the final results of neural-style after several hundreds of iterations. I like to look at the intermediate images, to see the beauty in them, and also to use them in animations. Like in the following video clip, where the Helsinki view gradually emerges from the abstractness of the initial image.<\/p>\n<p><iframe loading=\"lazy\" width=\"560\" height=\"315\" src=\"https:\/\/www.youtube.com\/embed\/fNUni7Uxs-0?feature=oembed\" frameborder=\"0\" allow=\"autoplay; encrypted-media\" allowfullscreen><\/iframe><\/p>\n<p>Next, I&#8217;ll give an example of how I work using neural-style and other tools to work on original images. Let us take a photo from Finland late last autumn.<\/p>\n<p><a href=\"http:\/\/liipetti.net\/erratic\/wp-content\/uploads\/2016\/02\/DSC01350.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-193\" src=\"http:\/\/liipetti.net\/erratic\/wp-content\/uploads\/2016\/02\/DSC01350-300x200.jpg\" alt=\"DSC01350\" width=\"455\" height=\"303\" srcset=\"http:\/\/liipetti.net\/erratic\/wp-content\/uploads\/2016\/02\/DSC01350-300x200.jpg 300w, http:\/\/liipetti.net\/erratic\/wp-content\/uploads\/2016\/02\/DSC01350-1024x682.jpg 1024w, http:\/\/liipetti.net\/erratic\/wp-content\/uploads\/2016\/02\/DSC01350-225x150.jpg 225w, http:\/\/liipetti.net\/erratic\/wp-content\/uploads\/2016\/02\/DSC01350-150x100.jpg 150w\" sizes=\"auto, (max-width: 455px) 100vw, 455px\" \/><\/a><\/p>\n<p>For the style image, I select an image which I have myself created, using a Processing script and webcam together with some acting in front of the camera.<\/p>\n<p><a href=\"http:\/\/liipetti.net\/erratic\/wp-content\/uploads\/2016\/02\/Tanssi.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-194\" src=\"http:\/\/liipetti.net\/erratic\/wp-content\/uploads\/2016\/02\/Tanssi-300x242.png\" alt=\"Tanssi\" width=\"455\" height=\"367\" srcset=\"http:\/\/liipetti.net\/erratic\/wp-content\/uploads\/2016\/02\/Tanssi-300x242.png 300w, http:\/\/liipetti.net\/erratic\/wp-content\/uploads\/2016\/02\/Tanssi-1024x827.png 1024w, http:\/\/liipetti.net\/erratic\/wp-content\/uploads\/2016\/02\/Tanssi-186x150.png 186w, http:\/\/liipetti.net\/erratic\/wp-content\/uploads\/2016\/02\/Tanssi-150x121.png 150w, http:\/\/liipetti.net\/erratic\/wp-content\/uploads\/2016\/02\/Tanssi.png 1178w\" sizes=\"auto, (max-width: 455px) 100vw, 455px\" \/><\/a><\/p>\n<p>Applying this style to the photo, with suitable parameters, gives me this:<\/p>\n<p><a href=\"http:\/\/liipetti.net\/erratic\/wp-content\/uploads\/2016\/02\/nin_tanssi_1350_r03h3_1000.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-195\" src=\"http:\/\/liipetti.net\/erratic\/wp-content\/uploads\/2016\/02\/nin_tanssi_1350_r03h3_1000-300x200.png\" alt=\"nin_tanssi_1350_r03h3_1000\" width=\"455\" height=\"303\" srcset=\"http:\/\/liipetti.net\/erratic\/wp-content\/uploads\/2016\/02\/nin_tanssi_1350_r03h3_1000-300x200.png 300w, http:\/\/liipetti.net\/erratic\/wp-content\/uploads\/2016\/02\/nin_tanssi_1350_r03h3_1000-1024x682.png 1024w, http:\/\/liipetti.net\/erratic\/wp-content\/uploads\/2016\/02\/nin_tanssi_1350_r03h3_1000-225x150.png 225w, http:\/\/liipetti.net\/erratic\/wp-content\/uploads\/2016\/02\/nin_tanssi_1350_r03h3_1000-150x100.png 150w, http:\/\/liipetti.net\/erratic\/wp-content\/uploads\/2016\/02\/nin_tanssi_1350_r03h3_1000.png 1280w\" sizes=\"auto, (max-width: 455px) 100vw, 455px\" \/><\/a><\/p>\n<p>Now, I might like it, the stripes in particular, but want to try with some color. I could use the original photo as a style image, but this time I&#8217;ll use another derivative of the same photo to add color. I had created this image earlier using a Processing script, webcam, some photos and neural-style.<\/p>\n<p><a href=\"http:\/\/liipetti.net\/erratic\/wp-content\/uploads\/2016\/02\/nin_canvas_1350_r023h2_200.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-196\" src=\"http:\/\/liipetti.net\/erratic\/wp-content\/uploads\/2016\/02\/nin_canvas_1350_r023h2_200-300x200.png\" alt=\"nin_canvas_1350_r023h2_200\" width=\"455\" height=\"303\" srcset=\"http:\/\/liipetti.net\/erratic\/wp-content\/uploads\/2016\/02\/nin_canvas_1350_r023h2_200-300x200.png 300w, http:\/\/liipetti.net\/erratic\/wp-content\/uploads\/2016\/02\/nin_canvas_1350_r023h2_200-1024x682.png 1024w, http:\/\/liipetti.net\/erratic\/wp-content\/uploads\/2016\/02\/nin_canvas_1350_r023h2_200-225x150.png 225w, http:\/\/liipetti.net\/erratic\/wp-content\/uploads\/2016\/02\/nin_canvas_1350_r023h2_200-150x100.png 150w, http:\/\/liipetti.net\/erratic\/wp-content\/uploads\/2016\/02\/nin_canvas_1350_r023h2_200.png 1280w\" sizes=\"auto, (max-width: 455px) 100vw, 455px\" \/><\/a><\/p>\n<p>The result, combining the grey stripes and the stylized autumn photo, currently looks like this. It may not be what I was looking for, and if not,\u00a0then I can go on like this. At this point, I have used several photos, Processing scripts and neural-style runs. At each phase, I can choose the style image and in addition I have control of many parameters.<\/p>\n<p><a href=\"http:\/\/liipetti.net\/erratic\/wp-content\/uploads\/2016\/02\/metsa_takaisin_1150.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-197\" src=\"http:\/\/liipetti.net\/erratic\/wp-content\/uploads\/2016\/02\/metsa_takaisin_1150-300x200.png\" alt=\"metsa_takaisin_1150\" width=\"455\" height=\"303\" srcset=\"http:\/\/liipetti.net\/erratic\/wp-content\/uploads\/2016\/02\/metsa_takaisin_1150-300x200.png 300w, http:\/\/liipetti.net\/erratic\/wp-content\/uploads\/2016\/02\/metsa_takaisin_1150-1024x682.png 1024w, http:\/\/liipetti.net\/erratic\/wp-content\/uploads\/2016\/02\/metsa_takaisin_1150-225x150.png 225w, http:\/\/liipetti.net\/erratic\/wp-content\/uploads\/2016\/02\/metsa_takaisin_1150-150x100.png 150w, http:\/\/liipetti.net\/erratic\/wp-content\/uploads\/2016\/02\/metsa_takaisin_1150.png 1280w\" sizes=\"auto, (max-width: 455px) 100vw, 455px\" \/><\/a><\/p>\n<p>Furthermore I have the freedom to watch neural-style producing intermediate results, so if I happen to like a rougher version from an early iteration, I can use it instead of the more polished results after 1000 to 2000 iterations. Here, for example, I have used\u00a0same content and style images, with different weight parameters and only 50 iterations.<\/p>\n<p><a href=\"http:\/\/liipetti.net\/erratic\/wp-content\/uploads\/2016\/02\/metsa_takaisin2_50.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-201\" src=\"http:\/\/liipetti.net\/erratic\/wp-content\/uploads\/2016\/02\/metsa_takaisin2_50-300x200.png\" alt=\"metsa_takaisin2_50\" width=\"455\" height=\"303\" srcset=\"http:\/\/liipetti.net\/erratic\/wp-content\/uploads\/2016\/02\/metsa_takaisin2_50-300x200.png 300w, http:\/\/liipetti.net\/erratic\/wp-content\/uploads\/2016\/02\/metsa_takaisin2_50-1024x682.png 1024w, http:\/\/liipetti.net\/erratic\/wp-content\/uploads\/2016\/02\/metsa_takaisin2_50-225x150.png 225w, http:\/\/liipetti.net\/erratic\/wp-content\/uploads\/2016\/02\/metsa_takaisin2_50-150x100.png 150w, http:\/\/liipetti.net\/erratic\/wp-content\/uploads\/2016\/02\/metsa_takaisin2_50.png 1280w\" sizes=\"auto, (max-width: 455px) 100vw, 455px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>Credits:<\/p>\n<p>Neural-style:\u00a0<a href=\"https:\/\/github.com\/jcjohnson\/neural-style\">https:\/\/github.com\/jcjohnson\/neural-style<\/a><\/p>\n<p>Nin-imagenet-conv:\u00a0<a href=\"https:\/\/gist.github.com\/mavenlin\/d802a5849de39225bcc6\">https:\/\/gist.github.com\/mavenlin\/d802a5849de39225bcc6<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The core of neural-style is the pre-trained neural network. Pre-trained means that the net has been trained using a large number of images, usually with the goal that the net be able to recognize objects and features in images. The default neural network for neural-style, VGG-19 is very effective for \u2026<\/p>\n<p class=\"continue-reading-button\"> <a class=\"continue-reading-link\" href=\"http:\/\/liipetti.net\/erratic\/2016\/02\/14\/switching-to-a-smaller-net\/\">Continue reading<i class=\"crycon-right-dir\"><\/i><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,3,4],"tags":[],"class_list":["post-190","post","type-post","status-publish","format-standard","hentry","category-art","category-neural-networks","category-processing-framework"],"_links":{"self":[{"href":"http:\/\/liipetti.net\/erratic\/wp-json\/wp\/v2\/posts\/190","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=190"}],"version-history":[{"count":10,"href":"http:\/\/liipetti.net\/erratic\/wp-json\/wp\/v2\/posts\/190\/revisions"}],"predecessor-version":[{"id":606,"href":"http:\/\/liipetti.net\/erratic\/wp-json\/wp\/v2\/posts\/190\/revisions\/606"}],"wp:attachment":[{"href":"http:\/\/liipetti.net\/erratic\/wp-json\/wp\/v2\/media?parent=190"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/liipetti.net\/erratic\/wp-json\/wp\/v2\/categories?post=190"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/liipetti.net\/erratic\/wp-json\/wp\/v2\/tags?post=190"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}