{"id":6,"date":"2022-07-06T17:00:45","date_gmt":"2022-07-06T17:00:45","guid":{"rendered":"https:\/\/formatswap.com\/blog\/?p=6"},"modified":"2023-01-25T20:33:19","modified_gmt":"2023-01-25T20:33:19","slug":"deep-learning-image-style-transfer-tutorial-using-neural-style-pt","status":"publish","type":"post","link":"https:\/\/formatswap.com\/blog\/machine-learning-tutorials\/deep-learning-image-style-transfer-tutorial-using-neural-style-pt\/","title":{"rendered":"Deep Learning Image Style Transfer Tutorial Using Neural Style Pt"},"content":{"rendered":"\n<p>In this tutorial you will learn how to transfer the style of one image onto the content of another. This program uses deep learning with python. The project uses an <a href=\"https:\/\/en.wikipedia.org\/wiki\/Algorithm\">algorithm<\/a> based on a convolutional neural network. Style any image using <a href=\"https:\/\/en.wikipedia.org\/wiki\/Machine_learning\">machine learning<\/a> image processing. We will be using Ubuntu 20.04 for this tutorial. Almost any Linux distribution <em>should<\/em> work.<\/p>\n\n\n\n<p>The project is based off of a PyTorch implementation of the <a href=\"http:\/\/arxiv.org\/abs\/1508.06576\">A Neural Algorithm of Artistic Style<\/a> article. It was published by Leon A. Gatys, Alexander S, Ecker, and Matthias Bethge. It is based on the  <a href=\"https:\/\/github.com\/jcjohnson\/neural-style\">Neural-Style<\/a> code by Justin Johnson&#8217;s. Here is an example of  <a href=\"https:\/\/en.wikipedia.org\/wiki\/The_Scream\" target=\"_blank\" rel=\"noreferrer noopener\">The Scream<\/a> painting&#8217;s style being transferred onto a picture of a New York City:<\/p>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow\"><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/formatswap.com\/blog\/wp-content\/uploads\/2022\/07\/york-1024x683.jpg\" alt=\"A photo of new york city\" class=\"wp-image-106\" width=\"573\" height=\"373\"\/><figcaption class=\"wp-element-caption\">Content Image<\/figcaption><\/figure>\n<\/div><\/div><\/div>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/formatswap.com\/blog\/wp-content\/uploads\/2022\/07\/scream-3-825x1024.jpg\" alt=\"scream painting\" class=\"wp-image-105\" width=\"395\" height=\"489\" srcset=\"https:\/\/formatswap.com\/blog\/wp-content\/uploads\/2022\/07\/scream-3-825x1024.jpg 825w, https:\/\/formatswap.com\/blog\/wp-content\/uploads\/2022\/07\/scream-3-242x300.jpg 242w, https:\/\/formatswap.com\/blog\/wp-content\/uploads\/2022\/07\/scream-3-768x953.jpg 768w, https:\/\/formatswap.com\/blog\/wp-content\/uploads\/2022\/07\/scream-3-1237x1536.jpg 1237w, https:\/\/formatswap.com\/blog\/wp-content\/uploads\/2022\/07\/scream-3.jpg 1289w\" sizes=\"auto, (max-width: 395px) 100vw, 395px\" \/><figcaption class=\"wp-element-caption\">Style Image<\/figcaption><\/figure>\n<\/div>\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/formatswap.com\/blog\/wp-content\/uploads\/2022\/07\/scream-sail_400-1024x683.jpg\" alt=\"style transferred image of new york\" class=\"wp-image-107\" width=\"615\" height=\"410\" srcset=\"https:\/\/formatswap.com\/blog\/wp-content\/uploads\/2022\/07\/scream-sail_400-1024x683.jpg 1024w, https:\/\/formatswap.com\/blog\/wp-content\/uploads\/2022\/07\/scream-sail_400-300x200.jpg 300w, https:\/\/formatswap.com\/blog\/wp-content\/uploads\/2022\/07\/scream-sail_400-768x512.jpg 768w, https:\/\/formatswap.com\/blog\/wp-content\/uploads\/2022\/07\/scream-sail_400-1536x1024.jpg 1536w, https:\/\/formatswap.com\/blog\/wp-content\/uploads\/2022\/07\/scream-sail_400.jpg 1800w\" sizes=\"auto, (max-width: 615px) 100vw, 615px\" \/><figcaption class=\"wp-element-caption\">Output Image<\/figcaption><\/figure>\n<\/div>\n\n\n<h2 class=\"wp-block-heading\">Dependencies Installation<\/h2>\n\n\n\n<p>This project requires you to install the following <\/p>\n\n\n\n<p><strong>Required<\/strong> <strong>Dependencies:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/varhowto.com\/install-pytorch-ubuntu-20-04\/#Install_PyTorch_with_pip\">PyTorch<\/a><\/li>\n<\/ul>\n\n\n\n<p><strong>Optional dependencies:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>For CUDA backend:\n<ul class=\"wp-block-list\">\n<li>CUDA 7.5 or above<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>For cuDNN backend:\n<ul class=\"wp-block-list\">\n<li>cuDNN v6 or above<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>For ROCm backend:\n<ul class=\"wp-block-list\">\n<li>ROCm 2.1 or above<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>For MKL backend:\n<ul class=\"wp-block-list\">\n<li>MKL 2019 or above<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>For OpenMP backend:\n<ul class=\"wp-block-list\">\n<li>OpenMP 5.0 or above<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Setup<\/h2>\n\n\n\n<p>Navigate to the directory you would like to download neural-style-pt project to. Then git clone the repository.<\/p>\n\n\n\n<pre class=\"wp-block-code has-vivid-cyan-blue-color has-black-background-color has-text-color has-background\"><code>git clone https:\/\/github.com\/ProGamerGov\/neural-style-pt.git<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Download Model<\/h2>\n\n\n\n<p>Next you will cd into the cloned directory and download the VGG model files.<\/p>\n\n\n\n<pre class=\"wp-block-code has-vivid-cyan-blue-color has-black-background-color has-text-color has-background\"><code>cd neural-style-pt\/\npython models\/download_models.py<\/code><\/pre>\n\n\n\n<p>This will download multiple model files. If you are running on a lighter system use the option <em>-model_file models\/nin_imagenet.pth<\/em> If you have a strong system with a powerful gpu use the option <em>-model_file models\/vgg19-d01eb7cb.pth<\/em> The second option will provide drastically better results at the expense of more strain to the GPU. If you have issues with VGG19 or VGG18 revert back to <em>nin_imagenet.pth<\/em>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Creating Deep Learning Style Transfer Images<\/h2>\n\n\n\n<p>In this example we will be using the cuDNN with NIN Model. Feel free to use the model of your choice. See the bottom of the tutorial for speed comparisons between the different models. Run the following command replacing <em>-style_image<\/em> with the path to the style image you want to use. You must all add the path of your content image to <em>-content_image<\/em>. Feel free to change the -image_size option to increase the resolution of your output <a href=\"https:\/\/en.wikipedia.org\/wiki\/Machine_learning\">machine learning<\/a> image.<\/p>\n\n\n\n<pre class=\"wp-block-code has-vivid-cyan-blue-color has-black-background-color has-text-color has-background\"><code>python neural_style.py -style_image examples\/inputs\/picasso_selfport1907.jpg -content_image examples\/inputs\/brad_pitt.jpg -output_image profile.png -model_file models\/nin_imagenet.pth -gpu 0 -backend cudnn -num_iterations 1000 -seed 123 -content_layers relu0,relu3,relu7,relu12 -style_layers relu0,relu3,relu7,relu12 -content_weight 10 -style_weight 500 -image_size 512 -optimizer adam<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Content Image<\/h2>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter is-resized\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/formatswap.com\/blog\/wp-content\/uploads\/2022\/07\/porsche_auto_car_cars_red_79763_1280x1024-1024x819.jpg\" alt=\"car photo\" class=\"wp-image-90\" width=\"620\" height=\"495\" srcset=\"https:\/\/formatswap.com\/blog\/wp-content\/uploads\/2022\/07\/porsche_auto_car_cars_red_79763_1280x1024-1024x819.jpg 1024w, https:\/\/formatswap.com\/blog\/wp-content\/uploads\/2022\/07\/porsche_auto_car_cars_red_79763_1280x1024-300x240.jpg 300w, https:\/\/formatswap.com\/blog\/wp-content\/uploads\/2022\/07\/porsche_auto_car_cars_red_79763_1280x1024-768x614.jpg 768w, https:\/\/formatswap.com\/blog\/wp-content\/uploads\/2022\/07\/porsche_auto_car_cars_red_79763_1280x1024.jpg 1280w\" sizes=\"auto, (max-width: 620px) 100vw, 620px\" \/><\/figure>\n<\/div>\n\n\n<h2 class=\"wp-block-heading\">Style Image <\/h2>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/formatswap.com\/blog\/wp-content\/uploads\/2022\/07\/4-1024x640.jpg\" alt=\"style image\" class=\"wp-image-91\" width=\"632\" height=\"395\" srcset=\"https:\/\/formatswap.com\/blog\/wp-content\/uploads\/2022\/07\/4-1024x640.jpg 1024w, https:\/\/formatswap.com\/blog\/wp-content\/uploads\/2022\/07\/4-300x188.jpg 300w, https:\/\/formatswap.com\/blog\/wp-content\/uploads\/2022\/07\/4-768x480.jpg 768w, https:\/\/formatswap.com\/blog\/wp-content\/uploads\/2022\/07\/4-1536x960.jpg 1536w, https:\/\/formatswap.com\/blog\/wp-content\/uploads\/2022\/07\/4.jpg 1920w\" sizes=\"auto, (max-width: 632px) 100vw, 632px\" \/><\/figure>\n<\/div>\n\n\n<h2 class=\"wp-block-heading\">Deep Learning Output Image<\/h2>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/formatswap.com\/blog\/wp-content\/uploads\/2022\/07\/car-out-1024x819.jpg\" alt=\"Image of a styled car\" class=\"wp-image-184\" width=\"633\" height=\"506\" srcset=\"https:\/\/formatswap.com\/blog\/wp-content\/uploads\/2022\/07\/car-out-1024x819.jpg 1024w, https:\/\/formatswap.com\/blog\/wp-content\/uploads\/2022\/07\/car-out-300x240.jpg 300w, https:\/\/formatswap.com\/blog\/wp-content\/uploads\/2022\/07\/car-out-768x614.jpg 768w, https:\/\/formatswap.com\/blog\/wp-content\/uploads\/2022\/07\/car-out.jpg 1280w\" sizes=\"auto, (max-width: 633px) 100vw, 633px\" \/><\/figure>\n<\/div>\n\n\n<h2 class=\"wp-block-heading\">Deep Learning Image Options<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong><code>-image_size<\/code>:<\/strong> Maximum side length (in pixels) of the generated deep learning image. Default is 512.<\/li>\n\n\n\n<li><strong><code>-style_blend_weights<\/code>:<\/strong> The weight for blending the style of multiple style images, as a comma-separated list, such as <code>-style_blend_weights 3,7<\/code>. By default all style images are equally weighted.<\/li>\n\n\n\n<li><strong><code>-gpu<\/code>:<\/strong> Zero-indexed ID of the GPU to use; for CPU mode set <code>-gpu<\/code> to <code>c<\/code>.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Advanced Optimization Options<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong><code>-content_weight<\/code>: <\/strong>How much to weight the content reconstruction term. Default is 5e0.<\/li>\n\n\n\n<li><strong><code>-style_weight<\/code>:<\/strong> How much to weight the style reconstruction term. Default is 1e2.<\/li>\n\n\n\n<li><strong><code>-tv_weight<\/code>:<\/strong> Weight of total-variation (TV) regularization; this helps to smooth the image. Default is 1e-3. Set to 0 to disable TV regularization.<\/li>\n\n\n\n<li><strong><code>-num_iterations<\/code>:<\/strong> Default is 1000.<\/li>\n\n\n\n<li><strong><code>-init<\/code>: <\/strong>Method for generating the generated image; one of <code>random<\/code> or <code>image<\/code>. Default is <code>random<\/code> which uses a noise initialization as in the paper; <code>image<\/code> initializes with the content image.<\/li>\n\n\n\n<li><strong><code>-init_image<\/code>: <\/strong>Replaces the initialization image with a user specified image.<\/li>\n\n\n\n<li><strong><code>-optimizer<\/code>:<\/strong> The optimization <a href=\"https:\/\/en.wikipedia.org\/wiki\/Algorithm\">algorithm<\/a> to use; either <code>lbfgs<\/code> or <code>adam<\/code>; default is <code>lbfgs<\/code>. L-BFGS tends to give better results, but uses more memory. Switching to ADAM will reduce memory usage; when using ADAM you will probably need to play with other parameters to get good results, especially the style weight, content weight, and learning rate.<\/li>\n\n\n\n<li><strong><code>-learning_rate<\/code>:<\/strong> Learning rate to use with the ADAM optimizer. Default is 1e1.<\/li>\n\n\n\n<li><strong><code>-normalize_gradients<\/code>:<\/strong> If this flag is present, style and content gradients from each layer will be L1 normalized.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Output and Layer Options<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong><code>-output_image<\/code>: <\/strong>Name of the output image. Default is <code>out.png<\/code>.<\/li>\n\n\n\n<li><strong><code>-print_iter<\/code>: <\/strong>Print progress every <code>print_iter<\/code> iterations. Set to 0 to disable printing.<\/li>\n\n\n\n<li><strong><code>-save_iter<\/code>:<\/strong> Save the image every <code>save_iter<\/code> iterations. Set to 0 to disable saving intermediate results.<\/li>\n\n\n\n<li><strong><code>-content_layers<\/code>:<\/strong> Comma-separated list of layer names to use for content reconstruction. Default is <code>relu4_2<\/code>.<\/li>\n\n\n\n<li><strong><code>-style_layers<\/code>:<\/strong> Comma-separated list of layer names to use for style reconstruction. Default is <code>relu1_1,relu2_1,relu3_1,relu4_1,relu5_1<\/code>.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Other Deep Learning Options<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong><code>-style_scale<\/code>:<\/strong> Scale at which to extract features from the style image. Default is 1.0.<\/li>\n\n\n\n<li><strong><code>-original_colors<\/code>:<\/strong> If you set this to 1, then the output image will keep the colors of the content image.<\/li>\n\n\n\n<li><strong><code>-model_file<\/code>:<\/strong> Path to the <code>.pth<\/code> file for the VGG Caffe model. Default is the original VGG-19 model; you can also try the original VGG-16 model.<\/li>\n\n\n\n<li><strong><code>-pooling<\/code>:<\/strong> The type of pooling layers to use; one of <code>max<\/code> or <code>avg<\/code>. Default is <code>max<\/code>. The VGG-19 models uses max pooling layers, but the paper mentions that replacing these layers with average pooling layers can improve the results. I haven&#8217;t been able to get good results using average pooling, but the option is here.<\/li>\n\n\n\n<li><strong><code>-seed<\/code>:<\/strong> An integer value that you can specify for repeatable results. By default this value is random for each run.<\/li>\n\n\n\n<li><strong><code>-multidevice_strategy<\/code>:<\/strong> A comma-separated list of layer indices at which to split the network when using multiple devices. See the Multi GPU Section for more details.<\/li>\n\n\n\n<li><strong><code>-backend<\/code>:<\/strong> <code>nn<\/code>, <code>cudnn<\/code>, <code>openmp<\/code>, or <code>mkl<\/code>. Default is <code>nn<\/code>. <code>mkl<\/code> requires Intel&#8217;s MKL backend.<\/li>\n\n\n\n<li><strong><code>-cudnn_autotune<\/code>:<\/strong> When using the cuDNN backend, pass this flag to use the built-in cuDNN autotuner to select the best convolution <a href=\"https:\/\/en.wikipedia.org\/wiki\/Algorithm\">algorithms<\/a> for your architecture. This will make the first iteration a bit slower and can take a bit more memory, but may significantly speed up the cuDNN backend.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">GTX 1080 Benchmark Speeds<\/h2>\n\n\n\n<pre class=\"wp-block-code has-vivid-cyan-blue-color has-black-background-color has-text-color has-background\"><code>\n    -backend nn -optimizer lbfgs: 56 seconds\n    -backend nn -optimizer adam: 38 seconds\n    -backend cudnn -optimizer lbfgs: 40 seconds\n    -backend cudnn -optimizer adam: 40 seconds\n    -backend cudnn -cudnn_autotune -optimizer lbfgs: 23 seconds\n    -backend cudnn -cudnn_autotune -optimizer adam: 24 seconds\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">FAQ and Issues<\/h2>\n\n\n\n<p><strong>Problem #1<\/strong>:<\/p>\n\n\n\n<p> When running the program you run out of memory.<\/p>\n\n\n\n<p><strong>Solution #1<\/strong><\/p>\n\n\n\n<p>Try reducing the image size: <code>-image_size 256<\/code> (or lower). Note that different image sizes will likely require non-default values for <code>-style_weight<\/code> and <code>-content_weight<\/code> for optimal results. If you are running on a GPU, you can also try running with <code>-backend cudnn<\/code> to reduce memory usage.<\/p>\n\n\n\n<p><strong>Problem #2<\/strong>: <\/p>\n\n\n\n<p>The <em>-backend cudnn<\/em> performs slower than the default backend.<\/p>\n\n\n\n<p><strong>Solution #2<\/strong>:<\/p>\n\n\n\n<p>Add the flag <code>-cudnn_autotune<\/code>; This will instead use the built-in cuDNN autotuner to select the best <a href=\"https:\/\/en.wikipedia.org\/wiki\/Convolution\">convolution<\/a> <a href=\"https:\/\/en.wikipedia.org\/wiki\/Algorithm\">algorithm<\/a> which will result in much better performance.<\/p>\n\n\n\n<p><strong>Problem #3<\/strong>: <\/p>\n\n\n\n<p>You receive this error message.<\/p>\n\n\n\n<pre class=\"wp-block-code has-vivid-cyan-blue-color has-black-background-color has-text-color has-background\"><code>Missing key(s) in state_dict: \"classifier.0.bias\", \"classifier.0.weight\", \"classifier.3.bias\", \"classifier.3.weight\". Unexpected key(s) in state_dict: \"classifier.1.weight\", \"classifier.1.bias\", \"classifier.4.weight\", \"classifier.4.bias\".<\/code><\/pre>\n\n\n\n<p><strong>Solution #3<\/strong>:<\/p>\n\n\n\n<p>Due to a mix up with layer locations, older models require an update to be compatible with newer versions of PyTorch. The included <a href=\"https:\/\/github.com\/ProGamerGov\/neural-style-pt\/blob\/master\/models\/download_models.py\"><code>donwload_models.py<\/code><\/a> script will perform these updates after downloading the models.<\/p>\n\n\n\n<p><strong>Problem #4:<\/strong><\/p>\n\n\n\n<p>The image generated is solid gray. <\/p>\n\n\n\n<p><strong>Solution #4:<\/strong> <\/p>\n\n\n\n<p>This is a bug that sometimes occurs in cuda. You need to reduce or increase the size of the image by at least 1px.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Related Resources<\/h2>\n\n\n\n<p>View more image examples on the <a href=\"https:\/\/twitter.com\/weformatswap\" target=\"_blank\" rel=\"noreferrer noopener\">Computer Dreams Twitter<\/a>.<\/p>\n\n\n\n<p>If you want to learn how to generate images with neural networks click <a href=\"https:\/\/formatswap.com\/blog\/2022\/06\/27\/how-to-generate-images-from-text-prompts-with-vqgan-clip-python-and-tensorflow\/\" target=\"_blank\" rel=\"noreferrer noopener\">HERE<\/a>.<\/p>\n\n\n\n<p>View our other <a href=\"https:\/\/formatswap.com\/blog\/category\/machine-learning-tutorials\/\">Machine Learning Tutorials<\/a>.<\/p>\n\n\n\n<p>Click here to learn <a href=\"https:\/\/formatswap.com\/blog\/linux-tutorials\/how-to-install-mysql-on-ubuntu-server-22-04-lts\/\" target=\"_blank\" rel=\"noreferrer noopener\">How to Install MySQL on Ubuntu 22.04 LTS<\/a>.<\/p>\n\n\n\n<p>Learn more cool things in Linux with our <a href=\"https:\/\/formatswap.com\/blog\/category\/linux-tutorials\/\">Linux Tutorials<\/a>.<\/p>\n\n\n\n<p>View all of our available online tools at <a href=\"https:\/\/formatswap.com\">Formatswap.com<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Questions<\/h2>\n\n\n\n<p>Feel free to leave a comment below if you have any further questions. Thank you for reading the tutorial.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial you will learn how to transfer the style of one image onto the content of another. This program uses deep learning with python. The project uses an algorithm based on a convolutional neural network. Style any image using machine learning image processing. We will be using Ubuntu 20.04 for this tutorial. Almost [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"nf_dc_page":"","pagelayer_contact_templates":[],"_pagelayer_content":"","footnotes":""},"categories":[7],"tags":[9,8,10,11,12,14],"class_list":["post-6","post","type-post","status-publish","format-standard","hentry","category-machine-learning-tutorials","tag-deep-learning","tag-linux","tag-machine-learning","tag-python","tag-tensorflow","tag-tutorial"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Deep Learning Image Style Transfer Tutorial Using Neural Style Pt - Format Swap - Tech Tutorials<\/title>\n<meta name=\"description\" content=\"This deep learning tutorial will teach you how to transfer the style of one image onto the content of another using Python &amp; Tensorflow.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/formatswap.com\/blog\/machine-learning-tutorials\/deep-learning-image-style-transfer-tutorial-using-neural-style-pt\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Deep Learning Image Style Transfer Tutorial Using Neural Style Pt - Format Swap - Tech Tutorials\" \/>\n<meta property=\"og:description\" content=\"This deep learning tutorial will teach you how to transfer the style of one image onto the content of another using Python &amp; Tensorflow.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/formatswap.com\/blog\/machine-learning-tutorials\/deep-learning-image-style-transfer-tutorial-using-neural-style-pt\/\" \/>\n<meta property=\"og:site_name\" content=\"Format Swap - Tech Tutorials\" \/>\n<meta property=\"article:published_time\" content=\"2022-07-06T17:00:45+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-01-25T20:33:19+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/formatswap.com\/blog\/wp-content\/uploads\/2022\/07\/york-1024x683.jpg\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/formatswap.com\\\/blog\\\/machine-learning-tutorials\\\/deep-learning-image-style-transfer-tutorial-using-neural-style-pt\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/formatswap.com\\\/blog\\\/machine-learning-tutorials\\\/deep-learning-image-style-transfer-tutorial-using-neural-style-pt\\\/\"},\"author\":{\"name\":\"admin\",\"@id\":\"https:\\\/\\\/formatswap.com\\\/blog\\\/#\\\/schema\\\/person\\\/3d01ee8e1e4f3718cfcc57eeb8ad6188\"},\"headline\":\"Deep Learning Image Style Transfer Tutorial Using Neural Style Pt\",\"datePublished\":\"2022-07-06T17:00:45+00:00\",\"dateModified\":\"2023-01-25T20:33:19+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/formatswap.com\\\/blog\\\/machine-learning-tutorials\\\/deep-learning-image-style-transfer-tutorial-using-neural-style-pt\\\/\"},\"wordCount\":1107,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/formatswap.com\\\/blog\\\/machine-learning-tutorials\\\/deep-learning-image-style-transfer-tutorial-using-neural-style-pt\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/formatswap.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/07\\\/york-1024x683.jpg\",\"keywords\":[\"deep learning\",\"linux\",\"machine learning\",\"python\",\"tensorflow\",\"tutorial\"],\"articleSection\":[\"Machine Learning Tutorials\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/formatswap.com\\\/blog\\\/machine-learning-tutorials\\\/deep-learning-image-style-transfer-tutorial-using-neural-style-pt\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/formatswap.com\\\/blog\\\/machine-learning-tutorials\\\/deep-learning-image-style-transfer-tutorial-using-neural-style-pt\\\/\",\"url\":\"https:\\\/\\\/formatswap.com\\\/blog\\\/machine-learning-tutorials\\\/deep-learning-image-style-transfer-tutorial-using-neural-style-pt\\\/\",\"name\":\"Deep Learning Image Style Transfer Tutorial Using Neural Style Pt - Format Swap - Tech Tutorials\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/formatswap.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/formatswap.com\\\/blog\\\/machine-learning-tutorials\\\/deep-learning-image-style-transfer-tutorial-using-neural-style-pt\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/formatswap.com\\\/blog\\\/machine-learning-tutorials\\\/deep-learning-image-style-transfer-tutorial-using-neural-style-pt\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/formatswap.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/07\\\/york-1024x683.jpg\",\"datePublished\":\"2022-07-06T17:00:45+00:00\",\"dateModified\":\"2023-01-25T20:33:19+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/formatswap.com\\\/blog\\\/#\\\/schema\\\/person\\\/3d01ee8e1e4f3718cfcc57eeb8ad6188\"},\"description\":\"This deep learning tutorial will teach you how to transfer the style of one image onto the content of another using Python & Tensorflow.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/formatswap.com\\\/blog\\\/machine-learning-tutorials\\\/deep-learning-image-style-transfer-tutorial-using-neural-style-pt\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/formatswap.com\\\/blog\\\/machine-learning-tutorials\\\/deep-learning-image-style-transfer-tutorial-using-neural-style-pt\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/formatswap.com\\\/blog\\\/machine-learning-tutorials\\\/deep-learning-image-style-transfer-tutorial-using-neural-style-pt\\\/#primaryimage\",\"url\":\"https:\\\/\\\/formatswap.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/07\\\/york.jpg\",\"contentUrl\":\"https:\\\/\\\/formatswap.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/07\\\/york.jpg\",\"width\":1800,\"height\":1200,\"caption\":\"A photo of new york city\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/formatswap.com\\\/blog\\\/machine-learning-tutorials\\\/deep-learning-image-style-transfer-tutorial-using-neural-style-pt\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/formatswap.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Deep Learning Image Style Transfer Tutorial Using Neural Style Pt\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/formatswap.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/formatswap.com\\\/blog\\\/\",\"name\":\"Format Swap - Tech Tutorials\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/formatswap.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/formatswap.com\\\/blog\\\/#\\\/schema\\\/person\\\/3d01ee8e1e4f3718cfcc57eeb8ad6188\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/55cb3548d8c931eac3f2facbca246c6bde86082f48ca304906d7da2214191b72?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/55cb3548d8c931eac3f2facbca246c6bde86082f48ca304906d7da2214191b72?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/55cb3548d8c931eac3f2facbca246c6bde86082f48ca304906d7da2214191b72?s=96&d=mm&r=g\",\"caption\":\"admin\"},\"sameAs\":[\"https:\\\/\\\/formatswap.com\\\/blog\",\"https:\\\/\\\/www.youtube.com\\\/channel\\\/UCsIPLkRPTbbTaT8YX0Dh2-A\"],\"url\":\"https:\\\/\\\/formatswap.com\\\/blog\\\/author\\\/admin\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Deep Learning Image Style Transfer Tutorial Using Neural Style Pt - Format Swap - Tech Tutorials","description":"This deep learning tutorial will teach you how to transfer the style of one image onto the content of another using Python & Tensorflow.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/formatswap.com\/blog\/machine-learning-tutorials\/deep-learning-image-style-transfer-tutorial-using-neural-style-pt\/","og_locale":"en_US","og_type":"article","og_title":"Deep Learning Image Style Transfer Tutorial Using Neural Style Pt - Format Swap - Tech Tutorials","og_description":"This deep learning tutorial will teach you how to transfer the style of one image onto the content of another using Python & Tensorflow.","og_url":"https:\/\/formatswap.com\/blog\/machine-learning-tutorials\/deep-learning-image-style-transfer-tutorial-using-neural-style-pt\/","og_site_name":"Format Swap - Tech Tutorials","article_published_time":"2022-07-06T17:00:45+00:00","article_modified_time":"2023-01-25T20:33:19+00:00","og_image":[{"url":"https:\/\/formatswap.com\/blog\/wp-content\/uploads\/2022\/07\/york-1024x683.jpg","type":"","width":"","height":""}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"Written by":"admin","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/formatswap.com\/blog\/machine-learning-tutorials\/deep-learning-image-style-transfer-tutorial-using-neural-style-pt\/#article","isPartOf":{"@id":"https:\/\/formatswap.com\/blog\/machine-learning-tutorials\/deep-learning-image-style-transfer-tutorial-using-neural-style-pt\/"},"author":{"name":"admin","@id":"https:\/\/formatswap.com\/blog\/#\/schema\/person\/3d01ee8e1e4f3718cfcc57eeb8ad6188"},"headline":"Deep Learning Image Style Transfer Tutorial Using Neural Style Pt","datePublished":"2022-07-06T17:00:45+00:00","dateModified":"2023-01-25T20:33:19+00:00","mainEntityOfPage":{"@id":"https:\/\/formatswap.com\/blog\/machine-learning-tutorials\/deep-learning-image-style-transfer-tutorial-using-neural-style-pt\/"},"wordCount":1107,"commentCount":0,"image":{"@id":"https:\/\/formatswap.com\/blog\/machine-learning-tutorials\/deep-learning-image-style-transfer-tutorial-using-neural-style-pt\/#primaryimage"},"thumbnailUrl":"https:\/\/formatswap.com\/blog\/wp-content\/uploads\/2022\/07\/york-1024x683.jpg","keywords":["deep learning","linux","machine learning","python","tensorflow","tutorial"],"articleSection":["Machine Learning Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/formatswap.com\/blog\/machine-learning-tutorials\/deep-learning-image-style-transfer-tutorial-using-neural-style-pt\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/formatswap.com\/blog\/machine-learning-tutorials\/deep-learning-image-style-transfer-tutorial-using-neural-style-pt\/","url":"https:\/\/formatswap.com\/blog\/machine-learning-tutorials\/deep-learning-image-style-transfer-tutorial-using-neural-style-pt\/","name":"Deep Learning Image Style Transfer Tutorial Using Neural Style Pt - Format Swap - Tech Tutorials","isPartOf":{"@id":"https:\/\/formatswap.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/formatswap.com\/blog\/machine-learning-tutorials\/deep-learning-image-style-transfer-tutorial-using-neural-style-pt\/#primaryimage"},"image":{"@id":"https:\/\/formatswap.com\/blog\/machine-learning-tutorials\/deep-learning-image-style-transfer-tutorial-using-neural-style-pt\/#primaryimage"},"thumbnailUrl":"https:\/\/formatswap.com\/blog\/wp-content\/uploads\/2022\/07\/york-1024x683.jpg","datePublished":"2022-07-06T17:00:45+00:00","dateModified":"2023-01-25T20:33:19+00:00","author":{"@id":"https:\/\/formatswap.com\/blog\/#\/schema\/person\/3d01ee8e1e4f3718cfcc57eeb8ad6188"},"description":"This deep learning tutorial will teach you how to transfer the style of one image onto the content of another using Python & Tensorflow.","breadcrumb":{"@id":"https:\/\/formatswap.com\/blog\/machine-learning-tutorials\/deep-learning-image-style-transfer-tutorial-using-neural-style-pt\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/formatswap.com\/blog\/machine-learning-tutorials\/deep-learning-image-style-transfer-tutorial-using-neural-style-pt\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/formatswap.com\/blog\/machine-learning-tutorials\/deep-learning-image-style-transfer-tutorial-using-neural-style-pt\/#primaryimage","url":"https:\/\/formatswap.com\/blog\/wp-content\/uploads\/2022\/07\/york.jpg","contentUrl":"https:\/\/formatswap.com\/blog\/wp-content\/uploads\/2022\/07\/york.jpg","width":1800,"height":1200,"caption":"A photo of new york city"},{"@type":"BreadcrumbList","@id":"https:\/\/formatswap.com\/blog\/machine-learning-tutorials\/deep-learning-image-style-transfer-tutorial-using-neural-style-pt\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/formatswap.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Deep Learning Image Style Transfer Tutorial Using Neural Style Pt"}]},{"@type":"WebSite","@id":"https:\/\/formatswap.com\/blog\/#website","url":"https:\/\/formatswap.com\/blog\/","name":"Format Swap - Tech Tutorials","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/formatswap.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/formatswap.com\/blog\/#\/schema\/person\/3d01ee8e1e4f3718cfcc57eeb8ad6188","name":"admin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/55cb3548d8c931eac3f2facbca246c6bde86082f48ca304906d7da2214191b72?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/55cb3548d8c931eac3f2facbca246c6bde86082f48ca304906d7da2214191b72?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/55cb3548d8c931eac3f2facbca246c6bde86082f48ca304906d7da2214191b72?s=96&d=mm&r=g","caption":"admin"},"sameAs":["https:\/\/formatswap.com\/blog","https:\/\/www.youtube.com\/channel\/UCsIPLkRPTbbTaT8YX0Dh2-A"],"url":"https:\/\/formatswap.com\/blog\/author\/admin\/"}]}},"_links":{"self":[{"href":"https:\/\/formatswap.com\/blog\/wp-json\/wp\/v2\/posts\/6","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/formatswap.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/formatswap.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/formatswap.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/formatswap.com\/blog\/wp-json\/wp\/v2\/comments?post=6"}],"version-history":[{"count":5,"href":"https:\/\/formatswap.com\/blog\/wp-json\/wp\/v2\/posts\/6\/revisions"}],"predecessor-version":[{"id":934,"href":"https:\/\/formatswap.com\/blog\/wp-json\/wp\/v2\/posts\/6\/revisions\/934"}],"wp:attachment":[{"href":"https:\/\/formatswap.com\/blog\/wp-json\/wp\/v2\/media?parent=6"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/formatswap.com\/blog\/wp-json\/wp\/v2\/categories?post=6"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/formatswap.com\/blog\/wp-json\/wp\/v2\/tags?post=6"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}