{"id":13454721,"url":"https://github.com/anishathalye/neural-style","last_synced_at":"2025-10-04T06:38:20.596Z","repository":{"id":44454310,"uuid":"46638669","full_name":"anishathalye/neural-style","owner":"anishathalye","description":"Neural style in TensorFlow! 🎨","archived":false,"fork":false,"pushed_at":"2025-04-19T16:40:58.000Z","size":2712,"stargazers_count":5544,"open_issues_count":1,"forks_count":1501,"subscribers_count":220,"default_branch":"master","last_synced_at":"2025-04-23T21:51:54.982Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://anishathalye.com/an-ai-that-can-mimic-any-artist/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/anishathalye.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2015-11-21T23:40:00.000Z","updated_at":"2025-04-19T16:41:02.000Z","dependencies_parsed_at":"2025-02-20T20:00:25.573Z","dependency_job_id":"ab92d3af-2617-4de4-96e8-f03139053bf7","html_url":"https://github.com/anishathalye/neural-style","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anishathalye%2Fneural-style","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anishathalye%2Fneural-style/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anishathalye%2Fneural-style/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anishathalye%2Fneural-style/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/anishathalye","download_url":"https://codeload.github.com/anishathalye/neural-style/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253979991,"owners_count":21994041,"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","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":[],"created_at":"2024-07-31T08:00:57.307Z","updated_at":"2025-10-04T06:38:20.578Z","avatar_url":"https://github.com/anishathalye.png","language":"Python","funding_links":[],"categories":["Images","Models/Projects","Python","🤖 AI \u0026 Machine Learning","模型项目","others"],"sub_categories":["微信群"],"readme":"# neural-style [![Build Status](https://github.com/anishathalye/neural-style/actions/workflows/ci.yml/badge.svg)](https://github.com/anishathalye/neural-style/actions/workflows/ci.yml)\n\nAn implementation of [neural style][paper] in TensorFlow.\n\nThis implementation is a lot simpler than a lot of the other ones out there,\nthanks to TensorFlow's really nice API and [automatic differentiation][ad].\n\nTensorFlow doesn't support [L-BFGS][l-bfgs] (which is what the original authors\nused), so we use [Adam][adam]. This may require a little bit more\nhyperparameter tuning to get nice results.\n\n## Running\n\nThis project uses the [uv](https://docs.astral.sh/uv/) project and package manager; you can install it by [following these instructions](https://docs.astral.sh/uv/getting-started/installation/) (e.g., installing it with your system package manager, like `brew install uv`).\n\nYou also need to download [required data files](#requirements).\n\nAfter that, you can run this program with:\n\n```bash\nuv run neural_style.py --content \u003ccontent file\u003e --styles \u003cstyle file\u003e --output \u003coutput file\u003e\n```\n\nRun `uv run neural_style.py --help` to see a list of all options.\n\nUse `--checkpoint-output` and `--checkpoint-iterations` to save checkpoint images.\n\nUse `--iterations` to change the number of iterations (default 1000). For a 512×512 pixel content file, 1000 iterations take 90 seconds on an M3 MacBook Pro, and significantly less time with a more powerful (e.g., NVIDIA) GPU.\n\n## Example 1\n\nRunning it for 500-2000 iterations seems to produce nice results. With certain\nimages or output sizes, you might need some hyperparameter tuning (especially\n`--content-weight`, `--style-weight`, and `--learning-rate`).\n\nThe following example was run for 1000 iterations to produce the result (with\ndefault parameters):\n\n![output](examples/1-output.jpg)\n\nThese were the input images used (me sleeping at a hackathon and Starry Night):\n\n![input-content](examples/1-content.jpg)\n\n![input-style](examples/1-style.jpg)\n\n## Example 2\n\nThe following example demonstrates style blending, and was run for 1000\niterations to produce the result (with style blend weight parameters 0.8 and\n0.2):\n\n![output](examples/2-output.jpg)\n\nThe content input image was a picture of the Stata Center at MIT:\n\n![input-content](examples/2-content.jpg)\n\nThe style input images were Picasso's \"Dora Maar\" and Starry Night, with the\nPicasso image having a style blend weight of 0.8 and Starry Night having a\nstyle blend weight of 0.2:\n\n![input-style](examples/2-style1.jpg)\n![input-style](examples/2-style2.jpg)\n\n## Tweaking\n\n`--style-layer-weight-exp` command line argument could be used to tweak how \"abstract\"\nthe style transfer should be. Lower values mean that style transfer of a finer features\nwill be favored over style transfer of a more coarse features, and vice versa. Default\nvalue is 1.0 - all layers treated equally. Somewhat extreme examples of what you can achieve:\n\n![--style-layer-weight-exp 0.2](examples/tweaks/swe02.jpg)\n![--style-layer-weight-exp 2.0](examples/tweaks/swe20.jpg)\n\n(**left**: 0.2 - finer features style transfer; **right**: 2.0 - coarser features style transfer)\n\n`--content-weight-blend` specifies the coefficient of content transfer layers. Default value -\n1.0, style transfer tries to preserve finer grain content details. The value should be\nin range [0.0; 1.0].\n\n![--content-weight-blend 1.0](examples/tweaks/cwe10_default.jpg)\n![--content-weight-blend 0.1](examples/tweaks/cwe01.jpg)\n\n(**left**: 1.0 - default value; **right**: 0.1 - more abstract picture)\n\n`--pooling` allows to select which pooling layers to use (specify either `max` or `avg`).\nOriginal VGG topology uses max pooling, but the [style transfer paper][paper] suggests\nreplacing it with average pooling. The outputs are perceptually different, max pool in\ngeneral tends to have finer detail style transfer, but could have troubles at\nlower-freqency detail level:\n\n![--pooling max](examples/tweaks/swe14_pmax.jpg)\n![--pooling avg](examples/tweaks/swe14_pavg.jpg)\n\n(**left**: max pooling; **right**: average pooling)\n\n`--preserve-colors` boolean command line argument adds post-processing step, which\ncombines colors from the original image and luma from the stylized image (YCbCr color\nspace), thus producing color-preserving style transfer:\n\n![--pooling max](examples/tweaks/swe14_pmax.jpg)\n![--pooling max](examples/tweaks/swe14_pmax_pcyuv.jpg)\n\n(**left**: original stylized image; **right**: color-preserving style transfer)\n\n## Requirements\n\n### Data Files\n\n* [Pre-trained VGG network][net] (SHA256 `abdb57167f82a2a1fbab1e1c16ad9373411883f262a1a37ee5db2e6fb0044695`) - put it in the top level of this repository, or specify its location using the `--network` option.\n\n## Related Projects\n\nSee [here][lengstrom-fast-style-transfer] for an implementation of [fast\n(feed-forward) neural style][fast-neural-style] in TensorFlow.\n\n**[Try neural style](https://tenso.rs/demos/fast-neural-style/) client-side in\nyour web browser without installing any software (using\n[TensorFire](https://tenso.rs/)).**\n\n## Citation\n\n```bibtex\n@misc{athalye2015neuralstyle,\n  author = {Anish Athalye},\n  title = {Neural Style},\n  year = {2015},\n  howpublished = {\\url{https://github.com/anishathalye/neural-style}},\n}\n```\n\n## License\n\nCopyright (c) Anish Athalye. Released under GPLv3. See\n[LICENSE.txt][license] for details.\n\n[net]: https://www.vlfeat.org/matconvnet/models/imagenet-vgg-verydeep-19.mat\n[paper]: http://arxiv.org/pdf/1508.06576v2.pdf\n[l-bfgs]: https://en.wikipedia.org/wiki/Limited-memory_BFGS\n[adam]: http://arxiv.org/abs/1412.6980\n[ad]: https://en.wikipedia.org/wiki/Automatic_differentiation\n[lengstrom-fast-style-transfer]: https://github.com/lengstrom/fast-style-transfer\n[fast-neural-style]: https://arxiv.org/pdf/1603.08155v1.pdf\n[license]: LICENSE.txt\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanishathalye%2Fneural-style","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanishathalye%2Fneural-style","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanishathalye%2Fneural-style/lists"}