{"id":32955095,"url":"https://github.com/ProGamerGov/neural-style-pt","last_synced_at":"2025-11-13T07:02:02.098Z","repository":{"id":43288366,"uuid":"142345353","full_name":"ProGamerGov/neural-style-pt","owner":"ProGamerGov","description":"PyTorch implementation of neural style transfer algorithm","archived":false,"fork":false,"pushed_at":"2022-10-15T16:07:29.000Z","size":37193,"stargazers_count":859,"open_issues_count":25,"forks_count":171,"subscribers_count":17,"default_branch":"master","last_synced_at":"2025-10-04T22:33:45.667Z","etag":null,"topics":["deep-learning","deep-style","neural-style","neural-style-pt","neural-style-transfer","nst","pytorch","pytorch-style-transfer","style-transfer","styletransfer"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ProGamerGov.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2018-07-25T19:35:33.000Z","updated_at":"2025-10-04T14:04:46.000Z","dependencies_parsed_at":"2025-04-12T05:08:47.080Z","dependency_job_id":null,"html_url":"https://github.com/ProGamerGov/neural-style-pt","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/ProGamerGov/neural-style-pt","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ProGamerGov%2Fneural-style-pt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ProGamerGov%2Fneural-style-pt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ProGamerGov%2Fneural-style-pt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ProGamerGov%2Fneural-style-pt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ProGamerGov","download_url":"https://codeload.github.com/ProGamerGov/neural-style-pt/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ProGamerGov%2Fneural-style-pt/sbom","scorecard":{"id":112338,"data":{"date":"2025-08-11","repo":{"name":"github.com/ProGamerGov/neural-style-pt","commit":"72514050755394270abf526252cb9ff95c20dcf2"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Code-Review","score":0,"reason":"Found 1/22 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 21 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-15T12:35:19.006Z","repository_id":43288366,"created_at":"2025-08-15T12:35:19.006Z","updated_at":"2025-08-15T12:35:19.006Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":284170493,"owners_count":26959115,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-11-13T02:00:06.582Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["deep-learning","deep-style","neural-style","neural-style-pt","neural-style-transfer","nst","pytorch","pytorch-style-transfer","style-transfer","styletransfer"],"created_at":"2025-11-12T22:00:41.099Z","updated_at":"2025-11-13T07:02:02.083Z","avatar_url":"https://github.com/ProGamerGov.png","language":"Python","funding_links":[],"categories":["Python","Paper implementations｜论文实现","Paper implementations","Projects"],"sub_categories":["General-Purpose Machine Learning","Other libraries｜其他库:","Other libraries:","Visual"],"readme":"# neural-style-pt\n\n[![DOI](https://zenodo.org/badge/142345353.svg)](https://zenodo.org/badge/latestdoi/142345353)\n\nThis is a PyTorch implementation of the paper [A Neural Algorithm of Artistic Style](http://arxiv.org/abs/1508.06576)\nby Leon A. Gatys, Alexander S. Ecker, and Matthias Bethge. The code is based on Justin Johnson's [Neural-Style](https://github.com/jcjohnson/neural-style).\n\nThe paper presents an algorithm for combining the content of one image with the style of another image using\nconvolutional neural networks. Here's an example that maps the artistic style of\n[The Starry Night](https://en.wikipedia.org/wiki/The_Starry_Night)\nonto a night-time photograph of the Stanford campus:\n\n\u003cdiv align=\"center\"\u003e\n \u003cimg src=\"https://raw.githubusercontent.com/ProGamerGov/neural-style-pt/master/examples/inputs/starry_night_google.jpg\" height=\"223px\"\u003e\n \u003cimg src=\"https://raw.githubusercontent.com/ProGamerGov/neural-style-pt/master/examples/inputs/hoovertowernight.jpg\" height=\"223px\"\u003e\n \u003cimg src=\"https://raw.githubusercontent.com/ProGamerGov/neural-style-pt/master/examples/outputs/starry_stanford_bigger.png\" width=\"710px\"\u003e\n\u003c/div\u003e\n\nApplying the style of different images to the same content image gives interesting results.\nHere we reproduce Figure 2 from the paper, which renders a photograph of the Tubingen in Germany in a\nvariety of styles:\n\n\u003cdiv align=\"center\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/ProGamerGov/neural-style-pt/master/examples/inputs/tubingen.jpg\" height=\"250px\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/ProGamerGov/neural-style-pt/master/examples/outputs/tubingen_shipwreck.png\" height=\"250px\"\u003e\n\n\u003cimg src=\"https://raw.githubusercontent.com/ProGamerGov/neural-style-pt/master/examples/outputs/tubingen_starry.png\" height=\"250px\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/ProGamerGov/neural-style-pt/master/examples/outputs/tubingen_scream.png\" height=\"250px\"\u003e\n\n\u003cimg src=\"https://raw.githubusercontent.com/ProGamerGov/neural-style-pt/master/examples/outputs/tubingen_seated_nude.png\" height=\"250px\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/ProGamerGov/neural-style-pt/master/examples/outputs/tubingen_composition_vii.png\" height=\"250px\"\u003e\n\u003c/div\u003e\n\nHere are the results of applying the style of various pieces of artwork to this photograph of the\ngolden gate bridge:\n\n\n\u003cdiv align=\"center\"\n\u003cimg src=\"https://raw.githubusercontent.com/ProGamerGov/neural-style-pt/master/examples/inputs/golden_gate.jpg\" height=\"200px\"\u003e\n\n\u003cimg src=\"https://raw.githubusercontent.com/ProGamerGov/neural-style-pt/master/examples/inputs/frida_kahlo.jpg\" height=\"160px\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/ProGamerGov/neural-style-pt/master/examples/outputs/golden_gate_kahlo.png\" height=\"160px\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/ProGamerGov/neural-style-pt/master/examples/inputs/escher_sphere.jpg\" height=\"160px\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/ProGamerGov/neural-style-pt/master/examples/outputs/golden_gate_escher.png\" height=\"160px\"\u003e\n\u003c/div\u003e\n\n\u003cdiv align=\"center\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/ProGamerGov/neural-style-pt/master/examples/inputs/woman-with-hat-matisse.jpg\" height=\"160px\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/ProGamerGov/neural-style-pt/master/examples/outputs/golden_gate_matisse.png\" height=\"160px\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/ProGamerGov/neural-style-pt/master/examples/inputs/the_scream.jpg\" height=\"160px\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/ProGamerGov/neural-style-pt/master/examples/outputs/golden_gate_scream.png\" height=\"160px\"\u003e\n\u003c/div\u003e\n\n\u003cdiv align=\"center\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/ProGamerGov/neural-style-pt/master/examples/inputs/starry_night_crop.png\" height=\"160px\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/ProGamerGov/neural-style-pt/master/examples/outputs/golden_gate_starry.png\" height=\"160px\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/ProGamerGov/neural-style-pt/master/examples/inputs/seated-nude.jpg\" height=\"160px\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/ProGamerGov/neural-style-pt/master/examples/outputs/golden_gate_seated.png\" height=\"160px\"\u003e\n\u003c/div\u003e\n\n### Content / Style Tradeoff\n\nThe algorithm allows the user to trade-off the relative weight of the style and content reconstruction terms,\nas shown in this example where we port the style of [Picasso's 1907 self-portrait](http://www.wikiart.org/en/pablo-picasso/self-portrait-1907) onto Brad Pitt:\n\n\u003cdiv align=\"center\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/ProGamerGov/neural-style-pt/master/examples/inputs/picasso_selfport1907.jpg\" height=\"220px\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/ProGamerGov/neural-style-pt/master/examples/inputs/brad_pitt.jpg\" height=\"220px\"\u003e\n\u003c/div\u003e\n\n\u003cdiv align=\"center\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/ProGamerGov/neural-style-pt/master/examples/outputs/pitt_picasso_content_5_style_100.png\" height=\"220px\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/ProGamerGov/neural-style-pt/master/examples/outputs/pitt_picasso_content_1_style_100.png\" height=\"220px\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/ProGamerGov/neural-style-pt/master/examples/outputs/pitt_picasso_content_01_style_100.png\" height=\"220px\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/ProGamerGov/neural-style-pt/master/examples/outputs/pitt_picasso_content_0025_style_100.png\" height=\"220px\"\u003e\n\u003c/div\u003e\n\n### Style Scale\n\nBy resizing the style image before extracting style features, we can control the types of artistic\nfeatures that are transfered from the style image; you can control this behavior with the `-style_scale` flag.\nBelow we see three examples of rendering the Golden Gate Bridge in the style of The Starry Night.\nFrom left to right, `-style_scale` is 2.0, 1.0, and 0.5.\n\n\u003cdiv align=\"center\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/ProGamerGov/neural-style-pt/master/examples/outputs/golden_gate_starry_scale2.png\" height=175px\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/ProGamerGov/neural-style-pt/master/examples/outputs/golden_gate_starry_scale1.png\" height=175px\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/ProGamerGov/neural-style-pt/master/examples/outputs/golden_gate_starry_scale05.png\" height=175px\u003e\n\u003c/div\u003e\n\n### Multiple Style Images\nYou can use more than one style image to blend multiple artistic styles.\n\nClockwise from upper left: \"The Starry Night\" + \"The Scream\", \"The Scream\" + \"Composition VII\",\n\"Seated Nude\" + \"Composition VII\", and \"Seated Nude\" + \"The Starry Night\"\n\n\u003cdiv align=\"center\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/ProGamerGov/neural-style-pt/master/examples/outputs/tubingen_starry_scream.png\" height=\"250px\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/ProGamerGov/neural-style-pt/master/examples/outputs/tubingen_scream_composition_vii.png\" height=\"250px\"\u003e\n\n\u003cimg src=\"https://raw.githubusercontent.com/ProGamerGov/neural-style-pt/master/examples/outputs/tubingen_starry_seated.png\" height=\"250px\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/ProGamerGov/neural-style-pt/master/examples/outputs/tubingen_seated_nude_composition_vii.png\" height=\"250px\"\u003e\n\u003c/div\u003e\n\n\n### Style Interpolation\nWhen using multiple style images, you can control the degree to which they are blended:\n\n\u003cdiv align=\"center\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/ProGamerGov/neural-style-pt/master/examples/outputs/golden_gate_starry_scream_3_7.png\" height=\"175px\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/ProGamerGov/neural-style-pt/master/examples/outputs/golden_gate_starry_scream_5_5.png\" height=\"175px\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/ProGamerGov/neural-style-pt/master/examples/outputs/golden_gate_starry_scream_7_3.png\" height=\"175px\"\u003e\n\u003c/div\u003e\n\n### Transfer style but not color\nIf you add the flag `-original_colors 1` then the output image will retain the colors of the original image.\n\n\u003cdiv align=\"center\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/ProGamerGov/neural-style-pt/master/examples/outputs/tubingen_starry.png\" height=\"185px\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/ProGamerGov/neural-style-pt/master/examples/outputs/tubingen_scream.png\" height=\"185px\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/ProGamerGov/neural-style-pt/master/examples/outputs/tubingen_composition_vii.png\" height=\"185px\"\u003e\n\n\u003cimg src=\"https://raw.githubusercontent.com/ProGamerGov/neural-style-pt/master/examples/outputs/original_color/tubingen_starry.png\" height=\"185px\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/ProGamerGov/neural-style-pt/master/examples/outputs/original_color/tubingen_scream.png\" height=\"185px\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/ProGamerGov/neural-style-pt/master/examples/outputs/original_color/tubingen_composition_vii.png\" height=\"185px\"\u003e\n\u003c/div\u003e\n\n## Setup:\n\nDependencies:\n* [PyTorch](http://pytorch.org/)\n\n\nOptional dependencies:\n* For CUDA backend:\n  * CUDA 7.5 or above\n* For cuDNN backend:\n  * cuDNN v6 or above\n* For ROCm backend:\n  * ROCm 2.1 or above\n* For MKL backend:\n  * MKL 2019 or above\n* For OpenMP backend:\n  * OpenMP 5.0 or above\n\nAfter installing the dependencies, you'll need to run the following script to download the VGG model:\n```\npython models/download_models.py\n```\nThis will download the original [VGG-19 model](https://gist.github.com/ksimonyan/3785162f95cd2d5fee77#file-readme-md).\nThe original [VGG-16 model](https://gist.github.com/ksimonyan/211839e770f7b538e2d8#file-readme-md) will also be downloaded. By default the original VGG-19 model is used.\n\nIf you have a smaller memory GPU then using NIN Imagenet model will be better and gives slightly worse yet comparable results. You can get the details on the model from [BVLC Caffe ModelZoo](https://github.com/BVLC/caffe/wiki/Model-Zoo). The NIN model is downloaded when you run the `download_models.py` script.\n\nYou can find detailed installation instructions for Ubuntu and Windows in the [installation guide](INSTALL.md).\n\n## Usage\nBasic usage:\n```\npython neural_style.py -style_image \u003cimage.jpg\u003e -content_image \u003cimage.jpg\u003e\n```\n\ncuDNN usage with NIN Model:\n```\npython 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\n```\n\n![cuDNN NIN Model Picasso Brad Pitt](https://raw.githubusercontent.com/ProGamerGov/neural-style-pt/master/examples/outputs/pitt_picasso_nin_cudnn.png)\n\n\nTo use multiple style images, pass a comma-separated list like this:\n\n`-style_image starry_night.jpg,the_scream.jpg`.\n\nNote that paths to images should not contain the `~` character to represent your home directory; you should instead use a relative\npath or a full absolute path.\n\n**Options**:\n* `-image_size`: Maximum side length (in pixels) of the generated image. Default is 512.\n* `-style_blend_weights`: The weight for blending the style of multiple style images, as a\n  comma-separated list, such as `-style_blend_weights 3,7`. By default all style images\n  are equally weighted.\n* `-gpu`: Zero-indexed ID of the GPU to use; for CPU mode set `-gpu` to `c`.\n\n**Optimization options**:\n* `-content_weight`: How much to weight the content reconstruction term. Default is 5e0.\n* `-style_weight`: How much to weight the style reconstruction term. Default is 1e2.\n* `-tv_weight`: Weight of total-variation (TV) regularization; this helps to smooth the image.\n  Default is 1e-3. Set to 0 to disable TV regularization.\n* `-num_iterations`: Default is 1000.\n* `-init`: Method for generating the generated image; one of `random` or `image`.\n  Default is `random` which uses a noise initialization as in the paper; `image`\n  initializes with the content image.\n* `-init_image`: Replaces the initialization image with a user specified image.\n* `-optimizer`: The optimization algorithm to use; either `lbfgs` or `adam`; default is `lbfgs`.\n  L-BFGS tends to give better results, but uses more memory. Switching to ADAM will reduce memory usage;\n  when using ADAM you will probably need to play with other parameters to get good results, especially\n  the style weight, content weight, and learning rate.\n* `-learning_rate`: Learning rate to use with the ADAM optimizer. Default is 1e1.\n* `-normalize_gradients`: If this flag is present, style and content gradients from each layer will be L1 normalized.\n\n**Output options**:\n* `-output_image`: Name of the output image. Default is `out.png`.\n* `-print_iter`: Print progress every `print_iter` iterations. Set to 0 to disable printing.\n* `-save_iter`: Save the image every `save_iter` iterations. Set to 0 to disable saving intermediate results.\n\n**Layer options**:\n* `-content_layers`: Comma-separated list of layer names to use for content reconstruction.\n  Default is `relu4_2`.\n* `-style_layers`: Comma-separated list of layer names to use for style reconstruction.\n  Default is `relu1_1,relu2_1,relu3_1,relu4_1,relu5_1`.\n\n**Other options**:\n* `-style_scale`: Scale at which to extract features from the style image. Default is 1.0.\n* `-original_colors`: If you set this to 1, then the output image will keep the colors of the content image.\n* `-model_file`: Path to the `.pth` file for the VGG Caffe model. Default is the original VGG-19 model; you can also try the original VGG-16 model.\n* `-pooling`: The type of pooling layers to use; one of `max` or `avg`. Default is `max`.\n  The VGG-19 models uses max pooling layers, but the paper mentions that replacing these layers with average\n  pooling layers can improve the results. I haven't been able to get good results using average pooling, but\n  the option is here.\n* `-seed`: An integer value that you can specify for repeatable results. By default this value is random for each run.\n* `-multidevice_strategy`: A comma-separated list of layer indices at which to split the network when using multiple devices. See [Multi-GPU scaling](https://github.com/ProGamerGov/neural-style-pt#multi-gpu-scaling) for more details.\n* `-backend`: `nn`, `cudnn`, `openmp`, or `mkl`. Default is `nn`. `mkl` requires Intel's MKL backend.\n* `-cudnn_autotune`: When using the cuDNN backend, pass this flag to use the built-in cuDNN autotuner to select\n  the best convolution algorithms for your architecture. This will make the first iteration a bit slower and can\n  take a bit more memory, but may significantly speed up the cuDNN backend.\n\n## Frequently Asked Questions\n\n**Problem:** The program runs out of memory and dies\n\n**Solution:** Try reducing the image size: `-image_size 256` (or lower). Note that different image sizes will likely\nrequire non-default values for `-style_weight` and `-content_weight` for optimal results.\nIf you are running on a GPU, you can also try running with `-backend cudnn` to reduce memory usage.\n\n**Problem:** `-backend cudnn` is slower than default NN backend\n\n**Solution:** Add the flag `-cudnn_autotune`; this will use the built-in cuDNN autotuner to select the best convolution algorithms.\n\n**Problem:** Get the following error message:\n\n`Missing key(s) in state_dict: \"classifier.0.bias\", \"classifier.0.weight\", \"classifier.3.bias\", \"classifier.3.weight\".\n        Unexpected key(s) in state_dict: \"classifier.1.weight\", \"classifier.1.bias\", \"classifier.4.weight\", \"classifier.4.bias\".`\n\n**Solution:** Due to a mix up with layer locations, older models require a fix to be compatible with newer versions of PyTorch. The included [`donwload_models.py`](https://github.com/ProGamerGov/neural-style-pt/blob/master/models/download_models.py) script will automatically perform these fixes after downloading the models.\n\n\n\n## Memory Usage\nBy default, `neural-style-pt` uses the `nn` backend for convolutions and L-BFGS for optimization. These give good results, but can both use a lot of memory. You can reduce memory usage with the following:\n\n* **Use cuDNN**: Add the flag `-backend cudnn` to use the cuDNN backend. This will only work in GPU mode.\n* **Use ADAM**: Add the flag `-optimizer adam` to use ADAM instead of L-BFGS. This should significantly\n  reduce memory usage, but may require tuning of other parameters for good results; in particular you should\n  play with the learning rate, content weight, and style weight.\n  This should work in both CPU and GPU modes.\n* **Reduce image size**: If the above tricks are not enough, you can reduce the size of the generated image;\n  pass the flag `-image_size 256` to generate an image at half the default size.\n\nWith the default settings, neural-style-pt uses about 3.7 GB of GPU memory on my system; switching to ADAM and cuDNN reduces the GPU memory footprint to about 1GB.\n\n## Speed\nSpeed can vary a lot depending on the backend and the optimizer.\nHere are some times for running 500 iterations with `-image_size=512` on a Tesla K80 with different settings:\n* `-backend nn -optimizer lbfgs`: 117 seconds\n* `-backend nn -optimizer adam`: 100 seconds\n* `-backend cudnn -optimizer lbfgs`: 124 seconds\n* `-backend cudnn -optimizer adam`: 107 seconds\n* `-backend cudnn -cudnn_autotune -optimizer lbfgs`: 109 seconds\n* `-backend cudnn -cudnn_autotune -optimizer adam`: 91 seconds\n\nHere are the same benchmarks on a GTX 1080:\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\n## Multi-GPU scaling\nYou can use multiple CPU and GPU devices to process images at higher resolutions; different layers of the network will be\ncomputed on different devices. You can control which GPU and CPU devices are used with the `-gpu` flag, and you can control\nhow to split layers across devices using the `-multidevice_strategy` flag.\n\nFor example in a server with four GPUs, you can give the flag `-gpu 0,1,2,3` to process on GPUs 0, 1, 2, and 3 in that order; by also giving the flag `-multidevice_strategy 3,6,12` you indicate that the first two layers should be computed on GPU 0, layers 3 to 5 should be computed on GPU 1, layers 6 to 11 should be computed on GPU 2, and the remaining layers should be computed on GPU 3. You will need to tune the `-multidevice_strategy` for your setup in order to achieve maximal resolution.\n\nWe can achieve very high quality results at high resolution by combining multi-GPU processing with multiscale\ngeneration as described in the paper\n\u003ca href=\"https://arxiv.org/abs/1611.07865\"\u003e**Controlling Perceptual Factors in Neural Style Transfer**\u003c/a\u003e by Leon A. Gatys,\nAlexander S. Ecker, Matthias Bethge, Aaron Hertzmann and Eli Shechtman.\n\n\nHere is a 4016 x 2213 image generated on a server with eight Tesla K80 GPUs:\n\n\u003cimg src=\"https://raw.githubusercontent.com/ProGamerGov/neural-style-pt/master/examples/outputs/starry_stanford_bigger.png\" height=\"400px\"\u003e\n\nThe script used to generate this image \u003ca href='examples/scripts/starry_stanford_bigger.sh'\u003ecan be found here\u003c/a\u003e.\n\n## Implementation details\nImages are initialized with white noise and optimized using L-BFGS.\n\nWe perform style reconstructions using the `conv1_1`, `conv2_1`, `conv3_1`, `conv4_1`, and `conv5_1` layers\nand content reconstructions using the `conv4_2` layer. As in the paper, the five style reconstruction losses have\nequal weights.\n\n## Citation\n\nIf you find this code useful for your research, please cite it using the provided citation.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FProGamerGov%2Fneural-style-pt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FProGamerGov%2Fneural-style-pt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FProGamerGov%2Fneural-style-pt/lists"}